Skip to content

Commit

Permalink
[t] Add tests for throwing subclasses of Exception, tene++
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Dec 1, 2010
1 parent 9073bda commit 416e564
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion t/pmc/exception.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Tests C<Exception> and C<ExceptionHandler> PMCs.

.sub main :main
.include 'test_more.pir'
plan(43)
plan(47)
test_bool()
test_int()
test_integer_keyed()
Expand All @@ -38,6 +38,36 @@ Tests C<Exception> and C<ExceptionHandler> PMCs.
test_throw_clone()
test_backtrace()
test_annotations()
test_throw_exception_subclass()
.end

.sub test_throw_exception_subclass
.local pmc exc, lexc, lex
exc = get_class 'Exception'
lexc = subclass exc, 'LolException'
lex = new lexc
lex['message'] = 'I CAN HAZ LOLEXCEPTION?'
$S0 = lex['message']

push_eh gotit
die $S0

throw lex
pop_eh

.return()
gotit:
.local pmc ex, cont
.local string msg, type, loltype
.get_results(ex)
type = typeof ex
loltype = typeof lex
is(type,loltype, 'throwing a subclass of Exception has the correct type')

msg = ex
is(msg,'I CAN HAZ LOLEXCEPTION?', 'throwing a subclass of Exception has the correct message')
cont = ex['resume']
cont()
.end

.sub test_bool
Expand Down Expand Up @@ -410,6 +440,12 @@ _handler:
is($I0, 0, 'annotations from unthrow Exception are empty')
.end

.namespace ['LolException']

.sub 'lol' :method
say 'OHAI'
.end

# Local Variables:
# mode: pir
# fill-column: 100
Expand Down

0 comments on commit 416e564

Please sign in to comment.