Skip to content

Commit 9eaf7df

Browse files
committed
add tests
1 parent e4d7980 commit 9eaf7df

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tests/test_cfg.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,27 @@ def test_iter_invalid_types(self):
8282
block[:] = [nop]
8383
self.assertEqual(len(block), 1)
8484

85-
# Only one jump allowed and only at the end — caught at extend time
85+
# Only one jump allowed and only at the end
8686
block = BasicBlock()
8787
block2 = BasicBlock()
88+
# caught at extend time (within batch)
8889
with self.assertRaises(ValueError):
8990
block.extend(
9091
[
9192
Instr("JUMP_FORWARD", block2),
9293
Instr("NOP"),
9394
]
9495
)
96+
# caught at append time (cross-boundary)
97+
block = BasicBlock()
98+
block.append(Instr("JUMP_FORWARD", block2))
99+
with self.assertRaises(ValueError):
100+
block.append(Instr("NOP"))
101+
# caught at extend time (cross-boundary)
102+
block = BasicBlock()
103+
block.append(Instr("JUMP_FORWARD", block2))
104+
with self.assertRaises(ValueError):
105+
block.extend([Instr("NOP")])
95106

96107
# jump target must be a BasicBlock
97108
block = BasicBlock()

0 commit comments

Comments
 (0)