diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-04-25 19:04:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-25 19:04:06 (GMT) |
commit | 57faf348872d1d0af1808c82f535cf220d64b028 (patch) | |
tree | 9c6d67a4920409a1701c14c2997e260f2c962c13 /Lib/test/test__opcode.py | |
parent | e9d9494d6b2a5e0c2d48d22c7f0d5e95504b4f7e (diff) | |
download | cpython-57faf348872d1d0af1808c82f535cf220d64b028.zip cpython-57faf348872d1d0af1808c82f535cf220d64b028.tar.gz cpython-57faf348872d1d0af1808c82f535cf220d64b028.tar.bz2 |
bpo-33334: Support NOP and EXTENDED_ARG in dis.stack_effect(). (#6566)
Added tests to ensure that all defined opcodes are supported.
Diffstat (limited to 'Lib/test/test__opcode.py')
-rw-r--r-- | Lib/test/test__opcode.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test__opcode.py b/Lib/test/test__opcode.py index 1075dec..2af1ee3 100644 --- a/Lib/test/test__opcode.py +++ b/Lib/test/test__opcode.py @@ -15,6 +15,21 @@ class OpcodeTests(unittest.TestCase): 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) + # All defined opcodes + for name, code in dis.opmap.items(): + with self.subTest(opname=name): + if code < dis.HAVE_ARGUMENT: + _opcode.stack_effect(code) + self.assertRaises(ValueError, _opcode.stack_effect, code, 0) + else: + _opcode.stack_effect(code, 0) + self.assertRaises(ValueError, _opcode.stack_effect, code) + # All not defined opcodes + for code in set(range(256)) - set(dis.opmap.values()): + with self.subTest(opcode=code): + self.assertRaises(ValueError, _opcode.stack_effect, code) + self.assertRaises(ValueError, _opcode.stack_effect, code, 0) + if __name__ == "__main__": unittest.main() |