diff --git a/compiler/tests/mutability/cond_mut.leo b/compiler/tests/mutability/cond_mut.leo new file mode 100644 index 0000000000..3d7c73ef2a --- /dev/null +++ b/compiler/tests/mutability/cond_mut.leo @@ -0,0 +1,7 @@ +function main () { + let mut x = 100i8; + if false { + x = 1i8; + x *= 100i8; + } +} \ No newline at end of file diff --git a/compiler/tests/mutability/mod.rs b/compiler/tests/mutability/mod.rs index a296e159d7..e0df21fb4e 100644 --- a/compiler/tests/mutability/mod.rs +++ b/compiler/tests/mutability/mod.rs @@ -51,13 +51,7 @@ fn test_const_fail() { #[test] fn test_cond_mut() { - let program_string = r#"function main () { - let mut x = 100i8; - if false { - x = 1i8; - x *= 100i8; - } - }"#; + let program_string = include_str!("cond_mut.leo"); let program = parse_program(program_string).unwrap(); assert_satisfied(program); diff --git a/compiler/tests/statements/conditional/cond_switch.leo b/compiler/tests/statements/conditional/cond_switch.leo new file mode 100644 index 0000000000..7b7845cde3 --- /dev/null +++ b/compiler/tests/statements/conditional/cond_switch.leo @@ -0,0 +1,9 @@ +function main (x: bool) -> bool { + if false { + return x + } else if x { + return false + } else { + return false + } +} \ No newline at end of file diff --git a/compiler/tests/statements/conditional/input/cond_switch.in b/compiler/tests/statements/conditional/input/cond_switch.in new file mode 100644 index 0000000000..b5abb29c2e --- /dev/null +++ b/compiler/tests/statements/conditional/input/cond_switch.in @@ -0,0 +1,5 @@ +[main] +x: bool = true; + +[registers] +r: bool = false; \ No newline at end of file diff --git a/compiler/tests/statements/conditional/mod.rs b/compiler/tests/statements/conditional/mod.rs index 040c8108dd..c57f7974de 100644 --- a/compiler/tests/statements/conditional/mod.rs +++ b/compiler/tests/statements/conditional/mod.rs @@ -221,3 +221,16 @@ fn test_multiple_returns() { output_zero(program); } + +#[test] +fn test_cond_switch() { + let input_string = include_str!("input/cond_switch.in"); + let program_string = include_str!("cond_switch.leo"); + let expect_output = include_bytes!("output/cond_switch.out"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + let actual_output = get_output(program); + + assert_eq!(expect_output, actual_output.bytes().as_slice()); +} diff --git a/compiler/tests/statements/conditional/output/cond_switch.out b/compiler/tests/statements/conditional/output/cond_switch.out new file mode 100644 index 0000000000..8ddb2792bd --- /dev/null +++ b/compiler/tests/statements/conditional/output/cond_switch.out @@ -0,0 +1,2 @@ +[registers] +r: bool = false;