# HG changeset patch # User Doug Simon # Date 1400010470 -7200 # Node ID 7b09605b29c5cfe219e40d2da6646dcdd8a65741 # Parent 396a483ccaa58157494a1a90f525ee10b0c67f84 renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Tue May 13 21:47:50 2014 +0200 @@ -300,7 +300,7 @@ final ValueNode getResult(String snippet) { processMethod(snippet); - assertEquals(1, graph.getNodes(ReturnNode.class).count()); + assertDeepEquals(1, graph.getNodes(ReturnNode.class).count()); return graph.getNodes(ReturnNode.class).first().result(); } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java Tue May 13 21:47:50 2014 +0200 @@ -132,7 +132,7 @@ result = getResult(getCanonicalizedGraph("integerTestCanonicalization2")); assertTrue(result.isConstant() && result.asConstant().asLong() == 1); StructuredGraph graph = getCanonicalizedGraph("integerTestCanonicalization3"); - assertEquals(1, graph.getNodes(ReturnNode.class).count()); + assertDeepEquals(1, graph.getNodes(ReturnNode.class).count()); assertTrue(graph.getNodes(ReturnNode.class).first().result() instanceof ConditionalNode); } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Tue May 13 21:47:50 2014 +0200 @@ -100,7 +100,7 @@ new ConditionalEliminationPhase(getMetaAccess()).apply(graph, context); canonicalizer.apply(graph, context); - assertEquals(1, graph.getNodes().filter(GuardNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(GuardNode.class).count()); } public static String testInstanceOfCheckCastSnippet(Object e) { @@ -123,7 +123,7 @@ new ConditionalEliminationPhase(getMetaAccess()).apply(graph, context); canonicalizer.apply(graph, context); - assertEquals(0, graph.getNodes().filter(GuardNode.class).count()); + assertDeepEquals(0, graph.getNodes().filter(GuardNode.class).count()); } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSenReduTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSenReduTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSenReduTest.java Tue May 13 21:47:50 2014 +0200 @@ -61,7 +61,7 @@ @Test public void redundantCheckCastTest() { - assertEquals(i7, redundantCheckCastSnippet(i7)); + assertDeepEquals(i7, redundantCheckCastSnippet(i7)); StructuredGraph result = afterFlowSensitiveReduce("redundantCheckCastSnippet"); nodeCountEquals(result, CheckCastNode.class, 0); nodeCountEquals(result, InstanceOfNode.class, 1); @@ -79,7 +79,7 @@ @Test public void redundantInstanceOfTest01() { String snippet = "redundantInstanceOfSnippet01"; - assertEquals(true, redundantInstanceOfSnippet01(i7)); + assertDeepEquals(true, redundantInstanceOfSnippet01(i7)); nodeCountEquals(afterFlowSensitiveReduce(snippet), InstanceOfNode.class, 1); } @@ -100,9 +100,9 @@ @Test public void redundantInstanceOfTest02() { String snippet = "redundantInstanceOfSnippet02"; - assertEquals(i7, redundantInstanceOfSnippet02(i7)); + assertDeepEquals(i7, redundantInstanceOfSnippet02(i7)); int ioAfter = getNodes(afterFlowSensitiveReduce(snippet), InstanceOfNode.class).size(); - assertEquals(ioAfter, 1); + assertDeepEquals(ioAfter, 1); } /* @@ -121,18 +121,18 @@ @Test public void devirtualizationTest() { String snippet = "devirtualizationSnippet"; - assertEquals(i7, devirtualizationSnippet(i7, i7)); + assertDeepEquals(i7, devirtualizationSnippet(i7, i7)); nodeCountEquals(afterFlowSensitiveReduce(snippet), CheckCastNode.class, 0); StructuredGraph graph = afterFlowSensitiveReduce(snippet); - assertEquals(0, graph.getNodes().filter(CheckCastNode.class).count()); + assertDeepEquals(0, graph.getNodes().filter(CheckCastNode.class).count()); List invokeNodes = getNodes(afterFlowSensitiveReduce(snippet), InvokeNode.class); - assertEquals(1, invokeNodes.size()); + assertDeepEquals(1, invokeNodes.size()); MethodCallTargetNode target = (MethodCallTargetNode) invokeNodes.get(0).callTarget(); - assertEquals(MethodCallTargetNode.InvokeKind.Special, target.invokeKind()); - assertEquals("HotSpotMethod", target.targetMethod().toString()); + assertDeepEquals(MethodCallTargetNode.InvokeKind.Special, target.invokeKind()); + assertDeepEquals("HotSpotMethod", target.targetMethod().toString()); } /* @@ -154,7 +154,7 @@ @Test public void t5a() { String snippet = "t5Snippet"; - assertEquals(false, t5Snippet(null, true)); + assertDeepEquals(false, t5Snippet(null, true)); StructuredGraph resultGraph = canonicalize(afterFlowSensitiveReduce(snippet)); nodeCountEquals(resultGraph, ReturnNode.class, 2); @@ -164,8 +164,8 @@ ConstantNode c1 = (ConstantNode) iter.next().result(); ConstantNode c2 = (ConstantNode) iter.next().result(); - assertEquals(c1, c2); - assertEquals(0, c1.getValue().asInt()); + assertDeepEquals(c1, c2); + assertDeepEquals(0, c1.getValue().asInt()); } @Test @@ -215,16 +215,16 @@ StructuredGraph graph = afterFlowSensitiveReduce(snippet); graph = dce(canonicalize(graph)); // TODO how to simplify IfNode(false) - assertEquals(1, getNodes(graph, InstanceOfNode.class).size()); + assertDeepEquals(1, getNodes(graph, InstanceOfNode.class).size()); List returnNodes = getNodes(graph, ReturnNode.class); - assertEquals(2, returnNodes.size()); + assertDeepEquals(2, returnNodes.size()); Iterator iter = returnNodes.iterator(); ConstantNode c1 = (ConstantNode) iter.next().result(); ConstantNode c2 = (ConstantNode) iter.next().result(); - assertEquals(c1, c2); + assertDeepEquals(c1, c2); Assert.assertTrue(c1.getValue().isNull()); } @@ -253,14 +253,14 @@ String snippet = "devirtualizationSnippet02"; StructuredGraph graph = afterFlowSensitiveReduce(snippet); - assertEquals(1, getNodes(graph, InvokeNode.class).size()); + assertDeepEquals(1, getNodes(graph, InvokeNode.class).size()); List invokeNodes = getNodes(graph, InvokeNode.class); - assertEquals(1, invokeNodes.size()); + assertDeepEquals(1, invokeNodes.size()); MethodCallTargetNode target = (MethodCallTargetNode) invokeNodes.get(0).callTarget(); - assertEquals(MethodCallTargetNode.InvokeKind.Special, target.invokeKind()); - assertEquals("HotSpotMethod", target.targetMethod().toString()); + assertDeepEquals(MethodCallTargetNode.InvokeKind.Special, target.invokeKind()); + assertDeepEquals("HotSpotMethod", target.targetMethod().toString()); } /* @@ -312,7 +312,7 @@ dce(graph); List returnNodes = getNodes(graph, ReturnNode.class); - assertEquals(2, returnNodes.size()); + assertDeepEquals(2, returnNodes.size()); Iterator iter = returnNodes.iterator(); ValueNode c1 = GraphUtil.unproxify(iter.next().result()); @@ -339,7 +339,7 @@ String snippet = "deduplicateInstanceOfSnippet"; StructuredGraph graph = afterFlowSensitiveReduce(snippet); List ioNodes = getNodes(graph, InstanceOfNode.class); - assertEquals(1, ioNodes.size()); + assertDeepEquals(1, ioNodes.size()); } @@ -371,7 +371,7 @@ } public void nodeCountEquals(StructuredGraph graph, Class nodeClass, int expected) { - assertEquals(expected, getNodes(graph, nodeClass).size()); + assertDeepEquals(expected, getNodes(graph, nodeClass).size()); } public StructuredGraph afterFlowSensitiveReduce(String snippet) { diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSensitiveReductionTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSensitiveReductionTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSensitiveReductionTest.java Tue May 13 21:47:50 2014 +0200 @@ -209,7 +209,7 @@ new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context); InvokeNode invoke = graph.getNodes().filter(InvokeNode.class).first(); - assertEquals(InvokeKind.Special, ((MethodCallTargetNode) invoke.callTarget()).invokeKind()); + assertDeepEquals(InvokeKind.Special, ((MethodCallTargetNode) invoke.callTarget()).invokeKind()); } public static void testTypeMergingSnippet(Object o, boolean b) { @@ -240,7 +240,7 @@ new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context); new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); - assertEquals(0, graph.getNodes().filter(StoreFieldNode.class).count()); + assertDeepEquals(0, graph.getNodes().filter(StoreFieldNode.class).count()); } public static String testInstanceOfCheckCastSnippet(Object e) { @@ -258,7 +258,7 @@ new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context); new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); - assertEquals(0, graph.getNodes().filter(CheckCastNode.class).count()); + assertDeepEquals(0, graph.getNodes().filter(CheckCastNode.class).count()); } public static int testDuplicateNullChecksSnippet(Object a) { @@ -287,7 +287,7 @@ new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context); canonicalizer.apply(graph, context); - assertEquals(1, graph.getNodes().filter(GuardNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(GuardNode.class).count()); } } diff -r 396a483ccaa5 -r 7b09605b29c5 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 Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Tue May 13 21:47:50 2014 +0200 @@ -528,7 +528,7 @@ actual.exception.printStackTrace(); Assert.fail("expected " + expect.returnValue + " but got an exception"); } - assertEquals(expect.returnValue, actual.returnValue); + assertDeepEquals(expect.returnValue, actual.returnValue); } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Tue May 13 21:47:50 2014 +0200 @@ -66,7 +66,7 @@ for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); if (sp instanceof Call) { - assertEquals(InfopointReason.CALL, sp.reason); + assertDeepEquals(InfopointReason.CALL, sp.reason); } } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Tue May 13 21:47:50 2014 +0200 @@ -65,8 +65,8 @@ StructuredGraph graph = getGraph("testSynchronizedSnippet"); new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); new LockEliminationPhase().apply(graph); - assertEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count()); - assertEquals(1, graph.getNodes().filter(MonitorExitNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(MonitorExitNode.class).count()); } public static void testSynchronizedMethodSnippet(A x) { @@ -83,8 +83,8 @@ StructuredGraph graph = getGraph("testSynchronizedMethodSnippet"); new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); new LockEliminationPhase().apply(graph); - assertEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count()); - assertEquals(1, graph.getNodes().filter(MonitorExitNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(MonitorExitNode.class).count()); } private StructuredGraph getGraph(String snippet) { diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Tue May 13 21:47:50 2014 +0200 @@ -164,7 +164,7 @@ @Test public void testLoop1() { SchedulePhase schedule = getFinalSchedule("testLoop1Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(6, schedule.getCFG().getBlocks().size()); + assertDeepEquals(6, schedule.getCFG().getBlocks().size()); assertReadWithinStartBlock(schedule, true); assertReadWithinAllReturnBlocks(schedule, false); } @@ -189,7 +189,7 @@ @Test public void testLoop2() { SchedulePhase schedule = getFinalSchedule("testLoop2Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(6, schedule.getCFG().getBlocks().size()); + assertDeepEquals(6, schedule.getCFG().getBlocks().size()); assertReadWithinStartBlock(schedule, false); assertReadWithinAllReturnBlocks(schedule, true); } @@ -211,7 +211,7 @@ @Test public void testLoop3() { SchedulePhase schedule = getFinalSchedule("testLoop3Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(6, schedule.getCFG().getBlocks().size()); + assertDeepEquals(6, schedule.getCFG().getBlocks().size()); assertReadWithinStartBlock(schedule, true); assertReadWithinAllReturnBlocks(schedule, false); } @@ -247,7 +247,7 @@ @Test public void testLoop5() { SchedulePhase schedule = getFinalSchedule("testLoop5Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(10, schedule.getCFG().getBlocks().size()); + assertDeepEquals(10, schedule.getCFG().getBlocks().size()); assertReadWithinStartBlock(schedule, false); assertReadWithinAllReturnBlocks(schedule, false); } @@ -264,10 +264,10 @@ public void testArrayCopy() { SchedulePhase schedule = getFinalSchedule("testArrayCopySnippet", TestMode.INLINED_WITHOUT_FRAMESTATES); StructuredGraph graph = schedule.getCFG().getStartBlock().getBeginNode().graph(); - assertEquals(1, graph.getNodes(ReturnNode.class).count()); + assertDeepEquals(1, graph.getNodes(ReturnNode.class).count()); ReturnNode ret = graph.getNodes(ReturnNode.class).first(); assertTrue(ret.result() + " should be a FloatingReadNode", ret.result() instanceof FloatingReadNode); - assertEquals(schedule.getCFG().blockFor(ret), schedule.getCFG().blockFor(ret.result())); + assertDeepEquals(schedule.getCFG().blockFor(ret), schedule.getCFG().blockFor(ret.result())); assertReadWithinAllReturnBlocks(schedule, true); } @@ -285,7 +285,7 @@ @Test public void testIfRead1() { SchedulePhase schedule = getFinalSchedule("testIfRead1Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(3, schedule.getCFG().getBlocks().size()); + assertDeepEquals(3, schedule.getCFG().getBlocks().size()); assertReadWithinStartBlock(schedule, true); assertReadAndWriteInSameBlock(schedule, false); } @@ -306,8 +306,8 @@ @Test public void testIfRead2() { SchedulePhase schedule = getFinalSchedule("testIfRead2Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(3, schedule.getCFG().getBlocks().size()); - assertEquals(1, schedule.getCFG().graph.getNodes().filter(FloatingReadNode.class).count()); + assertDeepEquals(3, schedule.getCFG().getBlocks().size()); + assertDeepEquals(1, schedule.getCFG().graph.getNodes().filter(FloatingReadNode.class).count()); assertReadWithinStartBlock(schedule, false); assertReadWithinAllReturnBlocks(schedule, false); assertReadAndWriteInSameBlock(schedule, false); @@ -328,7 +328,7 @@ @Test public void testIfRead3() { SchedulePhase schedule = getFinalSchedule("testIfRead3Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(4, schedule.getCFG().getBlocks().size()); + assertDeepEquals(4, schedule.getCFG().getBlocks().size()); assertReadWithinStartBlock(schedule, false); assertReadWithinAllReturnBlocks(schedule, true); } @@ -349,7 +349,7 @@ @Test public void testIfRead4() { SchedulePhase schedule = getFinalSchedule("testIfRead4Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(3, schedule.getCFG().getBlocks().size()); + assertDeepEquals(3, schedule.getCFG().getBlocks().size()); assertReadWithinStartBlock(schedule, false); assertReadWithinAllReturnBlocks(schedule, false); assertReadAndWriteInSameBlock(schedule, true); @@ -368,7 +368,7 @@ @Test public void testIfRead5() { SchedulePhase schedule = getFinalSchedule("testIfRead5Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(4, schedule.getCFG().getBlocks().size()); + assertDeepEquals(4, schedule.getCFG().getBlocks().size()); assertReadWithinStartBlock(schedule, false); assertReadWithinAllReturnBlocks(schedule, true); assertReadAndWriteInSameBlock(schedule, false); @@ -397,9 +397,9 @@ StructuredGraph graph = schedule.getCFG().graph; NodeIterable writeNodes = graph.getNodes().filter(WriteNode.class); - assertEquals(1, schedule.getCFG().getBlocks().size()); - assertEquals(8, writeNodes.count()); - assertEquals(1, graph.getNodes().filter(FloatingReadNode.class).count()); + assertDeepEquals(1, schedule.getCFG().getBlocks().size()); + assertDeepEquals(8, writeNodes.count()); + assertDeepEquals(1, graph.getNodes().filter(FloatingReadNode.class).count()); FloatingReadNode read = graph.getNodes().filter(FloatingReadNode.class).first(); @@ -554,7 +554,7 @@ } returnBlocks++; } - assertEquals(withRead == returnBlocks, withinReturnBlock); + assertDeepEquals(withRead == returnBlocks, withinReturnBlock); } private void assertReadWithinStartBlock(SchedulePhase schedule, boolean withinStartBlock) { @@ -564,7 +564,7 @@ readEncountered = true; } } - assertEquals(withinStartBlock, readEncountered); + assertDeepEquals(withinStartBlock, readEncountered); } private static void assertReadAndWriteInSameBlock(SchedulePhase schedule, boolean inSame) { @@ -617,7 +617,7 @@ SchedulePhase schedule = new SchedulePhase(schedulingStrategy, memsched); schedule.apply(graph); - assertEquals(1, graph.getNodes().filter(StartNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(StartNode.class).count()); return schedule; } } catch (Throwable e) { diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MergeCanonicalizerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MergeCanonicalizerTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MergeCanonicalizerTest.java Tue May 13 21:47:50 2014 +0200 @@ -61,6 +61,6 @@ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false))); new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false))); Debug.dump(graph, "Graph"); - assertEquals(returnCount, graph.getNodes(ReturnNode.class).count()); + assertDeepEquals(returnCount, graph.getNodes(ReturnNode.class).count()); } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java Tue May 13 21:47:50 2014 +0200 @@ -65,24 +65,24 @@ List blocks = cfg.getBlocks(); // check number of blocks - assertEquals(4, blocks.size()); + assertDeepEquals(4, blocks.size()); // check block - node assignment - assertEquals(blocks.get(0), cfg.blockFor(graph.start())); - assertEquals(blocks.get(0), cfg.blockFor(ifNode)); - assertEquals(blocks.get(1), cfg.blockFor(trueBegin)); - assertEquals(blocks.get(1), cfg.blockFor(trueEnd)); - assertEquals(blocks.get(2), cfg.blockFor(falseBegin)); - assertEquals(blocks.get(2), cfg.blockFor(falseEnd)); - assertEquals(blocks.get(3), cfg.blockFor(merge)); - assertEquals(blocks.get(3), cfg.blockFor(returnNode)); + assertDeepEquals(blocks.get(0), cfg.blockFor(graph.start())); + assertDeepEquals(blocks.get(0), cfg.blockFor(ifNode)); + assertDeepEquals(blocks.get(1), cfg.blockFor(trueBegin)); + assertDeepEquals(blocks.get(1), cfg.blockFor(trueEnd)); + assertDeepEquals(blocks.get(2), cfg.blockFor(falseBegin)); + assertDeepEquals(blocks.get(2), cfg.blockFor(falseEnd)); + assertDeepEquals(blocks.get(3), cfg.blockFor(merge)); + assertDeepEquals(blocks.get(3), cfg.blockFor(returnNode)); // check postOrder Iterator it = cfg.postOrder().iterator(); for (int i = blocks.size() - 1; i >= 0; i--) { assertTrue(it.hasNext()); Block b = it.next(); - assertEquals(blocks.get(i), b); + assertDeepEquals(blocks.get(i), b); } // check dominators diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EAMergingTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EAMergingTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EAMergingTest.java Tue May 13 21:47:50 2014 +0200 @@ -33,7 +33,7 @@ @Test public void testSimpleMerge() { testEscapeAnalysis("simpleMergeSnippet", null, false); - assertEquals(1, returnNodes.size()); + assertDeepEquals(1, returnNodes.size()); assertTrue(returnNodes.get(0).result() instanceof ValuePhiNode); PhiNode phi = (PhiNode) returnNodes.get(0).result(); assertTrue(phi.valueAt(0) instanceof ParameterNode); diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Tue May 13 21:47:50 2014 +0200 @@ -74,12 +74,12 @@ public void testSimple() { ValueNode result = getReturn("testSimpleSnippet").result(); assertTrue(graph.getNodes().filter(LoadFieldNode.class).isEmpty()); - assertEquals(graph.getParameter(0), result); + assertDeepEquals(graph.getParameter(0), result); } final ReturnNode getReturn(String snippet) { processMethod(snippet); - assertEquals(1, graph.getNodes(ReturnNode.class).count()); + assertDeepEquals(1, graph.getNodes(ReturnNode.class).count()); return graph.getNodes(ReturnNode.class).first(); } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Tue May 13 21:47:50 2014 +0200 @@ -87,7 +87,7 @@ ValueNode result = getReturn("testSimpleSnippet").result(); assertTrue(graph.getNodes().filter(LoadFieldNode.class).isEmpty()); assertTrue(result.isConstant()); - assertEquals(2, result.asConstant().asInt()); + assertDeepEquals(2, result.asConstant().asInt()); } @SuppressWarnings("all") @@ -115,7 +115,7 @@ public void testParam() { ValueNode result = getReturn("testParamSnippet").result(); assertTrue(graph.getNodes().filter(LoadFieldNode.class).isEmpty()); - assertEquals(graph.getParameter(1), result); + assertDeepEquals(graph.getParameter(1), result); } @SuppressWarnings("all") @@ -129,7 +129,7 @@ public void testMaterialized() { ValueNode result = getReturn("testMaterializedSnippet").result(); assertTrue(graph.getNodes().filter(LoadFieldNode.class).isEmpty()); - assertEquals(graph.getParameter(0), result); + assertDeepEquals(graph.getParameter(0), result); } @SuppressWarnings("all") @@ -145,7 +145,7 @@ public void testSimpleLoop() { ValueNode result = getReturn("testSimpleLoopSnippet").result(); assertTrue(graph.getNodes().filter(LoadFieldNode.class).isEmpty()); - assertEquals(graph.getParameter(1), result); + assertDeepEquals(graph.getParameter(1), result); } @SuppressWarnings("all") @@ -162,7 +162,7 @@ @Test public void testBadLoop() { ValueNode result = getReturn("testBadLoopSnippet").result(); - assertEquals(0, graph.getNodes().filter(LoadFieldNode.class).count()); + assertDeepEquals(0, graph.getNodes().filter(LoadFieldNode.class).count()); assertTrue(result instanceof ProxyNode); assertTrue(((ProxyNode) result).value() instanceof ValuePhiNode); } @@ -180,7 +180,7 @@ @Test public void testBadLoop2() { ValueNode result = getReturn("testBadLoop2Snippet").result(); - assertEquals(1, graph.getNodes().filter(LoadFieldNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(LoadFieldNode.class).count()); assertTrue(result instanceof LoadFieldNode); } @@ -199,7 +199,7 @@ processMethod("testPhiSnippet"); assertTrue(graph.getNodes().filter(LoadFieldNode.class).isEmpty()); List returnNodes = graph.getNodes(ReturnNode.class).snapshot(); - assertEquals(2, returnNodes.size()); + assertDeepEquals(2, returnNodes.size()); assertTrue(returnNodes.get(0).predecessor() instanceof StoreFieldNode); assertTrue(returnNodes.get(1).predecessor() instanceof StoreFieldNode); assertTrue(returnNodes.get(0).result().isConstant()); @@ -215,7 +215,7 @@ @Test public void testSimpleStore() { processMethod("testSimpleStoreSnippet"); - assertEquals(1, graph.getNodes().filter(StoreFieldNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(StoreFieldNode.class).count()); } public static int testValueProxySnippet(boolean b, TestObject o) { @@ -233,12 +233,12 @@ @Test public void testValueProxy() { processMethod("testValueProxySnippet"); - assertEquals(2, graph.getNodes().filter(LoadFieldNode.class).count()); + assertDeepEquals(2, graph.getNodes().filter(LoadFieldNode.class).count()); } final ReturnNode getReturn(String snippet) { processMethod(snippet); - assertEquals(1, graph.getNodes(ReturnNode.class).count()); + assertDeepEquals(1, graph.getNodes(ReturnNode.class).count()); return graph.getNodes(ReturnNode.class).first(); } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Tue May 13 21:47:50 2014 +0200 @@ -171,7 +171,7 @@ @Test public void testReference1() { prepareGraph("testReference1Snippet", false); - assertEquals(1, graph.getNodes().filter(NewInstanceNode.class).count()); + assertDeepEquals(1, graph.getNodes().filter(NewInstanceNode.class).count()); } @SafeVarargs diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Tue May 13 21:47:50 2014 +0200 @@ -66,19 +66,19 @@ @Test public void testStaticFinalObjectAOT() { StructuredGraph result = compile("getStaticFinalObject", true); - assertEquals(1, getConstantNodes(result).count()); - assertEquals(getCodeCache().getTarget().wordKind, getConstantNodes(result).first().getKind()); - assertEquals(2, result.getNodes(FloatingReadNode.class).count()); - assertEquals(0, result.getNodes().filter(ReadNode.class).count()); + assertDeepEquals(1, getConstantNodes(result).count()); + assertDeepEquals(getCodeCache().getTarget().wordKind, getConstantNodes(result).first().getKind()); + assertDeepEquals(2, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count()); } @Test public void testStaticFinalObject() { StructuredGraph result = compile("getStaticFinalObject", false); - assertEquals(1, getConstantNodes(result).count()); - assertEquals(Kind.Object, getConstantNodes(result).first().getKind()); - assertEquals(0, result.getNodes(FloatingReadNode.class).count()); - assertEquals(0, result.getNodes().filter(ReadNode.class).count()); + assertDeepEquals(1, getConstantNodes(result).count()); + assertDeepEquals(Kind.Object, getConstantNodes(result).first().getKind()); + assertDeepEquals(0, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count()); } public static Class getClassObject() { @@ -90,12 +90,12 @@ StructuredGraph result = compile("getClassObject", true); NodeIterable filter = getConstantNodes(result); - assertEquals(1, filter.count()); + assertDeepEquals(1, filter.count()); HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) getMetaAccess().lookupJavaType(AheadOfTimeCompilationTest.class); - assertEquals(type.klass(), filter.first().asConstant()); + assertDeepEquals(type.klass(), filter.first().asConstant()); - assertEquals(1, result.getNodes(FloatingReadNode.class).count()); - assertEquals(0, result.getNodes().filter(ReadNode.class).count()); + assertDeepEquals(1, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count()); } @Test @@ -103,13 +103,13 @@ StructuredGraph result = compile("getClassObject", false); NodeIterable filter = getConstantNodes(result); - assertEquals(1, filter.count()); + assertDeepEquals(1, filter.count()); Object mirror = HotSpotObjectConstant.asObject(filter.first().asConstant()); - assertEquals(Class.class, mirror.getClass()); - assertEquals(AheadOfTimeCompilationTest.class, mirror); + assertDeepEquals(Class.class, mirror.getClass()); + assertDeepEquals(AheadOfTimeCompilationTest.class, mirror); - assertEquals(0, result.getNodes(FloatingReadNode.class).count()); - assertEquals(0, result.getNodes().filter(ReadNode.class).count()); + assertDeepEquals(0, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count()); } public static Class getPrimitiveClassObject() { @@ -120,24 +120,24 @@ public void testPrimitiveClassObjectAOT() { StructuredGraph result = compile("getPrimitiveClassObject", true); NodeIterable filter = getConstantNodes(result); - assertEquals(1, filter.count()); - assertEquals(getCodeCache().getTarget().wordKind, filter.first().getKind()); + assertDeepEquals(1, filter.count()); + assertDeepEquals(getCodeCache().getTarget().wordKind, filter.first().getKind()); - assertEquals(2, result.getNodes(FloatingReadNode.class).count()); - assertEquals(0, result.getNodes().filter(ReadNode.class).count()); + assertDeepEquals(2, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count()); } @Test public void testPrimitiveClassObject() { StructuredGraph result = compile("getPrimitiveClassObject", false); NodeIterable filter = getConstantNodes(result); - assertEquals(1, filter.count()); + assertDeepEquals(1, filter.count()); Object mirror = HotSpotObjectConstant.asObject(filter.first().asConstant()); - assertEquals(Class.class, mirror.getClass()); - assertEquals(Integer.TYPE, mirror); + assertDeepEquals(Class.class, mirror.getClass()); + assertDeepEquals(Integer.TYPE, mirror); - assertEquals(0, result.getNodes(FloatingReadNode.class).count()); - assertEquals(0, result.getNodes().filter(ReadNode.class).count()); + assertDeepEquals(0, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count()); } public static String getStringObject() { @@ -159,13 +159,13 @@ StructuredGraph result = compile("getStringObject", compileAOT); NodeIterable filter = getConstantNodes(result); - assertEquals(1, filter.count()); + assertDeepEquals(1, filter.count()); Object mirror = HotSpotObjectConstant.asObject(filter.first().asConstant()); - assertEquals(String.class, mirror.getClass()); - assertEquals("test string", mirror); + assertDeepEquals(String.class, mirror.getClass()); + assertDeepEquals("test string", mirror); - assertEquals(0, result.getNodes(FloatingReadNode.class).count()); - assertEquals(0, result.getNodes().filter(ReadNode.class).count()); + assertDeepEquals(0, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count()); } public static Boolean getBoxedBoolean() { @@ -177,23 +177,23 @@ public void testBoxedBooleanAOT() { StructuredGraph result = compile("getBoxedBoolean", true); - assertEquals(2, result.getNodes(FloatingReadNode.class).count()); - assertEquals(1, result.getNodes(PiNode.class).count()); - assertEquals(1, getConstantNodes(result).count()); + assertDeepEquals(2, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(1, result.getNodes(PiNode.class).count()); + assertDeepEquals(1, getConstantNodes(result).count()); ConstantNode constant = getConstantNodes(result).first(); - assertEquals(Kind.Long, constant.getKind()); - assertEquals(((HotSpotResolvedObjectType) getMetaAccess().lookupJavaType(Boolean.class)).klass(), constant.asConstant()); + assertDeepEquals(Kind.Long, constant.getKind()); + assertDeepEquals(((HotSpotResolvedObjectType) getMetaAccess().lookupJavaType(Boolean.class)).klass(), constant.asConstant()); } @Test public void testBoxedBoolean() { StructuredGraph result = compile("getBoxedBoolean", false); - assertEquals(0, result.getNodes(FloatingReadNode.class).count()); - assertEquals(0, result.getNodes(PiNode.class).count()); - assertEquals(1, getConstantNodes(result).count()); + assertDeepEquals(0, result.getNodes(FloatingReadNode.class).count()); + assertDeepEquals(0, result.getNodes(PiNode.class).count()); + assertDeepEquals(1, getConstantNodes(result).count()); ConstantNode constant = getConstantNodes(result).first(); - assertEquals(Kind.Object, constant.getKind()); - assertEquals(Boolean.TRUE, HotSpotObjectConstant.asObject(constant.asConstant())); + assertDeepEquals(Kind.Object, constant.getKind()); + assertDeepEquals(Boolean.TRUE, HotSpotObjectConstant.asObject(constant.asConstant())); } private StructuredGraph compile(String test, boolean compileAOT) { diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ExplicitExceptionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ExplicitExceptionTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ExplicitExceptionTest.java Tue May 13 21:47:50 2014 +0200 @@ -37,7 +37,7 @@ @Override protected InstalledCode getCode(ResolvedJavaMethod method, StructuredGraph graph) { InstalledCode installedCode = super.getCode(method, graph); - assertEquals(expectedForeignCallCount, graph.getNodes().filter(ForeignCallNode.class).count()); + assertDeepEquals(expectedForeignCallCount, graph.getNodes().filter(ForeignCallNode.class).count()); return installedCode; } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMethodSubstitutionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMethodSubstitutionTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMethodSubstitutionTest.java Tue May 13 21:47:50 2014 +0200 @@ -45,8 +45,8 @@ Object obj = new Object(); - assertEquals("a string".getClass(), ObjectSubstitutions.getClass("a string")); - assertEquals(obj.hashCode(), ObjectSubstitutions.hashCode(obj)); + assertDeepEquals("a string".getClass(), ObjectSubstitutions.getClass("a string")); + assertDeepEquals(obj.hashCode(), ObjectSubstitutions.hashCode(obj)); } @SuppressWarnings("all") @@ -75,14 +75,14 @@ test("getComponentType"); for (Class c : new Class[]{getClass(), Cloneable.class, int[].class, String[][].class}) { - assertEquals(c.getModifiers(), ClassSubstitutions.getModifiers(c)); - assertEquals(c.isInterface(), ClassSubstitutions.isInterface(c)); - assertEquals(c.isArray(), ClassSubstitutions.isArray(c)); - assertEquals(c.isPrimitive(), ClassSubstitutions.isPrimitive(c)); - assertEquals(c.getSuperclass(), ClassSubstitutions.getSuperclass(c)); - assertEquals(c.getComponentType(), ClassSubstitutions.getComponentType(c)); + assertDeepEquals(c.getModifiers(), ClassSubstitutions.getModifiers(c)); + assertDeepEquals(c.isInterface(), ClassSubstitutions.isInterface(c)); + assertDeepEquals(c.isArray(), ClassSubstitutions.isArray(c)); + assertDeepEquals(c.isPrimitive(), ClassSubstitutions.isPrimitive(c)); + assertDeepEquals(c.getSuperclass(), ClassSubstitutions.getSuperclass(c)); + assertDeepEquals(c.getComponentType(), ClassSubstitutions.getComponentType(c)); for (Object o : new Object[]{this, new int[5], new String[2][], new Object()}) { - assertEquals(c.isInstance(o), ClassSubstitutions.isInstance(c, o)); + assertDeepEquals(c.isInstance(o), ClassSubstitutions.isInstance(c, o)); } } } @@ -134,8 +134,8 @@ test("threadInterrupted"); Thread currentThread = Thread.currentThread(); - assertEquals(currentThread, ThreadSubstitutions.currentThread()); - assertEquals(currentThread.isInterrupted(), ThreadSubstitutions.isInterrupted(currentThread, false)); + assertDeepEquals(currentThread, ThreadSubstitutions.currentThread()); + assertDeepEquals(currentThread.isInterrupted(), ThreadSubstitutions.isInterrupted(currentThread, false)); } @SuppressWarnings("all") @@ -161,7 +161,7 @@ SystemSubstitutions.currentTimeMillis(); SystemSubstitutions.nanoTime(); for (Object o : new Object[]{this, new int[5], new String[2][], new Object()}) { - assertEquals(System.identityHashCode(o), SystemSubstitutions.identityHashCode(o)); + assertDeepEquals(System.identityHashCode(o), SystemSubstitutions.identityHashCode(o)); } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMonitorValueTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMonitorValueTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMonitorValueTest.java Tue May 13 21:47:50 2014 +0200 @@ -51,8 +51,8 @@ BytecodeFrame caller = frame.caller(); assertNotNull(caller); assertNull(caller.caller()); - assertEquals(2, frame.numLocks); - assertEquals(2, caller.numLocks); + assertDeepEquals(2, frame.numLocks); + assertDeepEquals(2, caller.numLocks); HotSpotMonitorValue lock1 = (HotSpotMonitorValue) frame.getLockValue(0); HotSpotMonitorValue lock2 = (HotSpotMonitorValue) frame.getLockValue(1); HotSpotMonitorValue lock3 = (HotSpotMonitorValue) caller.getLockValue(0); @@ -67,7 +67,7 @@ } } } - assertEquals(lock3.getOwner(), lock4.getOwner()); + assertDeepEquals(lock3.getOwner(), lock4.getOwner()); assertThat(lock1.getOwner(), not(lock2.getOwner())); return super.addMethod(method, compResult); } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Tue May 13 21:47:50 2014 +0200 @@ -43,7 +43,7 @@ Object result; try { result = nmethod.executeVarargs(null, "b", "c"); - assertEquals(43, result); + assertDeepEquals(43, result); } catch (InvalidInstalledCodeException e) { Assert.fail("Code was invalidated"); } @@ -66,7 +66,7 @@ Object result; try { result = nmethod.executeVarargs(nmethod, null, null); - assertEquals(43, result); + assertDeepEquals(43, result); } catch (InvalidInstalledCodeException e) { Assert.fail("Code was invalidated"); } diff -r 396a483ccaa5 -r 7b09605b29c5 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 Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java Tue May 13 21:47:50 2014 +0200 @@ -80,11 +80,11 @@ Double delta; @Override - protected void assertEquals(Object expected, Object actual) { + protected void assertDeepEquals(Object expected, Object actual) { if (delta != null) { Assert.assertEquals(((Number) expected).doubleValue(), ((Number) actual).doubleValue(), delta); } else { - super.assertEquals(expected, actual); + super.assertDeepEquals(expected, actual); } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ArraysSubstitutionsTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ArraysSubstitutionsTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ArraysSubstitutionsTest.java Tue May 13 21:47:50 2014 +0200 @@ -79,9 +79,9 @@ Object arg1 = args1[i]; Object arg2 = args2[i]; // Verify that the original method and the substitution produce the same value - assertEquals(invokeSafe(testMethod, null, arg1, arg2), invokeSafe(realMethod, null, arg1, arg2)); + assertDeepEquals(invokeSafe(testMethod, null, arg1, arg2), invokeSafe(realMethod, null, arg1, arg2)); // Verify that the generated code and the original produce the same value - assertEquals(executeVarargsSafe(code, arg1, arg2), invokeSafe(realMethod, null, arg1, arg2)); + assertDeepEquals(executeVarargsSafe(code, arg1, arg2), invokeSafe(realMethod, null, arg1, arg2)); } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewArrayTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewArrayTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewArrayTest.java Tue May 13 21:47:50 2014 +0200 @@ -32,10 +32,10 @@ public class NewArrayTest extends GraalCompilerTest { @Override - protected void assertEquals(Object expected, Object actual) { + protected void assertDeepEquals(Object expected, Object actual) { Assert.assertTrue(expected != null); Assert.assertTrue(actual != null); - super.assertEquals(expected.getClass(), actual.getClass()); + super.assertDeepEquals(expected.getClass(), actual.getClass()); if (expected instanceof int[]) { Assert.assertArrayEquals((int[]) expected, (int[]) actual); } else if (expected instanceof byte[]) { diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewInstanceTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewInstanceTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewInstanceTest.java Tue May 13 21:47:50 2014 +0200 @@ -34,10 +34,10 @@ public class NewInstanceTest extends GraalCompilerTest { @Override - protected void assertEquals(Object expected, Object actual) { + protected void assertDeepEquals(Object expected, Object actual) { Assert.assertTrue(expected != null); Assert.assertTrue(actual != null); - super.assertEquals(expected.getClass(), actual.getClass()); + super.assertDeepEquals(expected.getClass(), actual.getClass()); if (expected instanceof Object[]) { Assert.assertTrue(actual instanceof Object[]); @@ -45,12 +45,12 @@ Object[] aArr = (Object[]) actual; Assert.assertTrue(eArr.length == aArr.length); for (int i = 0; i < eArr.length; i++) { - assertEquals(eArr[i], aArr[i]); + assertDeepEquals(eArr[i], aArr[i]); } } else if (expected.getClass() != Object.class) { try { expected.getClass().getDeclaredMethod("equals", Object.class); - super.assertEquals(expected, actual); + super.assertDeepEquals(expected, actual); } catch (Exception e) { } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java Tue May 13 21:47:50 2014 +0200 @@ -44,12 +44,12 @@ test("math"); double value = 34567.891D; - assertEquals(Math.sqrt(value), MathSubstitutionsX86.sqrt(value)); - assertEquals(Math.log(value), MathSubstitutionsX86.log(value)); - assertEquals(Math.log10(value), MathSubstitutionsX86.log10(value)); - assertEquals(Math.sin(value), MathSubstitutionsX86.sin(value)); - assertEquals(Math.cos(value), MathSubstitutionsX86.cos(value)); - assertEquals(Math.tan(value), MathSubstitutionsX86.tan(value)); + assertDeepEquals(Math.sqrt(value), MathSubstitutionsX86.sqrt(value)); + assertDeepEquals(Math.log(value), MathSubstitutionsX86.log(value)); + assertDeepEquals(Math.log10(value), MathSubstitutionsX86.log10(value)); + assertDeepEquals(Math.sin(value), MathSubstitutionsX86.sin(value)); + assertDeepEquals(Math.cos(value), MathSubstitutionsX86.cos(value)); + assertDeepEquals(Math.tan(value), MathSubstitutionsX86.tan(value)); } @SuppressWarnings("all") @@ -98,9 +98,9 @@ assert optional || code != null; for (Object l : args) { // Verify that the original method and the substitution produce the same value - assertEquals(invokeSafe(testMethod, l), invokeSafe(realMethod, l)); + assertDeepEquals(invokeSafe(testMethod, l), invokeSafe(realMethod, l)); // Verify that the generated code and the original produce the same value - assertEquals(executeVarargsSafe(code, l), invokeSafe(realMethod, l)); + assertDeepEquals(executeVarargsSafe(code, l), invokeSafe(realMethod, l)); } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java Tue May 13 21:47:50 2014 +0200 @@ -73,9 +73,9 @@ Object arg1 = args1[i]; Object arg2 = args2[i]; // Verify that the original method and the substitution produce the same value - assertEquals(invokeSafe(testMethod, null, arg1, arg2), invokeSafe(realMethod, arg1, arg2)); + assertDeepEquals(invokeSafe(testMethod, null, arg1, arg2), invokeSafe(realMethod, arg1, arg2)); // Verify that the generated code and the original produce the same value - assertEquals(executeVarargsSafe(code, arg1, arg2), invokeSafe(realMethod, arg1, arg2)); + assertDeepEquals(executeVarargsSafe(code, arg1, arg2), invokeSafe(realMethod, arg1, arg2)); } } diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java Tue May 13 21:47:50 2014 +0200 @@ -69,14 +69,14 @@ { Object expected = invokeSafe(originalMethod, receiver, args1); Object actual = invokeSafe(testMethod, null, args2); - assertEquals(expected, actual); + assertDeepEquals(expected, actual); } // Verify that the generated code and the original produce the same value { Object expected = invokeSafe(originalMethod, receiver, args1); Object actual = executeVarargsSafe(code, args2); - assertEquals(expected, actual); + assertDeepEquals(expected, actual); } } @@ -201,18 +201,18 @@ AtomicInteger a1 = new AtomicInteger(42); AtomicInteger a2 = new AtomicInteger(42); - assertEquals(unsafe.compareAndSwapInt(a1, off(a1, "value"), 42, 53), compareAndSwapInt(unsafe, a2, off(a2, "value"), 42, 53)); - assertEquals(a1.get(), a2.get()); + assertDeepEquals(unsafe.compareAndSwapInt(a1, off(a1, "value"), 42, 53), compareAndSwapInt(unsafe, a2, off(a2, "value"), 42, 53)); + assertDeepEquals(a1.get(), a2.get()); AtomicLong l1 = new AtomicLong(42); AtomicLong l2 = new AtomicLong(42); - assertEquals(unsafe.compareAndSwapLong(l1, off(l1, "value"), 42, 53), compareAndSwapLong(unsafe, l2, off(l2, "value"), 42, 53)); - assertEquals(l1.get(), l2.get()); + assertDeepEquals(unsafe.compareAndSwapLong(l1, off(l1, "value"), 42, 53), compareAndSwapLong(unsafe, l2, off(l2, "value"), 42, 53)); + assertDeepEquals(l1.get(), l2.get()); AtomicReference o1 = new AtomicReference<>("42"); AtomicReference o2 = new AtomicReference<>("42"); - assertEquals(unsafe.compareAndSwapObject(o1, off(o1, "value"), "42", "53"), compareAndSwapObject(unsafe, o2, off(o2, "value"), "42", "53")); - assertEquals(o1.get(), o2.get()); + assertDeepEquals(unsafe.compareAndSwapObject(o1, off(o1, "value"), "42", "53"), compareAndSwapObject(unsafe, o2, off(o2, "value"), "42", "53")); + assertDeepEquals(o1.get(), o2.get()); Foo f1 = new Foo(); f1.test("z", "Boolean", Boolean.TRUE); diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java --- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java Tue May 13 21:47:50 2014 +0200 @@ -76,37 +76,81 @@ * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}. * Does a deep copy equality comparison if {@code expected} is an array. */ - protected void assertEquals(Object expected, Object actual) { - if (expected != null && expected.getClass().isArray()) { - Assert.assertTrue(expected != null); - Assert.assertTrue(actual != null); - Assert.assertEquals(expected.getClass(), actual.getClass()); - if (expected instanceof int[]) { - Assert.assertArrayEquals((int[]) expected, (int[]) actual); - } else if (expected instanceof byte[]) { - Assert.assertArrayEquals((byte[]) expected, (byte[]) actual); - } else if (expected instanceof char[]) { - Assert.assertArrayEquals((char[]) expected, (char[]) actual); - } else if (expected instanceof short[]) { - Assert.assertArrayEquals((short[]) expected, (short[]) actual); - } else if (expected instanceof float[]) { - Assert.assertArrayEquals((float[]) expected, (float[]) actual, 0.0f); - } else if (expected instanceof long[]) { - Assert.assertArrayEquals((long[]) expected, (long[]) actual); - } else if (expected instanceof double[]) { - Assert.assertArrayEquals((double[]) expected, (double[]) actual, 0.0d); - } else if (expected instanceof boolean[]) { - new ExactComparisonCriteria().arrayEquals(null, expected, actual); - } else if (expected instanceof Object[]) { - Assert.assertArrayEquals((Object[]) expected, (Object[]) actual); - } else { - Assert.fail("non-array value encountered: " + expected); + protected void assertDeepEquals(Object expected, Object actual) { + assertDeepEquals(null, expected, actual); + } + + /** + * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}. + * Does a deep copy equality comparison if {@code expected} is an array. + * + * @param message the identifying message for the {@link AssertionError} + */ + protected void assertDeepEquals(String message, Object expected, Object actual) { + assertDeepEquals(message, expected, actual, equalFloatsOrDoublesDelta()); + } + + /** + * Compares two given values for equality, doing a recursive test if both values are arrays of + * the same type. + * + * @param message the identifying message for the {@link AssertionError} + * @param delta the maximum delta between two doubles or floats for which both numbers are still + * considered equal. + */ + protected void assertDeepEquals(String message, Object expected, Object actual, double delta) { + if (expected != null && actual != null) { + Class expectedClass = expected.getClass(); + Class actualClass = actual.getClass(); + if (expectedClass.isArray()) { + Assert.assertTrue(message, expected != null); + Assert.assertTrue(message, actual != null); + Assert.assertEquals(message, expectedClass, actual.getClass()); + if (expected instanceof int[]) { + Assert.assertArrayEquals(message, (int[]) expected, (int[]) actual); + } else if (expected instanceof byte[]) { + Assert.assertArrayEquals(message, (byte[]) expected, (byte[]) actual); + } else if (expected instanceof char[]) { + Assert.assertArrayEquals(message, (char[]) expected, (char[]) actual); + } else if (expected instanceof short[]) { + Assert.assertArrayEquals(message, (short[]) expected, (short[]) actual); + } else if (expected instanceof float[]) { + Assert.assertArrayEquals(message, (float[]) expected, (float[]) actual, (float) delta); + } else if (expected instanceof long[]) { + Assert.assertArrayEquals(message, (long[]) expected, (long[]) actual); + } else if (expected instanceof double[]) { + Assert.assertArrayEquals(message, (double[]) expected, (double[]) actual, delta); + } else if (expected instanceof boolean[]) { + new ExactComparisonCriteria().arrayEquals(message, expected, actual); + } else if (expected instanceof Object[]) { + new ComparisonCriteria() { + @Override + protected void assertElementsEqual(Object e, Object a) { + assertDeepEquals(message, e, a, delta); + } + }.arrayEquals(message, expected, actual); + } else { + Assert.fail((message == null ? "" : message) + "non-array value encountered: " + expected); + } + } else if (expectedClass.equals(double.class) && actualClass.equals(double.class)) { + Assert.assertEquals((double) expected, (double) actual, delta); + } else if (expectedClass.equals(float.class) && actualClass.equals(float.class)) { + Assert.assertEquals((float) expected, (float) actual, delta); } } else { - Assert.assertEquals(expected, actual); + Assert.assertEquals(message, expected, actual); } } + /** + * Gets the value used by {@link #assertDeepEquals(Object, Object)} and + * {@link #assertDeepEquals(String, Object, Object)} for the maximum delta between two doubles + * or floats for which both numbers are still considered equal. + */ + protected double equalFloatsOrDoublesDelta() { + return 0.0D; + } + @SuppressWarnings("serial") public static class MultiCauseAssertionError extends AssertionError { diff -r 396a483ccaa5 -r 7b09605b29c5 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/AssumptionPartialEvaluationTest.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/AssumptionPartialEvaluationTest.java Tue May 13 19:17:59 2014 +0200 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/AssumptionPartialEvaluationTest.java Tue May 13 21:47:50 2014 +0200 @@ -46,7 +46,7 @@ InstalledCode installedCode = assertPartialEvalEquals("constant42", rootNode); Assert.assertTrue(installedCode.isValid()); try { - assertEquals(42, installedCode.executeVarargs(null, null, null)); + assertDeepEquals(42, installedCode.executeVarargs(null, null, null)); } catch (InvalidInstalledCodeException e) { Assert.fail("Code must not have been invalidated."); }