-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for missing lambda closure environment (#2120)
- Loading branch information
1 parent
9fb6b09
commit 22256ef
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
test_programs/execution_success/missing_closure_env/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "missing_closure_env" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.23.0" | ||
|
||
[dependencies] |
15 changes: 15 additions & 0 deletions
15
test_programs/execution_success/missing_closure_env/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
fn main() { | ||
let x1 = &mut 42; | ||
let set_x1 = |y| { *x1 = y; }; | ||
|
||
assert(*x1 == 42); | ||
set_x1(44); | ||
assert(*x1 == 44); | ||
set_x1(*x1); | ||
assert(*x1 == 44); | ||
} | ||
|
||
#[test] | ||
fn test_main() { | ||
main(); | ||
} |