Skip to content

Commit

Permalink
fire: Add more complex return tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Oct 19, 2023
1 parent bbeb5c0 commit c82473f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions fire/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,40 @@ mod tests {
let result = fir!(ast).interpret();
assert_eq!(result, Some(Instance::from("boo")))
}

#[test]
fn nested_return() {
let ast = ast! {
func halloween() -> string {
{ { { {
return "boo";
} } } }
}

halloween()
};

let result = fir!(ast).interpret();
assert_eq!(result, Some(Instance::from("boo")))
}

#[test]
fn nested_return_inner_fn() {
let ast = ast! {
func halloween() -> string {
func inner() -> string {
{ { { {
return "boo";
} } } }
};

"different string"
}

halloween()
};

let result = fir!(ast).interpret();
assert_eq!(result, Some(Instance::from("different string")))
}
}

0 comments on commit c82473f

Please sign in to comment.