[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Test and exceptions

brian.kejser

9/8/2006 6:29:00 PM

Hi

In the file testcase.rb that is part of the Test module why are only the
AssertionFailedError, StandardError and ScriptError exceptions caught?

Shouldn't snippet one (see below) be changed to snippet two (see below)?

Thanks

Snippet One:

begin
setup
__send__(@method_name)
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue StandardError, ScriptError
add_error($!)
ensure
begin
teardown
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue StandardError, ScriptError
add_error($!)
end
end

Snippet Two:

begin
setup
__send__(@method_name)
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Object
add_error($!)
ensure
begin
teardown
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Object
add_error($!)
end
end




Here's the run method that is part of the testcase class ....

def run(result)
yield(STARTED, name)
@_result = result
begin
setup
__send__(@method_name)
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Object #StandardError, ScriptError
add_error($!)
ensure
begin
teardown
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Object #StandardError, ScriptError
add_error($!)
end
end
result.add_run
yield(FINISHED, name)
end







1 Answer

Jano Svitok

9/8/2006 7:08:00 PM

0

On 9/8/06, brian.kejser@protexis.com <brian.kejser@protexis.com> wrote:
> Hi
>
> In the file testcase.rb that is part of the Test module why are only the
> AssertionFailedError, StandardError and ScriptError exceptions caught?
>
> Shouldn't snippet one (see below) be changed to snippet two (see below)?

This was discussed on ruby-core, topic "test/unit doesn't rescue a
Exception", but it seems it's not commited yet.

Good point anyway ;-)