From 5af08b53b5b0f200e523cecd0af9b1924e1d82fc Mon Sep 17 00:00:00 2001 From: evan-schott <53463459+evan-schott@users.noreply.github.com> Date: Fri, 9 Feb 2024 15:57:54 -0800 Subject: [PATCH] update tests --- compiler/parser/src/parser/context.rs | 2 -- compiler/parser/src/parser/expression.rs | 2 +- leo/cli/cli.rs | 2 ++ leo/cli/commands/build.rs | 2 -- .../compiler/finalize/mapping_fail.out | 2 +- .../shadow_function_with_input_fail.out | 5 ----- .../function/undefined_data_type_fail.out | 2 +- .../compiler/structs/duplicate_name_context.out | 5 ----- .../compiler/structs/inline_undefined.out | 2 +- .../shadow_function_with_input_fail.leo | 17 ----------------- .../compiler/structs/duplicate_name_context.leo | 17 ----------------- 11 files changed, 6 insertions(+), 52 deletions(-) delete mode 100644 tests/expectations/compiler/function/shadow_function_with_input_fail.out delete mode 100644 tests/expectations/compiler/structs/duplicate_name_context.out delete mode 100644 tests/tests/compiler/function/shadow_function_with_input_fail.leo delete mode 100644 tests/tests/compiler/structs/duplicate_name_context.leo diff --git a/compiler/parser/src/parser/context.rs b/compiler/parser/src/parser/context.rs index f54d85d089..90db26a4b2 100644 --- a/compiler/parser/src/parser/context.rs +++ b/compiler/parser/src/parser/context.rs @@ -39,8 +39,6 @@ pub(crate) struct ParserContext<'a> { pub(crate) prev_token: SpannedToken, /// true if parsing an expression for if and loop statements -- means struct inits are not legal pub(crate) disallow_struct_construction: bool, - /// true if parsing an identifier inside an input file. - pub(crate) allow_identifier_underscores: bool, /// The name of the program being parsed. pub(crate) program_name: Option, } diff --git a/compiler/parser/src/parser/expression.rs b/compiler/parser/src/parser/expression.rs index fe434a0183..aaaffdf472 100644 --- a/compiler/parser/src/parser/expression.rs +++ b/compiler/parser/src/parser/expression.rs @@ -17,7 +17,7 @@ use super::*; use leo_errors::{ParserError, Result}; -use leo_span::sym; +use leo_span::{sym, Symbol}; use snarkvm::console::{account::Address, network::Testnet3}; const INT_TYPES: &[Token] = &[ diff --git a/leo/cli/cli.rs b/leo/cli/cli.rs index 72b166c36a..8df77590d1 100644 --- a/leo/cli/cli.rs +++ b/leo/cli/cli.rs @@ -263,6 +263,7 @@ mod tests { name: "inner_1_main".to_string(), inputs: vec!["1u32".to_string(), "2u32".to_string()], compiler_options: Default::default(), + file: None, }, }, path: Some(project_directory.clone()), @@ -299,6 +300,7 @@ mod tests { name: "main".to_string(), inputs: vec!["1u32".to_string(), "2u32".to_string()], compiler_options: Default::default(), + file: None, }, }, path: Some(project_directory.clone()), diff --git a/leo/cli/commands/build.rs b/leo/cli/commands/build.rs index 292989f31e..cb1c505bba 100644 --- a/leo/cli/commands/build.rs +++ b/leo/cli/commands/build.rs @@ -188,7 +188,6 @@ fn compile_leo_file( handler: &Handler, options: BuildOptions, stubs: IndexMap, -) -> Result> { ) -> Result<()> { // Construct the Leo file name with extension `foo.leo`. let file_name = @@ -196,7 +195,6 @@ fn compile_leo_file( // Construct program name from the program_id found in `package.json`. let program_name = program_id.name().to_string(); - let program_symbol = Symbol::intern(&program_name); // Create the path to the Aleo file. let mut aleo_file_path = build.to_path_buf(); diff --git a/tests/expectations/compiler/finalize/mapping_fail.out b/tests/expectations/compiler/finalize/mapping_fail.out index 717175b9e3..b11a44e699 100644 --- a/tests/expectations/compiler/finalize/mapping_fail.out +++ b/tests/expectations/compiler/finalize/mapping_fail.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [ETYC0372030]: A mapping's key cannot be a tuple\n --> compiler-test:4:5\n |\n 4 | mapping foo: (u32, u32) => u32;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372017]: The type `baz` is not found in the current scope.\n --> compiler-test:6:5\n |\n 6 | mapping floo: baz => u8;\n | ^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `foo` is not found in the current scope.\n --> compiler-test:8:5\n |\n 8 | mapping floop: foo => foo;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `foo` is not found in the current scope.\n --> compiler-test:8:5\n |\n 8 | mapping floop: foo => foo;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `foo` is not found in the current scope.\n --> compiler-test:10:5\n |\n 10 | mapping bar: foo => baz;\n | ^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `baz` is not found in the current scope.\n --> compiler-test:10:5\n |\n 10 | mapping bar: foo => baz;\n | ^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372030]: A mapping's value cannot be a record\n --> compiler-test:19:5\n |\n 19 | mapping real_tokens: address => RealToken;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372030]: A mapping's key cannot be a record\n --> compiler-test:21:5\n |\n 21 | mapping owners: RealToken => address;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Error [ETYC0372030]: A mapping's key cannot be a tuple\n --> compiler-test:4:5\n |\n 4 | mapping foo: (u32, u32) => u32;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372017]: The type `baz` is not found in the current scope.\n --> compiler-test:6:5\n |\n 6 | mapping floo: baz => u8;\n | ^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `foo` is not found in the current scope.\n --> compiler-test:8:5\n |\n 8 | mapping floop: foo => foo;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `foo` is not found in the current scope.\n --> compiler-test:8:5\n |\n 8 | mapping floop: foo => foo;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `foo` is not found in the current scope.\n --> compiler-test:10:5\n |\n 10 | mapping bar: foo => baz;\n | ^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `baz` is not found in the current scope.\n --> compiler-test:10:5\n |\n 10 | mapping bar: foo => baz;\n | ^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372030]: A mapping's value cannot be a record\n --> compiler-test:19:5\n |\n 19 | mapping real_tokens: address => RealToken;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372030]: A mapping's key cannot be a record\n --> compiler-test:21:5\n |\n 21 | mapping owners: RealToken => address;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372093]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n" diff --git a/tests/expectations/compiler/function/shadow_function_with_input_fail.out b/tests/expectations/compiler/function/shadow_function_with_input_fail.out deleted file mode 100644 index 8c6f9254e1..0000000000 --- a/tests/expectations/compiler/function/shadow_function_with_input_fail.out +++ /dev/null @@ -1,5 +0,0 @@ ---- -namespace: Compile -expectation: Fail -outputs: - - "Failed to parse string. Parsing Error: VerboseError { errors: [(\"closure hi:\\n output 0u8 as u8;\\n\\n\\nclosure tester:\\n input r0 as u8;\\n output 0u8 as u8;\\n\\n\\nclosure main:\\n input r0 as boolean;\\n output r0 as boolean;\\n\", Nom(Tag)), (\"\\n\\n\\n\\nclosure hi:\\n output 0u8 as u8;\\n\\n\\nclosure tester:\\n input r0 as u8;\\n output 0u8 as u8;\\n\\n\\nclosure main:\\n input r0 as boolean;\\n output r0 as boolean;\\n\", Nom(Alt)), (\"\\n\\n\\n\\nclosure hi:\\n output 0u8 as u8;\\n\\n\\nclosure tester:\\n input r0 as u8;\\n output 0u8 as u8;\\n\\n\\nclosure main:\\n input r0 as boolean;\\n output r0 as boolean;\\n\", Nom(Many1))] }" diff --git a/tests/expectations/compiler/function/undefined_data_type_fail.out b/tests/expectations/compiler/function/undefined_data_type_fail.out index 40ca4bf0c2..5db603eeae 100644 --- a/tests/expectations/compiler/function/undefined_data_type_fail.out +++ b/tests/expectations/compiler/function/undefined_data_type_fail.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [ETYC0372017]: The type `Board` is not found in the current scope.\n --> compiler-test:4:35\n |\n 4 | function aria192check_for_win(b: Board, p: u8) -> u128bool {\n | ^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `u128bool` is not found in the current scope.\n --> compiler-test:4:55\n |\n 4 | function aria192check_for_win(b: Board, p: u8) -> u128bool {\n | ^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372005]: Unknown variable `test`\n --> compiler-test:5:16\n |\n 5 | return test;\n | ^^^^\n" + - "Error [ETYC0372017]: The type `Board` is not found in the current scope.\n --> compiler-test:4:35\n |\n 4 | function aria192check_for_win(b: Board, p: u8) -> u128bool {\n | ^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `u128bool` is not found in the current scope.\n --> compiler-test:4:55\n |\n 4 | function aria192check_for_win(b: Board, p: u8) -> u128bool {\n | ^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372005]: Unknown variable `test`\n --> compiler-test:5:16\n |\n 5 | return test;\n | ^^^^\nError [ETYC0372093]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo {\n | ^^^^^^^^^^^^\n" diff --git a/tests/expectations/compiler/structs/duplicate_name_context.out b/tests/expectations/compiler/structs/duplicate_name_context.out deleted file mode 100644 index fd478a86c3..0000000000 --- a/tests/expectations/compiler/structs/duplicate_name_context.out +++ /dev/null @@ -1,5 +0,0 @@ ---- -namespace: Compile -expectation: Fail -outputs: - - "No functions present in the deployment for program 'test.aleo'" diff --git a/tests/expectations/compiler/structs/inline_undefined.out b/tests/expectations/compiler/structs/inline_undefined.out index d751572fa1..6ae0cf5553 100644 --- a/tests/expectations/compiler/structs/inline_undefined.out +++ b/tests/expectations/compiler/structs/inline_undefined.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [ETYC0372017]: The type `Foo` is not found in the current scope.\n --> compiler-test:5:9\n |\n 5 | let a: Foo = Foo { };\n | ^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `Foo` is not found in the current scope.\n --> compiler-test:5:9\n |\n 5 | let a: Foo = Foo { };\n | ^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372005]: Unknown struct `Foo`\n --> compiler-test:5:22\n |\n 5 | let a: Foo = Foo { };\n | ^^^\n" + - "Error [ETYC0372017]: The type `Foo` is not found in the current scope.\n --> compiler-test:5:9\n |\n 5 | let a: Foo = Foo { };\n | ^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372017]: The type `Foo` is not found in the current scope.\n --> compiler-test:5:9\n |\n 5 | let a: Foo = Foo { };\n | ^^^^^^^^^^^^^^^^^^^^\n |\n = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`\nError [ETYC0372005]: Unknown struct `Foo`\n --> compiler-test:5:22\n |\n 5 | let a: Foo = Foo { };\n | ^^^\nError [ETYC0372093]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n" diff --git a/tests/tests/compiler/function/shadow_function_with_input_fail.leo b/tests/tests/compiler/function/shadow_function_with_input_fail.leo deleted file mode 100644 index 2cbe2948e4..0000000000 --- a/tests/tests/compiler/function/shadow_function_with_input_fail.leo +++ /dev/null @@ -1,17 +0,0 @@ -/* -namespace: Compile -expectation: Fail -*/ - -program test.aleo { - function hi() -> u8 { - return 0u8; - } - - function tester(hi: u8) -> u8 { - return 0u8; - } - - function main (y: bool) -> bool { - return y; - }} diff --git a/tests/tests/compiler/structs/duplicate_name_context.leo b/tests/tests/compiler/structs/duplicate_name_context.leo deleted file mode 100644 index ecc0bac5e0..0000000000 --- a/tests/tests/compiler/structs/duplicate_name_context.leo +++ /dev/null @@ -1,17 +0,0 @@ -/* -namespace: Compile -expectation: Fail -*/ - -program test.aleo { - struct Bar { - b2: u32 - } - - function main(y: bool) -> bool { - let Bar: u32 = 66u32; - let k1: Bar = Bar { b2: 30u32 }; - - return y == true; - } -}