Skip to content

Commit

Permalink
test(xsnap): reject regex with non-standard hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Feb 4, 2021
1 parent b586eaf commit 9f2ac65
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/xsnap/test/test-xsnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ test('evaluate error', async t => {
await vat.terminate();
});

test('reject odd regex range', async t => {
const opts = options();
const vat = xsnap(opts);
await vat
.evaluate(
`const FILENAME_FILTER = /^((?:.*[( ])?)[:/\\w-_]*\\/(packages\\/.+)$/;`,
)
.then(_ => {
t.fail('should throw');
})
.catch(_ => {
t.pass();
});
await vat.terminate();
});

test('idle includes setImmediate too', async t => {
const opts = options();
const vat = xsnap(opts);
Expand Down Expand Up @@ -233,7 +249,7 @@ test('fail to send command to already-terminated xnsap worker', async t => {
const vat = xsnap({ ...xsnapOptions });
await vat.terminate();
await vat.evaluate(``).catch(err => {
t.is(err.message, 'xsnap test worker exited due to signal SIGTERM')
t.is(err.message, 'xsnap test worker exited due to signal SIGTERM');
});
});

Expand All @@ -258,7 +274,7 @@ test('abnormal termination', async t => {
const hang = vat.evaluate(`for (;;) {}`).then(
() => t.fail('command should not complete'),
err => {
t.is(err.message, 'xsnap test worker exited due to signal SIGTERM')
t.is(err.message, 'xsnap test worker exited due to signal SIGTERM');
},
);

Expand Down

0 comments on commit 9f2ac65

Please sign in to comment.