Chromium Code Reviews| Index: tests/lib/mirrors/metadata_scope_test.dart |
| diff --git a/tests/lib/mirrors/metadata_scope_test.dart b/tests/lib/mirrors/metadata_scope_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..530c2fa8c23069772241d438eebefadd61f3bb1a |
| --- /dev/null |
| +++ b/tests/lib/mirrors/metadata_scope_test.dart |
| @@ -0,0 +1,55 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library test.metadata_scope; |
| + |
| +import 'dart:mirrors'; |
| +import 'package:expect/expect.dart'; |
| + |
| +class Annotation { |
| + final contents; |
| + const Annotation(this.contents); |
| + toString() => "Annotation($contents)"; |
| +} |
| + |
| +@Annotation(foo) /// 01: compile-time error |
|
hausner
2014/03/28 22:25:33
Maybe a comment why this is a compile-time error?
rmacnak
2014/03/28 22:36:58
Done
|
| +class A { |
| + @Annotation(foo) |
| + static foo() {} |
| + |
| + @Annotation(foo) |
| + static bar() {} |
| +} |
| + |
| +@Annotation(B.foo) |
| +class B { |
| + @Annotation(B.foo) |
| + static foo() {} |
| + |
| + @Annotation(B.foo) |
| + static bar() {} |
| +} |
| + |
| +baz() {} |
| + |
| +@Annotation(baz) |
|
hausner
2014/03/28 22:25:33
Comment to note that the baz in the metadata shoul
rmacnak
2014/03/28 22:36:58
Done
|
| +class C { |
| + @Annotation(baz) |
| + static baz() {} |
| +} |
| + |
| +checkMetadata(DeclarationMirror mirror, List expectedMetadata) { |
| + Expect.listEquals(expectedMetadata.map(reflect).toList(), mirror.metadata); |
| +} |
| + |
| +main() { |
| + reflectClass(A).metadata; |
| + checkMetadata(reflectClass(A).declarations[#foo], [const Annotation(A.foo)]); |
| + checkMetadata(reflectClass(A).declarations[#bar], [const Annotation(A.foo)]); |
| + checkMetadata(reflectClass(B), [const Annotation(B.foo)]); |
| + checkMetadata(reflectClass(B).declarations[#foo], [const Annotation(B.foo)]); |
| + checkMetadata(reflectClass(B).declarations[#bar], [const Annotation(B.foo)]); |
| + checkMetadata(reflectClass(C), [const Annotation(baz)]); |
| + checkMetadata(reflectClass(C).declarations[#baz], [const Annotation(C.baz)]); |
| +} |