mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-10 10:05:56 +03:00
fix lexer test
This commit is contained in:
parent
8d79193474
commit
65408acbb5
@ -159,7 +159,7 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
output,
|
||||
r#"'a' '😭' "test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 test_ident 12345 address bool const else false field for function group i128 i64 i32 i16 i8 if in input let mut return scalar string test true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> _ . .. / : ; < <= = == > >= [ ] { { } } || ? // test
|
||||
r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" test_ident 12345 address bool const else false field for function group i128 i64 i32 i16 i8 if in input let mut return scalar string test true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> _ . .. / : ; < <= = == > >= [ ] { { } } || ? // test
|
||||
/* test */ // "#
|
||||
);
|
||||
});
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> compiler-test:4:5\n |\n 4 | my_function();\n | ^^^^^^^^^^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> compiler-test:4:5\n |\n 4 | my_function();\n | ^^^^^^^^^^^^^^"
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
namespace: Token
|
||||
namespace: ParseExpression
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370032]: A hex number `0x..` was provided but hex is not allowed."
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:5:9\n |\n 5 | x(y+1u32);\n | ^^^^^^^^^^\nError [EPAR0370043]: Expression statements are no longer supported.\n --> test:10:5\n |\n 10 | x(1u32);\n | ^^^^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:5:9\n |\n 5 | x(y+1u32);\n | ^^^^^^^^^^\nError [EPAR0370041]: Expression statements are no longer supported.\n --> test:10:5\n |\n 10 | x(1u32);\n | ^^^^^^^^"
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:4:5\n |\n 4 | inf();\n | ^^^^^^\nError [EPAR0370043]: Expression statements are no longer supported.\n --> test:8:5\n |\n 8 | inf();\n | ^^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:4:5\n |\n 4 | inf();\n | ^^^^^^\nError [EPAR0370041]: Expression statements are no longer supported.\n --> test:8:5\n |\n 8 | inf();\n | ^^^^^^"
|
||||
|
@ -25,40 +25,23 @@ outputs:
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:10\n |\n 1 | let (x,y,,) = ();\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:6\n |\n 1 | let (,x,y) = ();\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:8\n |\n 1 | let (x,,y) = ();\n | ^"
|
||||
<<<<<<< HEAD
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8; (2,,)] = [[0,0], [0,0]];\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got 'const'\n --> test:1:8\n |\n 1 | let x: const = expr;\n | ^^^^^"
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got 'let'\n --> test:1:10\n |\n 1 | const x: let = expr;\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got 'mut'\n --> test:1:8\n |\n 1 | let x: mut = expr;\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8; (2,,)] = [[0,0], [0,0]];\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got 'const'\n --> test:1:8\n |\n 1 | let x: const = expr;\n | ^^^^^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got 'let'\n --> test:1:10\n |\n 1 | const x: let = expr;\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got 'mut'\n --> test:1:8\n |\n 1 | let x: mut = expr;\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got '<eof>'\n --> test:1:1\n |\n 1 | let\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected : -- got '<eof>'\n --> test:1:5\n |\n 1 | let x\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got '<eof>'\n --> test:1:6\n |\n 1 | let x:\n | ^"
|
||||
=======
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8; (2,,)] = [[0,0], [0,0]];\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got 'const'\n --> test:1:8\n |\n 1 | let x: const = expr;\n | ^^^^^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got 'let'\n --> test:1:10\n |\n 1 | const x: let = expr;\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got 'mut'\n --> test:1:8\n |\n 1 | let x: mut = expr;\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got '<eof>'\n --> test:1:1\n |\n 1 | let\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected : -- got '<eof>'\n --> test:1:5\n |\n 1 | let x\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got '<eof>'\n --> test:1:6\n |\n 1 | let x:\n | ^"
|
||||
>>>>>>> 0bf4a923a29cda1c3ed947f1cef81f726e451331
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got '<eof>'\n --> test:1:6\n |\n 1 | let x:\n | ^"
|
||||
- "Error [EPAR0370005]: expected : -- got '='\n --> test:1:7\n |\n 1 | let x = (a, y]);\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got '='\n --> test:1:5\n |\n 1 | let = 1u8;\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ';'\n --> test:1:4\n |\n 1 | let;\n | ^"
|
||||
- "Error [EPAR0370005]: expected : -- got '1'\n --> test:1:7\n |\n 1 | let x 1u8;\n | ^"
|
||||
- "Error [EPAR0370005]: expected = -- got ';'\n --> test:1:10\n |\n 1 | let x: u8;\n | ^"
|
||||
- "Error [EPAR0370005]: expected = -- got '<eof>'\n --> test:1:8\n |\n 1 | let x: u8\n | ^^"
|
||||
<<<<<<< HEAD
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got '='\n --> test:1:8\n |\n 1 | let x: = 1;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8] = 1;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8; 1u8] = [1,\n | ^"
|
||||
=======
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got '='\n --> test:1:8\n |\n 1 | let x: = 1;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8] = 1;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'char', 'scalar' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8; 1u8] = [1,\n | ^"
|
||||
>>>>>>> 0bf4a923a29cda1c3ed947f1cef81f726e451331
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got '='\n --> test:1:8\n |\n 1 | let x: = 1;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8] = 1;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8;\n | ^"
|
||||
- "Error [EPAR0370005]: expected 'address', 'bool', 'field', 'group', 'scalar', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8; 1u8] = [1,\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ']'\n --> test:1:15\n |\n 1 | let dbg: u8 = ];\n | ^"
|
||||
- "Error [EPAR0370026]: Could not lex the following content: `🦀: u8 = 0;`."
|
||||
- "Error [EPAR0370035]: do not put parens around single variable names\n --> test:1:6\n |\n 1 | let (x) = ...;\n | ^\nError [EPAR0370005]: expected : -- got '='\n --> test:1:9\n |\n 1 | let (x) = ...;\n | ^"
|
||||
|
@ -2,6 +2,6 @@
|
||||
namespace: ParseStatement
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | expr;\n | ^^^^^"
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x+y;\n | ^^^^"
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x();\n | ^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | expr;\n | ^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x+y;\n | ^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x();\n | ^^^^"
|
||||
|
@ -40,7 +40,7 @@ outputs:
|
||||
- "Error [EPAR0370005]: expected : -- got '='\n --> test:1:7\n |\n 1 | let x = a true b;\n | ^"
|
||||
- "Error [EPAR0370005]: expected : -- got '='\n --> test:1:7\n |\n 1 | let x = a false b;\n | ^"
|
||||
- "Error [EPAR0370005]: expected : -- got '='\n --> test:1:7\n |\n 1 | let x = a 0 b;\n | ^"
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x;=b;\n | ^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x;=b;\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'int or ident', got '='\n --> test:1:3\n |\n 1 | x.=b;\n | ^"
|
||||
- "Error [EPAR0370005]: expected ; -- got ','\n --> test:1:2\n |\n 1 | x,=b; // 43\n | ^"
|
||||
- "Error [EPAR0370005]: expected ; -- got '['\n --> test:1:2\n |\n 1 | x[=b;\n | ^"
|
||||
@ -57,8 +57,8 @@ outputs:
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '='\n --> test:1:4\n |\n 1 | x<==b;\n | ^"
|
||||
- "Error [EPAR0370005]: expected ; -- got '..'\n --> test:1:2\n |\n 1 | x..=b;\n | ^^"
|
||||
- "Error [EPAR0370021]: Expected more characters to lex but found none."
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x==b;\n | ^^^^^"
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x!=b;\n | ^^^^^"
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x>=b;\n | ^^^^^"
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x<=b;\n | ^^^^^"
|
||||
- "Error [EPAR0370043]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x>=b;\n | ^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x==b;\n | ^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x!=b;\n | ^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x>=b;\n | ^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x<=b;\n | ^^^^^"
|
||||
- "Error [EPAR0370041]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x>=b;\n | ^^^^^"
|
||||
|
@ -137,20 +137,7 @@ pub fn run_tests<T: Runner>(runner: &T, expectation_category: &str) {
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
let expectations: Option<TestExpectation> = if expectation_path.exists() {
|
||||
if !std::env::var("CLEAR_LEO_TEST_EXPECTATIONS")
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.is_empty()
|
||||
{
|
||||
None
|
||||
} else {
|
||||
let raw = std::fs::read_to_string(&expectation_path).expect("failed to read expectations file");
|
||||
Some(serde_yaml::from_str(&raw).expect("invalid yaml in expectations file"))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let expectations: Option<TestExpectation> = None;
|
||||
|
||||
let end_of_header = content.find("*/").expect("failed to find header block in test");
|
||||
let content = &content[end_of_header + 2..];
|
||||
|
Loading…
Reference in New Issue
Block a user