From: ts Date: 2008-06-09T22:38:25+09:00 Subject: [ruby-core:17164] Re: lambda { break } SASADA Koichi wrote: > Can you write a test cases such as in "bootstraptest/test_*.rb"? Well, originally there were written in another form to make easy to test with 1.8 > We can test it automatically. all tests are based on 1.8, i.e. 1.8 pass these tests where 1.9 fail vgs% svn diff KNOWNBUGS.rb Index: KNOWNBUGS.rb =================================================================== --- KNOWNBUGS.rb (revision 17060) +++ KNOWNBUGS.rb (working copy) @@ -105,3 +105,76 @@ a = [false] (a[0] &&= true) == false ? :ok : :ng }, '[ruby-dev:34679]' +assert_equal 'ok', %q{ + $x = :ok + def def7(x, y) + x[y] + $x = :ng + end + def test_def7 + def7(lambda {|x| x.call}, Proc.new {return}) + $x = :ng + end + test_def7 + $x +} + +assert_equal 'ok', %q{ + lambda { a = lambda { return }; $x = :ng; a[]; $x = :ok }.call + $x +} + +assert_equal 'ok', %q{ + lambda { a = lambda { break }; $x = :ng; a[]; $x = :ok }.call + $x +} + +assert_equal 'ok', %q{ + def def8 + lambda { a = Proc.new { return }; $x = :ok; a[]; $x = :ng }.call + $x = :ng + end + def8 + $x +} + + +assert_equal 'ok', %q{ + def def9 + lambda {|a| $x = :ok; a[]; $x = :ng }.call(Proc.new { return }) + $x = :ng + end + def9 + $x +} + +assert_equal 'ok', %q{ + def def10 + lambda { 1.times { return } }.call + $x = :ng + end + $x = :ok + def10 + $x +} + +assert_equal 'ok', %q{ + def def11 + yield + end + begin + lambda { def11 { return } }.call + rescue LocalJumpError + :ok + else + :ng + end +} + +assert_equal 'ok', %q{ + def def12 + b = Proc.new { $x = :ng; lambda { return }.call; $x = :ok }.call + end + def12 + $x +} vgs% Guy Decoux