| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Testing the basic set of features that are needed for polymer. | 5 // Testing the basic set of features that are needed for polymer. |
| 6 | 6 |
| 7 library test_reflectable.test.polymer_basic_needs_test; | 7 library test_reflectable.test.polymer_basic_needs_test; |
| 8 | 8 |
| 9 import 'package:reflectable/reflectable.dart'; | 9 import 'package:reflectable/reflectable.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 declaration.isGetter && | 42 declaration.isGetter && |
| 43 !_hasSetter(declaration.owner, declaration)); | 43 !_hasSetter(declaration.owner, declaration)); |
| 44 | 44 |
| 45 bool isMethod() => !isField() && !isProperty(); | 45 bool isMethod() => !isField() && !isProperty(); |
| 46 | 46 |
| 47 return new ThinDeclarationMirror(declaration.simpleName, | 47 return new ThinDeclarationMirror(declaration.simpleName, |
| 48 declaration is VariableMirror, isProperty(), isFinal(), isMethod()); | 48 declaration is VariableMirror, isProperty(), isFinal(), isMethod()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 class MyReflectable extends Reflectable { | 51 class MyReflectable extends Reflectable { |
| 52 const MyReflectable() : super(instanceInvokeCapability); | 52 const MyReflectable() |
| 53 : super(instanceInvokeCapability, declarationsCapability); |
| 53 } | 54 } |
| 55 |
| 54 const myReflectable = const MyReflectable(); | 56 const myReflectable = const MyReflectable(); |
| 55 | 57 |
| 56 List<DeclarationMirror> _query(Type dartType) { | 58 List<DeclarationMirror> _query(Type dartType) { |
| 57 ClassMirror mirror = myReflectable.reflectType(dartType); | 59 ClassMirror mirror = myReflectable.reflectType(dartType); |
| 58 return mirror.declarations.values.toList(); | 60 return mirror.declarations.values.toList(); |
| 59 } | 61 } |
| 60 | 62 |
| 61 List<ThinDeclarationMirror> buildMirrors(Type dartType) { | 63 List<ThinDeclarationMirror> buildMirrors(Type dartType) { |
| 62 return _query(dartType).map(makeThin).toList(); | 64 return _query(dartType).map(makeThin).toList(); |
| 63 } | 65 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 110 } |
| 109 | 111 |
| 110 // Check other methods from `polymer_basic_needs_lib`. | 112 // Check other methods from `polymer_basic_needs_lib`. |
| 111 A a = new A(); | 113 A a = new A(); |
| 112 write(a, "i", 7); | 114 write(a, "i", 7); |
| 113 expect(read(a, "i"), 7); | 115 expect(read(a, "i"), 7); |
| 114 invoke(a, "bar", [42]); | 116 invoke(a, "bar", [42]); |
| 115 expect(invoke(a, "foo", []), "OK!"); | 117 expect(invoke(a, "foo", []), "OK!"); |
| 116 }); | 118 }); |
| 117 } | 119 } |
| OLD | NEW |