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

Discussion in 'Ruby' started by timr, Nov 20, 2010.

  1. timr

    timr Guest

    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
     
    timr, Nov 20, 2010
    #1
    1. Advertising

  2. timr

    timr Guest

    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
     
    timr, Nov 20, 2010
    #2
    1. Advertising

  3. timr

    timr Guest

    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?
     
    timr, Nov 20, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arjen
    Replies:
    3
    Views:
    471
    Scott Allen
    Feb 27, 2005
  2. VvanN
    Replies:
    5
    Views:
    515
    Phlip
    Apr 28, 2006
  3. matt
    Replies:
    1
    Views:
    296
    George Ogata
    Aug 6, 2004
  4. Steven Taylor
    Replies:
    9
    Views:
    280
    Brian Candler
    Apr 27, 2009
  5. Yotta Meter
    Replies:
    12
    Views:
    177
    Richard Conroy
    Feb 23, 2010
Loading...

Share This Page