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 a447996 commit b6d264a
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 @@ -532,6 +532,42 @@ mod tests {
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")))
}

#[test]
fn return_from_fn_not_block() {
let ast = ast! {
Expand Down

0 comments on commit b6d264a

Please sign in to comment.