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

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

Issue 10868078: Fix for 4700 - accept metadata in more places (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
« 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
===================================================================
--- compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java (revision 11322)
+++ compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java (working copy)
@@ -957,6 +957,36 @@
assertEquals(0, metadata.getArguments().size());
}
+ public void test_metadata_localVariable() {
+ String code = makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "const annotation = 0;",
+ "class A {",
+ " test() {",
+ " @annotation",
+ " var v = 0;",
+ " }",
+ "}",
+ "");
+ DartUnit unit = parseUnit(getName() + ".dart", code);
+ DartClass classA = (DartClass) unit.getTopLevelNodes().get(1);
+
+ DartMethodDefinition method = (DartMethodDefinition) classA.getMembers().get(0);
+ assertEquals("test", method.getName().toSource());
+ assertEquals(0, method.getMetadata().size());
+
+ DartVariableStatement statement = (DartVariableStatement) method.getFunction().getBody().getStatements().get(0);
+ DartVariable variable = statement.getVariables().get(0);
+ assertEquals("v", variable.getName().toSource());
+ assertEquals(1, variable.getMetadata().size());
+ DartAnnotation metadata = variable.getMetadata().get(0);
+ assertNotNull(metadata);
+ DartExpression name = metadata.getName();
+ assertTrue(name instanceof DartIdentifier);
+ assertEquals("annotation", name.toSource());
+ assertEquals(0, metadata.getArguments().size());
+ }
+
public void test_metadata_constructor() {
String code = makeCode(
"// 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