Add two tests regarding crashes in context switching.

This commit is contained in:
Cheng Zhao 2013-07-17 18:52:02 +08:00
Родитель ec33b4d579
Коммит 42a6a7d0d3
1 изменённых файлов: 21 добавлений и 0 удалений

21
spec/node/contexts.coffee Normal file
Просмотреть файл

@ -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