jashkenas--coffeescript/test/test_try_catch.coffee

42 lines
431 B
CoffeeScript
Raw Normal View History

# Basic exception throwing.
2010-07-25 05:23:37 +00:00
block = -> (throw 'up')
throws block, 'up'
# Basic try/catch.
2010-07-25 05:23:37 +00:00
result = try
10
finally
15
ok result is 10
2010-07-25 05:23:37 +00:00
result = try
throw 'up'
catch err
err.length
2010-06-28 12:50:44 +00:00
ok result is 2
2010-07-25 05:23:37 +00:00
result = try throw 'error' catch err then err.length
2010-06-28 12:50:44 +00:00
ok result is 5
# try/catch with empty clauses still compiles.
try
# nothing
catch err
# nothing
try
# nothing
finally
# nothing
try
catch err
finally
ok yes