0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/mjsunit/test-exception-handler.js
Felix Geisendörfer 530328f12b CommonJS testing for node.js
Refactored test suite to use the assert module for testing rather than
mjsunit.
2009-12-05 01:05:16 +01:00

26 lines
578 B
JavaScript

process.mixin(require("./common"));
var MESSAGE = 'catch me if you can';
var caughtException = false;
process.addListener('uncaughtException', function (e) {
puts("uncaught exception! 1");
assert.equal(MESSAGE, e.message);
caughtException = true;
});
process.addListener('uncaughtException', function (e) {
puts("uncaught exception! 2");
assert.equal(MESSAGE, e.message);
caughtException = true;
});
setTimeout(function() {
throw new Error(MESSAGE);
}, 10);
process.addListener("exit", function () {
puts("exit");
assert.equal(true, caughtException);
});