Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: compiler/javatests/com/google/dart/compiler/CompilerTestCase.java

Issue 9959054: More error recovery back to the top level for some cases (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Previous patch had problems when JUnit tests added Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
diff --git a/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java b/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
index 86e6c482246304e7a4aa27541a711d1ba715f16f..b9edb10098593c6326ee54b20be57c19b054cc74 100644
--- a/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
+++ b/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
@@ -251,7 +251,27 @@ public abstract class CompilerTestCase extends TestCase {
return unit;
}
- protected DartUnit parseUnitAsSystemLibrary(final String srcName, String sourceCode,
+ /**
+ * Parse a single compilation unit for the name and source. The parse expects some kind of error,
+ * but isn't picky about the actual contents. This is useful for testing parser recovery where we
+ * don't want to make the test too brittle.
+ */
+ protected DartUnit parseUnitUnspecifiedErrors(String srcName, String sourceCode) {
+ DartSourceTest src = new DartSourceTest(srcName, sourceCode, null);
+ final List<DartCompilationError> errorsEncountered = Lists.newArrayList();
+ DartCompilerListener listener = new DartCompilerListener.Empty() {
+ @Override
+ public void onError(DartCompilationError event) {
+ errorsEncountered.add(event);
+ }
+ };
+ ParserContext context = makeParserContext(src, sourceCode, listener);
+ DartUnit unit = makeParser(context).parseUnit(src);
+ assertTrue("Expected some compilation errors, got none.", errorsEncountered.size() > 0);
+ return unit;
+ }
+
+ protected DartUnit parseUnitAsSystemLibrary(final String srcName, String sourceCode,
Object... errors) {
DartSourceTest src = new DartSourceTest(srcName, sourceCode, null) {
@Override

Powered by Google App Engine
This is Rietveld 408576698