Skip to content

Commit 1d9d545

Browse files
committed
test: Add example using options
There is currently no way to assert that an option value is None. We can match option values, but we cannot write failing branches. I will add something like is_none and potentially panic! in a future PR. Also order the example programs lexicographically.
1 parent 26c36d0 commit 1d9d545

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

example_progs/option.simf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn checked_div_32(x: u32, y: u32) -> Option<u32> {
2+
match jet_is_zero_32(y) {
3+
true => None,
4+
false => Some(jet_divide_32(x, y)),
5+
}
6+
}
7+
8+
fn main() {
9+
let res: Option<u32> = checked_div_32(10, 3);
10+
jet_verify(jet_eq_32(3, unwrap(res)));
11+
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ mod tests {
6363
#[test]
6464
fn test_progs() {
6565
for (prog_file, wit_file) in [
66-
("add.simf", "empty.wit"),
6766
("add.simf", "empty.wit"),
6867
("array.simf", "empty.wit"),
6968
("cat.simf", "empty.wit"),
@@ -72,9 +71,11 @@ mod tests {
7271
"checksigfromstackverify.wit",
7372
),
7473
("ctv.simf", "empty.wit"),
74+
("function.simf", "empty.wit"),
7575
("list.simf", "empty.wit"),
7676
("match.simf", "empty.wit"),
7777
("nesting.simf", "empty.wit"),
78+
("option.simf", "empty.wit"),
7879
("recursive-covenant.simf", "empty.wit"),
7980
("scopes.simf", "empty.wit"),
8081
("sighash_all.simf", "empty.wit"),
@@ -85,7 +86,6 @@ mod tests {
8586
("sighash_none.simf", "sighash_none.wit"),
8687
("tuple.simf", "empty.wit"),
8788
("unwrap.simf", "empty.wit"),
88-
("function.simf", "empty.wit"),
8989
] {
9090
_test_progs(prog_file, wit_file)
9191
}

0 commit comments

Comments
 (0)