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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ErrorParserTest.java

Issue 11364134: Merge libv1. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error Created 8 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: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ErrorParserTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ErrorParserTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ErrorParserTest.java
index 747393436a1fec0b49e591170aed96dae6ccc7b2..66a532f09e57b40201d426fd2049f94a49e8b660 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ErrorParserTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ErrorParserTest.java
@@ -46,11 +46,51 @@ public class ErrorParserTest extends ParserTestCase {
parse("parseExpression", "super = x;", ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE);
}
+ public void fail_invalidCommentReference__new_nonIdentifier() throws Exception {
+ // This test fails because the parse method returns null.
+ parse(
+ "parseCommentReference",
+ new Class[] {String.class, int.class},
+ new Object[] {"new 42", 0},
+ "",
+ ParserErrorCode.INVALID_COMMENT_REFERENCE);
+ }
+
+ public void fail_invalidCommentReference__nonNew_nonIdentifier() throws Exception {
+ // This test fails because the parse method returns null.
+ parse(
+ "parseCommentReference",
+ new Class[] {String.class, int.class},
+ new Object[] {"42", 0},
+ "",
+ ParserErrorCode.INVALID_COMMENT_REFERENCE);
+ }
+
public void fail_unexpectedToken_invalidPostfixExpression() throws Exception {
// Note: this might not be the right error to produce, but some error should be produced
parse("parseExpression", "f()++", ParserErrorCode.UNEXPECTED_TOKEN);
}
+ public void test_abstractClassMember_constructor() throws Exception {
+ parse("parseClassMember", "abstract C.c();", ParserErrorCode.ABSTRACT_CLASS_MEMBER);
+ }
+
+ public void test_abstractClassMember_field() throws Exception {
+ parse("parseClassMember", "abstract C f;", ParserErrorCode.ABSTRACT_CLASS_MEMBER);
+ }
+
+ public void test_abstractClassMember_getter() throws Exception {
+ parse("parseClassMember", "abstract get m;", ParserErrorCode.ABSTRACT_CLASS_MEMBER);
+ }
+
+ public void test_abstractClassMember_method() throws Exception {
+ parse("parseClassMember", "abstract m();", ParserErrorCode.ABSTRACT_CLASS_MEMBER);
+ }
+
+ public void test_abstractClassMember_setter() throws Exception {
+ parse("parseClassMember", "abstract set m(v);", ParserErrorCode.ABSTRACT_CLASS_MEMBER);
+ }
+
public void test_breakOutsideOfLoop_breakInDoStatement() throws Exception {
parse("parseDoStatement", "do {break;} while (x);");
}
@@ -79,47 +119,6 @@ public class ErrorParserTest extends ParserTestCase {
parse("parseStatement", "() {for (; x;) {break;}};");
}
- public void test_builtInIdentifierAsFunctionName_constConstructor() throws Exception {
- parse(
- "parseClassMember",
- "const C.as() {}",
- ParserErrorCode.BUILT_IN_IDENTIFIER_AS_FUNCTION_NAME);
- }
-
- public void test_builtInIdentifierAsFunctionName_constructor() throws Exception {
- parse("parseClassMember", "C.as() {}", ParserErrorCode.BUILT_IN_IDENTIFIER_AS_FUNCTION_NAME);
- }
-
- public void test_builtInIdentifierAsFunctionName_functionExpression() throws Exception {
- parse(
- "parseFunctionExpression",
- "as() {}",
- ParserErrorCode.BUILT_IN_IDENTIFIER_AS_FUNCTION_NAME);
- }
-
- public void test_builtInIdentifierAsFunctionName_getter() throws Exception {
- parse("parseClassMember", "get as {}", ParserErrorCode.BUILT_IN_IDENTIFIER_AS_FUNCTION_NAME);
- }
-
- public void test_builtInIdentifierAsFunctionName_method() throws Exception {
- parse("parseClassMember", "void as() {}", ParserErrorCode.BUILT_IN_IDENTIFIER_AS_FUNCTION_NAME);
- }
-
- public void test_builtInIdentifierAsFunctionName_setter() throws Exception {
- parse("parseClassMember", "set as(v) {}", ParserErrorCode.BUILT_IN_IDENTIFIER_AS_FUNCTION_NAME);
- }
-
- public void test_builtInIdentifierAsLabel_statement() throws Exception {
- parse("parseStatement", "as: m();", ParserErrorCode.BUILT_IN_IDENTIFIER_AS_LABEL);
- }
-
- public void test_builtInIdentifierAsLabel_switchMember() throws Exception {
- parse(
- "parseSwitchStatement",
- "switch (e) {as: case 0: break;}",
- ParserErrorCode.BUILT_IN_IDENTIFIER_AS_LABEL);
- }
-
public void test_builtInIdentifierAsTypeDefName() throws Exception {
parse(
"parseTypeAlias",
@@ -142,17 +141,6 @@ public class ErrorParserTest extends ParserTestCase {
parse("parseTypeParameter", "as", ParserErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME);
}
- public void test_builtInIdentifierAsVariableName_for() throws Exception {
- parse(
- "parseForStatement",
- "for (as in list) {}",
- ParserErrorCode.BUILT_IN_IDENTIFIER_AS_VARIABLE_NAME);
- }
-
- public void test_builtInIdentifierAsVariableName_variable() throws Exception {
- parse("parseVariableDeclaration", "as", ParserErrorCode.BUILT_IN_IDENTIFIER_AS_VARIABLE_NAME);
- }
-
public void test_continueOutsideOfLoop_continueInDoStatement() throws Exception {
parse("parseDoStatement", "do {continue;} while (x);");
}
@@ -252,22 +240,69 @@ public class ErrorParserTest extends ParserTestCase {
}
public void test_exportDirectiveAfterPartDirective() throws Exception {
- parseCompilationUnit(
+ parse(
+ "parseCompilationUnit",
"part 'a.dart'; export 'b.dart';",
ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE);
}
- public void test_externalConstructorWithBody() throws Exception {
+ public void test_externalConstructorWithBody_factory() throws Exception {
parse(
"parseClassMember",
"external factory A() {}",
ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY);
}
+ public void test_externalConstructorWithBody_named() throws Exception {
+ parse("parseClassMember", "external A.c() {}", ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY);
+ }
+
+ public void test_externalField_const() throws Exception {
+ parse("parseClassMember", "external const C f;", ParserErrorCode.EXTERNAL_FIELD);
+ }
+
+ public void test_externalField_final() throws Exception {
+ parse("parseClassMember", "external final C f;", ParserErrorCode.EXTERNAL_FIELD);
+ }
+
+ public void test_externalField_static() throws Exception {
+ parse("parseClassMember", "external static C f;", ParserErrorCode.EXTERNAL_FIELD);
+ }
+
+ public void test_externalField_typed() throws Exception {
+ parse("parseClassMember", "external A f;", ParserErrorCode.EXTERNAL_FIELD);
+ }
+
+ public void test_externalField_untyped() throws Exception {
+ parse("parseClassMember", "external var f;", ParserErrorCode.EXTERNAL_FIELD);
+ }
+
+ public void test_externalGetterWithBody() throws Exception {
+ parse("parseClassMember", "external int get x {}", ParserErrorCode.EXTERNAL_GETTER_WITH_BODY);
+ }
+
public void test_externalMethodWithBody() throws Exception {
parse("parseClassMember", "external m() {}", ParserErrorCode.EXTERNAL_METHOD_WITH_BODY);
}
+ public void test_externalOperatorWithBody() throws Exception {
+ parse(
+ "parseClassMember",
+ "external operator +(int value) {}",
+ ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY);
+ }
+
+ public void test_externalSetterWithBody() throws Exception {
+ parse(
+ "parseClassMember",
+ "external set x(int value) {}",
+ ParserErrorCode.EXTERNAL_SETTER_WITH_BODY);
+ }
+
+ public void test_getterWithParameters() throws Exception {
+ parse("parseClassMember", "int get x() {}", ParserErrorCode.GETTER_WITH_PARAMETERS);
+ }
+
public void test_illegalAssignmentToNonAssignable_superAssigned() throws Exception {
// TODO(brianwilkerson) When the test fail_illegalAssignmentToNonAssignable_superAssigned starts
// to pass, remove this test (there should only be one error generated, but we're keeping this
@@ -280,11 +315,73 @@ public class ErrorParserTest extends ParserTestCase {
}
public void test_importDirectiveAfterPartDirective() throws Exception {
- parseCompilationUnit(
+ parse(
+ "parseCompilationUnit",
"part 'a.dart'; import 'b.dart';",
ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE);
}
+ public void test_initializedVariableInForEach() throws Exception {
+ parse(
+ "parseForStatement",
+ "for (int a = 0 in foo) {}",
+ ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH);
+ }
+
+ public void test_invalidCodePoint() throws Exception {
+ parse("parseStringLiteral", "'\\uD900'", ParserErrorCode.INVALID_CODE_POINT);
+ }
+
+ public void test_invalidCommentReference__new_tooMuch() throws Exception {
+ parse("parseCommentReference", new Class[] {String.class, int.class}, new Object[] {
+ "new a.b.c.d", 0}, "", ParserErrorCode.INVALID_COMMENT_REFERENCE);
+ }
+
+ public void test_invalidCommentReference__nonNew_tooMuch() throws Exception {
+ parse("parseCommentReference", new Class[] {String.class, int.class}, new Object[] {
+ "a.b.c.d", 0}, "", ParserErrorCode.INVALID_COMMENT_REFERENCE);
+ }
+
+ public void test_invalidHexEscape_invalidDigit() throws Exception {
+ parse("parseStringLiteral", "'\\x0 a'", ParserErrorCode.INVALID_HEX_ESCAPE);
+ }
+
+ public void test_invalidHexEscape_tooFewDigits() throws Exception {
+ parse("parseStringLiteral", "'\\x0'", ParserErrorCode.INVALID_HEX_ESCAPE);
+ }
+
+ public void test_invalidOperatorForSuper() throws Exception {
+ parse("parseUnaryExpression", "++super", ParserErrorCode.INVALID_OPERATOR_FOR_SUPER);
+ }
+
+ public void test_invalidUnicodeEscape_incomplete_noDigits() throws Exception {
+ parse("parseStringLiteral", "'\\u{'", ParserErrorCode.INVALID_UNICODE_ESCAPE);
+ }
+
+ public void test_invalidUnicodeEscape_incomplete_someDigits() throws Exception {
+ parse("parseStringLiteral", "'\\u{0A'", ParserErrorCode.INVALID_UNICODE_ESCAPE);
+ }
+
+ public void test_invalidUnicodeEscape_invalidDigit() throws Exception {
+ parse("parseStringLiteral", "'\\u0 a'", ParserErrorCode.INVALID_UNICODE_ESCAPE);
+ }
+
+ public void test_invalidUnicodeEscape_tooFewDigits_fixed() throws Exception {
+ parse("parseStringLiteral", "'\\u04'", ParserErrorCode.INVALID_UNICODE_ESCAPE);
+ }
+
+ public void test_invalidUnicodeEscape_tooFewDigits_variable() throws Exception {
+ parse("parseStringLiteral", "'\\u{}'", ParserErrorCode.INVALID_UNICODE_ESCAPE);
+ }
+
+ public void test_invalidUnicodeEscape_tooManyDigits_variable() throws Exception {
+ parse(
+ "parseStringLiteral",
+ "'\\u{12345678}'",
+ ParserErrorCode.INVALID_UNICODE_ESCAPE,
+ ParserErrorCode.INVALID_CODE_POINT);
+ }
+
public void test_libraryDirectiveNotFirst() throws Exception {
parse(
"parseCompilationUnit",
@@ -332,6 +429,32 @@ public class ErrorParserTest extends ParserTestCase {
assertNotNull(statement);
}
+ public void test_missingConstFinalVarOrType() throws Exception {
+ parse(
+ "parseFinalConstVarOrType",
+ new Class[] {boolean.class},
+ new Object[] {false},
+ "a;",
+ ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE);
+ }
+
+ public void test_missingFunctionBody_emptyNotAllowed() throws Exception {
+ parse("parseFunctionBody", new Class[] {boolean.class, boolean.class}, new Object[] {
+ false, false}, ";", ParserErrorCode.MISSING_FUNCTION_BODY);
+ }
+
+ public void test_missingFunctionBody_invalid() throws Exception {
+ parse("parseFunctionBody", new Class[] {boolean.class, boolean.class}, new Object[] {
+ false, false}, "return 0;", ParserErrorCode.MISSING_FUNCTION_BODY);
+ }
+
+ public void test_missingVariableInForEach() throws Exception {
+ parse(
+ "parseForStatement",
+ "for (a < b in foo) {}",
+ ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH);
+ }
+
public void test_mixedParameterGroups_namedPositional() throws Exception {
parse("parseFormalParameterList", "(a, {b}, [c])", ParserErrorCode.MIXED_PARAMETER_GROUPS);
}
@@ -368,6 +491,13 @@ public class ErrorParserTest extends ParserTestCase {
ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS);
}
+ public void test_multipleVariablesInForEach() throws Exception {
+ parse(
+ "parseForStatement",
+ "for (int a, b in foo) {}",
+ ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH);
+ }
+
public void test_namedParameterOutsideGroup() throws Exception {
parse("parseFormalParameterList", "(a, b : 0)", ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP);
}

Powered by Google App Engine
This is Rietveld 408576698