Skip to content

Commit 70fc83f

Browse files
Aren BabikianArenBabikian
Aren Babikian
authored andcommitted
Finalizes quantifiers regression tests for ensures.
1 parent aaf460a commit 70fc83f

File tree

8 files changed

+115
-0
lines changed

8 files changed

+115
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
int f1(int *arr)
2+
__CPROVER_ensures(
3+
__CPROVER_exists {int i; (0 <= i && i < 10) && arr[i] == i}
4+
)
5+
{
6+
for(int i = 0; i < 10; i++)
7+
{
8+
arr[i] = i;
9+
}
10+
11+
return 0;
12+
}
13+
14+
int main()
15+
{
16+
int arr[10];
17+
f1(arr);
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
main.c
3+
--enforce-all-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | assumed | asserted
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
int f1(int *arr)
2+
__CPROVER_ensures(
3+
__CPROVER_exists {int i; (0 <= i && i < 10) && arr[i] != 0}
4+
)
5+
{
6+
for(int i = 0; i < 10; i++)
7+
{
8+
arr[i] = 0;
9+
}
10+
11+
return 0;
12+
}
13+
14+
int main()
15+
{
16+
int arr[10];
17+
f1(arr);
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--enforce-all-contracts
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
--
9+
Verification:
10+
This test asserts the postconditions of f1.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
int f1(int *arr)
2+
__CPROVER_ensures(
3+
__CPROVER_forall {int i; (0 <= i && i < 10) ==> arr[i] == 0}
4+
)
5+
{
6+
for(int i = 0; i < 10; i++)
7+
{
8+
arr[i] = 0;
9+
}
10+
11+
return 0;
12+
}
13+
14+
int main()
15+
{
16+
int arr[10];
17+
f1(arr);
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--replace-all-calls-with-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Verification:
10+
This test asserts the preconditions of f1.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
int f1(int *arr)
2+
__CPROVER_ensures(
3+
__CPROVER_forall {int i; (0 <= i && i < 10) ==> arr[i] == i}
4+
)
5+
{
6+
for(int i = 0; i < 10; i++)
7+
{
8+
if (i == 0) arr[i] = -1;
9+
else arr[i] = i;
10+
}
11+
12+
return 0;
13+
}
14+
15+
int main()
16+
{
17+
int arr[10];
18+
f1(arr);
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--enforce-all-contracts
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
--
9+
Verification:
10+
This test asserts the postconditions of f1.

0 commit comments

Comments
 (0)