diff options
author | Rich Trott <rtrott@gmail.com> | 2017-08-05 18:41:10 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-08-10 09:11:43 -0700 |
commit | 0d3ef5b0f863a1caa538673c08747d62d23f3d31 (patch) | |
tree | 422ed5689363bf5ecb1358a59530a2b1cf240e1e /test | |
parent | 2249234fee2b4f0ce204859728135b9767538383 (diff) | |
download | android-node-v8-0d3ef5b0f863a1caa538673c08747d62d23f3d31.tar.gz android-node-v8-0d3ef5b0f863a1caa538673c08747d62d23f3d31.tar.bz2 android-node-v8-0d3ef5b0f863a1caa538673c08747d62d23f3d31.zip |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-next-tick.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/parallel/test-next-tick.js b/test/parallel/test-next-tick.js index 9c69efeb78..511d0559cd 100644 --- a/test/parallel/test-next-tick.js +++ b/test/parallel/test-next-tick.js @@ -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()); }); |