| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package com.google.dart.compiler.parser; | 5 package com.google.dart.compiler.parser; |
| 6 | 6 |
| 7 import com.google.common.base.Joiner; | 7 import com.google.common.base.Joiner; |
| 8 import com.google.dart.compiler.DartCompilerListener; | 8 import com.google.dart.compiler.DartCompilerListener; |
| 9 import com.google.dart.compiler.DartSourceTest; | 9 import com.google.dart.compiler.DartSourceTest; |
| 10 import com.google.dart.compiler.ast.DartArrayLiteral; | 10 import com.google.dart.compiler.ast.DartArrayLiteral; |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 assertEquals("m1", method1.getName().toSource()); | 950 assertEquals("m1", method1.getName().toSource()); |
| 951 assertEquals(1, method1.getMetadata().size()); | 951 assertEquals(1, method1.getMetadata().size()); |
| 952 DartAnnotation metadata = method1.getMetadata().get(0); | 952 DartAnnotation metadata = method1.getMetadata().get(0); |
| 953 assertNotNull(metadata); | 953 assertNotNull(metadata); |
| 954 DartExpression name = metadata.getName(); | 954 DartExpression name = metadata.getName(); |
| 955 assertTrue(name instanceof DartIdentifier); | 955 assertTrue(name instanceof DartIdentifier); |
| 956 assertEquals("annotation", name.toSource()); | 956 assertEquals("annotation", name.toSource()); |
| 957 assertEquals(0, metadata.getArguments().size()); | 957 assertEquals(0, metadata.getArguments().size()); |
| 958 } | 958 } |
| 959 | 959 |
| 960 public void test_metadata_localVariable() { |
| 961 String code = makeCode( |
| 962 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 963 "const annotation = 0;", |
| 964 "class A {", |
| 965 " test() {", |
| 966 " @annotation", |
| 967 " var v = 0;", |
| 968 " }", |
| 969 "}", |
| 970 ""); |
| 971 DartUnit unit = parseUnit(getName() + ".dart", code); |
| 972 DartClass classA = (DartClass) unit.getTopLevelNodes().get(1); |
| 973 |
| 974 DartMethodDefinition method = (DartMethodDefinition) classA.getMembers().get
(0); |
| 975 assertEquals("test", method.getName().toSource()); |
| 976 assertEquals(0, method.getMetadata().size()); |
| 977 |
| 978 DartVariableStatement statement = (DartVariableStatement) method.getFunction
().getBody().getStatements().get(0); |
| 979 DartVariable variable = statement.getVariables().get(0); |
| 980 assertEquals("v", variable.getName().toSource()); |
| 981 assertEquals(1, variable.getMetadata().size()); |
| 982 DartAnnotation metadata = variable.getMetadata().get(0); |
| 983 assertNotNull(metadata); |
| 984 DartExpression name = metadata.getName(); |
| 985 assertTrue(name instanceof DartIdentifier); |
| 986 assertEquals("annotation", name.toSource()); |
| 987 assertEquals(0, metadata.getArguments().size()); |
| 988 } |
| 989 |
| 960 public void test_metadata_constructor() { | 990 public void test_metadata_constructor() { |
| 961 String code = makeCode( | 991 String code = makeCode( |
| 962 "// filler filler filler filler filler filler filler filler filler fille
r", | 992 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 963 "class A {", | 993 "class A {", |
| 964 " const A();", | 994 " const A();", |
| 965 "}", | 995 "}", |
| 966 "", | 996 "", |
| 967 "class B {", | 997 "class B {", |
| 968 " m0() {}", | 998 " m0() {}", |
| 969 " @A()", | 999 " @A()", |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 "typedef func(var arg());", | 1331 "typedef func(var arg());", |
| 1302 ParserErrorCode.FUNCTION_TYPED_PARAMETER_IS_VAR, 1, 18); | 1332 ParserErrorCode.FUNCTION_TYPED_PARAMETER_IS_VAR, 1, 18); |
| 1303 } | 1333 } |
| 1304 | 1334 |
| 1305 public void test_finalInFunctionType() throws Exception { | 1335 public void test_finalInFunctionType() throws Exception { |
| 1306 parseUnit("phony_var_in_function_type.dart", | 1336 parseUnit("phony_var_in_function_type.dart", |
| 1307 "typedef func(final arg());", | 1337 "typedef func(final arg());", |
| 1308 ParserErrorCode.FUNCTION_TYPED_PARAMETER_IS_FINAL, 1, 20); | 1338 ParserErrorCode.FUNCTION_TYPED_PARAMETER_IS_FINAL, 1, 20); |
| 1309 } | 1339 } |
| 1310 } | 1340 } |
| OLD | NEW |