mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
- Refactor vm.SourceTextModule (again) - Add vm.Module abstract superclass - Add vm.SyntheticModule Refs: https://heycam.github.io/webidl/#synthetic-module-records PR-URL: https://github.com/nodejs/node/pull/29864 Reviewed-By: Guy Bedford <guybedford@gmail.com>
30 lines
901 B
JavaScript
30 lines
901 B
JavaScript
'use strict';
|
|
|
|
// Flags: --expose-internals
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const { ModuleWrap } = internalBinding('module_wrap');
|
|
const { getPromiseDetails, isPromise } = internalBinding('util');
|
|
const setTimeoutAsync = require('util').promisify(setTimeout);
|
|
|
|
const foo = new ModuleWrap('foo', undefined, 'export * from "bar"; 6;', 0, 0);
|
|
const bar = new ModuleWrap('bar', undefined, 'export const five = 5', 0, 0);
|
|
|
|
(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(-1, false), 6);
|
|
assert.strictEqual(foo.getNamespace().five, 5);
|
|
})();
|