add tests

This commit is contained in:
gluax 2022-03-04 10:26:34 -08:00
parent 85764aa394
commit 308512fab9
9 changed files with 44 additions and 1 deletions

View File

@ -161,7 +161,11 @@ impl Token {
return Err(ParserError::lexer_eat_integer_leading_zero(String::from_utf8_lossy(input)).into());
}
let mut i = 1;
while i < input.len() {
if i == 1 && input[0] == b'0' && input[i] == b'x' {
return Err(ParserError::lexer_hex_number_provided(&input_tendril[0..3]).into());
}
if !input[i].is_ascii_digit() {
break;
}

View File

@ -351,6 +351,13 @@ create_errors!(
msg: format!("The escaped unicode char `{}` is greater than 0x10FFFF.", input),
help: None,
}
/// When a hex number is provided.
@backtraced
lexer_hex_number_provided {
args: (input: impl Display),
msg: format!("A hex number `{}..` was provided but hex is not allowed.", input),
help: None,
}
/// When a function recieved a self argument outside the first argument.
@backtraced

View File

@ -2,4 +2,4 @@
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370040]: A function received a self argument as not the first argument."
- "Error [EPAR0370041]: A function received a self argument as not the first argument."

View File

@ -36,4 +36,6 @@ outputs:
- "Error [EPAR0370026]: Expected a valid escape character but found `117`."
- "Error [EPAR0370026]: Expected a valid escape character but found `117`."
- "Error [EPAR0370026]: Expected a valid escape character but found `117`."
- "Error [EPAR0370039]: The escaped unicode char `110000` is greater than 0x10FFFF."
- "Error [EPAR0370037]: There was no closing `}` after a escaped unicode `\\u{af🦀`."
- "Error [EPAR0370028]: Expected a closed char but found `😭😂😘`."

View File

@ -0,0 +1,5 @@
---
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370009]: unexpected string: expected 'ident', got '?'\n --> test:3:6\n |\n 3 | @foo(?, bar, ?)\n | ^\nError [EPAR0370009]: unexpected string: expected 'ident', got '?'\n --> test:3:14\n |\n 3 | @foo(?, bar, ?)\n | ^\nError [EPAR0370009]: unexpected string: expected 'ident', got '123'\n --> test:8:6\n |\n 8 | @bar(123) // ints not vali\n | ^^^\nError [EPAR0370017]: \"@context(...)\" is deprecated. Did you mean @test annotation?\n --> test:14:2\n |\n 14 | @context // recovery witness\n | ^^^^^^^"

View File

@ -0,0 +1,7 @@
---
namespace: ParseStatement
expectation: Fail
outputs:
- "Error [EPAR0370040]: A hex number `0x4..` was provided but hex is not allowed."
- "Error [EPAR0370040]: A hex number `0xA..` was provided but hex is not allowed."
- "Error [EPAR0370040]: A hex number `0xF..` was provided but hex is not allowed."

View File

@ -43,5 +43,7 @@ expectation: Fail
'\u00000000'
'\u01000000'
'\u9999999'
'\u{110000}'
'\u{af🦀'
'😭😂😘'

View File

@ -8,6 +8,12 @@ function x() {
return ();
}
@bar(123) // ints not vali
function x() {
return ();
}
@context // recovery witness
function x() {
return ();

View File

@ -0,0 +1,10 @@
/*
namespace: ParseStatement
expectation: Fail
*/
let x = 0x40u32;
let y: u32 = 0xAAu32;
let z = 0xFFu8;