Skip to content

Commit 3015887

Browse files
juanarboltargos
authored andcommitted
test: check args on SourceTextModule cachedData
PR-URL: #32956 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
1 parent 8a9be1d commit 3015887

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/parallel/test-vm-module-errors.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,22 @@ async function checkInvalidOptionForEvaluate() {
209209
});
210210
}
211211

212+
function checkInvalidCachedData() {
213+
[true, false, 'foo', {}, Array, function() {}].forEach((invalidArg) => {
214+
const message = 'The "options.cachedData" property must be an ' +
215+
'instance of Buffer, TypedArray, or DataView.' +
216+
common.invalidArgTypeHelper(invalidArg);
217+
assert.throws(
218+
() => new SourceTextModule('import "foo";', { cachedData: invalidArg }),
219+
{
220+
code: 'ERR_INVALID_ARG_TYPE',
221+
name: 'TypeError',
222+
message,
223+
}
224+
);
225+
});
226+
}
227+
212228
const finished = common.mustCall();
213229

214230
(async function main() {
@@ -217,5 +233,6 @@ const finished = common.mustCall();
217233
await checkLinking();
218234
await checkExecution();
219235
await checkInvalidOptionForEvaluate();
236+
checkInvalidCachedData();
220237
finished();
221238
})();

0 commit comments

Comments
 (0)