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

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

Issue 10536031: Fix for issue 3401: Implement casts in Analyzer (Closed) Base URL: http://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
Index: compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
===================================================================
--- compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java (revision 8336)
+++ compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java (working copy)
@@ -24,6 +24,7 @@
import com.google.dart.compiler.ast.DartStringInterpolation;
import com.google.dart.compiler.ast.DartStringLiteral;
import com.google.dart.compiler.ast.DartTryStatement;
+import com.google.dart.compiler.ast.DartTypeExpression;
import com.google.dart.compiler.ast.DartTypeNode;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.DartVariableStatement;
@@ -180,6 +181,18 @@
assertEquals(3, ((DartIntegerLiteral)array.getExpressions().get(2)).getValue().intValue());
}
+ public void testAs() {
+ DartUnit unit = parseUnit("phony_cast.dart", "var x = 3 as int;");
+ List<DartNode> nodes = unit.getTopLevelNodes();
+ assertEquals(1, nodes.size());
+ DartFieldDefinition f = (DartFieldDefinition)nodes.get(0);
+ DartField fieldX = f.getFields().get(0);
+ DartBinaryExpression cast = (DartBinaryExpression) fieldX.getValue();
+ assertTrue(cast.getArg1() instanceof DartIntegerLiteral);
+ assertEquals(Token.AS, cast.getOperator());
+ assertTrue(cast.getArg2() instanceof DartTypeExpression);
+ }
+
public void testMapLiteral() {
DartUnit unit = parseUnit("phony_map_literal.dart", "var x = <int>{'a':1,'b':2,'c':3};");
List<DartNode> nodes = unit.getTopLevelNodes();

Powered by Google App Engine
This is Rietveld 408576698