Adds assert method to verify AST node toString() strings are equal.
Change on 2017/05/29 by tball
@@ -23,6 +23,7 @@ import com.google.common.io.Resources;
import com.google.devtools.j2objc.ast.CompilationUnit;
import com.google.devtools.j2objc.ast.MethodDeclaration;
import com.google.devtools.j2objc.ast.Statement;
+import com.google.devtools.j2objc.ast.TreeNode;
import com.google.devtools.j2objc.ast.TreeVisitor;
import com.google.devtools.j2objc.file.RegularInputFile;
import com.google.devtools.j2objc.gen.GenerationUnit;
@@ -310,6 +311,15 @@ public class GenerationTest extends TestCase {
}
}
+ /**
+ * Verify that two AST nodes are equal, by comparing their toString() outputs.
+ */
+ protected void assertEqualASTs(TreeNode first, TreeNode second) {
+ if (!first.toString().equals(second.toString())) {
+ fail("unmatched:\"" + first + "\" vs:\n" + second);
+ }
+ }
+
/**
* Translate a Java method into a JDT DOM MethodDeclaration. Although JDT
* has support for parsing methods, it doesn't resolve them. The statements
