>From d15485f6e586e0f5cc7823b976ae4bd83f99b527 Mon Sep 17 00:00:00 2001
From: Vegard Nossum <vegard.nos...@gmail.com>
Date: Sat, 27 Jun 2009 12:19:29 +0200
Subject: [PATCH] regression: add BranchTest to suite

This tests whether the code flow resulting from the use of || and &&
seems plausible.

Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
---
 Makefile                       |    1 +
 regression/jvm/BranchTest.java |   64 ++++++++++++++++++++++++++++++++++++++++
 regression/run-suite.sh        |    1 +
 3 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100644 regression/jvm/BranchTest.java

diff --git a/Makefile b/Makefile
index c2da16c..e1fbf49 100644
--- a/Makefile
+++ b/Makefile
@@ -211,6 +211,7 @@ REGRESSION_TEST_SUITE_CLASSES = \
        regression/jato/internal/VM.class \
        regression/jvm/TestCase.class \
        regression/jvm/ArrayTest.class \
+       regression/jvm/BranchTest.class \
        regression/jvm/ObjectArrayTest.class \
        regression/jvm/ExitStatusIsOneTest.class \
        regression/jvm/ExitStatusIsZeroTest.class \
diff --git a/regression/jvm/BranchTest.java b/regression/jvm/BranchTest.java
new file mode 100644
index 0000000..6c58919
--- /dev/null
+++ b/regression/jvm/BranchTest.java
@@ -0,0 +1,64 @@
+package jvm;
+
+class BranchTest extends TestCase {
+    static boolean t;
+    static boolean f;
+
+    private static void ok() {
+    }
+
+    private static void testAndBranch() {
+        if (t && t)
+            ok();
+        else
+            fail();
+
+        if (t && f)
+            fail();
+        else
+            ok();
+
+        if (f && t)
+            fail();
+        else
+            ok();
+
+        if (f && f)
+            fail();
+        else
+            ok();
+    }
+
+    private static void testOrBranch() {
+        if (t || t)
+            ok();
+        else
+            fail();
+
+        if (t || f)
+            ok();
+        else
+            fail();
+
+        if (f || t)
+            ok();
+        else
+            fail();
+
+        if (f || f)
+            fail();
+        else
+            ok();
+    }
+
+    public static void main(String[] args) {
+        /* Try to work around the optimizing compiler */
+        t = true;
+        f = false;
+
+        testAndBranch();
+        testOrBranch();
+
+        exit();
+    }
+}
diff --git a/regression/run-suite.sh b/regression/run-suite.sh
index f5b7625..ee06b9a 100755
--- a/regression/run-suite.sh
+++ b/regression/run-suite.sh
@@ -52,6 +52,7 @@ done
 
 if [ -z "$CLASS_LIST" ]; then
     run_java jvm.ArrayTest 0
+    run_java jvm.BranchTest 0
     run_java jvm.ObjectArrayTest 0
     run_java jvm.ExitStatusIsZeroTest 0
     run_java jvm.ExitStatusIsOneTest 1
-- 
1.6.0.4


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to