-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Expand file tree
/
Copy pathtest.js
More file actions
35 lines (28 loc) · 1.05 KB
/
test.js
File metadata and controls
35 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const common = require('../../common');
const assert = require('assert');
const domain = require('domain');
const binding = require(`./build/${common.buildType}/binding`);
function makeCallback(object, cb) {
binding.makeCallback(object, () => setImmediate(cb));
}
let latestWarning = null;
process.on('warning', function(warning) {
latestWarning = warning;
});
const d = domain.create();
// When domain is disabled, no warning will be emitted
makeCallback({ domain: d }, common.mustCall(function() {
assert.strictEqual(latestWarning, null);
d.run(common.mustCall(function() {
// No warning will be emitted when no domain property is applied
makeCallback({}, common.mustCall(function() {
assert.strictEqual(latestWarning, null);
// Warning is emitted when domain property is used and domain is enabled
makeCallback({ domain: d }, common.mustCall(function() {
assert.strictEqual(latestWarning.name, 'DeprecationWarning');
assert.strictEqual(latestWarning.code, 'DEP00XX');
}));
}));
}));
}));