Skip to content

Commit

Permalink
Add more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Jan 25, 2011
1 parent f7117a2 commit f1449d7
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions t/op/push_cached_eh.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Test various use cases of the push_cached_eh opcode.
'test_handle'() # Call second time
'test_handle_twice'()

'test_handle_typed'()
'test_handle_typed'() # Call second time

'done_testing'()
.end

Expand All @@ -42,6 +45,46 @@ Test various use cases of the push_cached_eh opcode.
.return()
.end

.sub "test_handle_typed"
push_cached_eh .CONTROL_RETURN, catch

$P0 = new ["Exception"]
$P0["type"] = .CONTROL_RETURN
throw $P0
nok(1, "Not caught")

goto try_again

catch:
pop_eh
ok(1, "Caught typed")


try_again:
push_cached_eh .CONTROL_RETURN, catch_typed
push_cached_eh .CONTROL_ERROR, catch_untyped

$P0 = new ["Exception"]
$P0["type"] = .CONTROL_RETURN
throw $P0
nok(1, "Not caught")
.return()

catch_untyped:
pop_eh
nok(1, "Caught wrong exception")
.return()

catch_typed:
pop_eh
ok(1, "Caught correct exception")
.return()



.return()
.end


.sub "test_handle_twice"
diag("First")
Expand Down

0 comments on commit f1449d7

Please sign in to comment.