Skip to content

Commit

Permalink
Add two tests regarding crashes in context switching.
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Jul 17, 2013
1 parent ec33b4d commit 42a6a7d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/node/contexts.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
assert = require 'assert'
fs = require 'fs'

describe 'contexts', ->
describe 'setTimeout in fs callback', ->
it 'does not crash', (done) ->
fs.readFile __filename, ->
setTimeout done, 0

describe 'throw error in node context', ->
it 'get caught', (done) ->
error = new Error('boo!')
lsts = process.listeners 'uncaughtException'
process.removeAllListeners 'uncaughtException'
process.on 'uncaughtException', (err) ->
process.removeAllListeners 'uncaughtException'
for lst in lsts
process.on 'uncaughtException', lst
done()
fs.readFile __filename, ->
throw error

0 comments on commit 42a6a7d

Please sign in to comment.