Sha256: ad0235ba786d8fac0ceb4f17843208a5a758aa95daab31282497e048f67fc797

Contents?: true

Size: 1.67 KB

Versions: 10

Compression:

Stored size: 1.67 KB

Contents

# Exceptions
# ----------

# shared nonce
nonce = {}


#### Throw

test "basic exception throwing", ->
  throws (-> throw 'error'), 'error'


#### Empty Try/Catch/Finally

test "try can exist alone", ->
  try

test "try/catch with empty try, empty catch", ->
  try
    # nothing
  catch err
    # nothing

test "single-line try/catch with empty try, empty catch", ->
  try catch err

test "try/finally with empty try, empty finally", ->
  try
    # nothing
  finally
    # nothing

test "single-line try/finally with empty try, empty finally", ->
  try finally

test "try/catch/finally with empty try, empty catch, empty finally", ->
  try
  catch err
  finally

test "single-line try/catch/finally with empty try, empty catch, empty finally", ->
  try catch err then finally


#### Try/Catch/Finally as an Expression

test "return the result of try when no exception is thrown", ->
  result = try
    nonce
  catch err
    undefined
  finally
    undefined
  eq nonce, result

test "single-line result of try when no exception is thrown", ->
  result = try nonce catch err then undefined
  eq nonce, result

test "return the result of catch when an exception is thrown", ->
  fn = ->
    try
      throw ->
    catch err
      nonce
  doesNotThrow fn
  eq nonce, fn()

test "single-line result of catch when an exception is thrown", ->
  fn = ->
    try throw (->) catch err then nonce
  doesNotThrow fn
  eq nonce, fn()

test "optional catch", ->
  fn = ->
    try throw ->
    nonce
  doesNotThrow fn
  eq nonce, fn()


#### Try/Catch/Finally Interaction With Other Constructs

test "try/catch with empty catch as last statement in a function body", ->
  fn = ->
    try nonce
    catch err
  eq nonce, fn()

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
spade-packager-0.1.0.1 packages/coffee-script/test/exception_handling.coffee
spade-packager-0.1.0 packages/coffee-script/test/exception_handling.coffee
spade-0.0.8.1 packages/coffee-script/test/exception_handling.coffee
spade-0.0.7 packages/coffee-script/test/exception_handling.coffee
spade-0.0.6 packages/coffee-script/test/exception_handling.coffee
spade-0.0.5 packages/coffee-script/test/exception_handling.coffee
spade-0.0.4 packages/coffee-script/test/exception_handling.coffee
spade-0.0.3 packages/coffee-script/test/exception_handling.coffee
spade-0.0.2 packages/coffee-script/test/exception_handling.coffee
spade-0.0.1 packages/coffee-script/test/exception_handling.coffee