From d46a041895d7daeccd7b09f0736d9d36a6da29b7 Mon Sep 17 00:00:00 2001 From: 0rphon <59403052+0rphon@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:33:52 -0800 Subject: [PATCH] save progress before denver --- cover.bat | 1 - parser/src/parser/context.rs | 2 +- .../functions/const_function_fail.leo.out | 5 +++++ .../parser/statement/definition_fail.leo.out | 7 +++++++ .../parser/statement/expression_fail.leo.out | 10 ++++++++++ tests/parser/functions/const_function_fail.leo | 6 ++++++ tests/parser/statement/definition.leo | 2 +- tests/parser/statement/definition_fail.leo | 17 ++++++++++++++++- tests/parser/statement/expression_fail.leo | 16 ++++++++++++++++ 9 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 tests/expectations/parser/parser/functions/const_function_fail.leo.out create mode 100644 tests/expectations/parser/parser/statement/expression_fail.leo.out create mode 100644 tests/parser/functions/const_function_fail.leo create mode 100644 tests/parser/statement/expression_fail.leo diff --git a/cover.bat b/cover.bat index bab6ec621b..1dddc20219 100644 --- a/cover.bat +++ b/cover.bat @@ -1,4 +1,3 @@ -set CLEAR_LEO_TEST_EXPECTATIONS= cargo clean cd parser set RUSTFLAGS=-Cinstrument-coverage diff --git a/parser/src/parser/context.rs b/parser/src/parser/context.rs index 91d1082de4..d020087b57 100644 --- a/parser/src/parser/context.rs +++ b/parser/src/parser/context.rs @@ -339,7 +339,7 @@ impl<'a> ParserContext<'a> { }); } if let Some((int, span)) = self.eat_int() { - let name = Symbol::intern(&int.value); + let name = Symbol::intern(&int.value); //todo 0rphon: covered by unused import tests return Ok(Identifier { name, span }); } self.expect_ident() diff --git a/tests/expectations/parser/parser/functions/const_function_fail.leo.out b/tests/expectations/parser/parser/functions/const_function_fail.leo.out new file mode 100644 index 0000000000..72572b4700 --- /dev/null +++ b/tests/expectations/parser/parser/functions/const_function_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Parse +expectation: Fail +outputs: + - "Error [EPAR0370003]: unexpected EOF\n --> test:3:1\n |\n 3 | const\n | ^^^^^" diff --git a/tests/expectations/parser/parser/statement/definition_fail.leo.out b/tests/expectations/parser/parser/statement/definition_fail.leo.out index 98d09165bb..4a5f231f94 100644 --- a/tests/expectations/parser/parser/statement/definition_fail.leo.out +++ b/tests/expectations/parser/parser/statement/definition_fail.leo.out @@ -26,3 +26,10 @@ outputs: - "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 | ^" - "Error [EPAR0370009]: unexpected string: expected 'int', got ','\n --> test:1:16\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', 'char' -- 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', 'char' -- 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', 'char' -- got 'mut'\n --> test:1:8\n |\n 1 | let x: mut = expr;\n | ^^^" + - "Error [EPAR0370003]: unexpected EOF\n --> test:1:1\n |\n 1 | let\n | ^^^" + - "Error [EPAR0370003]: unexpected EOF\n --> test:1:5\n |\n 1 | let x\n | ^" + - "Error [EPAR0370003]: unexpected EOF\n --> test:1:6\n |\n 1 | let x:\n | ^" + - "Error [EPAR0370005]: expected ) -- got ']'\n --> test:1:14\n |\n 1 | let x = (a, y]);\n | ^" diff --git a/tests/expectations/parser/parser/statement/expression_fail.leo.out b/tests/expectations/parser/parser/statement/expression_fail.leo.out new file mode 100644 index 0000000000..4142d0155e --- /dev/null +++ b/tests/expectations/parser/parser/statement/expression_fail.leo.out @@ -0,0 +1,10 @@ +--- +namespace: ParseStatement +expectation: Fail +outputs: + - "Error [EPAR0370009]: unexpected string: expected 'expression', got ']'\n --> test:1:2\n |\n 1 | (];\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', got ')'\n --> test:1:2\n |\n 1 | [);\n | ^" + - "Error [EPAR0370000]: \\\n --> test:1:2\n |\n 1 | x\\y;\n | ^" + - "Error [EPAR0370000]: |\n --> test:1:5\n |\n 1 | (x,y|;\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', got '}'\n --> test:1:3\n |\n 1 | x[};\n | ^" + - "Error [EPAR0370005]: expected ) -- got ']'\n --> test:1:6\n |\n 1 | (x, y];\n | ^" diff --git a/tests/parser/functions/const_function_fail.leo b/tests/parser/functions/const_function_fail.leo new file mode 100644 index 0000000000..1da7e79739 --- /dev/null +++ b/tests/parser/functions/const_function_fail.leo @@ -0,0 +1,6 @@ +/* +namespace: Parse +expectation: Fail +*/ + +const diff --git a/tests/parser/statement/definition.leo b/tests/parser/statement/definition.leo index 91d9aaaad6..f038300794 100644 --- a/tests/parser/statement/definition.leo +++ b/tests/parser/statement/definition.leo @@ -107,4 +107,4 @@ let x: [[u8; 2]; 2] = [[0,0], [0,0]]; let x: [u8; (2, 2)] = [[0,0], [0,0]]; -let x: address = aleo15u4r0gzjtqzepkgurgn7p3u5kkhs9p74rx6aun3uh2s5std6759svgmg53; \ No newline at end of file +let x: address = aleo15u4r0gzjtqzepkgurgn7p3u5kkhs9p74rx6aun3uh2s5std6759svgmg53; diff --git a/tests/parser/statement/definition_fail.leo b/tests/parser/statement/definition_fail.leo index 53f03aca3b..f08dbb99f0 100644 --- a/tests/parser/statement/definition_fail.leo +++ b/tests/parser/statement/definition_fail.leo @@ -53,4 +53,19 @@ let (,x,y) = (); let (x,,y) = (); -let x: [u8; (2,,)] = [[0,0], [0,0]]; \ No newline at end of file +let x: [u8; (2,,)] = [[0,0], [0,0]]; + + +let x: const = expr; + +const x: let = expr; + +let x: mut = expr; + +let + +let x + +let x: + +let x = (a, y]); diff --git a/tests/parser/statement/expression_fail.leo b/tests/parser/statement/expression_fail.leo new file mode 100644 index 0000000000..98efd8b9e0 --- /dev/null +++ b/tests/parser/statement/expression_fail.leo @@ -0,0 +1,16 @@ +/* +namespace: ParseStatement +expectation: Fail +*/ + +(]; + +[); + +x\y; + +(x,y|; + +x[}; + +(x, y];