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

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

Issue 10857041: Fix for issue 3550 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 10845)
+++ compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java (working copy)
@@ -30,6 +30,7 @@
import com.google.dart.compiler.ast.DartTypeNode;
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 java.util.List;
@@ -915,6 +916,18 @@
ParserErrorCode.DISALLOWED_ABSTRACT_KEYWORD, 3, 3);
}
+ public void test_localVariable_const() {
+ DartUnit unit = parseUnit("constVar.dart", makeCode(
+ "main() {",
+ " const v = 1;",
+ "}"));
+ assertNotNull(unit);
+ DartNode firstNode = unit.getTopLevelNodes().get(0);
+ assertTrue(firstNode instanceof DartMethodDefinition);
+ DartStatement statement = ((DartMethodDefinition) firstNode).getFunction().getBody().getStatements().get(0);
+ assertTrue(((DartVariableStatement) statement).getModifiers().isConstant());
+ }
+
public void test_metadata_deprecated() {
String code = makeCode(
"// filler filler filler filler filler filler filler filler filler filler",
@@ -1066,6 +1079,15 @@
ParserErrorCode.VOID_FIELD, 5, 3);
}
+ public void test_topLevelVariable_const() {
+ DartUnit unit = parseUnit("constVar.dart", "const v = 1;");
+ assertNotNull(unit);
+ DartNode firstNode = unit.getTopLevelNodes().get(0);
+ assertTrue(firstNode instanceof DartFieldDefinition);
+ DartField field = ((DartFieldDefinition) firstNode).getFields().get(0);
+ assertTrue(field.getModifiers().isConstant());
+ }
+
public void test_unexpectedTypeArgument() throws Exception {
// This is valid code that was previously rejected.
// Invoking a named constructor in a prefixed library should work.

Powered by Google App Engine
This is Rietveld 408576698