MCPcopy Index your code
hub / github.com/python/cpython / test_basics

Method test_basics

Lib/test/test_compile.py:2977–3000  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2975 expected)
2976
2977 def test_basics(self):
2978 seq = _testinternalcapi.new_instruction_sequence()
2979
2980 def add_op(seq, opname, oparg, bl, bc=0, el=0, ec=0):
2981 seq.addop(opcode.opmap[opname], oparg, bl, bc, el, el)
2982
2983 add_op(seq, 'LOAD_CONST', 1, 1)
2984 add_op(seq, 'JUMP', lbl1 := seq.new_label(), 2)
2985 add_op(seq, 'LOAD_CONST', 1, 3)
2986 add_op(seq, 'JUMP', lbl2 := seq.new_label(), 4)
2987 seq.use_label(lbl1)
2988 add_op(seq, 'LOAD_CONST', 2, 4)
2989 seq.use_label(lbl2)
2990 add_op(seq, 'RETURN_VALUE', 0, 3)
2991
2992 expected = [('LOAD_CONST', 1, 1),
2993 ('JUMP', 4, 2),
2994 ('LOAD_CONST', 1, 3),
2995 ('JUMP', 5, 4),
2996 ('LOAD_CONST', 2, 4),
2997 ('RETURN_VALUE', None, 3),
2998 ]
2999
3000 self.compare_instructions(seq, [ex + (0,0,0) for ex in expected])
3001
3002 def test_nested(self):
3003 seq = _testinternalcapi.new_instruction_sequence()

Callers

nothing calls this directly

Calls 2

compare_instructionsMethod · 0.95
add_opFunction · 0.85

Tested by

no test coverage detected