summaryrefslogtreecommitdiff
path: root/test/parallel/test-internal-module-wrap.js
diff options
context:
space:
mode:
authorGus Caplan <me@gus.host>2018-02-01 09:44:27 -0600
committerTimothy Gu <timothygu99@gmail.com>2018-02-04 13:49:06 -0800
commitb0f114ddb08a289dcef4a2ec68a598d31fc36f0c (patch)
tree45641ca440f405bafb870c0a6b45188729dda942 /test/parallel/test-internal-module-wrap.js
parent05e702d9f16f6808e83f6a47cfa4294dea3f7343 (diff)
downloadandroid-node-v8-b0f114ddb08a289dcef4a2ec68a598d31fc36f0c.tar.gz
android-node-v8-b0f114ddb08a289dcef4a2ec68a598d31fc36f0c.tar.bz2
android-node-v8-b0f114ddb08a289dcef4a2ec68a598d31fc36f0c.zip
loader: fix up #18394
This commit fixes up some issues in #18394. * Switch vm.Module internals to use the new link method properly * Fix bug with ModuleWrap::Link * Add tests for ModuleWrap::Link PR-URL: https://github.com/nodejs/node/pull/18509 Fixes: https://github.com/nodejs/node/issues/18249 Refs: https://github.com/nodejs/node/pull/18394 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'test/parallel/test-internal-module-wrap.js')
-rw-r--r--test/parallel/test-internal-module-wrap.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/parallel/test-internal-module-wrap.js b/test/parallel/test-internal-module-wrap.js
new file mode 100644
index 0000000000..634d1ebc6f
--- /dev/null
+++ b/test/parallel/test-internal-module-wrap.js
@@ -0,0 +1,29 @@
+'use strict';
+
+// Flags: --expose-internals
+
+const common = require('../common');
+common.crashOnUnhandledRejection();
+const assert = require('assert');
+
+const ModuleWrap = require('internal/loader/ModuleWrap');
+const { getPromiseDetails, isPromise } = process.binding('util');
+const setTimeoutAsync = require('util').promisify(setTimeout);
+
+const foo = new ModuleWrap('export * from "bar"; 6;', 'foo');
+const bar = new ModuleWrap('export const five = 5', 'bar');
+
+(async () => {
+ const promises = foo.link(() => setTimeoutAsync(1000).then(() => bar));
+ assert.strictEqual(promises.length, 1);
+ assert(isPromise(promises[0]));
+
+ await Promise.all(promises);
+
+ assert.strictEqual(getPromiseDetails(promises[0])[1], bar);
+
+ foo.instantiate();
+
+ assert.strictEqual(await foo.evaluate(), 6);
+ assert.strictEqual(foo.namespace().five, 5);
+})();