diff --git a/test/validate/Makefile b/test/validate/Makefile index 13fb92ef9dabdca02b94fb5fef3012810c553ffa..2616ce03e91984396efe268137174965fe2e264d 100644 --- a/test/validate/Makefile +++ b/test/validate/Makefile @@ -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 diff --git a/test/validate/foreignTypes.st b/test/validate/foreignTypes.st new file mode 100644 index 0000000000000000000000000000000000000000..807dfc998fc9d233e2f14c37db84082a52116d34 --- /dev/null +++ b/test/validate/foreignTypes.st @@ -0,0 +1,74 @@ +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(); +}