Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
Trott committed Aug 9, 2017
commit 23918c4cd4e5a5ff0e1f9bf0a46465a33a8936d9
16 changes: 16 additions & 0 deletions test/parallel/test-next-tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

'use strict';
const common = require('../common');

const assert = require('assert');

process.nextTick(common.mustCall(function() {
Expand All @@ -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());
});