diff options
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test__opcode.py | 9 | ||||
| -rw-r--r-- | Lib/test/test_dis.py | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test__opcode.py b/Lib/test/test__opcode.py index 2a4c0d2..f548e36 100644 --- a/Lib/test/test__opcode.py +++ b/Lib/test/test__opcode.py @@ -18,9 +18,10 @@ class OpcodeTests(unittest.TestCase): self.assertRaises(ValueError, stack_effect, dis.opmap['BUILD_SLICE']) self.assertRaises(ValueError, stack_effect, dis.opmap['POP_TOP'], 0) # All defined opcodes + has_arg = dis.hasarg for name, code in filter(lambda item: item[0] not in dis.deoptmap, dis.opmap.items()): with self.subTest(opname=name): - if code < dis.HAVE_ARGUMENT: + if code not in has_arg: stack_effect(code) self.assertRaises(ValueError, stack_effect, code, 0) else: @@ -46,10 +47,12 @@ class OpcodeTests(unittest.TestCase): self.assertEqual(stack_effect(JUMP_FORWARD, 0, jump=True), 0) self.assertEqual(stack_effect(JUMP_FORWARD, 0, jump=False), 0) # All defined opcodes + has_arg = dis.hasarg + has_exc = dis.hasexc has_jump = dis.hasjabs + dis.hasjrel for name, code in filter(lambda item: item[0] not in dis.deoptmap, dis.opmap.items()): with self.subTest(opname=name): - if code < dis.HAVE_ARGUMENT: + if code not in has_arg: common = stack_effect(code) jump = stack_effect(code, jump=True) nojump = stack_effect(code, jump=False) @@ -57,7 +60,7 @@ class OpcodeTests(unittest.TestCase): common = stack_effect(code, 0) jump = stack_effect(code, 0, jump=True) nojump = stack_effect(code, 0, jump=False) - if code in has_jump: + if code in has_jump or code in has_exc: self.assertEqual(common, max(jump, nojump)) else: self.assertEqual(jump, common) diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 2554253..07f1203 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -897,7 +897,7 @@ class DisTests(DisTestBase): continue with self.subTest(opname=opname): width = dis._OPNAME_WIDTH - if opcode < dis.HAVE_ARGUMENT: + if opcode in dis.hasarg: width += 1 + dis._OPARG_WIDTH self.assertLessEqual(len(opname), width) |
