protected void checkSucceeds( ParseTreeNode inputNode, ParseTreeNode expectedResultNode, MessageLevel highest) { mq.getMessages().clear(); ParseTreeNode actualResultNode = getRewriter().expand(inputNode); for (Message m : mq.getMessages()) { if (m.getMessageLevel().compareTo(highest) >= 0) { fail(m.toString()); } } if (expectedResultNode != null) { // Test that the source code-like renderings are identical. This // will catch any obvious differences between expected and // actual. assertEquals(render(expectedResultNode), render(actualResultNode)); // Then, for good measure, test that the S-expression-like // formatted representations are also identical. This will catch // any differences in tree topology that somehow do not appear // in the source code representation (usually due to programming // errors). assertEquals(TestUtil.format(expectedResultNode), TestUtil.format(actualResultNode)); } }