Skip to content

Commit

Permalink
Comparison test for implicit domain binding on fs module, reference for
Browse files Browse the repository at this point in the history
  • Loading branch information
langpavel committed Sep 5, 2012
1 parent 9c01e6e commit 0b61410
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/simple/test-domain-implicit-fs.js
Expand Up @@ -27,9 +27,10 @@ var assert = require('assert');
var domain = require('domain');
var events = require('events');
var caught = 0;
var expectCaught = 1;
var expectCaught = 2;

var d = new domain.Domain();
var d2 = new domain.Domain();
var e = new events.EventEmitter();

d.on('error', function(er) {
Expand All @@ -45,6 +46,17 @@ d.on('error', function(er) {
caught++;
});

d2.on('error', function(er) {
console.error('caught', er);

assert.strictEqual(er.domain, d2);
assert.strictEqual(er.domain_thrown, true);
assert.ok(!er.domain_emitter);
assert.strictEqual(er.message, 'TEST');

caught++;
});

process.on('exit', function() {
console.error('exit');
assert.equal(caught, expectCaught);
Expand All @@ -70,3 +82,14 @@ d.run(function() {
});
}, 100);
});

d2.run(function() {
setTimeout(function() {
var fs = require('fs');
fs.readdir(__dirname, function() {
fs.open('this file does not exist', 'r', function(er) {
throw new Error('TEST');
});
});
}, 100);
});

0 comments on commit 0b61410

Please sign in to comment.