Skip to content

Commit 5564547

Browse files
committed
Fixed formatting issues
1 parent eae9473 commit 5564547

File tree

10 files changed

+87
-88
lines changed
  • regression/contracts

10 files changed

+87
-88
lines changed

regression/contracts/invar_check_break_fail/main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ int main()
77

88
while(r > 0)
99
__CPROVER_loop_invariant(r >= 0)
10-
{
11-
--r;
12-
if (r <= 1)
13-
{
14-
break;
15-
}
16-
else
1710
{
1811
--r;
12+
if(r <= 1)
13+
{
14+
break;
15+
}
16+
else
17+
{
18+
--r;
19+
}
1920
}
20-
}
2121

2222
assert(r == 0);
2323

regression/contracts/invar_check_break_pass/main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ int main()
77

88
while(r > 0)
99
__CPROVER_loop_invariant(r >= 0)
10-
{
11-
--r;
12-
if (r <= 1)
13-
{
14-
break;
15-
}
16-
else
1710
{
1811
--r;
12+
if(r <= 1)
13+
{
14+
break;
15+
}
16+
else
17+
{
18+
--r;
19+
}
1920
}
20-
}
2121

2222
assert(r == 0 || r == 1);
2323

regression/contracts/invar_check_continue/main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ int main()
77

88
while(r > 0)
99
__CPROVER_loop_invariant(r >= 0)
10-
{
11-
--r;
12-
if (r < 5)
13-
{
14-
continue;
15-
}
16-
else
1710
{
1811
--r;
12+
if(r < 5)
13+
{
14+
continue;
15+
}
16+
else
17+
{
18+
--r;
19+
}
1920
}
20-
}
2121

2222
assert(r == 0);
2323

regression/contracts/invar_check_large/main.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ void swap(int *a, int *b)
88
}
99

