Skip to content

Commit

Permalink
test(fib): fix fib test
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Jul 19, 2024
1 parent 9f5a630 commit 9949738
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ mod tests {
#[test]
fn test_fib() {
let expected_name = "fib".to_owned();
let expected_return_type = "i32".to_owned();
let expected_return_type = "i128".to_owned();
let expected_params = vec![
CairoParameter::new("a".to_owned(), "i32".to_owned()),
CairoParameter::new("b".to_owned(), "i32".to_owned()),
CairoParameter::new("n".to_owned(), "i32".to_owned()),
CairoParameter::new("a".to_owned(), "i128".to_owned()),
CairoParameter::new("b".to_owned(), "i128".to_owned()),
CairoParameter::new("n".to_owned(), "i128".to_owned()),
];
let code = compile("examples/fib/fib.ll");

Expand All @@ -108,45 +108,47 @@ mod tests {
);

// Check function body
pretty_assertions::assert_eq!(
assert_eq!(
function.body,
CairoFunctionBody::new(vec![
"let mut is_from_bb2 = false;".to_owned(),
"let mut is_from_start = false;".to_owned(),
"let result = n == 0_i32;".to_owned(),
"".to_owned(),
"is_from_bb2 = false;".to_owned(),
"let mut is_from_bb2 = false;".to_owned(),
"let var3 = n == 0_i128;".to_owned(),
"is_from_start = true;".to_owned(),
"let mut ntr3 = 0_i32;".to_owned(),
"let mut btr2 = 0_i32;".to_owned(),
"let mut atr1 = 0_i32;".to_owned(),
"let mut _4 = 0_i32;".to_owned(),
"let mut _5 = 0_i32;".to_owned(),
"is_from_bb2 = false;".to_owned(),
"let mut n_tr3 = 0_i128;".to_owned(),
"let mut b_tr2 = 0_i128;".to_owned(),
"let mut a_tr1 = 0_i128;".to_owned(),
"let mut _4 = 0_i128;".to_owned(),
"let mut _5 = 0_i128;".to_owned(),
"let mut var9 = false;".to_owned(),
"if !result {".to_owned(),
"if !var3 {".to_owned(),
"loop {".to_owned(),
"ntr3 = if is_from_bb2 { _5 } else if is_from_start { n } else { panic!(\"There is a bug in the \
compiler please report it\")};"
"let n_tr3 = if is_from_bb2 { _5 } else if is_from_start { n } else { panic!(\"There is a bug in the \
compiler at var n_tr3 please report it\")};"
.to_owned(),
"btr2 = if is_from_bb2 { _4 } else if is_from_start { b } else { panic!(\"There is a bug in the \
compiler please report it\")};"
"let b_tr2_temp = if is_from_bb2 { _4 } else if is_from_start { b } else { panic!(\"There is a bug in \
the compiler at var b_tr2_temp please report it\")};"
.to_owned(),
"atr1 = if is_from_bb2 { btr2 } else if is_from_start { a } else { panic!(\"There is a bug in the \
compiler please report it\")};"
"let a_tr1 = if is_from_bb2 { b_tr2 } else if is_from_start { a } else { panic!(\"There is a bug in \
the compiler at var a_tr1 please report it\")};"
.to_owned(),
"_4 = btr2 + atr1;".to_owned(),
"_5 = ntr3 + -1_i32;".to_owned(),
"var9 = _5 == 0_i32;".to_owned(),
"if var9\n{break;}".to_owned(),
"is_from_bb2 = true;".to_owned(),
"_4 = b_tr2_temp + a_tr1;".to_owned(),
"_5 = n_tr3 + -1_i128;".to_owned(),
"var9 = _5 == 0_i128;".to_owned(),
"b_tr2 = b_tr2_temp;".to_owned(),
"is_from_start = false;".to_owned(),
"is_from_bb2 = true;".to_owned(),
"if var9".to_owned(),
"{break;}".to_owned(),
"};".to_owned(),
"let mut atrlcssa = 0_i32;".to_owned(),
"let mut a_tr_lcssa = 0_i128;".to_owned(),
"}".to_owned(),
"let atrlcssa = if is_from_start { a } else if is_from_bb2 { btr2 } else { panic!(\"There is a bug in \
the compiler please report it\")};"
"let a_tr_lcssa = if is_from_start { a } else if is_from_bb2 { b_tr2 } else { panic!(\"There is a bug \
in the compiler at var a_tr_lcssa please report it\")};"
.to_owned(),
"return btr2;".to_owned()
"return a_tr_lcssa;".to_owned(),
"".to_owned(),
]),
);
}
Expand Down

0 comments on commit 9949738

Please sign in to comment.