summaryrefslogtreecommitdiff
path: root/test/parallel/test-vm-module-errors.js
diff options
context:
space:
mode:
authorGus Caplan <me@gus.host>2018-07-27 21:21:30 -0500
committerGus Caplan <me@gus.host>2018-07-31 10:23:03 -0500
commit2bdcdfc3cbf735ede8130901f58efcd4c6fe9697 (patch)
tree5f040a87e2f7ef06b67a4ef17a7478a89b5a985a /test/parallel/test-vm-module-errors.js
parent3b23b4d7c08e3e61f7e1ff3b91a6626b2bcfd5e3 (diff)
downloadandroid-node-v8-2bdcdfc3cbf735ede8130901f58efcd4c6fe9697.tar.gz
android-node-v8-2bdcdfc3cbf735ede8130901f58efcd4c6fe9697.tar.bz2
android-node-v8-2bdcdfc3cbf735ede8130901f58efcd4c6fe9697.zip
vm: rename vm.Module to vm.SourceTextModule
At the last TC39 meeting, a new type of Module Records backed by JavaScript source called Dynamic Module Records was discussed, and it is now at Stage 1. Regardless of whether that proposal makes it all the way into the spec, SourceTextModule is indeed a more descriptive and accurate name for what this class represents. PR-URL: https://github.com/nodejs/node/pull/22007 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Diffstat (limited to 'test/parallel/test-vm-module-errors.js')
-rw-r--r--test/parallel/test-vm-module-errors.js44
1 files changed, 22 insertions, 22 deletions
diff --git a/test/parallel/test-vm-module-errors.js b/test/parallel/test-vm-module-errors.js
index 720f28525b..6803e0d86b 100644
--- a/test/parallel/test-vm-module-errors.js
+++ b/test/parallel/test-vm-module-errors.js
@@ -6,7 +6,7 @@ const common = require('../common');
const assert = require('assert');
-const { Module, createContext } = require('vm');
+const { SourceTextModule, createContext } = require('vm');
async function expectsRejection(fn, settings) {
const validateError = common.expectsError(settings);
@@ -29,14 +29,14 @@ async function expectsRejection(fn, settings) {
}
async function createEmptyLinkedModule() {
- const m = new Module('');
+ const m = new SourceTextModule('');
await m.link(common.mustNotCall());
return m;
}
async function checkArgType() {
common.expectsError(() => {
- new Module();
+ new SourceTextModule();
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
@@ -46,7 +46,7 @@ async function checkArgType() {
0, 1, null, true, 'str', () => {}, { url: 0 }, Symbol.iterator
]) {
common.expectsError(() => {
- new Module('', invalidOptions);
+ new SourceTextModule('', invalidOptions);
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
@@ -57,7 +57,7 @@ async function checkArgType() {
0, 1, undefined, null, true, 'str', {}, Symbol.iterator
]) {
await expectsRejection(async () => {
- const m = new Module('');
+ const m = new SourceTextModule('');
await m.link(invalidLinker);
}, {
code: 'ERR_INVALID_ARG_TYPE',
@@ -69,7 +69,7 @@ async function checkArgType() {
// Check methods/properties can only be used under a specific state.
async function checkModuleState() {
await expectsRejection(async () => {
- const m = new Module('');
+ const m = new SourceTextModule('');
await m.link(common.mustNotCall());
assert.strictEqual(m.linkingStatus, 'linked');
await m.link(common.mustNotCall());
@@ -78,7 +78,7 @@ async function checkModuleState() {
});
await expectsRejection(async () => {
- const m = new Module('');
+ const m = new SourceTextModule('');
m.link(common.mustNotCall());
assert.strictEqual(m.linkingStatus, 'linking');
await m.link(common.mustNotCall());
@@ -87,14 +87,14 @@ async function checkModuleState() {
});
common.expectsError(() => {
- const m = new Module('');
+ const m = new SourceTextModule('');
m.instantiate();
}, {
code: 'ERR_VM_MODULE_NOT_LINKED'
});
await expectsRejection(async () => {
- const m = new Module('import "foo";');
+ const m = new SourceTextModule('import "foo";');
try {
await m.link(common.mustCall(() => ({})));
} catch (err) {
@@ -107,7 +107,7 @@ async function checkModuleState() {
});
{
- const m = new Module('import "foo";');
+ const m = new SourceTextModule('import "foo";');
await m.link(common.mustCall(async (specifier, module) => {
assert.strictEqual(module, m);
assert.strictEqual(specifier, 'foo');
@@ -117,14 +117,14 @@ async function checkModuleState() {
}, {
code: 'ERR_VM_MODULE_NOT_LINKED'
});
- return new Module('');
+ return new SourceTextModule('');
}));
m.instantiate();
await m.evaluate();
}
await expectsRejection(async () => {
- const m = new Module('');
+ const m = new SourceTextModule('');
await m.evaluate();
}, {
code: 'ERR_VM_MODULE_STATUS',
@@ -140,7 +140,7 @@ async function checkModuleState() {
});
common.expectsError(() => {
- const m = new Module('');
+ const m = new SourceTextModule('');
m.error;
}, {
code: 'ERR_VM_MODULE_STATUS',
@@ -158,7 +158,7 @@ async function checkModuleState() {
});
common.expectsError(() => {
- const m = new Module('');
+ const m = new SourceTextModule('');
m.namespace;
}, {
code: 'ERR_VM_MODULE_STATUS',
@@ -177,7 +177,7 @@ async function checkModuleState() {
// Check link() fails when the returned module is not valid.
async function checkLinking() {
await expectsRejection(async () => {
- const m = new Module('import "foo";');
+ const m = new SourceTextModule('import "foo";');
try {
await m.link(common.mustCall(() => ({})));
} catch (err) {
@@ -191,9 +191,9 @@ async function checkLinking() {
await expectsRejection(async () => {
const c = createContext({ a: 1 });
- const foo = new Module('', { context: c });
+ const foo = new SourceTextModule('', { context: c });
await foo.link(common.mustNotCall());
- const bar = new Module('import "foo";');
+ const bar = new SourceTextModule('import "foo";');
try {
await bar.link(common.mustCall(() => foo));
} catch (err) {
@@ -206,7 +206,7 @@ async function checkLinking() {
});
await expectsRejection(async () => {
- const erroredModule = new Module('import "foo";');
+ const erroredModule = new SourceTextModule('import "foo";');
try {
await erroredModule.link(common.mustCall(() => ({})));
} catch (err) {
@@ -215,7 +215,7 @@ async function checkLinking() {
assert.strictEqual(erroredModule.linkingStatus, 'errored');
}
- const rootModule = new Module('import "errored";');
+ const rootModule = new SourceTextModule('import "errored";');
await rootModule.link(common.mustCall(() => erroredModule));
}, {
code: 'ERR_VM_MODULE_LINKING_ERRORED'
@@ -225,8 +225,8 @@ async function checkLinking() {
// Check the JavaScript engine deals with exceptions correctly
async function checkExecution() {
await (async () => {
- const m = new Module('import { nonexistent } from "module";');
- await m.link(common.mustCall(() => new Module('')));
+ const m = new SourceTextModule('import { nonexistent } from "module";');
+ await m.link(common.mustCall(() => new SourceTextModule('')));
// There is no code for this exception since it is thrown by the JavaScript
// engine.
@@ -236,7 +236,7 @@ async function checkExecution() {
})();
await (async () => {
- const m = new Module('throw new Error();');
+ const m = new SourceTextModule('throw new Error();');
await m.link(common.mustNotCall());
m.instantiate();
const evaluatePromise = m.evaluate();