minor enhancements to test/exception_handling.coffee

This commit is contained in:
Michael Ficarra 2010-12-13 01:27:22 -05:00
parent d13e0762d3
commit 835840e8da
1 changed files with 14 additions and 7 deletions

View File

@ -4,11 +4,13 @@
# shared nonce
nonce = {}
#### Throw
test "basic exception throwing", ->
throws (-> throw 'error'), 'error'
#### Empty Try/Catch/Finally
test "try can exist alone", ->
@ -57,20 +59,25 @@ test "single-line result of try when no exception is thrown", ->
eq nonce, result
test "return the result of catch when an exception is thrown", ->
result = try
throw ->
catch err
nonce
eq nonce, result
fn = ->
try
throw ->
catch err
nonce
doesNotThrow fn
eq nonce, fn()
test "single-line result of catch when an exception is thrown", ->
result = try throw -> catch err then nonce
eq nonce, result
fn = ->
try throw (->) catch err then nonce
doesNotThrow fn
eq nonce, fn()
test "optional catch", ->
fn = ->
try throw ->
nonce
doesNotThrow fn
eq nonce, fn()