Skip to content

Commit

Permalink
test: add simplification of noir-lang#1088 as a resolve test, enable …
Browse files Browse the repository at this point in the history
…another test
  • Loading branch information
alehander92 committed Aug 2, 2023
1 parent 45a3a52 commit 0233a1a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/noirc_frontend/src/hir/resolution/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,7 @@ mod test {
}
}

#[test]
fn resolve_basic_closure() {
let src = r#"
fn main(x : Field) -> pub Field {
Expand All @@ -1829,6 +1830,29 @@ mod test {
}
}

#[test]
fn resolve_simplified_closure() {
// based on bug https://github.com/noir-lang/noir/issues/1088

let src = r#"fn do_closure(x: Field) -> Field {
let y = x;
let ret_capture = || {
y
};
ret_capture()
}
fn main(x: Field) {
assert(do_closure(x) == 100);
}
"#;
let parsed_captures = get_program_captures(src);
let mut expected_captures = vec![];
expected_captures.push(vec!["y".to_string()]);
assert_eq!(expected_captures, parsed_captures);
}

#[test]
fn resolve_complex_closures() {
let src = r#"
Expand Down

0 comments on commit 0233a1a

Please sign in to comment.