1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/test/test_try_catch.coffee

46 lines
465 B
CoffeeScript
Raw Normal View History

# Basic exception throwing.
block = -> throw 'up'
throws block, 'up'
# Basic try/catch.
2010-07-25 01:23:37 -04:00
result = try
10
finally
15
ok result is 10
2010-07-25 01:23:37 -04:00
result = try
throw 'up'
catch err
err.length
2010-06-28 08:50:44 -04:00
ok result is 2
2010-07-25 01:23:37 -04:00
result = try throw 'error' catch err then err.length
2010-06-28 08:50:44 -04:00
ok result is 5
2010-10-04 16:53:32 -04:00
try throw 'catch is optional'
# try/catch with empty clauses still compiles.
2010-10-04 16:53:32 -04:00
try
try
# nothing
catch err
# nothing
try
# nothing
finally
# nothing
try
catch err
finally
2010-10-04 16:53:32 -04:00
ok yes