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

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

Issue 11048021: Issue 5508. Fix for parsing cascade after conditional expression (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« 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/SyntaxTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java b/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
index 73ba73c9aefd2345042ea9832e805e2083e97fa0..9fc8bfe01ff7dc49001df495203ba83d5ddb0c5e 100644
--- a/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
+++ b/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
@@ -12,6 +12,7 @@ import com.google.dart.compiler.ast.DartArrayLiteral;
import com.google.dart.compiler.ast.DartAssertStatement;
import com.google.dart.compiler.ast.DartBinaryExpression;
import com.google.dart.compiler.ast.DartBooleanLiteral;
+import com.google.dart.compiler.ast.DartCascadeExpression;
import com.google.dart.compiler.ast.DartClass;
import com.google.dart.compiler.ast.DartComment;
import com.google.dart.compiler.ast.DartExprStmt;
@@ -37,6 +38,7 @@ import com.google.dart.compiler.ast.DartUnaryExpression;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.DartVariable;
import com.google.dart.compiler.ast.DartVariableStatement;
+import com.google.dart.compiler.ast.NodeList;
import java.util.List;
@@ -148,6 +150,35 @@ public class SyntaxTest extends AbstractParserTest {
assertTrue(expression instanceof DartBooleanLiteral);
}
+ public void test_cascade_withConditionalInside() {
+ DartUnit unit = parseUnit("function.dart", Joiner.on("\n").join(
+ "class A {",
+ " var name;",
+ " foo() {}",
+ "}",
+ "",
+ "",
+ "",
+ "main() {",
+ " A a = new A();",
+ " a",
+ " ..name = true ? 'true' : 'false'",
+ " ..foo();",
+ "}"
+ ));
+ assertNotNull(unit);
+ assertEquals(2, unit.getTopLevelNodes().size());
+ DartMethodDefinition function = (DartMethodDefinition) unit.getTopLevelNodes().get(1);
+ assertNotNull(function);
+ DartStatement statement = function.getFunction().getBody().getStatements().get(1);
+ assertTrue(statement instanceof DartExprStmt);
+ DartCascadeExpression cascade = (DartCascadeExpression) ((DartExprStmt) statement).getExpression();
+ NodeList<DartExpression> cascadeSections = cascade.getCascadeSections();
+ assertEquals(2, cascadeSections.size());
+ assertEquals("..name = true ? \"true\" : \"false\"", cascadeSections.get(0).toString());
+ assertEquals("..foo()", cascadeSections.get(1).toString());
+ }
+
public void test_functionExpression_asStatement() {
DartUnit unit = parseUnit("function.dart", Joiner.on("\n").join(
"main() {",
« 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