OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library test.metadata_test; | 5 library test.metadata_test; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 | 8 |
9 const string = 'a metadata string'; | 9 const string = 'a metadata string'; |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 if (MirrorSystem.getName(symbol) != 'symbol') { | 47 if (MirrorSystem.getName(symbol) != 'symbol') { |
48 // This happened in dart2js due to how early library metadata is | 48 // This happened in dart2js due to how early library metadata is |
49 // computed. | 49 // computed. |
50 throw 'Bad constant: $symbol'; | 50 throw 'Bad constant: $symbol'; |
51 } | 51 } |
52 | 52 |
53 MirrorSystem mirrors = currentMirrorSystem(); | 53 MirrorSystem mirrors = currentMirrorSystem(); |
54 ClassMirror myClassMirror = reflectClass(MyClass); | 54 ClassMirror myClassMirror = reflectClass(MyClass); |
55 checkMetadata(myClassMirror, [symbol, string]); | 55 checkMetadata(myClassMirror, [symbol, string]); |
56 LibraryMirror lib = mirrors.findLibrary(#test.metadata_test); | 56 LibraryMirror lib = mirrors.findLibrary(#test.metadata_test); |
57 MethodMirror function = lib.functions[#main]; | 57 MethodMirror function = lib.declarations[#main]; |
58 checkMetadata(function, [symbol, string, symbol]); | 58 checkMetadata(function, [symbol, string, symbol]); |
59 MethodMirror method = myClassMirror.methods[#myMethod]; | 59 MethodMirror method = myClassMirror.declarations[#myMethod]; |
60 checkMetadata(method, [string, symbol, string]); | 60 checkMetadata(method, [string, symbol, string]); |
61 method = myClassMirror.methods[#myOtherMethod]; | 61 method = myClassMirror.declarations[#myOtherMethod]; |
62 checkMetadata(method, []); | 62 checkMetadata(method, []); |
63 | 63 |
64 VariableMirror xMirror = myClassMirror.variables[#x]; | 64 VariableMirror xMirror = myClassMirror.declarations[#x]; |
65 checkMetadata(xMirror, [hest, hest, symbol]); | 65 checkMetadata(xMirror, [hest, hest, symbol]); |
66 | 66 |
67 VariableMirror yMirror = myClassMirror.variables[#y]; | 67 VariableMirror yMirror = myClassMirror.declarations[#y]; |
68 checkMetadata(yMirror, []); | 68 checkMetadata(yMirror, []); |
69 | 69 |
70 // TODO(ahe): Test local functions. | 70 // TODO(ahe): Test local functions. |
71 } | 71 } |
OLD | NEW |