From 61b114848293ab8cbb8f7ce49d3c9cf892c8770c Mon Sep 17 00:00:00 2001
From: "benjamin.franksen" <benjamin.franksen@helmholtz-berlin.de>
Date: Wed, 2 Oct 2013 01:44:44 +0000
Subject: [PATCH] test: added void.st and indirectCall.st, expanded sizeof.st

---
 test/validate/Makefile        |  2 +
 test/validate/indirectCall.st | 82 +++++++++++++++++++++++++++++++++++
 test/validate/sizeof.st       |  9 +++-
 test/validate/void.st         | 28 ++++++++++++
 4 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 test/validate/indirectCall.st
 create mode 100644 test/validate/void.st

diff --git a/test/validate/Makefile b/test/validate/Makefile
index 42c89bf9..e11a8186 100644
--- a/test/validate/Makefile
+++ b/test/validate/Makefile
@@ -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
diff --git a/test/validate/indirectCall.st b/test/validate/indirectCall.st
new file mode 100644
index 00000000..9b26de18
--- /dev/null
+++ b/test/validate/indirectCall.st
@@ -0,0 +1,82 @@
+/*************************************************************************\
+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();
+}
diff --git a/test/validate/sizeof.st b/test/validate/sizeof.st
index 07f0e3cc..94038ade 100644
--- a/test/validate/sizeof.st
+++ b/test/validate/sizeof.st
@@ -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
     }
diff --git a/test/validate/void.st b/test/validate/void.st
new file mode 100644
index 00000000..0f294bbc
--- /dev/null
+++ b/test/validate/void.st
@@ -0,0 +1,28 @@
+/*************************************************************************\
+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();
+}
-- 
GitLab