From: Christian Thalinger Date: Sat, 26 Apr 2008 14:41:27 +0000 (+0200) Subject: * .hgignore: Added tests/regression/junit/*.class. X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=cacao.git;a=commitdiff_plain;h=9f4c652dfe91e6cdd1da9031eae0c61dab696b29 * .hgignore: Added tests/regression/junit/*.class. * 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. --- diff --git a/.hgignore b/.hgignore index 751e5c858..4f4ca6e21 100644 --- 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 diff --git a/configure.ac b/configure.ac index 670e163d6..ffc382ec8 100644 --- a/configure.ac +++ b/configure.ac @@ -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] diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am index c62ecbd2c..6bd7697eb 100644 --- a/tests/regression/Makefile.am +++ b/tests/regression/Makefile.am @@ -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 index 9f6a36078..000000000 --- a/tests/regression/clinitexception.2output +++ /dev/null @@ -1,4 +0,0 @@ -Exception in thread "main" java.lang.ExceptionInInitializerError - <> -Caused by: java.lang.RuntimeException - at clinitexception.(clinitexception.java:4) diff --git a/tests/regression/clinitexception.java b/tests/regression/clinitexception.java deleted file mode 100644 index aa75bc498..000000000 --- a/tests/regression/clinitexception.java +++ /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 index 000000000..013535388 --- /dev/null +++ b/tests/regression/junit/All.java @@ -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 index 000000000..31b78a27e --- /dev/null +++ b/tests/regression/junit/Makefile.am @@ -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 index 000000000..e6cc93e07 --- /dev/null +++ b/tests/regression/junit/TestExceptionInStaticClassInitializer.java @@ -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(); + } +}