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

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

Issue 23226002: Implement ClassMirror.superinterfaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 7 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
« no previous file with comments | « dart/tests/lib/lib.status ('k') | dart/tests/lib/mirrors/mixin_members_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/lib/mirrors/hierarchy_test.dart
diff --git a/dart/tests/lib/mirrors/hierarchy_test.dart b/dart/tests/lib/mirrors/hierarchy_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..44ad0f215bb1de6bbcba84cd19b2ef0de052e6af
--- /dev/null
+++ b/dart/tests/lib/mirrors/hierarchy_test.dart
@@ -0,0 +1,56 @@
+// 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.
+
+library hierarchy_test;
+
+@MirrorsUsed(targets: 'hierarchy_test, Object')
+import 'dart:mirrors';
+
+import 'package:expect/expect.dart';
+
+class FooMixin {
+ foo() => print('foo');
+}
+
+class Qux {
+ qux() => print('qux');
+}
+
+class Bar extends Qux implements FooMixin {
+ bar() => print('bar');
+ foo() => print('foo');
+}
+
+class Baz extends Qux with FooMixin {
+ bar() => print('bar');
+}
+
+stringifyHierarchy(mirror) {
+ var sb = new StringBuffer();
+ for (var type = mirror.type; type != null; type = type.superclass) {
+ sb.write('> ${MirrorSystem.getName(type.qualifiedName)}\n');
+ for (var i in type.superinterfaces) {
+ sb.write(' + ${MirrorSystem.getName(i.qualifiedName)}\n');
+ }
+ }
+ return '$sb';
+}
+
+main() {
+ Expect.stringEquals('''
+> hierarchy_test.Bar
+ + hierarchy_test.FooMixin
+> hierarchy_test.Qux
+> dart.core.Object
+''', stringifyHierarchy(reflect(new Bar()..foo()..bar()..qux())));
+
+ // TODO(ahe): Using wrong mixin syntax, see http://dartbug.com/12464.
+ Expect.stringEquals('''
+> hierarchy_test.Baz
+> hierarchy_test.FooMixin(hierarchy_test.Qux)
+ + hierarchy_test.FooMixin
+> hierarchy_test.Qux
+> dart.core.Object
+''', stringifyHierarchy(reflect(new Baz()..foo()..bar()..qux())));
+}
« no previous file with comments | « dart/tests/lib/lib.status ('k') | dart/tests/lib/mirrors/mixin_members_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698