Contradicting unit test regarding blocks pass, bug in unit/test?

require "test/unit"

class TestProcs < Test::Unit::TestCase

  def blk(&b)
    yield
  end

  def test_blocks_can_return_for_methods
      assert_nothing_raised do
         blk{return}
       end
  end

  def test_blocks_cannot_return_for_methods
      assert_raise LocalJumpError do
         blk{return}
       end
  end

end

#In fact it calling a method with a block with top level return raises
a LocalJumpError. So why is the assert_nothing_raised do; blk{return};
end passing?
Thanks,
Tim

Sorry for those typos. Corrected:

#In fact, calling a method within a block with top level return
raises
a LocalJumpError. So why is the assert_nothing_raised do;
blk{return};
end passing?
Thanks,
Tim

One last try:
#In fact, calling a method with a block with top level return
raises a LocalJumpError. So why is the assert_nothing_raised do;
blk{return}; end passing?

probably because it returns from your test method without further
processing the assert_nothing_raised call. It's placed correctly, as
it's within a method and evaluated while the method is still on the
stack

···

On Sat, 2010-11-20 at 15:35 +0900, timr wrote:

One last try:
#In fact, calling a method with a block with top level return
raises a LocalJumpError. So why is the assert_nothing_raised do;
blk{return}; end passing?