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

Unified Diff: test/codegen/lib/mirrors/method_mirror_properties_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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: test/codegen/lib/mirrors/method_mirror_properties_test.dart
diff --git a/test/codegen/lib/mirrors/method_mirror_properties_test.dart b/test/codegen/lib/mirrors/method_mirror_properties_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4d45a3153fdebee83c79a1c1170b92e874668629
--- /dev/null
+++ b/test/codegen/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; }
+
+abstract class AbstractC {
+
+ AbstractC();
+
+ void bar();
+ get priv;
+ set priv(value);
+}
+
+abstract 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(kinds[0], method.isStatic, "isStatic");
+ Expect.equals(kinds[1], method.isAbstract, "isAbstract");
+ Expect.equals(kinds[2], method.isGetter, "isGetter");
+ Expect.equals(kinds[3], method.isSetter, "isSetter");
+ Expect.equals(kinds[4], method.isConstructor, "isConstructor");
+}
+
+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.declarations[#topGetter],
+ [true, false, true, false, false]);
+ checkKinds(libraryMirror.declarations[const Symbol("topSetter=")],
+ [true, false, false, true, false]);
+ var classMirror;
+ classMirror = reflectClass(C);
+ checkKinds(classMirror.declarations[#foo],
+ [true, false, false, false, false]);
+ checkKinds(classMirror.declarations[#priv],
+ [false, false, true, false, false]);
+ checkKinds(classMirror.declarations[const Symbol("priv=")],
+ [false, false, false, true, false]);
+ checkKinds(classMirror.declarations[#C],
+ [false, false, false, false, true]);
+ checkKinds(classMirror.declarations[#C.other],
+ [false, false, false, false, true]);
+ checkKinds(classMirror.declarations[#C.other2],
+ [false, false, false, false, true]);
+ classMirror = reflectClass(AbstractC);
+ checkKinds(classMirror.declarations[#AbstractC],
+ [false, false, false, false, true]);
+ checkKinds(classMirror.declarations[#bar],
+ [false, true, false, false, false]);
+ checkKinds(classMirror.declarations[#priv],
+ [false, true, true, false, false]);
+ checkKinds(classMirror.declarations[const Symbol("priv=")],
+ [false, true, false, true, false]);
+}
« no previous file with comments | « test/codegen/lib/mirrors/method_mirror_name_test.dart ('k') | test/codegen/lib/mirrors/method_mirror_returntype_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698