Staging
v0.8.1
Revision 7f554c536cfe2e66a1ff0a36c8896040be1e5aee authored by Miss Islington (bot) on 28 March 2018, 06:43:51 UTC, committed by Ned Deily on 28 March 2018, 07:33:49 UTC
(cherry picked from commit e52ac045972a4f75d7f52e4ee0d6de128259134d)

Co-authored-by: Ned Deily <nad@python.org>
1 parent 3647f85
Raw File
test__opcode.py
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()
back to top