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

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

Issue 8576007: Expect 'extends' in type parameters declaration and recover, issue 341 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Better recovering, more tests. Created 9 years, 1 month 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 c983d061327f09395f4ed8e20517b574ded83047..3c2cd900ba6edcd21be9322fa86c20cc1e1d269b 100644
--- a/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
+++ b/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
@@ -9,6 +9,7 @@ import com.google.dart.compiler.CommandLineOptions.CompilerOptions;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.LibraryUnit;
import com.google.dart.compiler.parser.DartParser;
+import com.google.dart.compiler.parser.DartParserRunner;
import com.google.dart.compiler.parser.DartScannerParserContext;
import com.google.dart.compiler.parser.ParserContext;
@@ -274,6 +275,22 @@ public abstract class CompilerTestCase extends TestCase {
return new DartScannerParserContext(src, sourceCode, listener);
}
+ /**
+ * @return the {@link DartParserRunner} with parsed source. It can be used to request
+ * {@link DartUnit} or compilation problems.
+ */
+ protected final DartParserRunner parseSource(String code) {
+ return DartParserRunner.parse(getName(), code, Integer.MAX_VALUE, false);
+ }
+
+ /**
+ * Parses given source and checks parsing problems.
+ */
+ protected final void parseExpectErrors(String code, ErrorExpectation... expectedErrors) {
+ List<DartCompilationError> errors = parseSource(code).getErrors();
+ assertErrors(errors, expectedErrors);
+ }
+
protected static class ErrorExpectation {
final ErrorCode errorCode;
final int line;

Powered by Google App Engine
This is Rietveld 408576698