2 # This test program is contributed by George Marrows
3 # Re: [Yarv-devel] Some tests for test_jump.rb
6 require 'yarvtest/yarvtest'
8 class TestFlow < YarvTestBase
9 def ae_flow(src, for_value=true)
10 # Tracks flow through the code
15 # gets transformed into
25 # before being run. This tracks control flow through the code.
28 src = src.gsub(/(\n|$)/) { "; $a << #{cnt+=1}\n" }
29 src = "$a = []; begin; #{src}; rescue Exception; $a << 99; end; $a"
41 def test_while_with_ensure
107 def test_ensure_normal_flow
114 def test_ensure_exception
123 def test_break_in_block_runs_ensure
134 def test_next_in_block_runs_ensure
144 def test_return_from_method_runs_ensure
155 def test_break_from_ifunc
157 ["a"].inject("ng"){|x,y|
162 unless ''.respond_to? :lines
175 ["a"].inject("ng"){|x,y|
186 def test_break_ensure_interaction1
187 # make sure that any 'break state' set up in the VM is c
188 # the time of the ensure
199 def test_break_ensure_interaction2
200 # ditto, different arrangement
211 def test_break_through_2_ensures
225 def test_ensure_break_ensure
226 # break through an ensure; run 2nd normally
240 def test_exception_overrides_break
252 def test_break_overrides_exception
273 def test_break_in_exception
308 def test_next_in_exception
344 def test_complex_break
429 def test_jump_from_class
502 def test_flow_with_cont_sp
530 m(1, 1.times{break 3}) +
531 m(10, (1.times{next 3}; 20))
535 def test_return_in_deep_stack
541 m1(:a, :b, (return 1; :c))
547 def test_return_in_ensure