From 244af7a9d528b105b3e84db2c7d1a05fa295b334 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Sat, 7 Apr 2018 22:26:08 -0400 Subject: 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 Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/addons/hello-world/test.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'test') 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); -- cgit v1.2.3