From 71486fb6281daf5f5c4cb50e73db9dce995cc2c7 Mon Sep 17 00:00:00 2001 From: damirka Date: Wed, 5 May 2021 11:37:51 +0300 Subject: [PATCH] circuits --- .../compiler/circuits/const_self_variable.leo | 7 +- .../circuits/const_self_variable_fail.leo | 2 +- ...define_circuit_inside_circuit_function.leo | 24 +- .../circuits/duplicate_name_context.leo | 13 +- tests/compiler/circuits/inline.leo | 19 +- tests/compiler/circuits/inline_fail.leo | 8 +- .../compiler/circuits/inline_member_fail.leo | 7 +- .../compiler/circuits/inline_member_pass.leo | 19 +- tests/compiler/circuits/inline_undefined.leo | 7 +- tests/compiler/circuits/member_function.leo | 15 +- .../circuits/member_function_fail.leo | 7 +- .../circuits/member_function_invalid.leo | 7 +- .../circuits/member_function_nested.leo | 18 +- .../circuits/member_static_function.leo | 15 +- .../member_static_function_invalid.leo | 7 +- .../member_static_function_nested.leo | 7 +- .../member_static_function_undefined.leo | 7 +- tests/compiler/circuits/member_variable.leo | 15 +- .../circuits/member_variable_and_function.leo | 14 +- .../circuits/member_variable_fail.leo | 8 +- tests/compiler/circuits/mod.rs | 318 ------------------ tests/compiler/circuits/mut_function_fail.leo | 7 +- .../circuits/mut_self_function_fail.leo | 7 +- .../mut_self_static_function_fail.leo | 7 +- tests/compiler/circuits/mut_self_variable.leo | 7 +- .../circuits/mut_self_variable_branch.leo | 7 +- .../mut_self_variable_conditional.leo | 7 +- .../circuits/mut_self_variable_fail.leo | 7 +- .../circuits/mut_static_function_fail.leo | 7 +- tests/compiler/circuits/mut_variable.leo | 7 +- tests/compiler/circuits/mut_variable_fail.leo | 7 +- .../mutable_call_immutable_context.leo | 7 +- tests/compiler/circuits/pedersen_mock.leo | 17 +- tests/compiler/circuits/self_circuit.leo | 6 + tests/compiler/circuits/self_fail.leo | 5 + tests/compiler/circuits/self_member.leo | 5 + .../compiler/circuits/self_member_invalid.leo | 5 + .../circuits/self_member_undefined.leo | 5 + .../const_self_variable.leo.out} | 0 ...ne_circuit_inside_circuit_function.leo.out | 18 + .../circuits/duplicate_name_context.leo.out | 15 + .../compiler/compiler/circuits/inline.leo.out | 18 + .../compiler/circuits/inline_fail.leo.out | 5 + .../circuits/inline_member_fail.leo.out | 5 + .../circuits/inline_member_pass.leo.out | 18 + .../circuits/inline_undefined.leo.out | 5 + .../compiler/circuits/member_function.leo.out | 18 + .../circuits/member_function_fail.leo.out | 5 + .../circuits/member_function_invalid.leo.out | 5 + .../circuits/member_function_nested.leo.out | 18 + .../circuits/member_static_function.leo.out | 18 + .../member_static_function_invalid.leo.out | 5 + .../member_static_function_nested.leo.out | 15 + .../member_static_function_undefined.leo.out | 5 + .../compiler/circuits/member_variable.leo.out | 18 + .../member_variable_and_function.leo.out | 18 + .../circuits/member_variable_fail.leo.out | 5 + .../circuits/mut_function_fail.leo.out | 5 + .../circuits/mut_self_function_fail.leo.out | 5 + .../mut_self_static_function_fail.leo.out | 5 + .../circuits/mut_self_variable.leo.out | 15 + .../circuits/mut_self_variable_branch.leo.out | 15 + .../mut_self_variable_conditional.leo.out | 15 + .../circuits/mut_self_variable_fail.leo.out | 5 + .../circuits/mut_static_function_fail.leo.out | 5 + .../compiler/circuits/mut_variable.leo.out | 15 + .../circuits/mut_variable_fail.leo.out | 5 + .../mutable_call_immutable_context.leo.out | 15 + .../compiler/circuits/pedersen_mock.leo.out | 18 + .../compiler/circuits/self_circuit.leo.out | 5 + .../compiler/circuits/self_fail.leo.out | 5 + .../compiler/circuits/self_member.leo.out | 15 + .../circuits/self_member_invalid.leo.out | 5 + .../circuits/self_member_undefined.leo.out | 5 + .../compiler/compiler/integers/i8/mul.leo.out | 2 +- .../compiler/compiler/integers/i8/ne.leo.out | 2 +- .../compiler/integers/i8/negate.leo.out | 2 +- .../compiler/compiler/integers/i8/pow.leo.out | 2 +- .../compiler/compiler/integers/i8/sub.leo.out | 2 +- .../compiler/integers/i8/ternary.leo.out | 5 +- 80 files changed, 671 insertions(+), 380 deletions(-) delete mode 100644 tests/compiler/circuits/mod.rs rename tests/expectations/compiler/compiler/{mutability/circuit_mut.leo.out => circuits/const_self_variable.leo.out} (100%) create mode 100644 tests/expectations/compiler/compiler/circuits/define_circuit_inside_circuit_function.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/duplicate_name_context.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/inline.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/inline_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/inline_member_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/inline_member_pass.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/inline_undefined.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_function.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_function_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_function_invalid.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_function_nested.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_static_function.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_static_function_invalid.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_static_function_nested.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_static_function_undefined.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_variable.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_variable_and_function.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/member_variable_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_function_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_self_function_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_self_static_function_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_self_variable.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_self_variable_branch.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_self_variable_conditional.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_self_variable_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_static_function_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_variable.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mut_variable_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/mutable_call_immutable_context.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/pedersen_mock.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/self_circuit.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/self_fail.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/self_member.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/self_member_invalid.leo.out create mode 100644 tests/expectations/compiler/compiler/circuits/self_member_undefined.leo.out diff --git a/tests/compiler/circuits/const_self_variable.leo b/tests/compiler/circuits/const_self_variable.leo index 8ba32ba0df..f614a18c55 100644 --- a/tests/compiler/circuits/const_self_variable.leo +++ b/tests/compiler/circuits/const_self_variable.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Pass +*/ + circuit Foo { a: u8, @@ -10,4 +15,4 @@ function main() { let f = Foo { a: 0u8 }; console.assert(1u8 == f.use_a()); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/const_self_variable_fail.leo b/tests/compiler/circuits/const_self_variable_fail.leo index 2a1e633ab6..d59d7cec48 100644 --- a/tests/compiler/circuits/const_self_variable_fail.leo +++ b/tests/compiler/circuits/const_self_variable_fail.leo @@ -15,4 +15,4 @@ function main() { let f = Foo { a: 0u8 }; f.set_a(1u8); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/define_circuit_inside_circuit_function.leo b/tests/compiler/circuits/define_circuit_inside_circuit_function.leo index cedabf2185..e3eb425f54 100644 --- a/tests/compiler/circuits/define_circuit_inside_circuit_function.leo +++ b/tests/compiler/circuits/define_circuit_inside_circuit_function.leo @@ -1,13 +1,27 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - func_circ.in: | + [main] + a: u32 = 100; + + [registers] + r0: bool = false; +*/ + circuit Foo { a: u32, } circuit Bar { - function bar() { - const f = Foo { a: 0u32 }; + function bar(a: u32) -> u32 { + const f = Foo { a: a }; + return f.a; } } -function main() { - const b = Bar::bar(); -} \ No newline at end of file +function main(a: u32) -> bool { + const b = Bar::bar(a); + return a == b; +} diff --git a/tests/compiler/circuits/duplicate_name_context.leo b/tests/compiler/circuits/duplicate_name_context.leo index 8644d27fcb..5173956d6d 100644 --- a/tests/compiler/circuits/duplicate_name_context.leo +++ b/tests/compiler/circuits/duplicate_name_context.leo @@ -1,13 +1,18 @@ +/* +namespace: Compile +expectation: Pass +*/ + circuit Bar { b2: u32 - function add_five(z:u32) -> u32 { - return z+5u32; + function add_five(z: u32) -> u32 { + return z + 5u32; } } function main () { const Bar = 66u32; - const k1 = Bar{ b2: 30u32 }; + const k1 = Bar { b2: 30u32 }; const k2 = Bar::add_five(55u32); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/inline.leo b/tests/compiler/circuits/inline.leo index 9ba06f4191..0d15894e68 100644 --- a/tests/compiler/circuits/inline.leo +++ b/tests/compiler/circuits/inline.leo @@ -1,7 +1,20 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - inline.in: | + [main] + x: u32 = 100; + + [registers] + r0: u32 = 0; +*/ + circuit Foo { x: u32 } -function main() { - const a = Foo { x: 1u32 }; -} \ No newline at end of file +function main(x: u32) -> u32 { + const a = Foo { x: x }; + return a.x; +} diff --git a/tests/compiler/circuits/inline_fail.leo b/tests/compiler/circuits/inline_fail.leo index 01597005fb..cca4779ba4 100644 --- a/tests/compiler/circuits/inline_fail.leo +++ b/tests/compiler/circuits/inline_fail.leo @@ -1,7 +1,13 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { x: u32 } function main() { + // no member y in Foo const a = Foo { y: 0u32 }; -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/inline_member_fail.leo b/tests/compiler/circuits/inline_member_fail.leo index 59f6d7992b..91dc1c3ab4 100644 --- a/tests/compiler/circuits/inline_member_fail.leo +++ b/tests/compiler/circuits/inline_member_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { x: u8 } @@ -5,4 +10,4 @@ circuit Foo { function main() { const y: u8 = 1; const a = Foo { y }; -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/inline_member_pass.leo b/tests/compiler/circuits/inline_member_pass.leo index 6fd7f7dff7..e966c9b0fb 100644 --- a/tests/compiler/circuits/inline_member_pass.leo +++ b/tests/compiler/circuits/inline_member_pass.leo @@ -1,3 +1,15 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - inline.in: | + [main] + x: u8 = 10; + + [registers] + r0: bool = false; +*/ + circuit Foo { x: u8 @@ -6,8 +18,9 @@ circuit Foo { } } -function main() { - const x: u8 = 1; +function main(x: u8) -> bool { const a = Foo { x }; const b = Foo::new(x); -} \ No newline at end of file + + return b.x == a.x; +} diff --git a/tests/compiler/circuits/inline_undefined.leo b/tests/compiler/circuits/inline_undefined.leo index 40c4cf722c..f7b9e40eaa 100644 --- a/tests/compiler/circuits/inline_undefined.leo +++ b/tests/compiler/circuits/inline_undefined.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + function main() { const a = Foo { }; -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/member_function.leo b/tests/compiler/circuits/member_function.leo index eee44be448..f5b64e8e19 100644 --- a/tests/compiler/circuits/member_function.leo +++ b/tests/compiler/circuits/member_function.leo @@ -1,3 +1,12 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - member.in: | + [registers] + r0: bool = false; +*/ + circuit Foo { x: u32, @@ -6,8 +15,8 @@ circuit Foo { } } -function main() { +function main() -> bool { const a = Foo { x: 1u32 }; - console.assert(a.echo() == 1u32); -} \ No newline at end of file + return a.echo() == 1u32; +} diff --git a/tests/compiler/circuits/member_function_fail.leo b/tests/compiler/circuits/member_function_fail.leo index 57b15383a3..4409fa88bb 100644 --- a/tests/compiler/circuits/member_function_fail.leo +++ b/tests/compiler/circuits/member_function_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { function echo(x: u32) -> u32 { return x; @@ -7,4 +12,4 @@ circuit Foo { function main() { const a = Foo { }; const err = a.echoed(1u32); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/member_function_invalid.leo b/tests/compiler/circuits/member_function_invalid.leo index 7283cf144d..d116dc3b6c 100644 --- a/tests/compiler/circuits/member_function_invalid.leo +++ b/tests/compiler/circuits/member_function_invalid.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { function echo(x: u32) -> u32 { return x; @@ -7,4 +12,4 @@ circuit Foo { function main() { const a = Foo { }; const err = a.echo(1u32); // echo is a static function and must be accessed using `::` -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/member_function_nested.leo b/tests/compiler/circuits/member_function_nested.leo index b8bf172947..888cd69d11 100644 --- a/tests/compiler/circuits/member_function_nested.leo +++ b/tests/compiler/circuits/member_function_nested.leo @@ -1,3 +1,15 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - inline.in: | + [main] + x: u32 = 10; + + [registers] + r0: bool = false; +*/ + circuit Foo { x: u32, @@ -10,9 +22,9 @@ circuit Foo { } } -function main() { - const a = Foo { x: 1u32 }; +function main(x: u32) -> bool { + const a = Foo { x }; const b = a.add_x(1u32); - console.assert(b == 2u32); + return b == x + 1; } diff --git a/tests/compiler/circuits/member_static_function.leo b/tests/compiler/circuits/member_static_function.leo index 68f6065754..ab78b0bbc0 100644 --- a/tests/compiler/circuits/member_static_function.leo +++ b/tests/compiler/circuits/member_static_function.leo @@ -1,11 +1,20 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - static.in: | + [registers] + r0: bool = false; +*/ + circuit Foo { function echo(x: u32) -> u32 { return x; } } -function main() { +function main() -> bool { const a = Foo::echo(1u32); - console.assert(a == 1u32); -} \ No newline at end of file + return a == 1u32; +} diff --git a/tests/compiler/circuits/member_static_function_invalid.leo b/tests/compiler/circuits/member_static_function_invalid.leo index b886cff8fa..c7f3efea3a 100644 --- a/tests/compiler/circuits/member_static_function_invalid.leo +++ b/tests/compiler/circuits/member_static_function_invalid.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { function echo(x: u32) -> u32 { return x; @@ -6,4 +11,4 @@ circuit Foo { function main() { const err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/member_static_function_nested.leo b/tests/compiler/circuits/member_static_function_nested.leo index ef536e3f6e..52e3d0900f 100644 --- a/tests/compiler/circuits/member_static_function_nested.leo +++ b/tests/compiler/circuits/member_static_function_nested.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Pass +*/ + circuit Foo { function qux() {} @@ -12,4 +17,4 @@ circuit Foo { function main() { Foo::baz(); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/member_static_function_undefined.leo b/tests/compiler/circuits/member_static_function_undefined.leo index 121c80e34c..11e33b4166 100644 --- a/tests/compiler/circuits/member_static_function_undefined.leo +++ b/tests/compiler/circuits/member_static_function_undefined.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { function echo(x: u32) -> u32 { return x; @@ -6,4 +11,4 @@ circuit Foo { function main() { const err = Foo::echoed(1u32); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/member_variable.leo b/tests/compiler/circuits/member_variable.leo index a3f3fbe7e6..f14178bf6b 100644 --- a/tests/compiler/circuits/member_variable.leo +++ b/tests/compiler/circuits/member_variable.leo @@ -1,9 +1,18 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - member.in: | + [registers] + r0: bool = false; +*/ + circuit Foo { x: u32, } -function main() { +function main() -> bool { const a = Foo { x: 1u32 }; - console.assert(a.x == 1u32); -} \ No newline at end of file + return a.x == 1u32; +} diff --git a/tests/compiler/circuits/member_variable_and_function.leo b/tests/compiler/circuits/member_variable_and_function.leo index f90cdca072..f6f179a61f 100644 --- a/tests/compiler/circuits/member_variable_and_function.leo +++ b/tests/compiler/circuits/member_variable_and_function.leo @@ -1,3 +1,12 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - member.in: | + [registers] + r0: bool = false; +*/ + circuit Foo { foo: u32, @@ -6,10 +15,9 @@ circuit Foo { } } -function main() { +function main() -> bool { const a = Foo { foo: 1 }; - const b = a.foo + Foo::bar(); - console.assert(b == 2u32); + return b == 2u32; } diff --git a/tests/compiler/circuits/member_variable_fail.leo b/tests/compiler/circuits/member_variable_fail.leo index fdf42068d5..d2c899baa0 100644 --- a/tests/compiler/circuits/member_variable_fail.leo +++ b/tests/compiler/circuits/member_variable_fail.leo @@ -1,9 +1,13 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { x: u32 } function main() { const a = Foo { x: 1u32 }; - const err = a.y; -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mod.rs b/tests/compiler/circuits/mod.rs deleted file mode 100644 index 093e2263e1..0000000000 --- a/tests/compiler/circuits/mod.rs +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright (C) 2019-2021 Aleo Systems Inc. -// This file is part of the Leo library. - -// The Leo library is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The Leo library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with the Leo library. If not, see . - -use crate::{assert_satisfied, expect_asg_error, parse_program}; - -// Expressions - -#[test] -fn test_inline() { - let program_string = include_str!("inline.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_inline_fail() { - let program_string = include_str!("inline_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_inline_undefined() { - let program_string = include_str!("inline_undefined.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -// Members - -#[test] -fn test_member_variable() { - let program_string = include_str!("member_variable.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_member_variable_fail() { - let program_string = include_str!("member_variable_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_member_variable_and_function() { - let program_string = include_str!("member_variable_and_function.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_member_function() { - let program_string = include_str!("member_function.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_member_function_fail() { - let program_string = include_str!("member_function_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_member_function_invalid() { - let program_string = include_str!("member_function_invalid.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_member_function_nested() { - let program_string = include_str!("member_function_nested.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_member_static_function() { - let program_string = include_str!("member_static_function.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_member_static_function_nested() { - let program_string = include_str!("member_static_function_nested.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_member_static_function_invalid() { - let program_string = include_str!("member_static_function_invalid.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error) -} - -#[test] -fn test_member_static_function_undefined() { - let program_string = include_str!("member_static_function_undefined.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error) -} - -// Constant -#[test] -fn test_const_self_variable() { - let program_string = include_str!("const_self_variable.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_const_self_variable_fail() { - let program_string = include_str!("const_self_variable_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -// Mutability - -#[test] -fn test_mutate_function_fail() { - let program_string = include_str!("mut_function_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_mutate_self_variable() { - let program_string = include_str!("mut_self_variable.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_mutate_self_variable_branch() { - let program_string = include_str!("mut_self_variable_branch.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_mutate_self_variable_conditional() { - let program_string = include_str!("mut_self_variable_conditional.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_mutate_self_variable_fail() { - let program_string = include_str!("mut_self_variable_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_mutate_self_function_fail() { - let program_string = include_str!("mut_self_function_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_mutate_self_static_function_fail() { - let program_string = include_str!("mut_self_static_function_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_mutate_static_function_fail() { - let program_string = include_str!("mut_static_function_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_mutate_variable() { - let program_string = include_str!("mut_variable.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_mutate_variable_fail() { - let program_string = include_str!("mut_variable_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -// Self - -#[test] -fn test_self_fail() { - let program_string = include_str!("self_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_self_member_pass() { - let program_string = include_str!("self_member.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_self_member_invalid() { - let program_string = include_str!("self_member_invalid.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -#[test] -fn test_self_member_undefined() { - let program_string = include_str!("self_member_undefined.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -// Inline circuit member - -#[test] -fn test_inline_member_pass() { - let program_string = include_str!("inline_member_pass.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_inline_member_fail() { - let program_string = include_str!("inline_member_fail.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - -// All - -#[test] -fn test_pedersen_mock() { - let program_string = include_str!("pedersen_mock.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_define_circuit_inside_circuit_function() { - let program_string = include_str!("define_circuit_inside_circuit_function.leo"); - let program = parse_program(program_string).unwrap(); - - 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); -} - -#[test] -fn test_mutable_call_immutable_context() { - let program_string = include_str!("mutable_call_immutable_context.leo"); - let program = parse_program(program_string).unwrap(); - - assert_satisfied(program); -} diff --git a/tests/compiler/circuits/mut_function_fail.leo b/tests/compiler/circuits/mut_function_fail.leo index 44583810dd..9f4971fd60 100644 --- a/tests/compiler/circuits/mut_function_fail.leo +++ b/tests/compiler/circuits/mut_function_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { a: u8, @@ -8,4 +13,4 @@ function main() { let f = Foo { a: 0u8 }; f.bar = 1u8; -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_self_function_fail.leo b/tests/compiler/circuits/mut_self_function_fail.leo index b81b18e743..a5b4427474 100644 --- a/tests/compiler/circuits/mut_self_function_fail.leo +++ b/tests/compiler/circuits/mut_self_function_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { a: u8, @@ -12,4 +17,4 @@ function main() { let f = Foo { a: 0u8 }; f.set_a(1u8); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_self_static_function_fail.leo b/tests/compiler/circuits/mut_self_static_function_fail.leo index b81b18e743..a5b4427474 100644 --- a/tests/compiler/circuits/mut_self_static_function_fail.leo +++ b/tests/compiler/circuits/mut_self_static_function_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { a: u8, @@ -12,4 +17,4 @@ function main() { let f = Foo { a: 0u8 }; f.set_a(1u8); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_self_variable.leo b/tests/compiler/circuits/mut_self_variable.leo index dc2047d872..cb25448ffa 100644 --- a/tests/compiler/circuits/mut_self_variable.leo +++ b/tests/compiler/circuits/mut_self_variable.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Pass +*/ + circuit Foo { a: u8, @@ -19,4 +24,4 @@ function main() { f.set_a(2u8); console.assert(f.a == 2u8); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_self_variable_branch.leo b/tests/compiler/circuits/mut_self_variable_branch.leo index 1c2f126f08..5ed2e5e1d4 100644 --- a/tests/compiler/circuits/mut_self_variable_branch.leo +++ b/tests/compiler/circuits/mut_self_variable_branch.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Pass +*/ + circuit Foo { a: u8, @@ -29,4 +34,4 @@ function main() { f.set_a(true, 2u8); console.assert(f.a == 2u8); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_self_variable_conditional.leo b/tests/compiler/circuits/mut_self_variable_conditional.leo index 61a5e354dc..f9b8550b79 100644 --- a/tests/compiler/circuits/mut_self_variable_conditional.leo +++ b/tests/compiler/circuits/mut_self_variable_conditional.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Pass +*/ + function main() { let f = Foo { a: 0u32 }; @@ -12,4 +17,4 @@ circuit Foo { self.a = 5u32; // Mutating a variable inside a conditional statement should work. } } -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_self_variable_fail.leo b/tests/compiler/circuits/mut_self_variable_fail.leo index 4db62a4d3e..c974433045 100644 --- a/tests/compiler/circuits/mut_self_variable_fail.leo +++ b/tests/compiler/circuits/mut_self_variable_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { a: u8, @@ -10,4 +15,4 @@ function main() { let f = Foo { a: 0u8 }; f.set_a(1u8); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_static_function_fail.leo b/tests/compiler/circuits/mut_static_function_fail.leo index e7db3a1df9..8e70eb1ca0 100644 --- a/tests/compiler/circuits/mut_static_function_fail.leo +++ b/tests/compiler/circuits/mut_static_function_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { function bar() {} } @@ -6,4 +11,4 @@ function main() { let f = Foo { a: 0u8 }; f.bar = 1u8; -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_variable.leo b/tests/compiler/circuits/mut_variable.leo index ddc7412038..4ef68f03bd 100644 --- a/tests/compiler/circuits/mut_variable.leo +++ b/tests/compiler/circuits/mut_variable.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Pass +*/ + circuit Foo { a: u8, } @@ -14,4 +19,4 @@ function main() { f.a = 2u8; console.assert(f.a == 2u8); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mut_variable_fail.leo b/tests/compiler/circuits/mut_variable_fail.leo index e116b33d5c..d4c7ac6d26 100644 --- a/tests/compiler/circuits/mut_variable_fail.leo +++ b/tests/compiler/circuits/mut_variable_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { a: u8, } @@ -6,4 +11,4 @@ function main() { const f = Foo { a: 0u8 }; f.a = 1u8; -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/mutable_call_immutable_context.leo b/tests/compiler/circuits/mutable_call_immutable_context.leo index d235d11cb7..ec5c3fbc44 100644 --- a/tests/compiler/circuits/mutable_call_immutable_context.leo +++ b/tests/compiler/circuits/mutable_call_immutable_context.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Pass +*/ + circuit TestMe { x: u8, @@ -22,4 +27,4 @@ function main () { console.assert(u == 1u8); const v = TestMe::new().test_me(); console.assert(v == 2u8); -} \ No newline at end of file +} diff --git a/tests/compiler/circuits/pedersen_mock.leo b/tests/compiler/circuits/pedersen_mock.leo index 0fc6752f2f..ee001de4f3 100644 --- a/tests/compiler/circuits/pedersen_mock.leo +++ b/tests/compiler/circuits/pedersen_mock.leo @@ -1,3 +1,15 @@ +/* +namespace: Compile +expectation: Pass +inputs: + - pedersen.in: | + [main] + hash_input: [bool; 512] = [true; 512]; + + [registers] + r0: bool = false; +*/ + circuit PedersenHash { parameters: [u32; 512] @@ -16,12 +28,11 @@ circuit PedersenHash { } // The 'pedersen_hash' main function. -function main() { +function main(hash_input: [bool; 512]) -> bool { const parameters = [0u32; 512]; const pedersen = PedersenHash::new(parameters); - const hash_input: [bool; 512] = [true; 512]; - const res = pedersen.hash(hash_input); console.assert(res == 0u32); + return res == 0u32; } diff --git a/tests/compiler/circuits/self_circuit.leo b/tests/compiler/circuits/self_circuit.leo index 6faa42278b..097712f94e 100644 --- a/tests/compiler/circuits/self_circuit.leo +++ b/tests/compiler/circuits/self_circuit.leo @@ -1,4 +1,10 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { + // static is deprecated static function new() -> Self { return Self { }; } diff --git a/tests/compiler/circuits/self_fail.leo b/tests/compiler/circuits/self_fail.leo index e4e878dc89..8cc50d3aae 100644 --- a/tests/compiler/circuits/self_fail.leo +++ b/tests/compiler/circuits/self_fail.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + function main() { Self::main(); } \ No newline at end of file diff --git a/tests/compiler/circuits/self_member.leo b/tests/compiler/circuits/self_member.leo index 237baac9de..86b24053ee 100644 --- a/tests/compiler/circuits/self_member.leo +++ b/tests/compiler/circuits/self_member.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Pass +*/ + circuit Foo { f: u32, diff --git a/tests/compiler/circuits/self_member_invalid.leo b/tests/compiler/circuits/self_member_invalid.leo index 7283b3260a..0b14bcf7e6 100644 --- a/tests/compiler/circuits/self_member_invalid.leo +++ b/tests/compiler/circuits/self_member_invalid.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { f: u32, diff --git a/tests/compiler/circuits/self_member_undefined.leo b/tests/compiler/circuits/self_member_undefined.leo index 8b52d305a3..5674da414b 100644 --- a/tests/compiler/circuits/self_member_undefined.leo +++ b/tests/compiler/circuits/self_member_undefined.leo @@ -1,3 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + circuit Foo { function bar() -> u32 { return self.f; diff --git a/tests/expectations/compiler/compiler/mutability/circuit_mut.leo.out b/tests/expectations/compiler/compiler/circuits/const_self_variable.leo.out similarity index 100% rename from tests/expectations/compiler/compiler/mutability/circuit_mut.leo.out rename to tests/expectations/compiler/compiler/circuits/const_self_variable.leo.out diff --git a/tests/expectations/compiler/compiler/circuits/define_circuit_inside_circuit_function.leo.out b/tests/expectations/compiler/compiler/circuits/define_circuit_inside_circuit_function.leo.out new file mode 100644 index 0000000000..19a426b72e --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/define_circuit_inside_circuit_function.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 95 + num_constraints: 95 + at: 5267486d9db0d5d95b248da00196e1a6e5c6e165f8580eae4fbf20d8e1560fd7 + bt: e0a9aa0cab882fb690b28137d24f271ccaa334521934a3badc07592a31b7be7f + ct: 5983ee7f60c1fc1ad4aaece7815002040cd4b5a7e019b3967f948d30f5d7ec96 + output: + - input_file: func_circ.in + output: + registers: + r0: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/circuits/duplicate_name_context.leo.out b/tests/expectations/compiler/compiler/circuits/duplicate_name_context.leo.out new file mode 100644 index 0000000000..2a650384ef --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/duplicate_name_context.leo.out @@ -0,0 +1,15 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: empty + output: + registers: {} diff --git a/tests/expectations/compiler/compiler/circuits/inline.leo.out b/tests/expectations/compiler/compiler/circuits/inline.leo.out new file mode 100644 index 0000000000..3f39906b02 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/inline.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 32 + num_constraints: 32 + at: 4f36fe54f989d60bb9c279120800f4f44596c2efb7ba703669d4c4d591569780 + bt: d378030968a64801f66d95699329086ca17e676d8bffcf73f6b431cbda7c7005 + ct: dbd098af6556ed79650d149b1691be336a46f8bad6f327e942508dd11342575e + output: + - input_file: inline.in + output: + registers: + r0: + type: u32 + value: "100" diff --git a/tests/expectations/compiler/compiler/circuits/inline_fail.leo.out b/tests/expectations/compiler/compiler/circuits/inline_fail.leo.out new file mode 100644 index 0000000000..6ac648a3e6 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/inline_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:9:15\n |\n 9 | const a = Foo { y: 0u32 };\n | ^^^^^^^^^^^^^^^\n |\n = missing circuit member 'x' for initialization of circuit 'Foo'" diff --git a/tests/expectations/compiler/compiler/circuits/inline_member_fail.leo.out b/tests/expectations/compiler/compiler/circuits/inline_member_fail.leo.out new file mode 100644 index 0000000000..ca83db6796 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/inline_member_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:9:15\n |\n 9 | const a = Foo { y };\n | ^^^^^^^^^\n |\n = missing circuit member 'x' for initialization of circuit 'Foo'" diff --git a/tests/expectations/compiler/compiler/circuits/inline_member_pass.leo.out b/tests/expectations/compiler/compiler/circuits/inline_member_pass.leo.out new file mode 100644 index 0000000000..76eda84c48 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/inline_member_pass.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 23 + num_constraints: 23 + at: 1b2521e1b6fa3c84507b93ff0c68d463de22e8fcf6e750ff11dbf856494e9851 + bt: e07261c391194324de6c9bb8706ff09c30ce64dfc55ce30bd8aa4b19f7b1443a + ct: f053ce5b6adb30f5c4f21f4c4c4001a77517d9c0ca3d113cece2585b22e56635 + output: + - input_file: inline.in + output: + registers: + r0: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/circuits/inline_undefined.leo.out b/tests/expectations/compiler/compiler/circuits/inline_undefined.leo.out new file mode 100644 index 0000000000..8b7a0be7d5 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/inline_undefined.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:4:15\n |\n 4 | const a = Foo { };\n | ^^^\n |\n = failed to resolve circuit: 'Foo'" diff --git a/tests/expectations/compiler/compiler/circuits/member_function.leo.out b/tests/expectations/compiler/compiler/circuits/member_function.leo.out new file mode 100644 index 0000000000..f54cdfaa9c --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_function.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: member.in + output: + registers: + r0: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/circuits/member_function_fail.leo.out b/tests/expectations/compiler/compiler/circuits/member_function_fail.leo.out new file mode 100644 index 0000000000..cfd7656f46 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_function_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:11:17\n |\n 11 | const err = a.echoed(1u32);\n | ^^^^^^^^\n |\n = illegal reference to non-existant member 'echoed' of circuit 'Foo'" diff --git a/tests/expectations/compiler/compiler/circuits/member_function_invalid.leo.out b/tests/expectations/compiler/compiler/circuits/member_function_invalid.leo.out new file mode 100644 index 0000000000..16fa915b96 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_function_invalid.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:11:17\n |\n 11 | const err = a.echo(1u32); // echo is a static function and must be accessed using `::`\n | ^^^^^^\n |\n = cannot call static function 'echo' of circuit 'Foo' from target" diff --git a/tests/expectations/compiler/compiler/circuits/member_function_nested.leo.out b/tests/expectations/compiler/compiler/circuits/member_function_nested.leo.out new file mode 100644 index 0000000000..966431934e --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_function_nested.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 161 + num_constraints: 163 + at: e35800570ea5a58f3587ffba2b1be2a1df1c5790a6cbe215083e3d5d5a13b2bf + bt: 799dc824f6ba6a51959a395a3b5ebf05629aa241dbca9550190f32380b91ae1c + ct: 2aa6128cdf932752c8864c26a6a3d4991f3e6a75b22c1261a3389efa67375b01 + output: + - input_file: inline.in + output: + registers: + r0: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/circuits/member_static_function.leo.out b/tests/expectations/compiler/compiler/circuits/member_static_function.leo.out new file mode 100644 index 0000000000..be68ef6293 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_static_function.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: static.in + output: + registers: + r0: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/circuits/member_static_function_invalid.leo.out b/tests/expectations/compiler/compiler/circuits/member_static_function_invalid.leo.out new file mode 100644 index 0000000000..a518cb4078 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_static_function_invalid.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:10:17\n |\n 10 | const err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::`\n | ^^^\n |\n = failed to resolve variable reference 'Foo'" diff --git a/tests/expectations/compiler/compiler/circuits/member_static_function_nested.leo.out b/tests/expectations/compiler/compiler/circuits/member_static_function_nested.leo.out new file mode 100644 index 0000000000..2a650384ef --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_static_function_nested.leo.out @@ -0,0 +1,15 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: empty + output: + registers: {} diff --git a/tests/expectations/compiler/compiler/circuits/member_static_function_undefined.leo.out b/tests/expectations/compiler/compiler/circuits/member_static_function_undefined.leo.out new file mode 100644 index 0000000000..6b68a9ab05 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_static_function_undefined.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:10:17\n |\n 10 | const err = Foo::echoed(1u32);\n | ^^^^^^^^^^^\n |\n = illegal reference to non-existant member 'echoed' of circuit 'Foo'" diff --git a/tests/expectations/compiler/compiler/circuits/member_variable.leo.out b/tests/expectations/compiler/compiler/circuits/member_variable.leo.out new file mode 100644 index 0000000000..f54cdfaa9c --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_variable.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: member.in + output: + registers: + r0: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/circuits/member_variable_and_function.leo.out b/tests/expectations/compiler/compiler/circuits/member_variable_and_function.leo.out new file mode 100644 index 0000000000..f54cdfaa9c --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_variable_and_function.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: member.in + output: + registers: + r0: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/circuits/member_variable_fail.leo.out b/tests/expectations/compiler/compiler/circuits/member_variable_fail.leo.out new file mode 100644 index 0000000000..952e3fdacb --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/member_variable_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:9:17\n |\n 9 | const err = a.y;\n | ^^^\n |\n = illegal reference to non-existant member 'y' of circuit 'Foo'" diff --git a/tests/expectations/compiler/compiler/circuits/mut_function_fail.leo.out b/tests/expectations/compiler/compiler/circuits/mut_function_fail.leo.out new file mode 100644 index 0000000000..1d236af849 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_function_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:12:5\n |\n 12 | f.bar = 1u8;\n | ^^^^^^^^^^^\n |\n = attempt to assign to function 'bar'" diff --git a/tests/expectations/compiler/compiler/circuits/mut_self_function_fail.leo.out b/tests/expectations/compiler/compiler/circuits/mut_self_function_fail.leo.out new file mode 100644 index 0000000000..165ac66fac --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_self_function_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:9:9\n |\n 9 | self.bar = new;\n | ^^^^^^^^^^^^^^\n |\n = attempt to assign to function 'bar'" diff --git a/tests/expectations/compiler/compiler/circuits/mut_self_static_function_fail.leo.out b/tests/expectations/compiler/compiler/circuits/mut_self_static_function_fail.leo.out new file mode 100644 index 0000000000..165ac66fac --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_self_static_function_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:9:9\n |\n 9 | self.bar = new;\n | ^^^^^^^^^^^^^^\n |\n = attempt to assign to function 'bar'" diff --git a/tests/expectations/compiler/compiler/circuits/mut_self_variable.leo.out b/tests/expectations/compiler/compiler/circuits/mut_self_variable.leo.out new file mode 100644 index 0000000000..2a650384ef --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_self_variable.leo.out @@ -0,0 +1,15 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: empty + output: + registers: {} diff --git a/tests/expectations/compiler/compiler/circuits/mut_self_variable_branch.leo.out b/tests/expectations/compiler/compiler/circuits/mut_self_variable_branch.leo.out new file mode 100644 index 0000000000..2a650384ef --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_self_variable_branch.leo.out @@ -0,0 +1,15 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: empty + output: + registers: {} diff --git a/tests/expectations/compiler/compiler/circuits/mut_self_variable_conditional.leo.out b/tests/expectations/compiler/compiler/circuits/mut_self_variable_conditional.leo.out new file mode 100644 index 0000000000..2a650384ef --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_self_variable_conditional.leo.out @@ -0,0 +1,15 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: empty + output: + registers: {} diff --git a/tests/expectations/compiler/compiler/circuits/mut_self_variable_fail.leo.out b/tests/expectations/compiler/compiler/circuits/mut_self_variable_fail.leo.out new file mode 100644 index 0000000000..48f3614d62 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_self_variable_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:7:9\n |\n 7 | self.a = new;\n | ^^^^^^^^^^^^\n |\n = illegal assignment to immutable variable 'self'" diff --git a/tests/expectations/compiler/compiler/circuits/mut_static_function_fail.leo.out b/tests/expectations/compiler/compiler/circuits/mut_static_function_fail.leo.out new file mode 100644 index 0000000000..ebae3568f6 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_static_function_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:8:19\n |\n 8 | let f = Foo { a: 0u8 };\n | ^\n |\n = extra circuit member 'a' for initialization of circuit 'Foo' is not allowed" diff --git a/tests/expectations/compiler/compiler/circuits/mut_variable.leo.out b/tests/expectations/compiler/compiler/circuits/mut_variable.leo.out new file mode 100644 index 0000000000..2a650384ef --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_variable.leo.out @@ -0,0 +1,15 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: empty + output: + registers: {} diff --git a/tests/expectations/compiler/compiler/circuits/mut_variable_fail.leo.out b/tests/expectations/compiler/compiler/circuits/mut_variable_fail.leo.out new file mode 100644 index 0000000000..ae22229256 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mut_variable_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:10:5\n |\n 10 | f.a = 1u8;\n | ^^^^^^^^^\n |\n = illegal assignment to immutable variable 'f'" diff --git a/tests/expectations/compiler/compiler/circuits/mutable_call_immutable_context.leo.out b/tests/expectations/compiler/compiler/circuits/mutable_call_immutable_context.leo.out new file mode 100644 index 0000000000..2a650384ef --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/mutable_call_immutable_context.leo.out @@ -0,0 +1,15 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: empty + output: + registers: {} diff --git a/tests/expectations/compiler/compiler/circuits/pedersen_mock.leo.out b/tests/expectations/compiler/compiler/circuits/pedersen_mock.leo.out new file mode 100644 index 0000000000..93b1d0d42a --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/pedersen_mock.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 33854 + num_constraints: 50750 + at: ef530d618c6915bbff2137e7f057b1135dacbdd02e8d4be420320999724633ad + bt: 4ec9fd3915bf2762cb32a7f7805918c1b976ca6c59852f505089fd23c0f321b7 + ct: e13fb652749582faae780837f6de4900f3b6c7202289d2219a543bfdd4f6836e + output: + - input_file: pedersen.in + output: + registers: + r0: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/circuits/self_circuit.leo.out b/tests/expectations/compiler/compiler/circuits/self_circuit.leo.out new file mode 100644 index 0000000000..8c69b77e46 --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/self_circuit.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:5:5\n |\n 5 | static function new() -> Self {\n | ^^^^^^\n |\n = expected 'ident', got 'static'" diff --git a/tests/expectations/compiler/compiler/circuits/self_fail.leo.out b/tests/expectations/compiler/compiler/circuits/self_fail.leo.out new file mode 100644 index 0000000000..8ef345f61a --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/self_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:4:5\n |\n 4 | Self::main();\n | ^^^^\n |\n = failed to resolve circuit: 'Self'" diff --git a/tests/expectations/compiler/compiler/circuits/self_member.leo.out b/tests/expectations/compiler/compiler/circuits/self_member.leo.out new file mode 100644 index 0000000000..2a650384ef --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/self_member.leo.out @@ -0,0 +1,15 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 0 + num_constraints: 0 + at: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + bt: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + ct: 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945 + output: + - input_file: empty + output: + registers: {} diff --git a/tests/expectations/compiler/compiler/circuits/self_member_invalid.leo.out b/tests/expectations/compiler/compiler/circuits/self_member_invalid.leo.out new file mode 100644 index 0000000000..6ad055c2fe --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/self_member_invalid.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:13:17\n |\n 13 | const err = foo.bar();\n | ^^^^^^^\n |\n = cannot call static function 'bar' of circuit 'Foo' from target" diff --git a/tests/expectations/compiler/compiler/circuits/self_member_undefined.leo.out b/tests/expectations/compiler/compiler/circuits/self_member_undefined.leo.out new file mode 100644 index 0000000000..f00cd79c2d --- /dev/null +++ b/tests/expectations/compiler/compiler/circuits/self_member_undefined.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> /test/src/main.leo:11:17\n |\n 11 | const err = foo.bar();\n | ^^^^^^^\n |\n = cannot call static function 'bar' of circuit 'Foo' from target" diff --git a/tests/expectations/compiler/compiler/integers/i8/mul.leo.out b/tests/expectations/compiler/compiler/integers/i8/mul.leo.out index 2816652491..1b213ebb13 100644 --- a/tests/expectations/compiler/compiler/integers/i8/mul.leo.out +++ b/tests/expectations/compiler/compiler/integers/i8/mul.leo.out @@ -10,6 +10,6 @@ outputs: bt: 0b017985fe9a0650c67351f1cc247871e9cc9e8c907f2cb47791c5ae1a5b324a ct: 3fb41ccb74d402bc413944e9eb543a7333552052b7781eb257d2b861659d5a09 output: - - input_file: i16.in + - input_file: i8.in output: registers: {} diff --git a/tests/expectations/compiler/compiler/integers/i8/ne.leo.out b/tests/expectations/compiler/compiler/integers/i8/ne.leo.out index e2b3ec4e41..dabe909afa 100644 --- a/tests/expectations/compiler/compiler/integers/i8/ne.leo.out +++ b/tests/expectations/compiler/compiler/integers/i8/ne.leo.out @@ -10,6 +10,6 @@ outputs: bt: 10b52342f8c44eb9b3335b4df9ca4136de3ad35d5b580b2ab32ae5e10bcdf3b4 ct: 2aae7d6631260dcaafbfe9709ade84e75f5172a9baad48e108e7264d5fc17cf6 output: - - input_file: i16.in + - input_file: i8.in output: registers: {} diff --git a/tests/expectations/compiler/compiler/integers/i8/negate.leo.out b/tests/expectations/compiler/compiler/integers/i8/negate.leo.out index 3a58aed4be..210b46a3a5 100644 --- a/tests/expectations/compiler/compiler/integers/i8/negate.leo.out +++ b/tests/expectations/compiler/compiler/integers/i8/negate.leo.out @@ -10,6 +10,6 @@ outputs: bt: 43214e3563d9bc921ffc9079215a945f8450cf3c02506bd6e23144b2e18944d3 ct: a2352ad3a95bc4b0d0ca56ac5b1bcec0cc3b62077d2c3d883f90f8bf014a8e28 output: - - input_file: i16.in + - input_file: i8.in output: registers: {} diff --git a/tests/expectations/compiler/compiler/integers/i8/pow.leo.out b/tests/expectations/compiler/compiler/integers/i8/pow.leo.out index 905b5aa8b7..3052caf6f5 100644 --- a/tests/expectations/compiler/compiler/integers/i8/pow.leo.out +++ b/tests/expectations/compiler/compiler/integers/i8/pow.leo.out @@ -10,6 +10,6 @@ outputs: bt: b8979c4494b630792fad6a0b29a53293c7649f3d5fcd45b8c1d2396f970ca0dd ct: 1acbdb8598982e7bf38d0a531f67d6937a6bd98418c6d382e4201c4a8285df55 output: - - input_file: i16.in + - input_file: i8.in output: registers: {} diff --git a/tests/expectations/compiler/compiler/integers/i8/sub.leo.out b/tests/expectations/compiler/compiler/integers/i8/sub.leo.out index 1c57c96986..2009bad971 100644 --- a/tests/expectations/compiler/compiler/integers/i8/sub.leo.out +++ b/tests/expectations/compiler/compiler/integers/i8/sub.leo.out @@ -10,6 +10,6 @@ outputs: bt: 35a61219fd7bf101cf1a1a66ad2f71df661d6dc9dda2ed9df12c7650164559aa ct: 50f1a63551e44fb1f2ef29982d5b1580340dcda67d8d8caaa9c837353a950d8f output: - - input_file: i16.in + - input_file: i8.in output: registers: {} diff --git a/tests/expectations/compiler/compiler/integers/i8/ternary.leo.out b/tests/expectations/compiler/compiler/integers/i8/ternary.leo.out index e10d3f99c7..e4b884a40d 100644 --- a/tests/expectations/compiler/compiler/integers/i8/ternary.leo.out +++ b/tests/expectations/compiler/compiler/integers/i8/ternary.leo.out @@ -10,6 +10,9 @@ outputs: bt: 90a2489533355ee3e27d5cf485612441ec10e21923eb78e6be21633ce11fa8f1 ct: 4c2d67fc6e1c4ad44f323c1b958ed94313153573aa72a3c0f0d25b17b54e63bc output: - - input_file: i16.in + - input_file: i8.in + output: + registers: {} + - input_file: i8_rev.in output: registers: {}