# HG changeset patch # User Gilles Duboscq # Date 1363190790 -3600 # Node ID ab374f69e4e86214cb0b63d67259266184a60fb6 # Parent 9560289a2b3ec1d0af6bc314fb8166760c1ed3b9 JTTTest gets the expeted result only once diff -r 9560289a2b3e -r ab374f69e4e8 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Mar 13 07:35:34 2013 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Mar 13 17:06:30 2013 +0100 @@ -221,7 +221,7 @@ return method.invoke(receiver, args); } - static class Result { + protected static class Result { final Object returnValue; final Throwable exception; @@ -296,16 +296,28 @@ Method method = getMethod(name); Object receiver = Modifier.isStatic(method.getModifiers()) ? null : this; + test(method, receiver, args); + } + + protected void test(Method method, Object receiver, Object... args) { Result expect = executeExpected(method, receiver, args); if (runtime == null) { return; } + test(method, expect, receiver, args); + } + + protected void test(Method method, Result expect, Object receiver, Object... args) { Result actual = executeActual(method, receiver, args); if (expect.exception != null) { Assert.assertTrue("expected " + expect.exception, actual.exception != null); Assert.assertEquals(expect.exception.getClass(), actual.exception.getClass()); } else { + if (actual.exception != null) { + actual.exception.printStackTrace(); + Assert.fail("expected " + expect.returnValue + " but got an exception"); + } assertEquals(expect.returnValue, actual.returnValue); } } diff -r 9560289a2b3e -r ab374f69e4e8 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java Wed Mar 13 07:35:34 2013 +0100 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java Wed Mar 13 17:06:30 2013 +0100 @@ -32,6 +32,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; +import com.oracle.graal.compiler.test.GraalCompilerTest.*; import com.oracle.graal.nodes.*; /** @@ -48,6 +49,10 @@ */ Object[] argsToBind; + public JTTTest() { + Assert.assertNotNull(runtime); + } + @Override protected StructuredGraph parse(Method m) { StructuredGraph graph = super.parse(m); @@ -89,10 +94,14 @@ } protected void runTest(String name, Object... args) { - // System.out.println(getClass().getSimpleName() + "." + name); - super.test(name, args); + Method method = getMethod(name); + Object receiver = Modifier.isStatic(method.getModifiers()) ? null : this; + + Result expect = executeExpected(method, receiver, args); + + test(method, expect, receiver, args); this.argsToBind = args; - super.test(name, args); + test(method, expect, receiver, args); this.argsToBind = null; } }