mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-19 15:41:36 +03:00
add tests for dead code elim
This commit is contained in:
parent
99efdf00cb
commit
113ba12959
7
compiler/tests/mutability/cond_mut.leo
Normal file
7
compiler/tests/mutability/cond_mut.leo
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function main () {
|
||||||
|
let mut x = 100i8;
|
||||||
|
if false {
|
||||||
|
x = 1i8;
|
||||||
|
x *= 100i8;
|
||||||
|
}
|
||||||
|
}
|
@ -51,13 +51,7 @@ fn test_const_fail() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cond_mut() {
|
fn test_cond_mut() {
|
||||||
let program_string = r#"function main () {
|
let program_string = include_str!("cond_mut.leo");
|
||||||
let mut x = 100i8;
|
|
||||||
if false {
|
|
||||||
x = 1i8;
|
|
||||||
x *= 100i8;
|
|
||||||
}
|
|
||||||
}"#;
|
|
||||||
let program = parse_program(program_string).unwrap();
|
let program = parse_program(program_string).unwrap();
|
||||||
|
|
||||||
assert_satisfied(program);
|
assert_satisfied(program);
|
||||||
|
9
compiler/tests/statements/conditional/cond_switch.leo
Normal file
9
compiler/tests/statements/conditional/cond_switch.leo
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
function main (x: bool) -> bool {
|
||||||
|
if false {
|
||||||
|
return x
|
||||||
|
} else if x {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
[main]
|
||||||
|
x: bool = true;
|
||||||
|
|
||||||
|
[registers]
|
||||||
|
r: bool = false;
|
@ -221,3 +221,16 @@ fn test_multiple_returns() {
|
|||||||
|
|
||||||
output_zero(program);
|
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());
|
||||||
|
}
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
[registers]
|
||||||
|
r: bool = false;
|
Loading…
Reference in New Issue
Block a user