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

Side by Side 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: Long lines and caching 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 library hierarchy_test;
6
7 @MirrorsUsed(targets: 'hierarchy_test')
8 import 'dart:mirrors';
9
10 import 'package:expect/expect.dart';
11
12 class FooMixin {
13 foo() => print('foo');
14 }
15
16 class Qux {
17 qux() => print('qux');
18 }
19
20 class Bar extends Qux implements FooMixin {
21 bar() => print('bar');
22 foo() => print('foo');
23 }
24
25 class Baz extends Qux with FooMixin {
26 bar() => print('bar');
27 }
28
29 stringifyHierarchy(mirror) {
30 var sb = new StringBuffer();
31 for (var type = mirror.type; type != null; type = type.superclass) {
32 sb.write('> ${MirrorSystem.getName(type.qualifiedName)}\n');
33 for (var i in type.superinterfaces) {
34 sb.write(' + ${MirrorSystem.getName(i.qualifiedName)}\n');
35 }
36 }
37 return '$sb';
38 }
39
40 main() {
41 Expect.stringEquals('''
42 > hierarchy_test.Bar
43 + hierarchy_test.FooMixin
44 > hierarchy_test.Qux
45 > dart.core.Object
46 ''', stringifyHierarchy(reflect(new Bar()..foo()..bar()..qux())));
47
48 // TODO(ahe): Using wrong mixin syntax, see http://dartbug.com/12464.
49 Expect.stringEquals('''
50 > hierarchy_test.Baz
51 > hierarchy_test.FooMixin(hierarchy_test.Qux)
52 + hierarchy_test.FooMixin
53 > hierarchy_test.Qux
54 > dart.core.Object
55 ''', stringifyHierarchy(reflect(new Baz()..foo()..bar()..qux())));
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698