summaryrefslogtreecommitdiff
path: root/Lib/test/test__opcode.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test__opcode.py')
-rw-r--r--Lib/test/test__opcode.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test__opcode.py b/Lib/test/test__opcode.py
index 1075decc27..2af1ee35bf 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()