Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CN-Test-Gen] Add failing examples to CI #441

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/cn-test-gen/src/abs.fail.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
int abs(int x)
/*@ requires MINi32() < x;
ensures return == ((x >= 0i32) ? x : (0i32-x));
@*/
{
if (x >= 0) {
return x;
}
else {
return x;
}
}
16 changes: 16 additions & 0 deletions tests/cn-test-gen/src/abs_mem.fail.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
int abs_mem(int* p)
/*@ requires take x = Owned<int>(p);
MINi32() < x;
ensures take x2 = Owned<int>(p);
x == x2;
return == ((x >= 0i32) ? x : (0i32-x));
@*/
{
int x = *p;
if (x >= 0) {
return x;
}
else {
return x;
}
}
79 changes: 79 additions & 0 deletions tests/cn-test-gen/src/list_rev.fail.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
struct int_list {
int head;
struct int_list* tail;
};

/*@
datatype seq {
Seq_Nil {},
Seq_Cons {i32 head, datatype seq tail}
}

predicate (datatype seq) IntList(pointer p) {
if (is_null(p)) {
return Seq_Nil{};
} else {
take H = Owned<struct int_list>(p);
take tl = IntList(H.tail);
return (Seq_Cons { head: H.head, tail: tl });
}
}

function [rec] (datatype seq) append(datatype seq xs, datatype seq ys) {
match xs {
Seq_Nil {} => {
ys
}
Seq_Cons {head : h, tail : zs} => {
Seq_Cons {head: h, tail: append(zs, ys)}
}
}
}

function [rec] (datatype seq) snoc(datatype seq xs, i32 y) {
match xs {
Seq_Nil {} => {
Seq_Cons {head: y, tail: Seq_Nil{}}
}
Seq_Cons {head: x, tail: zs} => {
Seq_Cons{head: x, tail: snoc (zs, y)}
}
}
}

function [rec] (datatype seq) rev(datatype seq xs) {
match xs {
Seq_Nil {} => {
Seq_Nil {}
}
Seq_Cons {head : h, tail : zs} => {
snoc (rev(zs), h)
}
}
}
@*/

struct int_list* IntList_rev_aux(struct int_list* xs, struct int_list* ys)
/*@ requires take L1 = IntList(xs); @*/
/*@ requires take L2 = IntList(ys); @*/
/*@ ensures take R = IntList(return); @*/
/*@ ensures R == append(rev(L2), L1); @*/
{
if (ys == 0) {
return xs;
}
else {
struct int_list* tmp = ys->tail;
ys->head = -1;
ys->tail = xs;
return IntList_rev_aux(ys, tmp);
}
}

struct int_list* IntList_rev(struct int_list* xs)
/*@ requires take L1 = IntList(xs); @*/
/*@ ensures take L1_rev = IntList(return); @*/
/*@ ensures L1_rev == rev(L1); @*/
{
return IntList_rev_aux(0, xs);
}
Loading