Skip to content

Commit

Permalink
Add tests for backslash behavior (#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
erights authored Aug 28, 2021
1 parent 1c82af4 commit 9b138fc
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/ses/test/test-backslash-u-identifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import '../index.js';
import './lockdown-safe.js';
import test from 'ava';

test('backslash-u-varname', t => {
const c = new Compartment();
t.is(
c.evaluate(`
const \\u0069 = 88;
i;`),
88,
);
});

test('backslash-u-keyword-as-var-fails', t => {
const c = new Compartment();
t.throws(
() => {
c.evaluate(`const \\u0069f = 55;`);
},
{ instanceOf: SyntaxError },
);
});

test('backslash-u-keyword-fails', t => {
const c = new Compartment();
t.is(c.evaluate('if(true){99}'), 99);
t.throws(
() => {
c.evaluate(`u0069f(true){77}`);
},
{ instanceOf: SyntaxError },
);
});

0 comments on commit 9b138fc

Please sign in to comment.