OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:mirrors'; |
| 6 import 'package:expect/expect.dart'; |
| 7 |
| 8 import 'stringify.dart'; |
| 9 |
| 10 class A<T> { |
| 11 var instanceVariable; |
| 12 get instanceGetter => null; |
| 13 set instanceSetter(x) => x; |
| 14 instanceMethod() => null; |
| 15 |
| 16 var _instanceVariable; |
| 17 get _instanceGetter => null; |
| 18 set _instanceSetter(x) => x; |
| 19 _instanceMethod() => null; |
| 20 |
| 21 static var staticVariable; |
| 22 static get staticGetter => null; |
| 23 static set staticSetter(x) => x; |
| 24 static staticMethod() => null; |
| 25 |
| 26 static var _staticVariable; |
| 27 static get _staticGetter => null; |
| 28 static set _staticSetter(x) => x; |
| 29 static _staticMethod() => null; |
| 30 } |
| 31 |
| 32 main() { |
| 33 ClassMirror cm = reflect(new A<String>()).type; |
| 34 Expect.setEquals( |
| 35 ['Variable(s(_instanceVariable) in s(A), private)', |
| 36 'Variable(s(_staticVariable) in s(A), private, static)', |
| 37 'Variable(s(instanceVariable) in s(A))', |
| 38 'Variable(s(staticVariable) in s(A), static)'], |
| 39 cm.declarations.values |
| 40 .where((dm) => dm is VariableMirror).map(stringify), |
| 41 'variables'); |
| 42 |
| 43 Expect.setEquals( |
| 44 ['Method(s(_instanceGetter) in s(A), private, getter)', |
| 45 'Method(s(_staticGetter) in s(A), private, static, getter)', |
| 46 'Method(s(instanceGetter) in s(A), getter)', |
| 47 'Method(s(staticGetter) in s(A), static, getter)'], |
| 48 cm.declarations.values |
| 49 .where((dm) => dm is MethodMirror && dm.isGetter).map(stringify), |
| 50 'getters'); |
| 51 |
| 52 Expect.setEquals( |
| 53 ['Method(s(_instanceSetter=) in s(A), private, setter)', |
| 54 'Method(s(_staticSetter=) in s(A), private, static, setter)', |
| 55 'Method(s(instanceSetter=) in s(A), setter)', |
| 56 'Method(s(staticSetter=) in s(A), static, setter)'], |
| 57 cm.declarations.values |
| 58 .where((dm) => dm is MethodMirror && dm.isSetter).map(stringify), |
| 59 'setters'); |
| 60 |
| 61 Expect.setEquals( |
| 62 ['Method(s(_instanceMethod) in s(A), private)', |
| 63 'Method(s(_staticMethod) in s(A), private, static)', |
| 64 'Method(s(instanceMethod) in s(A))', |
| 65 'Method(s(staticMethod) in s(A), static)'], |
| 66 cm.declarations.values |
| 67 .where((dm) => dm is MethodMirror && dm.isRegularMethod) |
| 68 .map(stringify), 'methods'); |
| 69 |
| 70 Expect.setEquals( |
| 71 ['Method(s(A) in s(A), constructor)'], |
| 72 cm.declarations.values |
| 73 .where((dm) => dm is MethodMirror && dm.isConstructor).map(stringify), |
| 74 'constructors'); |
| 75 |
| 76 Expect.setEquals( |
| 77 ['TypeVariable(s(T) in s(A), upperBound = Class(s(Object) in ' |
| 78 's(dart.core), top-level))'], |
| 79 cm.declarations.values |
| 80 .where((dm) => dm is TypeVariableMirror).map(stringify), |
| 81 'type variables'); |
| 82 |
| 83 } |
OLD | NEW |