| 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 @string @symbol | |
| 6 library test.metadata_test; | 5 library test.metadata_test; |
| 7 | 6 |
| 8 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 9 | 8 |
| 10 const string = 'a metadata string'; | 9 const string = 'a metadata string'; |
| 11 | 10 |
| 12 const symbol = const Symbol('symbol'); | 11 const symbol = const Symbol('symbol'); |
| 13 | 12 |
| 14 const hest = 'hest'; | 13 const hest = 'hest'; |
| 15 | 14 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 44 | 43 |
| 45 @symbol @string @symbol | 44 @symbol @string @symbol |
| 46 main() { | 45 main() { |
| 47 if (MirrorSystem.getName(symbol) != 'symbol') { | 46 if (MirrorSystem.getName(symbol) != 'symbol') { |
| 48 // This happened in dart2js due to how early library metadata is | 47 // This happened in dart2js due to how early library metadata is |
| 49 // computed. | 48 // computed. |
| 50 throw 'Bad constant: $symbol'; | 49 throw 'Bad constant: $symbol'; |
| 51 } | 50 } |
| 52 | 51 |
| 53 MirrorSystem mirrors = currentMirrorSystem(); | 52 MirrorSystem mirrors = currentMirrorSystem(); |
| 54 checkMetadata(mirrors.findLibrary(const Symbol('test.metadata_test')).first, | |
| 55 [string, symbol]); | |
| 56 ClassMirror myClassMirror = reflectClass(MyClass); | 53 ClassMirror myClassMirror = reflectClass(MyClass); |
| 57 checkMetadata(myClassMirror, [symbol, string]); | 54 checkMetadata(myClassMirror, [symbol, string]); |
| 58 ClosureMirror closure = reflect(main); | 55 LibraryMirror lib = mirrors.findLibrary(const Symbol('test.metadata_test')).fi
rst; |
| 59 checkMetadata(closure.function, [symbol, string, symbol]); | 56 MethodMirror function = lib.functions[const Symbol('main')]; |
| 60 closure = reflect(new MyClass().myMethod); | 57 checkMetadata(function, [symbol, string, symbol]); |
| 61 checkMetadata(closure.function, [string, symbol, string]); | 58 MethodMirror method = myClassMirror.methods[const Symbol('myMethod')]; |
| 59 checkMetadata(method, [string, symbol, string]); |
| 62 | 60 |
| 63 VariableMirror xMirror = myClassMirror.variables[const Symbol('x')]; | 61 VariableMirror xMirror = myClassMirror.variables[const Symbol('x')]; |
| 64 checkMetadata(xMirror, [hest, hest, symbol]); | 62 checkMetadata(xMirror, [hest, hest, symbol]); |
| 65 | 63 |
| 66 VariableMirror yMirror = myClassMirror.variables[const Symbol('y')]; | 64 VariableMirror yMirror = myClassMirror.variables[const Symbol('y')]; |
| 67 checkMetadata(yMirror, []); | 65 checkMetadata(yMirror, []); |
| 68 | 66 |
| 69 // TODO(ahe): Test local functions. | 67 // TODO(ahe): Test local functions. |
| 70 } | 68 } |
| OLD | NEW |