From: Sylvain Joyeux Date: 2008-04-08T02:10:00+09:00 Subject: Re: Module.new(&block) in Ruby 1.9 --dkEUBIird37B8yKS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline About bug [#19304] http://rubyforge.org/tracker/?func=detail&aid=19304&group_id=426&atid=1698 Shyouhei mentionned that it could be an intended behaviour. I really doubt it, but I wanted to check and hit other bugs of the same flavour with lambda (see attached file). So, first question: is it a bug or a feature ? Second question: if it is a bug, should I submit a new bug for it or is it better to add it as a follow up for the return-in-method bug ? Finally, I'm not sure my last mail actually reached the list. Guy: I wanted to ask you if the tests you did are actually on a patched version of 1.9 (in which case, could you send it to me ?), or is it that your build of ruby trunk do not show the issues in question ? Best regards, Sylvain --dkEUBIird37B8yKS Content-Type: application/x-ruby Content-Description: test_lambda.rb Content-Disposition: attachment; filename="lambda_test.rb" Content-Transfer-Encoding: quoted-printable require 'test/unit/testcase'=0A=0Aclass TC_LambdaBehaviour < Test::Unit::Te= stCase=0A def direct_lambda=0A l =3D lambda { return :bar }=0A = [l.call, :foo]=0A end=0A def indirect_lambda(&block)=0A l= =3D lambda(&block)=0A [l.call, :foo]=0A end=0A def create_lam= bda_direct; lambda { return :bar } end=0A def create_lambda_indirect(&bl= ock); lambda(&block) end=0A def create_lambda_more_indirect; create_lamb= da_indirect { return :bar } end=0A def call_lambda(l); [l.call, :foo] en= d=0A=0A def test_return_in_lambda=0A # These two variables are us= ed to check that 'return' does not shortcut=0A # while used in lambd= a functions=0A has_error =3D nil=0A result =3D nil=0A=0A = count =3D 0=0A assert_equal([:bar, :foo], direct_lambda)=0A=0A = count =3D 1=0A l =3D create_lambda_direct=0A assert_noth= ing_raised { result =3D call_lambda(l) }=0A assert_equal([:bar, :foo= ], result)=0A=0A count =3D 2=0A l =3D create_lambda_indirect = { return :bar }=0A assert_nothing_raised { result =3D call_lambda(l)= }=0A assert_equal([:bar, :foo], result)=0A=0A count =3D 3=0A= l =3D create_lambda_more_indirect=0A assert_nothing_raised {= result =3D call_lambda(l) }=0A assert_equal([:bar, :foo], result)= =0A=0A count =3D 4=0A assert_equal([:bar, :foo], indirect_lam= bda { return :bar })=0A=0A count =3D 5=0A=0A rescue Exception=0A = has_error =3D true=0A raise=0A ensure=0A unless has= _error=0A assert_equal(5, count)=0A end=0A end=0Aend= =0A=0A --dkEUBIird37B8yKS--