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

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

Issue 10558016: Issue 2339. Fix for parsing function expression inside of new expression inside of initializer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
« no previous file with comments | « compiler/java/com/google/dart/compiler/parser/DartParser.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 136d291c1bae3c7d3cc1ef17dd7dcb3dec68a106..f7bb7ca0c7ffbf62d2a52d7c49c9f8135530ee78 100644
--- a/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
+++ b/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
@@ -951,6 +951,70 @@ public class NegativeParserTest extends CompilerTestCase {
errEx(ParserErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME, 14, 9, 7));
}
+ /**
+ * There is ambiguity in parsing function expression inside of initializer.
+ * <p>
+ * But we should be able to parse when function expression is inside of "new expression".
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2339
+ */
+ public void test_functionExpression_inInitializer_newExpression() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " A(var p) {}",
+ "}",
+ "class B {",
+ " var f;",
+ " B() : f = new A(() => 42) {",
+ " }",
+ "}",
+ ""));
+ }
+
+ /**
+ * There is ambiguity in parsing function expression inside of initializer.
+ * <p>
+ * But we should be able to parse when function expression is inside of "const expression".
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2339
+ */
+ public void test_functionExpression_inInitializer_constExpression() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " const A(var p) {}",
+ "}",
+ "class B {",
+ " var f;",
+ " B() : f = const A(() => 42) {",
+ " }",
+ "}",
+ ""));
+ }
+
+ /**
+ * There is ambiguity in parsing function expression inside of initializer.
+ * <p>
+ * But we should be able to parse when function expression is inside of "method invocation".
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2339
+ */
+ public void test_functionExpression_inInitializer_methodInvocation() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "foo(var p) {}",
+ "class B {",
+ " var f;",
+ " B() : f = foo(() => 42) {",
+ " }",
+ "}",
+ ""));
+ }
+
public void test_qualifiedType_inForIn() {
parseExpectErrors(Joiner.on("\n").join(
"// filler filler filler filler filler filler filler filler filler filler",
« no previous file with comments | « compiler/java/com/google/dart/compiler/parser/DartParser.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698