| OLD | NEW |
| 1 // compile options: --emit-metadata | 1 // compile options: --emit-metadata |
| 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 // Regression test for Issue 13817. | 6 // Regression test for Issue 13817. |
| 7 | 7 |
| 8 library test.metadata_constructor_arguments; | 8 library test.metadata_constructor_arguments; |
| 9 | 9 |
| 10 import 'dart:mirrors'; | 10 import 'dart:mirrors'; |
| 11 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
| 12 | 12 |
| 13 class Tag { | 13 class Tag { |
| 14 final name; | 14 final name; |
| 15 const Tag({named}) : this.name = named; | 15 const Tag({named}) : this.name = named; |
| 16 } | 16 } |
| 17 | 17 |
| 18 @Tag(named: undefined) // /// 01: compile-time error | 18 @Tag(named: undefined) // //# 01: compile-time error |
| 19 class A {} | 19 class A {} |
| 20 | 20 |
| 21 @Tag(named: 'valid') | 21 @Tag(named: 'valid') |
| 22 class B {} | 22 class B {} |
| 23 | 23 |
| 24 @Tag(named: C.STATIC_FIELD) | 24 @Tag(named: C.STATIC_FIELD) |
| 25 class C { | 25 class C { |
| 26 static const STATIC_FIELD = 3; | 26 static const STATIC_FIELD = 3; |
| 27 } | 27 } |
| 28 | 28 |
| 29 @Tag(named: D.instanceMethod()) // /// 02: compile-time error | 29 @Tag(named: D.instanceMethod()) // //# 02: compile-time error |
| 30 class D { | 30 class D { |
| 31 instanceMethod() {} | 31 instanceMethod() {} |
| 32 } | 32 } |
| 33 | 33 |
| 34 @Tag(named: instanceField) // /// 03: compile-time error | 34 @Tag(named: instanceField) // //# 03: compile-time error |
| 35 class E { | 35 class E { |
| 36 var instanceField; | 36 var instanceField; |
| 37 } | 37 } |
| 38 | 38 |
| 39 @Tag(named: F.nonConstStaticField) // /// 04: compile-time error | 39 @Tag(named: F.nonConstStaticField) // //# 04: compile-time error |
| 40 class F { | 40 class F { |
| 41 static var nonConstStaticField = 6; | 41 static var nonConstStaticField = 6; |
| 42 } | 42 } |
| 43 | 43 |
| 44 @Tag(named: instanceMethod) // /// 05: compile-time error | 44 @Tag(named: instanceMethod) // //# 05: compile-time error |
| 45 class G { | 45 class G { |
| 46 instanceMethod() {} | 46 instanceMethod() {} |
| 47 } | 47 } |
| 48 | 48 |
| 49 @Tag(named: this) // /// 06: compile-time error | 49 @Tag(named: this) // //# 06: compile-time error |
| 50 class H { | 50 class H { |
| 51 instanceMethod() {} | 51 instanceMethod() {} |
| 52 } | 52 } |
| 53 | 53 |
| 54 @Tag(named: super) // /// 07: compile-time error | 54 @Tag(named: super) // //# 07: compile-time error |
| 55 class I { | 55 class I { |
| 56 instanceMethod() {} | 56 instanceMethod() {} |
| 57 } | 57 } |
| 58 | 58 |
| 59 checkMetadata(DeclarationMirror mirror, List expectedMetadata) { | 59 checkMetadata(DeclarationMirror mirror, List expectedMetadata) { |
| 60 Expect.listEquals(expectedMetadata.map(reflect).toList(), mirror.metadata); | 60 Expect.listEquals(expectedMetadata.map(reflect).toList(), mirror.metadata); |
| 61 } | 61 } |
| 62 | 62 |
| 63 main() { | 63 main() { |
| 64 reflectClass(A).metadata; | 64 reflectClass(A).metadata; |
| 65 checkMetadata(reflectClass(B), [const Tag(named: 'valid')]); | 65 checkMetadata(reflectClass(B), [const Tag(named: 'valid')]); |
| 66 checkMetadata(reflectClass(C), [const Tag(named: C.STATIC_FIELD)]); | 66 checkMetadata(reflectClass(C), [const Tag(named: C.STATIC_FIELD)]); |
| 67 reflectClass(D).metadata; | 67 reflectClass(D).metadata; |
| 68 reflectClass(E).metadata; | 68 reflectClass(E).metadata; |
| 69 reflectClass(F).metadata; | 69 reflectClass(F).metadata; |
| 70 reflectClass(G).metadata; | 70 reflectClass(G).metadata; |
| 71 reflectClass(H).metadata; | 71 reflectClass(H).metadata; |
| 72 reflectClass(I).metadata; | 72 reflectClass(I).metadata; |
| 73 } | 73 } |
| OLD | NEW |