mirror of
https://github.com/AleoHQ/leo.git
synced 2024-09-22 12:39:52 +03:00
add tests
This commit is contained in:
parent
85764aa394
commit
308512fab9
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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."
|
||||
|
@ -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 `😭😂😘`."
|
||||
|
@ -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 | ^^^^^^^"
|
@ -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."
|
@ -43,5 +43,7 @@ expectation: Fail
|
||||
'\u00000000'
|
||||
'\u01000000'
|
||||
'\u9999999'
|
||||
'\u{110000}'
|
||||
'\u{af🦀'
|
||||
|
||||
'😭😂😘'
|
||||
|
@ -8,6 +8,12 @@ function x() {
|
||||
return ();
|
||||
}
|
||||
|
||||
@bar(123) // ints not vali
|
||||
function x() {
|
||||
return ();
|
||||
}
|
||||
|
||||
|
||||
@context // recovery witness
|
||||
function x() {
|
||||
return ();
|
10
tests/parser/statement/hex_int_fail.leo
Normal file
10
tests/parser/statement/hex_int_fail.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: ParseStatement
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
let x = 0x40u32;
|
||||
|
||||
let y: u32 = 0xAAu32;
|
||||
|
||||
let z = 0xFFu8;
|
Loading…
Reference in New Issue
Block a user