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

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

Issue 9015002: Check for abstract method with body and top-level abstract elements, issue 871 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 66518253982275eacbd6b499a7fcaad016b2addc..a5ff8c4af248580843b684ff4edc06a9982a7847 100644
--- a/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
+++ b/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
@@ -200,7 +200,6 @@ public class NegativeParserTest extends CompilerTestCase {
errEx(ParserErrorCode.EXPECTED_EXTENDS, 3, 11, 2),
errEx(ParserErrorCode.EXPECTED_EXTENDS, 5, 11, 7),
errEx(ParserErrorCode.EXPECTED_EXTENDS, 7, 11, 7));
-
// check structure of AST
DartUnit dartUnit = parserRunner.getDartUnit();
String expected =
@@ -299,12 +298,13 @@ public class NegativeParserTest extends CompilerTestCase {
}
public void testReservedWordClass() {
- parseExpectErrors(Joiner.on("\n").join(
- "class foo {}",
- "main() {",
- " int class = 10;",
- " print(\"class = $class\");",
- "}"),
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "class foo {}",
+ "main() {",
+ " int class = 10;",
+ " print(\"class = $class\");",
+ "}"),
errEx(ParserErrorCode.EXPECTED_TOKEN, 3, 7, 5),
errEx(ParserErrorCode.UNEXPECTED_TOKEN, 4, 19, 5));
}
@@ -338,7 +338,46 @@ public class NegativeParserTest extends CompilerTestCase {
public void tstDeprecatedFactoryInInterface() {
parseExpectErrors(
- "interface foo factory bar {}",
- errEx(ParserErrorCode.DEPRECATED_USE_OF_FACTORY_KEYWORD, 1, 15, 8));
+ "interface foo factory bar {}",
+ errEx(ParserErrorCode.DEPRECATED_USE_OF_FACTORY_KEYWORD, 1, 15, 8));
+ }
+
+ public void test_abstractTopLevel_class() {
+ parseExpectErrors(Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "abstract class A {",
+ "}"));
+ }
+
+ public void test_abstractTopLevel_interface() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "abstract interface A {",
+ "}"),
+ errEx(ParserErrorCode.ABSTRACT_TOP_LEVEL_ELEMENT, 2, 1, 8));
+ }
+
+ public void test_abstractTopLevel_typedef() {
+ parseExpectErrors(
+ "abstract typedef void f();",
+ errEx(ParserErrorCode.ABSTRACT_TOP_LEVEL_ELEMENT, 1, 1, 8));
+ }
+
+ public void test_abstractTopLevel_method() {
+ parseExpectErrors(
+ "abstract void foo() {}",
+ errEx(ParserErrorCode.ABSTRACT_TOP_LEVEL_ELEMENT, 1, 1, 8));
+ }
+
+ public void test_abstractMethodWithBody() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " abstract foo() {",
+ " }",
+ "}"),
+ errEx(ParserErrorCode.ABSTRACT_METHOD_WITH_BODY, 3, 3, 8));
}
}

Powered by Google App Engine
This is Rietveld 408576698