Skip to content
Snippets Groups Projects
Commit 61b11484 authored by benjamin.franksen's avatar benjamin.franksen
Browse files

test: added void.st and indirectCall.st, expanded sizeof.st

parent 9a3c4b7a
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ REGRESSION_TESTS_WITHOUT_DB += assign
REGRESSION_TESTS_WITHOUT_DB += change
REGRESSION_TESTS_WITHOUT_DB += commaOperator
REGRESSION_TESTS_WITHOUT_DB += foreignTypes
REGRESSION_TESTS_WITHOUT_DB += indirectCall
REGRESSION_TESTS_WITHOUT_DB += local
REGRESSION_TESTS_WITHOUT_DB += opttVar
REGRESSION_TESTS_WITHOUT_DB += pvSync
......@@ -53,6 +54,7 @@ REGRESSION_TESTS_WITHOUT_DB += safeMonitor
REGRESSION_TESTS_WITHOUT_DB += sizeof
REGRESSION_TESTS_WITHOUT_DB += userfunc
REGRESSION_TESTS_WITHOUT_DB += userfuncEf
REGRESSION_TESTS_WITHOUT_DB += void
REGRESSION_TESTS_REMOTE_ONLY += pvGetSync
REGRESSION_TESTS_REMOTE_ONLY += pvGetComplete
......
/*************************************************************************\
Copyright (c) 2013 Helmholtz-Zentrum Berlin f. Materialien
und Energie GmbH, Germany (HZB)
This file is distributed subject to a Software License Agreement found
in the file LICENSE that is included with this distribution.
\*************************************************************************/
program indirectCallTest
option +r;
%%#include "../testSupport.h"
%{
typedef int fun_t(int);
struct s {
fun_t *f;
};
int id(int x) {
return x;
}
int inc(int x) {
return x + 1;
}
}%
struct s gx;
struct s *p;
entry {
seq_test_init(3*8);
}
ss test {
struct s ssx;
state test {
struct s stx;
when () {
p = &gx;
gx.f = id;
testOk1(42==p->f(42));
testOk1(42==(*p->f)(42));
testOk1(42==gx.f(42));
testOk1(42==(*gx.f)(42));
gx.f = inc;
testOk1(1==p->f(0));
testOk1(1==(*p->f)(0));
testOk1(1==gx.f(0));
testOk1(1==(*gx.f)(0));
p = &ssx;
ssx.f = id;
testOk1(42==p->f(42));
testOk1(42==(*p->f)(42));
testOk1(42==ssx.f(42));
testOk1(42==(*ssx.f)(42));
ssx.f = inc;
testOk1(1==p->f(0));
testOk1(1==(*p->f)(0));
testOk1(1==ssx.f(0));
testOk1(1==(*ssx.f)(0));
p = &stx;
stx.f = id;
testOk1(42==p->f(42));
testOk1(42==(*p->f)(42));
testOk1(42==stx.f(42));
testOk1(42==(*stx.f)(42));
stx.f = inc;
testOk1(1==p->f(0));
testOk1(1==(*p->f)(0));
testOk1(1==stx.f(0));
testOk1(1==(*stx.f)(0));
} exit
}
}
exit {
seq_test_done();
}
......@@ -9,7 +9,7 @@ program sizeofTest
%%#include "../testSupport.h"
entry {
seq_test_init(2);
seq_test_init(9);
}
ss test {
......@@ -19,6 +19,13 @@ ss test {
char *p = &c;
testOk1(sizeof(char)==1);
testOk1(sizeof(*p)==1);
testOk1(sizeof(string) >= 40);
testOk1(sizeof(int8_t) == 1);
testOk1(sizeof(uint8_t) == 1);
testOk1(sizeof(int16_t) == 2);
testOk1(sizeof(uint16_t) == 2);
testOk1(sizeof(int32_t) == 4);
testOk1(sizeof(uint32_t) == 4);
c = *p;
} exit
}
......
/*************************************************************************\
Copyright (c) 2013 Helmholtz-Zentrum Berlin f. Materialien
und Energie GmbH, Germany (HZB)
This file is distributed subject to a Software License Agreement found
in the file LICENSE that is included with this distribution.
\*************************************************************************/
program voidTest
%%#include "../testSupport.h"
int x = 42;
void *p = &x;
entry {
seq_test_init(1);
}
ss test {
state sizes {
when () {
testOk1(*(int *)p == x);
} exit
}
}
exit {
seq_test_done();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment