Skip to content

Commit e41ab2b

Browse files
authored
Test for Carbon issue 355 (#844)
1 parent 924804b commit e41ab2b

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

Diff for: src/test/resources/all/issues/carbon/0259.vpr

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Any copyright is dedicated to the Public Domain.
2-
// http://creativecommons.org/publicdomain/zero/1.0/
3-
1+
// Any copyright is dedicated to the Public Domain.
2+
// http://creativecommons.org/publicdomain/zero/1.0/
3+
44
field f: Int
55

66
predicate P(self: Ref) { acc(self.f) }
@@ -16,8 +16,6 @@ method test(x: Ref, y: Ref)
1616
{
1717
i := i + 1;
1818
}
19-
//:: UnexpectedOutput(assert.failed:assertion.false, /carbon/issue/259/)
2019
assert (unfolding P(x) in x.f) == old(unfolding P(x) in x.f)
21-
//:: UnexpectedOutput(assert.failed:assertion.false, /carbon/issue/259/)
2220
assert (unfolding P(y) in y.f) == old(unfolding P(y) in y.f)
2321
}

Diff for: src/test/resources/all/issues/carbon/0355.vpr

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Any copyright is dedicated to the Public Domain.
2+
// http://creativecommons.org/publicdomain/zero/1.0/
3+
4+
field balance: Int
5+
field amount: Int
6+
7+
predicate is_balance(addr: Ref)
8+
{
9+
acc(addr.balance)
10+
}
11+
12+
method deposit(coin1: Ref)
13+
requires acc(coin1.amount)
14+
ensures acc(coin1.amount)
15+
16+
method failing_assertion(x: Ref, coin: Ref)
17+
requires is_balance(x)
18+
&& acc(coin.amount)
19+
{
20+
// inserting this allows Carbon to verify the assertion
21+
// var b : Int
22+
// b := unfolding is_balance(x) in x.balance
23+
24+
// this should be completely unrelated, however without this line the assertion succeeds
25+
deposit(coin)
26+
27+
// fails in carbon but succeeds in silicon
28+
assert (unfolding is_balance(x) in x.balance) == old(unfolding is_balance(x) in x.balance)
29+
}

0 commit comments

Comments
 (0)