mirror of
https://github.com/nodejs/node.git
synced 2025-05-19 17:48:40 +00:00

v8 6.8 supports all removed flags. For example for BigInt. PR-URL: https://github.com/nodejs/node/pull/22285 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
// Flags: --experimental-vm-modules
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { SourceTextModule } = require('vm');
|
|
|
|
async function testBasic() {
|
|
const m = new SourceTextModule('import.meta;', {
|
|
initializeImportMeta: common.mustCall((meta, module) => {
|
|
assert.strictEqual(module, m);
|
|
meta.prop = 42;
|
|
})
|
|
});
|
|
await m.link(common.mustNotCall());
|
|
m.instantiate();
|
|
const { result } = await m.evaluate();
|
|
assert.strictEqual(typeof result, 'object');
|
|
assert.strictEqual(Object.getPrototypeOf(result), null);
|
|
assert.strictEqual(result.prop, 42);
|
|
assert.deepStrictEqual(Reflect.ownKeys(result), ['prop']);
|
|
}
|
|
|
|
async function testInvalid() {
|
|
for (const invalidValue of [
|
|
null, {}, 0, Symbol.iterator, [], 'string', false
|
|
]) {
|
|
common.expectsError(() => {
|
|
new SourceTextModule('', {
|
|
initializeImportMeta: invalidValue
|
|
});
|
|
}, {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError
|
|
});
|
|
}
|
|
}
|
|
|
|
(async () => {
|
|
await testBasic();
|
|
await testInvalid();
|
|
})();
|