From 42a6a7d0d33f87d889cebc8d89aa37393dce6054 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 17 Jul 2013 18:52:02 +0800 Subject: [PATCH] Add two tests regarding crashes in context switching. --- spec/node/contexts.coffee | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/node/contexts.coffee diff --git a/spec/node/contexts.coffee b/spec/node/contexts.coffee new file mode 100644 index 0000000..589b74a --- /dev/null +++ b/spec/node/contexts.coffee @@ -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 -- 2.7.4