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. |