Commit f3eecbb0 authored by Sergio Costas's avatar Sergio Costas

Added some comments to the unitary tests

parent 39b28f29
void main() { void main() {
int v[] = {0}; int v[] = {0};
v[5] = 4; v[5] = 4; // all fine
} }
...@@ -10,5 +10,5 @@ void main() { ...@@ -10,5 +10,5 @@ void main() {
int f; int f;
test.v++; test.v++;
f = test.b; f = test.b; // all fine
} }
...@@ -12,6 +12,6 @@ typedef __crust__ struct crust_ts* crust_t; ...@@ -12,6 +12,6 @@ typedef __crust__ struct crust_ts* crust_t;
void function(crust_t var1, char *var2) { void function(crust_t var1, char *var2) {
free(var1); free(var1); // free() is a valid way of disposing a crust variable
free(var2); free(var2);
} }
typedef __crust__ unsigned char *crust_t; typedef __crust__ unsigned char *crust_t;
void test_function(crust_t __crust_borrow__ param); void test_function(crust_t __crust_borrow__ param);
void test_function(unsigned char *param); // this one must fail void test_function(unsigned char *param); // this one must fail because it is repeated and the parameters doesn't match
#define NULL ((void *)0) #define NULL ((void *)0)
......
...@@ -2,7 +2,7 @@ typedef __crust__ unsigned char *crust_t; ...@@ -2,7 +2,7 @@ typedef __crust__ unsigned char *crust_t;
crust_t main(crust_t param) { crust_t main(crust_t param) {
crust_t param2; crust_t param2;
param2 = ++param; param2 = ++param; // it is illegal to use preincrement, predecrement, postincrement or postdecrement with crust pointers
param2--; param2--;
int a = 5; int a = 5;
......
...@@ -6,7 +6,7 @@ void main(crust_t evento) { ...@@ -6,7 +6,7 @@ void main(crust_t evento) {
function(evento); function(evento);
if (evento != NULL) { if (evento != NULL) { // Valid: now evento is freed, but it still contains a pointer that can be compared with NULL
evento = NULL; evento = NULL;
} }
} }
\ No newline at end of file
void* function_name() { void* function_name() {
return 0; return 0; // fine, it returns the equivalent to NULL
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment