blob: bb45337cf1a83cbcd6a9d6e44a294712395287ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
'use strict';
// Flags: --experimental-vm-modules --experimental-modules --harmony-dynamic-import
const common = require('../common');
const assert = require('assert');
const { Module, createContext } = require('vm');
const finished = common.mustCall();
(async function() {
const m = new Module('import("foo")', { context: createContext() });
await m.link(common.mustNotCall());
m.instantiate();
const { result } = await m.evaluate();
let threw = false;
try {
await result;
} catch (err) {
threw = true;
assert.strictEqual(err.message, 'import() called outside of main context');
}
assert(threw);
finished();
}());
|