File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Any copyright is dedicated to the Public Domain.
2+ // http://creativecommons.org/publicdomain/zero/1.0/
3+
4+ // this testcase demonstrates how branching on a SIF expression behaves semantically
5+
6+ requires lowEvent
7+ method InLowEventContexts(t: Int)
8+ {
9+ if (low(t)) {
10+ assert low(t)
11+ } else {
12+ // this case is reachable as `t` might be the same in both executions or it might not
13+ //:: ExpectedOutput(assert.failed:assertion.false)
14+ assert false
15+ }
16+ }
17+
18+ requires lowEvent
19+ method InLowEventContexts2(t: Int)
20+ {
21+ // since `low(t)` evaluates to the same value in both executions, both executions are guaranteed
22+ // to enter the same branch
23+ if (low(t)) {
24+ assert lowEvent
25+ } else {
26+ assert lowEvent
27+ }
28+ }
29+
30+ requires !lowEvent
31+ method InNonLowEventContexts(t: Int)
32+ {
33+ if (low(t)) {
34+ assert low(t)
35+ } else {
36+ // this is a dead branch as `low(t)` trivially evaluates to `true` as there is no second execution
37+ assert false
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ // Any copyright is dedicated to the Public Domain.
2+ // http://creativecommons.org/publicdomain/zero/1.0/
3+
4+ // this testcase demonstrates how looping on a SIF expression behaves semantically
5+
6+ requires lowEvent
7+ method InLowEventContexts(t: Int)
8+ {
9+ while (low(t))
10+ {
11+ assert low(t)
12+ }
13+
14+ // this case is reachable as `t` might be the same in both executions or it might not
15+ //:: ExpectedOutput(assert.failed:assertion.false)
16+ assert false
17+ }
18+
19+ requires lowEvent
20+ method InLowEventContexts2(t: Int)
21+ {
22+ // since `low(t)` evaluates to the same value in both executions, both executions are guaranteed
23+ // to execute the loop bodies in sync
24+
25+ while (low(t))
26+ invariant lowEvent
27+ {
28+ assert lowEvent
29+ }
30+
31+ assert lowEvent
32+ }
33+
34+ requires !lowEvent
35+ method InNonLowEventContexts(t: Int)
36+ {
37+ while (low(t))
38+ {
39+ assert low(t)
40+ }
41+
42+ // the loop will never terminate as `low(t)` trivially evaluates to `true` as there is no second execution
43+ assert false
44+ }
You can’t perform that action at this time.
0 commit comments