Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: check for invalid importModuleDynamically type in vm.js for Script
  • Loading branch information
alyssaq committed Nov 12, 2018
commit 2d08864fbb39fcde8a3106d67b013f8fbe71dd8a
30 changes: 24 additions & 6 deletions test/parallel/test-vm-module-dynamic-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,34 @@ async function testInvalid() {
await result.catch(common.mustCall((e) => {
assert.strictEqual(e.code, 'ERR_VM_MODULE_NOT_MODULE');
}));

const s = new Script('import("foo")', {
importModuleDynamically: common.mustCall((specifier, wrap) => {
return undefined;
}),
});
let threw = false;
try {
await s.runInThisContext();
} catch (e) {
threw = true;
assert.strictEqual(e.code, 'ERR_VM_MODULE_NOT_MODULE');
}
assert(threw);
}

async function testInvalidimportModuleDynamically() {
assert.throws(
() => new Script(
'import("foo")',
{ importModuleDynamically: false }),
{ code: 'ERR_INVALID_ARG_TYPE' }
);
}

const done = common.mustCallAtLeast(3);
(async function() {
await testNoCallback();
done();

await test();
done();

await testInvalid();
done();
await testInvalidimportModuleDynamically();
}()).then(common.mustCall());