mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8f742bb13f
PR-URL: https://github.com/nodejs/node/pull/50318 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
31 lines
697 B
JavaScript
31 lines
697 B
JavaScript
'use strict';
|
|
|
|
// Flags: --experimental-vm-modules
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
const { SourceTextModule } = require('vm');
|
|
|
|
{
|
|
const m = new SourceTextModule('const a = 1');
|
|
const cachedData = m.createCachedData();
|
|
|
|
new SourceTextModule('const a = 1', { cachedData });
|
|
|
|
assert.throws(() => {
|
|
new SourceTextModule('differentSource', { cachedData });
|
|
}, {
|
|
code: 'ERR_VM_MODULE_CACHED_DATA_REJECTED',
|
|
});
|
|
}
|
|
|
|
assert.rejects(async () => {
|
|
const m = new SourceTextModule('const a = 1');
|
|
await m.link(() => {});
|
|
m.evaluate();
|
|
m.createCachedData();
|
|
}, {
|
|
code: 'ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA',
|
|
}).then(common.mustCall());
|