Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lexer-tests: Use tildas as invalid characters #3377

Merged
merged 1 commit into from Nov 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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