mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1016 B
39 lines
1016 B
'use strict';
|
|
// Make sure the domain stack is a stack
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const domain = require('domain');
|
|
|
|
function names(array) {
|
|
return array.map(function(d) {
|
|
return d.name;
|
|
}).join(', ');
|
|
}
|
|
|
|
var a = domain.create();
|
|
a.name = 'a';
|
|
var b = domain.create();
|
|
b.name = 'b';
|
|
var c = domain.create();
|
|
c.name = 'c';
|
|
|
|
a.enter(); // push
|
|
assert.deepStrictEqual(domain._stack, [a],
|
|
'a not pushed: ' + names(domain._stack));
|
|
|
|
b.enter(); // push
|
|
assert.deepStrictEqual(domain._stack, [a, b],
|
|
'b not pushed: ' + names(domain._stack));
|
|
|
|
c.enter(); // push
|
|
assert.deepStrictEqual(domain._stack, [a, b, c],
|
|
'c not pushed: ' + names(domain._stack));
|
|
|
|
b.exit(); // pop
|
|
assert.deepStrictEqual(domain._stack, [a],
|
|
'b and c not popped: ' + names(domain._stack));
|
|
|
|
b.enter(); // push
|
|
assert.deepStrictEqual(domain._stack, [a, b],
|
|
'b not pushed: ' + names(domain._stack));
|
|
|