From 9651af3089ce93eaaa317251086b761c8c256427 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Mon, 8 Feb 2021 13:44:30 -0500 Subject: [PATCH 1/2] add test for the fixed bug --- compiler/tests/circuits/duplicate_name_context.leo | 13 +++++++++++++ compiler/tests/circuits/mod.rs | 8 ++++++++ 2 files changed, 21 insertions(+) create mode 100644 compiler/tests/circuits/duplicate_name_context.leo diff --git a/compiler/tests/circuits/duplicate_name_context.leo b/compiler/tests/circuits/duplicate_name_context.leo new file mode 100644 index 0000000000..4fe20a12e8 --- /dev/null +++ b/compiler/tests/circuits/duplicate_name_context.leo @@ -0,0 +1,13 @@ +circuit Bar { + b2: u32 + + function add_five(z:u32) -> u32 { + return z+5u32 + } +} + +function main () { + let Bar = 66u32; + const k1 = Bar{ b2: 30u32 }; + const k2 = Bar::add_five(55u32); +} \ No newline at end of file diff --git a/compiler/tests/circuits/mod.rs b/compiler/tests/circuits/mod.rs index 488b639d0b..3fe4b54955 100644 --- a/compiler/tests/circuits/mod.rs +++ b/compiler/tests/circuits/mod.rs @@ -283,3 +283,11 @@ fn test_define_circuit_inside_circuit_function() { assert_satisfied(program); } + +#[test] +fn test_duplicate_name_context() { + let program_string = include_str!("duplicate_name_context.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} From 2f6cc6c99505335d954cf75cbbc623e4639bdc82 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Mon, 8 Feb 2021 15:42:37 -0500 Subject: [PATCH 2/2] add test for the fixed bug --- compiler/tests/function/array_params_direct_call.leo | 9 +++++++++ compiler/tests/function/mod.rs | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 compiler/tests/function/array_params_direct_call.leo diff --git a/compiler/tests/function/array_params_direct_call.leo b/compiler/tests/function/array_params_direct_call.leo new file mode 100644 index 0000000000..9305b0958d --- /dev/null +++ b/compiler/tests/function/array_params_direct_call.leo @@ -0,0 +1,9 @@ +function do_nothing(arr: [u32; 2]) {} + +function main() { + let arr: [u32; 2] = [0; 2]; + + do_nothing(arr); + do_nothing([...arr]); + do_nothing(arr[1u32..]); +} \ No newline at end of file diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index f7bf4ed3db..6de6cd8153 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -203,3 +203,11 @@ fn test_return_tuple_conditional() { assert_satisfied(program); } + +#[test] +fn test_array_params_direct_call() { + let program_string = include_str!("array_params_direct_call.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +}