Skip to content

Commit

Permalink
test: check args on SourceTextModule cachedData
Browse files Browse the repository at this point in the history
PR-URL: #32956
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
  • Loading branch information
juanarbol authored and targos committed May 4, 2020
1 parent 82e459d commit 92c7e06
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/parallel/test-vm-module-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,22 @@ async function checkInvalidOptionForEvaluate() {
});
}

function checkInvalidCachedData() {
[true, false, 'foo', {}, Array, function() {}].forEach((invalidArg) => {
const message = 'The "options.cachedData" property must be an ' +
'instance of Buffer, TypedArray, or DataView.' +
common.invalidArgTypeHelper(invalidArg);
assert.throws(
() => new SourceTextModule('import "foo";', { cachedData: invalidArg }),
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message,
}
);
});
}

const finished = common.mustCall();

(async function main() {
Expand All @@ -217,5 +233,6 @@ const finished = common.mustCall();
await checkLinking();
await checkExecution();
await checkInvalidOptionForEvaluate();
checkInvalidCachedData();
finished();
})();

0 comments on commit 92c7e06

Please sign in to comment.