1 | n/a | import dis |
---|
2 | n/a | from test.support import import_module |
---|
3 | n/a | import unittest |
---|
4 | n/a | |
---|
5 | n/a | _opcode = import_module("_opcode") |
---|
6 | n/a | |
---|
7 | n/a | class OpcodeTests(unittest.TestCase): |
---|
8 | n/a | |
---|
9 | n/a | def test_stack_effect(self): |
---|
10 | n/a | self.assertEqual(_opcode.stack_effect(dis.opmap['POP_TOP']), -1) |
---|
11 | n/a | self.assertEqual(_opcode.stack_effect(dis.opmap['DUP_TOP_TWO']), 2) |
---|
12 | n/a | self.assertEqual(_opcode.stack_effect(dis.opmap['BUILD_SLICE'], 0), -1) |
---|
13 | n/a | self.assertEqual(_opcode.stack_effect(dis.opmap['BUILD_SLICE'], 1), -1) |
---|
14 | n/a | self.assertEqual(_opcode.stack_effect(dis.opmap['BUILD_SLICE'], 3), -2) |
---|
15 | n/a | self.assertRaises(ValueError, _opcode.stack_effect, 30000) |
---|
16 | n/a | self.assertRaises(ValueError, _opcode.stack_effect, dis.opmap['BUILD_SLICE']) |
---|
17 | n/a | self.assertRaises(ValueError, _opcode.stack_effect, dis.opmap['POP_TOP'], 0) |
---|
18 | n/a | |
---|
19 | n/a | if __name__ == "__main__": |
---|
20 | n/a | unittest.main() |
---|