Skip to content

Commit

Permalink
test: verify multiple init via well-known symbol
Browse files Browse the repository at this point in the history
Re-`require()` the addon after clearing its cache to ensure that it is
re-initialized via the well-known symbol.

PR-URL: #19875
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
Gabriel Schulhof committed Apr 9, 2018
1 parent 0bd3da1 commit 244af7a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/addons/hello-world/test.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 244af7a

Please sign in to comment.