Minitest assert_throws, why rescue?

In minitest why does assert_throws rescue ArgumentError/NameError ?

def assert_throws sym, msg = nil
default = “Expected #{mu_pp(sym)} to have been thrown”
caught = true
catch(sym) do
begin
yield
rescue ArgumentError => e # 1.9 exception
default += “, not #{e.message.split(/ /).last}”
rescue NameError => e # 1.8 exception
default += “, not #{e.name.inspect}”
end
caught = false
end

  assert caught, message(msg) { default }
end

Thanks.

On Sep 2, 3:40 am, John B. [email protected] wrote:

On Sep 2, 2009, at 12:12 AM, Intransition wrote:

In minitest why does assert_throws rescue ArgumentError/NameError ?

NameError (or ArgumentError on 1.9) is what’s raised by Kernel#throw
when there’s no catch block for the thrown symbol.

I see. Thanks.

On Sep 2, 2009, at 12:12 AM, Intransition wrote:

In minitest why does assert_throws rescue ArgumentError/NameError ?

NameError (or ArgumentError on 1.9) is what’s raised by Kernel#throw
when there’s no catch block for the thrown symbol.

~ j.