diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2018-04-07 22:26:08 -0400 |
---|---|---|
committer | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2018-04-08 21:21:07 -0400 |
commit | 244af7a9d528b105b3e84db2c7d1a05fa295b334 (patch) | |
tree | 645cdd1eed37f44dff63ff6a5702de73a13bc252 /test/addons | |
parent | 0bd3da15a080e9b363b37da53ca6cad4088d4aff (diff) | |
download | android-node-v8-244af7a9d528b105b3e84db2c7d1a05fa295b334.tar.gz android-node-v8-244af7a9d528b105b3e84db2c7d1a05fa295b334.tar.bz2 android-node-v8-244af7a9d528b105b3e84db2c7d1a05fa295b334.zip |
test: verify multiple init via well-known symbol
Re-`require()` the addon after clearing its cache to ensure that it is
re-initialized via the well-known symbol.
PR-URL: https://github.com/nodejs/node/pull/19875
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/addons')
-rw-r--r-- | test/addons/hello-world/test.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/addons/hello-world/test.js b/test/addons/hello-world/test.js index b0148e9d9e..d1d67d34f6 100644 --- a/test/addons/hello-world/test.js +++ b/test/addons/hello-world/test.js @@ -1,6 +1,13 @@ 'use strict'; const common = require('../../common'); const assert = require('assert'); -const binding = require(`./build/${common.buildType}/binding`); +const bindingPath = require.resolve(`./build/${common.buildType}/binding`); +const binding = require(bindingPath); assert.strictEqual(binding.hello(), 'world'); console.log('binding.hello() =', binding.hello()); + +// Test multiple loading of the same module. +delete require.cache[bindingPath]; +const rebinding = require(bindingPath); +assert.strictEqual(rebinding.hello(), 'world'); +assert.notStrictEqual(binding.hello, rebinding.hello); |