Chromium Code Reviews| Index: tests/lib/mirrors/method_mirror_test.dart |
| diff --git a/tests/lib/mirrors/method_mirror_test.dart b/tests/lib/mirrors/method_mirror_test.dart |
| index 16851c9c209a1634de02ddac7d1103fd82c14204..306d8570f6089833d0d94530d3d90b90c86ea215 100644 |
| --- a/tests/lib/mirrors/method_mirror_test.dart |
| +++ b/tests/lib/mirrors/method_mirror_test.dart |
| @@ -12,10 +12,78 @@ String _symbolToString(Symbol sym) { |
| doNothing42() {} |
| +int _x = 5; |
| +int get topGetter => _x; |
| +void set topSetter(x) { _x = x } |
| + |
| +class AbstractC { |
| + |
| + AbstractC(); |
| + |
| + void bar(); |
| + get priv; |
| + set priv(value); |
| +} |
| + |
| +class C extends AbstractC { |
| + |
| + static foo() {} |
| + |
| + C(); |
| + C.other(); |
| + C.other2() : this.other(); |
| + |
| + var _priv; |
| + get priv => _priv; |
| + set priv(value) => _priv = value; |
| +} |
| + |
| +checkKinds(method, kinds) { |
| + expect(method.isStatic, kinds[0]); |
| + expect(method.isAbstract, kinds[1]); |
| + expect(method.isGetter, kinds[2]); |
| + expect(method.isSetter, kinds[3]); |
| + expect(method.isConstructor, kinds[4]); |
| +} |
| + |
| main() { |
| // Regression test for http://www.dartbug.com/6335 |
| test("NamedMethodName", () { |
| var closureMirror = reflect(doNothing42); |
| expect(_symbolToString(closureMirror.function.simpleName), "doNothing42"); |
| }); |
| + test("FunctionKinds", () { |
|
ahe
2013/07/16 20:36:53
As far as I can tell, the added tests reuse virtua
Michael Lippautz (Google)
2013/07/16 21:14:00
Done.
|
| + // Top level functions should be static. |
| + var closureMirror = reflect(doNothing42); |
| + checkKinds(closureMirror.function, |
| + [true, false, false, false, false]); |
| + var libraryMirror = reflectClass(C).owner; |
| + checkKinds(libraryMirror.getters[const Symbol("topGetter")], |
| + [true, false, true, false, false]); |
| + checkKinds(libraryMirror.setters[const Symbol("topSetter=")], |
| + [true, false, false, true, false]); |
| + var classMirror; |
| + classMirror = reflectClass(C); |
| + checkKinds(classMirror.members[const Symbol("foo")], |
| + [true, false, false, false, false]); |
| + checkKinds(classMirror.members[const Symbol("priv")], |
| + [false, false, true, false, false]); |
| + checkKinds(classMirror.members[const Symbol("priv=")], |
| + [false, false, false, true, false]); |
| + checkKinds(classMirror.constructors[const Symbol("C")], |
| + [false, false, false, false, true]); |
| + checkKinds(classMirror.constructors[const Symbol("C.other")], |
| + [false, false, false, false, true]); |
| + checkKinds(classMirror.constructors[const Symbol("C.other2")], |
| + [false, false, false, false, true]); |
| + classMirror = reflectClass(AbstractC); |
| + checkKinds(classMirror.constructors[const Symbol("AbstractC")], |
| + [false, false, false, false, true]); |
| + checkKinds(classMirror.members[const Symbol("bar")], |
| + [false, true, false, false, false]); |
| + checkKinds(classMirror.members[const Symbol("priv")], |
| + [false, true, true, false, false]); |
| + checkKinds(classMirror.members[const Symbol("priv=")], |
| + [false, true, false, true, false]); |
| + }); |
| } |