From 96c1c9b0b2bcc59630df7d9226f97d6df4555004 Mon Sep 17 00:00:00 2001
From: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date: Fri, 1 Aug 2014 16:52:25 +0000
Subject: [PATCH] test: added tests for option +p and -p

---
 test/compiler/opt_minus_p.st | 41 ++++++++++++++++++++++++++++++++++++
 test/compiler/opt_plus_p.st  | 41 ++++++++++++++++++++++++++++++++++++
 test/compiler/snc_test.plt   |  2 ++
 3 files changed, 84 insertions(+)
 create mode 100644 test/compiler/opt_minus_p.st
 create mode 100644 test/compiler/opt_plus_p.st

diff --git a/test/compiler/opt_minus_p.st b/test/compiler/opt_minus_p.st
new file mode 100644
index 00000000..539577a5
--- /dev/null
+++ b/test/compiler/opt_minus_p.st
@@ -0,0 +1,41 @@
+/*************************************************************************\
+Copyright (c) 2014      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 opt_p
+
+option -p;
+
+int a[1];
+assign a to {};
+
+ss test {
+    state test {
+        when () {
+            pvAssign(a,"");     /* error: not allowed */
+            pvAssigned(a);      /* error: not allowed */
+            pvConnected(a);     /* error: not allowed */
+            pvCount(a);         /* error: not allowed */
+            pvFlushQ(a);        /* error: not allowed */
+            pvFreeQ(a);         /* error: not allowed */
+            pvGet(a);           /* error: not allowed */
+            pvGetCancel(a);     /* ok: did not exist in 2.1 */
+            pvGetComplete(a);   /* error: not allowed in compatibility mode (option -p) */
+            pvGetQ(a);          /* error: not allowed */
+            pvIndex(a);         /* error: not allowed */
+            pvMessage(a);       /* error: not allowed */
+            pvMonitor(a);       /* error: not allowed in compatibility mode (option -p) */
+            pvName(a);          /* error: not allowed */
+            pvPut(a);           /* error: not allowed */
+            pvPutCancel(a);     /* ok: did not exist in 2.1 */
+            pvPutComplete(a);   /* ok: was already allowed in 2.1 */
+            pvSeverity(a);      /* error: not allowed */
+            pvStatus(a);        /* error: not allowed */
+            pvStopMonitor(a);   /* error: not allowed in compatibility mode (option -p) */
+            pvSync(a);          /* error: not allowed in compatibility mode (option -p) */
+            pvTimeStamp(a);     /* error: not allowed */
+        } exit
+    }
+}
diff --git a/test/compiler/opt_plus_p.st b/test/compiler/opt_plus_p.st
new file mode 100644
index 00000000..1327b178
--- /dev/null
+++ b/test/compiler/opt_plus_p.st
@@ -0,0 +1,41 @@
+/*************************************************************************\
+Copyright (c) 2014      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 opt_p
+
+option +p;
+
+int a[1];
+assign a to {};
+
+ss test {
+    state test {
+        when () {
+            pvAssign(a,"");     /* error: not allowed (even with +p) */
+            pvAssigned(a);      /* error: not allowed (even with +p) */
+            pvConnected(a);     /* error: not allowed (even with +p) */
+            pvCount(a);         /* error: not allowed (even with +p) */
+            pvFlushQ(a);        /* error: not allowed (even with +p) */
+            pvFreeQ(a);         /* error: not allowed (even with +p) */
+            pvGet(a);           /* error: not allowed (even with +p) */
+            pvGetCancel(a);     /* ok: always allowed */
+            pvGetComplete(a);   /* ok: allowed due to +p */
+            pvGetQ(a);          /* error: not allowed (even with +p) */
+            pvIndex(a);         /* error: not allowed (even with +p) */
+            pvMessage(a);       /* error: not allowed (even with +p) */
+            pvMonitor(a);       /* ok: allowed due to +p */
+            pvName(a);          /* error: not allowed (even with +p) */
+            pvPut(a);           /* error: not allowed (even with +p) */
+            pvPutCancel(a);     /* ok: always allowed */
+            pvPutComplete(a);   /* ok: always allowed */
+            pvSeverity(a);      /* error: not allowed (even with +p) */
+            pvStatus(a);        /* error: not allowed (even with +p) */
+            pvStopMonitor(a);   /* ok: allowed due to +p */
+            pvSync(a);          /* ok: allowed due to +p */
+            pvTimeStamp(a);     /* error: not allowed (even with +p) */
+        } exit
+    }
+}
diff --git a/test/compiler/snc_test.plt b/test/compiler/snc_test.plt
index 922ec28a..5e3f74a7 100644
--- a/test/compiler/snc_test.plt
+++ b/test/compiler/snc_test.plt
@@ -18,6 +18,8 @@ my $tests = {
   misplacedExit           => { warnings => 0, errors => 1  },
   namingConflict          => { warnings => 0, errors => 0  },
   nesting_depth           => { warnings => 0, errors => 0  },
+  opt_minus_p             => { warnings => 0, errors => 19 },
+  opt_plus_p              => { warnings => 0, errors => 15 },
   pvNotAssigned           => { warnings => 0, errors => 20 },
   reservedId              => { warnings => 0, errors => 2  },
   state_not_reachable     => { warnings => 3, errors => 0  },
-- 
GitLab