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

T

timr

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
 
T

timr

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
 
T

timr

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top