mirror of
https://github.com/python/cpython.git
synced 2024-12-01 11:15:56 +01:00
38c707e7e0
I have compared output between pre- and post-patch runs of these tests to make sure there's nothing missing and nothing broken, on both Windows and Linux. The only differences I found were actually tests that were previously *not* run.
21 lines
850 B
Python
21 lines
850 B
Python
import dis
|
|
from test.support import import_module
|
|
import unittest
|
|
|
|
_opcode = import_module("_opcode")
|
|
|
|
class OpcodeTests(unittest.TestCase):
|
|
|
|
def test_stack_effect(self):
|
|
self.assertEqual(_opcode.stack_effect(dis.opmap['POP_TOP']), -1)
|
|
self.assertEqual(_opcode.stack_effect(dis.opmap['DUP_TOP_TWO']), 2)
|
|
self.assertEqual(_opcode.stack_effect(dis.opmap['BUILD_SLICE'], 0), -1)
|
|
self.assertEqual(_opcode.stack_effect(dis.opmap['BUILD_SLICE'], 1), -1)
|
|
self.assertEqual(_opcode.stack_effect(dis.opmap['BUILD_SLICE'], 3), -2)
|
|
self.assertRaises(ValueError, _opcode.stack_effect, 30000)
|
|
self.assertRaises(ValueError, _opcode.stack_effect, dis.opmap['BUILD_SLICE'])
|
|
self.assertRaises(ValueError, _opcode.stack_effect, dis.opmap['POP_TOP'], 0)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|