1010
int main()
11-
{
11+
{
1212
int arr0, arr1, arr2, arr3, arr4;
1313
arr0 = 1;
1414
arr1 = 2;
1515
arr2 = 0;
1616
arr3 = 4;
17-
arr4 = 3;
17+
arr4 = 3;
1818
int *arr[5] = {&arr0, &arr1, &arr2, &arr3, &arr4};
1919
int pivot = 2;
2020

@@ -23,6 +23,8 @@ int main()
2323
int r = 1;
2424
while(h > l)
2525
__CPROVER_loop_invariant(
26+
// Turn off `clang-format` because it breaks the `==>` operator.
27+
/* clang-format off */
2628
h >= l &&
2729
0 <= l && l < 5 &&
2830
0 <= h && h < 5 &&
@@ -42,27 +44,35 @@ int main()
4244
(2 > h ==> arr2 >= pivot) &&
4345
(3 > h ==> arr3 >= pivot) &&
4446
(4 > h ==> arr4 >= pivot)
47+
/* clang-format on */
4548
)
46-
{
47-
if(*(arr[h]) <= pivot && *(arr[l]) >= pivot) {
48-
swap(arr[h], arr[l]);
49-
if (r == h) {
50-
r = l;
51-
h--;
49+
{
50+
if(*(arr[h]) <= pivot && *(arr[l]) >= pivot)
51+
{
52+
swap(arr[h], arr[l]);
53+
if(r == h)
54+
{
55+
r = l;
56+
h--;
57+
}
58+
else if(r == l)
59+
{
60+
r = h;
61+
l++;
62+
}
5263
}
53-
else if(r == l) {
54-
r = h;
64+
else if(*(arr[h]) <= pivot)
65+
{
5566
l++;
5667
}
68+
else
69+
{
70+
h--;
71+
}
5772
}
58-
else if(*(arr[h]) <= pivot) {
59-
l++;
60-
}
61-
else {
62-
h--;
63-
}
64-
}
6573

74+
// Turn off `clang-format` because it breaks the `==>` operator.
75+
/* clang-format off */
6676
assert(0 <= r && r < 5);
6777
assert(*(arr[r]) == pivot);
6878
assert(0 < r ==> arr0 <= pivot);
@@ -75,6 +85,7 @@ int main()
7585
assert(2 > r ==> arr2 >= pivot);
7686
assert(3 > r ==> arr3 >= pivot);
7787
assert(4 > r ==> arr4 >= pivot);
88+
/* clang-format on */
7889

7990
return r;
8091
}

regression/contracts/invar_check_multiple_loops/main.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@ int main()
66
__CPROVER_assume(n > 0 && x == y);
77

88
for(r = 0; r < n; ++r)
9-
__CPROVER_loop_invariant(
10-
0 <= r && r <= n &&
11-
x == y + r
12-
)
13-
{
14-
x++;
15-
}
9+
__CPROVER_loop_invariant(0 <= r && r <= n && x == y + r)
10+
{
11+
x++;
12+
}
1613
while(r > 0)
17-
__CPROVER_loop_invariant(
18-
r >= 0 &&
19-
x == y + n + (n - r)
20-
)
21-
{
22-
y--;
23-
r--;
24-
}
14+
__CPROVER_loop_invariant(r >= 0 && x == y + n + (n - r))
15+
{
16+
y--;
17+
r--;
18+
}
2519

2620
assert(x == y + 2 * n);
2721

regression/contracts/invar_check_nested_loops/main.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,20 @@ int main()
66
__CPROVER_assume(n >= 0);
77

88
for(int i = 0; i < n; ++i)
9-
__CPROVER_loop_invariant(
10-
i <= n &&
11-
s == i
12-
)
13-
{
14-
int a, b;
15-
__CPROVER_assume(b >= 0 && a == b);
16-
17-
while(a > 0)
18-
__CPROVER_loop_invariant(
19-
a >= 0 &&
20-
s == i + (b - a)
21-
)
9+
__CPROVER_loop_invariant(i <= n && s == i)
2210
{
23-
s++;
24-
a--;
25-
}
11+
int a, b;
12+
__CPROVER_assume(b >= 0 && a == b);
2613

27-
s -= (b - 1);
28-
}
14+
while(a > 0)
15+
__CPROVER_loop_invariant(a >= 0 && s == i + (b - a))
16+
{
17+
s++;
18+
a--;
19+
}
20+
21+
s -= (b - 1);
22+
}
2923

3024
assert(s == n);
3125

regression/contracts/invar_check_sufficiency/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ int main()
77

88
while(r > 0)
99
__CPROVER_loop_invariant(r >= 0)
10-
{
11-
--r;
12-
}
10+
{
11+
--r;
12+
}
1313

1414
assert(r == 0);
1515

regression/contracts/invar_loop_constant_fail/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ int main()
77
__CPROVER_assume(r >= 0);
88
while(r > 0)
99
__CPROVER_loop_invariant(r >= 0)
10-
{
11-
s = 1;
12-
r--;
13-
}
10+
{
11+
s = 1;
12+
r--;
13+
}
1414
assert(r == 0);
1515
assert(s == 1);
1616

regression/contracts/invar_loop_constant_no_modify/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ int main()
77
__CPROVER_assume(r >= 0);
88
while(r > 0)
99
__CPROVER_loop_invariant(r >= 0)
10-
{
11-
r--;
12-
}
10+
{
11+
r--;
12+
}
1313
assert(r == 0);
1414
assert(s == 1);
1515

regression/contracts/invar_loop_constant_pass/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ int main()
66
__CPROVER_assume(r >= 0);
77
while(r > 0)
88
__CPROVER_loop_invariant(r >= 0 && s == 1)
9-
{
10-
s = 1;
11-
r--;
12-
}
9+
{
10+
s = 1;
11+
r--;
12+
}
1313
assert(r == 0);
1414
assert(s == 1);
1515

0 commit comments

Comments
 (0)