Skip to content

Commit 741119f

Browse files
committed
add new test
1 parent 2d3f0f4 commit 741119f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/default_output_pattern.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use anodized::contract;
2+
3+
#[contract(
4+
returns: (a, b),
5+
ensures: a <= b,
6+
ensures: (a, b) == pair || (b, a) == pair,
7+
)]
8+
fn sort_pair(pair: (i32, i32)) -> (i32, i32) {
9+
// Deliberately wrong implementation to break the contract.
10+
pair
11+
}
12+
13+
#[test]
14+
#[should_panic(expected = "Postcondition failed: a <= b")]
15+
fn test_sort_fail_postcondition() {
16+
sort_pair((5, 2));
17+
}

0 commit comments

Comments
 (0)