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

Unified Diff: compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java

Issue 8381018: Expect '{' during class parsing, report error if not. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 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/parser/NegativeParserTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java b/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
index 2af6784d1e870e65b67f17d7beb893e2d2ed4912..24d0cb132ca10952ed6e5e757c93056751308a73 100644
--- a/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
+++ b/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
@@ -5,6 +5,9 @@
package com.google.dart.compiler.parser;
import com.google.dart.compiler.CompilerTestCase;
+import com.google.dart.compiler.DartCompilerErrorCode;
+import com.google.dart.compiler.ast.DartUnit;
+import com.google.dart.compiler.ast.DartVisitor;
/**
* Negative Parser/Syntax tests.
@@ -42,4 +45,34 @@ public class NegativeParserTest extends CompilerTestCase {
public void testMultipleRedirectionConstructors() {
parseExpectErrors("class A { A(x) { } A.foo(this.y) : this(1), this(2); }", 1);
}
+
+ public void testIncompleteClassDeclaration_noLBrace() {
+ String sourceCode =
+ makeCode(
+ "// filler filler filler filler filler",
zundel 2011/10/24 19:32:04 I don't think we need this line.
+ "class Baz",
+ "class Foo<T> implements Bar<T> {",
+ " Foo(T head, Bar<T> tail);",
+ "}");
+ DartUnit unit =
+ parseSourceUnitErrors(
+ sourceCode,
+ DartCompilerErrorCode.EXPECTED_CLASS_DECLARATION_LBRACE.getMessage(), 3, 1);
+ // there was NPE during this operation
zundel 2011/10/24 19:32:04 The NPE is fixed now, let's remove the comment
+ new DartVisitor().accept(unit);
+ // check structure of AST, top level Baz and Foo expected
+ assertEquals(2, unit.getTopLevelNodes().size());
+ assertEquals(
+ makeCode(
+ "// unit Test.dart",
+ "class Baz {",
+ "}",
+ "",
+ "class Foo<T> implements Bar<T> {",
+ "",
+ " Foo(T head, Bar<T> tail) ;",
+ "}",
+ ""),
+ unit.toSource());
+ }
}

Powered by Google App Engine
This is Rietveld 408576698