Commit 9355bd19

9355bd19e14cMerged

Erik Peterson <[email protected]> · 5 months ago · 12 files · +12 added

Description

test: cover loop/case control-flow codegen shapes

Adds regression and coverage tests for control-flow lowering that the suite previously did not exercise -- the gap that let two codegen bugs ship.

Regression tests (fail on the pre-fix codegen, pass after):

  • control_flow_loop_cond_method_arg: a method call used as an ARGUMENT inside a while condition must be re-evaluated each iteration, not hoisted into a pre-loop temp.
  • control_flow_until_cond_method_arg: same re-evaluation requirement on the until path.
  • control_flow_break_in_case_in_loop: a break inside a case with integer-literal whens (lowered to a C switch) inside a loop must exit the loop, not just the switch.

Coverage tests (pass before and after; previously-untested shapes):

  • control_flow_next_in_case_in_loop
  • control_flow_until_modifier_method
  • control_flow_while_modifier_method

Details

Commit
9355bd19e14c
Parent
349ff17e6875

test/control_flow_break_in_case_in_loop.rbaddedView file

1+out = []
2+i = 0
3+loop do
4+ case i
5+ when 3
6+ break
7+ when 7
8+ break
9+ end
10+ out << i
11+ i = i + 1
12+ break if i > 50
13+end
14+p out