Skip to content

Commit

Permalink
lexer-tests: Use tildas as invalid characters (#3377)
Browse files Browse the repository at this point in the history
  • Loading branch information
twof committed Nov 23, 2021
1 parent 0d1297a commit cce8a85
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/language/__tests__/lexer-test.ts
Expand Up @@ -168,36 +168,36 @@ describe('Lexer', () => {
it('errors respect whitespace', () => {
let caughtError;
try {
lexOne(['', '', ' ?', ''].join('\n'));
lexOne(['', '', ' ~', ''].join('\n'));
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Unexpected character: "?".
Syntax Error: Unexpected character: "~".
GraphQL request:3:5
GraphQL request:3:2
2 |
3 | ?
| ^
3 | ~
| ^
4 |
`);
});

it('updates line numbers in error for file context', () => {
let caughtError;
try {
const str = ['', '', ' ?', ''].join('\n');
const str = ['', '', ' ~', ''].join('\n');
const source = new Source(str, 'foo.js', { line: 11, column: 12 });
new Lexer(source).advance();
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Unexpected character: "?".
Syntax Error: Unexpected character: "~".
foo.js:13:6
12 |
13 | ?
13 | ~
| ^
14 |
`);
Expand All @@ -206,16 +206,16 @@ describe('Lexer', () => {
it('updates column numbers in error for file context', () => {
let caughtError;
try {
const source = new Source('?', 'foo.js', { line: 1, column: 5 });
const source = new Source('~', 'foo.js', { line: 1, column: 5 });
new Lexer(source).advance();
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Unexpected character: "?".
Syntax Error: Unexpected character: "~".
foo.js:1:5
1 | ?
1 | ~
| ^
`);
});
Expand Down Expand Up @@ -1027,8 +1027,8 @@ describe('Lexer', () => {
locations: [{ line: 1, column: 1 }],
});

expectSyntaxError('?').to.deep.equal({
message: 'Syntax Error: Unexpected character: "?".',
expectSyntaxError('~').to.deep.equal({
message: 'Syntax Error: Unexpected character: "~".',
locations: [{ line: 1, column: 1 }],
});

Expand Down

0 comments on commit cce8a85

Please sign in to comment.