Permalink
Browse files

Comparison test for implicit domain binding on fs module, reference for

  • Loading branch information...
1 parent 9c01e6e commit 0b61410a4b7fe86b53d2b46452ccdac8a04930d9 @langpavel committed Sep 5, 2012
Showing with 24 additions and 1 deletion.
  1. +24 −1 test/simple/test-domain-implicit-fs.js
@@ -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) {
@@ -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);
@@ -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.