OpenJDK / graal / graal-jvmci-8
changeset 8232:ab374f69e4e8
JTTTest gets the expeted result only once
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 13 Mar 2013 17:06:30 +0100 |
parents | 9560289a2b3e |
children | 9484e7602276 |
files | graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java |
diffstat | 2 files changed, 25 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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); } }
--- 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; } }