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

added validation test for access to variables of foreign types

parent 4e9c9ddb
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,7 @@ REGRESSION_TESTS_WITHOUT_DB += array
REGRESSION_TESTS_WITHOUT_DB += assign
REGRESSION_TESTS_WITHOUT_DB += change
REGRESSION_TESTS_WITHOUT_DB += commaOperator
REGRESSION_TESTS_WITHOUT_DB += foreignTypes
REGRESSION_TESTS_WITHOUT_DB += local
REGRESSION_TESTS_WITHOUT_DB += opttVar
REGRESSION_TESTS_WITHOUT_DB += pvSync
......
program foreignTypesTest
%%#include "../testSupport.h"
/* option +r; */
%%struct struct_t { int i; struct { double d; } s; };
%%union union_t { int i; struct struct_t *p; };
%%enum enum_t { zero, one, two };
%%typedef short typedef_t;
foreign zero, one, two;
struct struct_t s = {1, {0.1}};
union union_t u = {13};
enum enum_t e = one;
typename typedef_t t = 42;
entry {
seq_test_init(24);
}
ss simple {
state simple {
when () {
struct struct_t *ps = &s;
union union_t *pu = &u;
enum enum_t *pe = &e;
typename typedef_t *pt = &t;
testOk1(s.i == 1);
testOk1(s.s.d == 0.1);
testOk1(u.i == 13);
u.p = ps;
testOk1(u.p == ps);
testOk1(u.p->i == 1);
testOk1(u.p->s.d == 0.1);
u.i = 13; /* restore */
testOk1(e == one);
testOk1(t == 42);
testOk1(ps->i == 1);
testOk1(ps->s.d == 0.1);
testOk1(pu->i == 13);
pu->p = ps;
testOk1(pu->p == ps);
testOk1(pu->p->i == 1);
testOk1(pu->p->s.d == 0.1);
pu->i = 13; /* restore */
testOk1(*pe == one);
testOk1(*pt == 42);
ps->i++;
ps->s.d /= 3.0;
pu->i--;
*pe = two;
*pt %= 10;
testOk1(ps->i == 2);
testOk1(ps->s.d == 0.1/3.0);
testOk1(pu->i == 12);
pu->p = ps;
testOk1(pu->p == ps);
testOk1(pu->p->i == 2);
testOk1(pu->p->s.d == 0.1/3.0);
testOk1(*pe == two);
testOk1(*pt == 2);
} 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