Skip to content

Commit

Permalink
Add tests and make sure '1' is treated as 'true' for reachability
Browse files Browse the repository at this point in the history
  • Loading branch information
markshannon committed Oct 21, 2024
1 parent 5bc520b commit 4d0cf8e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions Lib/test/test_generated_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,33 @@ def test_push_then_error(self):
"""
self.run_cases_test(input, output)

def test_error_if_true(self):

input = """
inst(OP1, ( --)) {
ERROR_IF(true, here);
}
inst(OP2, ( --)) {
ERROR_IF(1, there);
}
"""
output = """
TARGET(OP1) {
frame->instr_ptr = next_instr;
next_instr += 1;
INSTRUCTION_STATS(OP1);
goto here;
}
TARGET(OP2) {
frame->instr_ptr = next_instr;
next_instr += 1;
INSTRUCTION_STATS(OP2);
goto there;
}
"""
self.run_cases_test(input, output)

def test_scalar_array_inconsistency(self):

input = """
Expand Down
2 changes: 1 addition & 1 deletion Tools/cases_generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def always_exits(op: parser.InstDef) -> bool:
if tkn.text == "DEOPT_IF" or tkn.text == "ERROR_IF":
next(tkn_iter) # '('
t = next(tkn_iter)
if t.text == "true":
if t.text in ("true", "1"):
return True
return False

Expand Down

0 comments on commit 4d0cf8e

Please sign in to comment.