Skip to content

Commit

Permalink
test: update failing tests error message checks
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino committed May 9, 2024
1 parent b98247a commit 2fd415a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
40 changes: 20 additions & 20 deletions pkg/core/test/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ Error colors:
- ${extraColor('extra words')}
ParseError: at 2:9-17
${errorColor('"gibberish"')} may be ${suggestedColor('"send"')}
${errorColor('gibberish')} may be ${suggestedColor('send')}
ParseError: at 2:9-17
must be followed by one of: ${missingColor('"param"')}
must be followed by one of: ${missingColor('param')}
ParseError: at 2
missing one of: ${missingColor('"<identifier>"')}
missing one of: ${missingColor('\'<identifier>\'')}
ParseError: at 2
missing one of: ${missingColor('"and"')}
missing one of: ${missingColor('and')}
ParseError: at 2
missing one of: ${missingColor('"do"')}
missing one of: ${missingColor('do')}
ParseError: at 2
missing one of: ${missingColor('"some"')}
missing one of: ${missingColor('some')}
ParseError: at 2
missing one of: ${missingColor('"action"')}
missing one of: ${missingColor('action')}
`

const err = await t.throwsAsync(fn);
Expand Down Expand Up @@ -107,43 +107,43 @@ Error colors:
- ${extraColor('extra words')}
ParseError: at 2:1-9
${errorColor('"Gibberish"')} may be ${suggestedColor('"given" "then"')}
${errorColor('Gibberish')} may be ${suggestedColor('given, then')}
ParseError: at 2:11-17
${errorColor('"connect"')} may be ${suggestedColor('"I"')}
${errorColor('connect')} may be ${suggestedColor('I')}
ParseError: at 2:19-20
${errorColor('"to"')} may be ${suggestedColor('"connect"')}
${errorColor('to')} may be ${suggestedColor('connect')}
ParseError: at 2:22-26
${errorColor('"\'url\'"')} may be ${suggestedColor('"to"')}
${errorColor('\'url\'')} may be ${suggestedColor('to')}
ParseError: at 2:28-30
${errorColor('"and"')} may be ${suggestedColor('"<identifier>"')}
${errorColor('and')} may be ${suggestedColor('\'<identifier>\'')}
ParseError: at 2:32-35
${errorColor('"send"')} may be ${suggestedColor('"and"')}
${errorColor('send')} may be ${suggestedColor('and')}
ParseError: at 2:37-41
${errorColor('"param"')} may be ${suggestedColor('"send"')}
${errorColor('param')} may be ${suggestedColor('send')}
ParseError: at 2:43-49
${errorColor('"\'param\'"')} may be ${suggestedColor('"param"')}
${errorColor('\'param\'')} may be ${suggestedColor('param')}
ParseError: at 2:51-53
${errorColor('"and"')} may be ${suggestedColor('"<identifier>"')}
${errorColor('and')} may be ${suggestedColor('\'<identifier>\'')}
ParseError: at 2:55-56
${errorColor('"do"')} may be ${suggestedColor('"and"')}
${errorColor('do')} may be ${suggestedColor('and')}
ParseError: at 2:58-61
${errorColor('"some"')} may be ${suggestedColor('"do"')}
${errorColor('some')} may be ${suggestedColor('do')}
ParseError: at 2:63-68
${errorColor('"action"')} may be ${suggestedColor('"some"')}
${errorColor('action')} may be ${suggestedColor('some')}
ParseError: at 2:70-72
${errorColor('"and"')} may be ${suggestedColor('"action"')}
${errorColor('and')} may be ${suggestedColor('action')}
ParseError: at 2:74-84
extra token ${extraColor('aoibndwebnd')}
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/test/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ test('lexer works', (t) => {

const res = lex("When I encrypt the secret message 'message", 1);
if (res.ok) throw new Error("Lex fail to dectect unclosed single-quote");
t.is(res.error.message.message as string, `at 1:35-42\n unclosed single-quote \x1b[41m'message\x1b[0m`);
t.is(res.error.message.message as string, `at 1:35-42\n unclosed single-quote \x1b[31m'message\x1b[0m`);
});

test('token constructor erros', (t) => {
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/test/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ test('parser works', (t) => {
{message: ParseError.wrong(new Token('send', 1, 24, 27), 'and'), lineNo: 1, start: 24, end: 27},
{message: ParseError.wrong(new Token('object', 1, 29, 34), 'send'), lineNo: 1, start: 29, end: 34},
{message: ParseError.wrong(new Token('\'myObj\'', 1, 36, 42), 'object'), lineNo: 1, start: 36, end: 42},
{message: ParseError.wrong(new Token('and', 1, 44, 46), '<identifier>'), lineNo: 1, start: 44, end: 46},
{message: ParseError.wrong(new Token('and', 1, 44, 46), '\'<identifier>\''), lineNo: 1, start: 44, end: 46},
{message: ParseError.wrong(new Token('send', 1, 48, 51), 'and'), lineNo: 1, start: 48, end: 51},
{message: ParseError.wrong(new Token('http', 1, 53, 56), 'send'), lineNo: 1, start: 53, end: 56},
{message: ParseError.wrong(new Token('request', 1, 58, 64), 'http'), lineNo: 1, start: 58, end: 64},
Expand Down
2 changes: 1 addition & 1 deletion pkg/helpers/test/concat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Error colors:
- extra words
ParseError: at 2:51-56
"concat" may be "compact"
concat may be compact
`);
});

Expand Down

0 comments on commit 2fd415a

Please sign in to comment.