test: check this
value for nextTick()
Depending on how many arguments are provided, `nextTick()` may run its callback with `this` set to `null` or not. Add assertions for both cases. PR-URL: https://github.com/nodejs/node/pull/14645 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
2249234fee
commit
0d3ef5b0f8
@ -21,6 +21,7 @@
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
process.nextTick(common.mustCall(function() {
|
||||
@ -40,8 +41,23 @@ const obj = {};
|
||||
process.nextTick(function(a, b) {
|
||||
assert.strictEqual(a, 42);
|
||||
assert.strictEqual(b, obj);
|
||||
assert.strictEqual(this, undefined);
|
||||
}, 42, obj);
|
||||
|
||||
process.nextTick((a, b) => {
|
||||
assert.strictEqual(a, 42);
|
||||
assert.strictEqual(b, obj);
|
||||
assert.deepStrictEqual(this, {});
|
||||
}, 42, obj);
|
||||
|
||||
process.nextTick(function() {
|
||||
assert.strictEqual(this, null);
|
||||
}, 1, 2, 3, 4);
|
||||
|
||||
process.nextTick(() => {
|
||||
assert.deepStrictEqual(this, {});
|
||||
}, 1, 2, 3, 4);
|
||||
|
||||
process.on('exit', function() {
|
||||
process.nextTick(common.mustNotCall());
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user