Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: tests/lib/mirrors/method_mirror_properties_test.dart

Issue 19299003: Moved some MethodMirror properties from embedded API to native calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/lib/mirrors/method_mirror_properties_test.dart
diff --git a/tests/lib/mirrors/method_mirror_properties_test.dart b/tests/lib/mirrors/method_mirror_properties_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c29c6f843f009ac29c84000d37336e8647f7191e
--- /dev/null
+++ b/tests/lib/mirrors/method_mirror_properties_test.dart
@@ -0,0 +1,78 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "dart:mirrors";
+
+import "package:expect/expect.dart";
+
+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.equals(method.isStatic, kinds[0]);
+ Expect.equals(method.isAbstract, kinds[1]);
+ Expect.equals(method.isGetter, kinds[2]);
+ Expect.equals(method.isSetter, kinds[3]);
+ Expect.equals(method.isConstructor, kinds[4]);
+}
+
+main() {
+ // 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]);
+}

Powered by Google App Engine
This is Rietveld 408576698