From f5be2e037fbff310b179c2078f9eeced6ec9a79a Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 4 Feb 2021 13:18:28 -0800 Subject: [PATCH] add inline circuit integration tests --- compiler/tests/circuits/inline_member_fail.leo | 8 ++++++++ compiler/tests/circuits/inline_member_pass.leo | 13 +++++++++++++ compiler/tests/circuits/mod.rs | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 compiler/tests/circuits/inline_member_fail.leo create mode 100644 compiler/tests/circuits/inline_member_pass.leo diff --git a/compiler/tests/circuits/inline_member_fail.leo b/compiler/tests/circuits/inline_member_fail.leo new file mode 100644 index 0000000000..7f0b8f7889 --- /dev/null +++ b/compiler/tests/circuits/inline_member_fail.leo @@ -0,0 +1,8 @@ +circuit Foo { + x: u8 +} + +function main() { + let y: u8 = 1; + let a = Foo { y }; +} \ No newline at end of file diff --git a/compiler/tests/circuits/inline_member_pass.leo b/compiler/tests/circuits/inline_member_pass.leo new file mode 100644 index 0000000000..5541a65638 --- /dev/null +++ b/compiler/tests/circuits/inline_member_pass.leo @@ -0,0 +1,13 @@ +circuit Foo { + x: u8 + + function new(x: u8) -> Self { + return Self { x } + } +} + +function main() { + let x: u8 = 1; + let a = Foo { x }; + let b = Foo::new(x); +} \ No newline at end of file diff --git a/compiler/tests/circuits/mod.rs b/compiler/tests/circuits/mod.rs index dbed6c7e41..488b639d0b 100644 --- a/compiler/tests/circuits/mod.rs +++ b/compiler/tests/circuits/mod.rs @@ -248,6 +248,24 @@ fn test_self_member_undefined() { 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]