* .hgignore: Added tests/regression/junit/*.class.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Sat, 26 Apr 2008 14:41:27 +0000 (16:41 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Sat, 26 Apr 2008 14:41:27 +0000 (16:41 +0200)
* configure.ac (AC_CONFIG_FILES): Added
tests/regression/junit/Makefile.

* tests/regression/Makefile.am (SUBDIRS): Added junit.
(SOURCE_FILES): Removed clinitexceptions.java.
(EXTRA_DIST): Removed clinitexceptions.2output.
(OUTPUT_JAVA_TESTS): Removed clinitexception.

* tests/regression/junit/All.java: Likewise.
* tests/regression/junit/Makefile.am: Likewise
* tests/regression/junit/TestExceptionInStaticClassInitializer.java:
Likewise.

* tests/regression/clinitexception.2output: Removed.
* tests/regression/clinitexception.java: Likewise.

.hgignore
configure.ac
tests/regression/Makefile.am
tests/regression/clinitexception.2output [deleted file]
tests/regression/clinitexception.java [deleted file]
tests/regression/junit/All.java [new file with mode: 0644]
tests/regression/junit/Makefile.am [new file with mode: 0644]
tests/regression/junit/TestExceptionInStaticClassInitializer.java [new file with mode: 0644]

index 751e5c858c8e804c4327135d019a2d30bb09425f..4f4ca6e213bf6b7d315deac3a6c56c207591b9cb 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -46,6 +46,7 @@ tests/regression/assertion/packagetest/*.class
 tests/regression/bugzilla/*.class
 tests/regression/codepatching/*.class
 tests/regression/jasmin/*.class
+tests/regression/junit/*.class
 tests/regression/native/*.class
 tests/regression/native/*.h
 tests/regression/native/*.so
index 670e163d6a76cb28b87ad0d34c1f97243ff28358..ffc382ec84dd059d0b8556917f8fae019fe7ef45 100644 (file)
@@ -922,6 +922,7 @@ AC_CONFIG_FILES([Makefile]
                [tests/regression/codepatching/Makefile]
                [tests/regression/assertion/Makefile]
                [tests/regression/jasmin/Makefile]
+               [tests/regression/junit/Makefile]
                [tests/regression/native/Makefile]
                [tests/regression/resolving/Makefile]
                [tests/regression/resolving/classes1/Makefile]
index c62ecbd2caf597081401058e2d750ea17237796c..6bd7697ebdd35f09eaf5b69956ada4eca3931cd0 100644 (file)
@@ -26,6 +26,7 @@ SUBDIRS = \
        bugzilla \
        codepatching \
        jasmin \
+       junit \
        native \
        resolving
 
@@ -39,7 +40,6 @@ SOURCE_FILES = \
        $(srcdir)/fptest.java \
        $(srcdir)/fp.java \
        $(srcdir)/extest.java \
-       $(srcdir)/clinitexception.java \
        $(srcdir)/LoadDisplacementOverflow.java \
        $(srcdir)/FieldDisplacementOverflow.java \
        $(srcdir)/StackDisplacementOverflow.java \
@@ -54,7 +54,6 @@ EXTRA_DIST = \
        fptest.output \
        fp.output\
        extest.2output \
-       clinitexception.2output \
        LoadDisplacementOverflow.output \
        FieldDisplacementOverflow.output \
        StackDisplacementOverflow.output \
@@ -74,7 +73,6 @@ OUTPUT_JAVA_TESTS = \
        fp \
        extest \
        \
-       clinitexception \
        LoadDisplacementOverflow \
        FieldDisplacementOverflow \
        StackDisplacementOverflow \
@@ -84,7 +82,7 @@ OUTPUT_JAVA_TESTS = \
 check: build $(SIMPLE_JAVA_TESTS) $(OUTPUT_JAVA_TESTS)
 
 build:
-       @$(JAVACCMD) -d . $(SOURCE_FILES)
+       $(JAVACCMD) -d . $(SOURCE_FILES)
 
 $(SIMPLE_JAVA_TESTS):
        @echo "$@: "
diff --git a/tests/regression/clinitexception.2output b/tests/regression/clinitexception.2output
deleted file mode 100644 (file)
index 9f6a360..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Exception in thread "main" java.lang.ExceptionInInitializerError
-   <<No stacktrace available>>
-Caused by: java.lang.RuntimeException
-   at clinitexception.<clinit>(clinitexception.java:4)
diff --git a/tests/regression/clinitexception.java b/tests/regression/clinitexception.java
deleted file mode 100644 (file)
index aa75bc4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-public class clinitexception {
-    static {
-        if (true)
-            throw new RuntimeException();
-    }
-
-    public static void main(String[] argv) {
-    }
-}
diff --git a/tests/regression/junit/All.java b/tests/regression/junit/All.java
new file mode 100644 (file)
index 0000000..0135353
--- /dev/null
@@ -0,0 +1,51 @@
+/* tests/regression/junit/All.java - runs all CACAO regression unit tests
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+import junit.framework.*;
+import junit.textui.*;
+
+public class All extends TestCase {
+    /**
+     * Runs all CACAO regression unit tests using
+     * junit.textui.TestRunner
+     */
+    public static void main(String[] args) {
+        Test s = suite();
+        TestRunner.run(s);
+    }
+
+    /**
+     * Collects all CACAO regression unit tests as one suite.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite("CACAO Regression Unit Tests");
+
+        // Add your test here.
+
+        suite.addTest(new TestSuite(TestExceptionInStaticClassInitializer.class));
+
+        return suite;
+    }
+}
diff --git a/tests/regression/junit/Makefile.am b/tests/regression/junit/Makefile.am
new file mode 100644 (file)
index 0000000..31b78a2
--- /dev/null
@@ -0,0 +1,47 @@
+## tests/regression/junit/Makefile.am
+##
+## Copyright (C) 2008
+## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+##
+## This file is part of CACAO.
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License as
+## published by the Free Software Foundation; either version 2, or (at
+## your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+
+JAVA     = LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(top_builddir)/src/cacao/cacao
+JAVACMD  = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH)
+JAVACCMD = $(JAVAC) -bootclasspath $(BOOTCLASSPATH)
+
+EXTRA_DIST = \
+       *.java
+
+CLEANFILES = \
+       *.class
+
+build:
+       $(JAVACCMD) -classpath /usr/share/java/junit4.jar -d . $(srcdir)/*.java
+
+check: build
+       $(JAVACMD) -classpath /usr/share/java/junit4.jar:. org.junit.runner.JUnitCore All
+
+
+## Local variables:
+## mode: Makefile
+## indent-tabs-mode: t
+## c-basic-offset: 4
+## tab-width: 8
+## compile-command: "automake --add-missing"
+## End:
diff --git a/tests/regression/junit/TestExceptionInStaticClassInitializer.java b/tests/regression/junit/TestExceptionInStaticClassInitializer.java
new file mode 100644 (file)
index 0000000..e6cc93e
--- /dev/null
@@ -0,0 +1,66 @@
+/* tests/regression/bugzilla/TestExceptionInStaticClassInitializer.java
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+import junit.framework.*;
+import junit.textui.*;
+
+public class TestExceptionInStaticClassInitializer extends TestCase {
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestExceptionInStaticClassInitializer.class);
+    }
+
+    public void test() {
+        try {
+            TestExceptionInStaticClassInitializer_x.i = 1;
+            fail("Should throw ExceptionInInitializerError");
+        }
+        catch (ExceptionInInitializerError success) {
+            Throwable cause = success.getCause();
+
+            assertTrue("Cause should be RuntimeException but is " + cause.getClass(), cause.getClass() == RuntimeException.class);
+
+            StackTraceElement[] ste = cause.getStackTrace();
+
+            assertTrue("Linenumber should be " + LINE + " but is " + ste[0].getLineNumber(), ste[0].getLineNumber() == LINE);
+        }
+    }
+
+    // This linenumber must be the one from...
+    final static int LINE = 64;
+}
+
+class TestExceptionInStaticClassInitializer_x {
+    static int i;
+
+    static {
+        if (true)
+            // ...the following line.
+            throw new RuntimeException();
+    }
+}