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

Side by Side Diff: tests/lib/mirrors/abstract_class_test.dart

Issue 129883002: Add ClassMirror.isAbstract to the API and VM implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 test.abstract_class_test;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9
10 void main() {
11 testSimple();
12 testFunctionType();
13 testFakeFunction();
14 testGeneric();
15 testAnonMixinApplication();
16 testNamedMixinApplication();
17 }
18
19 abstract class Foo {
20 foo();
21 }
22 class Bar extends Foo {
23 foo() {}
24 }
25
26 testSimple() {
27 Expect.isTrue(reflectClass(Foo).isAbstract);
28 Expect.isFalse(reflectClass(Bar).isAbstract);
29 Expect.isTrue(reflect(new Bar()).type.superclass.isAbstract);
30 Expect.isFalse(reflect(new Bar()).type.isAbstract);
31 }
32
33
34 void baz() {}
35
36 testFunctionType() {
37 Expect.isFalse(reflect(baz).type.isAbstract);
38 }
39
40 abstract class FunctionFoo implements Function {
41 call();
42 }
43 class FunctionBar extends FunctionFoo {
44 call() {}
45 }
46
47 testFakeFunction() {
48 Expect.isTrue(reflectClass(FunctionFoo).isAbstract);
49 Expect.isFalse(reflectClass(FunctionBar).isAbstract);
50 Expect.isTrue(reflect(new FunctionBar()).type.superclass.isAbstract);
51 Expect.isFalse(reflect(new FunctionBar()).type.isAbstract);
52 }
53
54 abstract class GenericFoo<T> {
55 T genericFoo();
56 }
57 class GenericBar<T> extends GenericFoo<T> {
58 T genericFoo() {}
59 }
60
61 testGeneric() {
62 // Unbound.
63 Expect.isTrue(reflectClass(GenericFoo).isAbstract);
64 Expect.isFalse(reflectClass(GenericBar).isAbstract);
65 // Bound.
66 Expect.isTrue(reflect(new GenericBar<int>()).type.superclass.isAbstract);
67 Expect.isFalse(reflect(new GenericBar<int>()).type.isAbstract);
68 }
69
70
71 class S {}
72 abstract class M {
73 mixinFoo();
74 }
75 abstract class MA extends S with M {
76 }
77 class SubMA extends MA {
78 mixinFoo() {}
79 }
80 class ConcreteMA extends S with M {
81 mixinFoo() {}
82 }
83
84 class M2 {
85 mixin2Foo() {}
86 }
87 abstract class MA2 extends S with M2 {
88 mixinBar();
89 }
90 class SubMA2 extends MA2 {
91 mixinBar() {}
92 }
93 class ConcreteMA2 extends S with M2 {
94 mixin2Foo() {}
95 }
96
97 testAnonMixinApplication() {
98 // Application is abstract.
99 {
100 // Mixin is abstract.
101 Expect.isFalse(reflectClass(SubMA).isAbstract);
102 Expect.isTrue(reflectClass(SubMA).superclass.isAbstract);
103 Expect.isFalse(reflectClass(SubMA).superclass.superclass.isAbstract);
104 Expect.isTrue(reflectClass(MA).isAbstract);
105 Expect.isFalse(reflectClass(MA).superclass.isAbstract);
106
107 // Mixin is concrete.
108 Expect.isFalse(reflectClass(SubMA2).isAbstract);
109 Expect.isTrue(reflectClass(SubMA2).superclass.isAbstract);
110 Expect.isFalse(reflectClass(SubMA2).superclass.superclass.isAbstract);
111 Expect.isTrue(reflectClass(MA2).isAbstract);
112 Expect.isFalse(reflectClass(MA2).superclass.isAbstract);
113 }
114
115 // Application is concrete.
116 {
117 // Mixin is abstract.
118 Expect.isFalse(reflectClass(ConcreteMA).isAbstract);
119 Expect.isFalse(reflectClass(ConcreteMA).superclass.isAbstract);
120 Expect.isFalse(reflectClass(ConcreteMA).superclass.superclass.isAbstract);
121
122 // Mixin is concrete.
123 Expect.isFalse(reflectClass(ConcreteMA2).isAbstract);
124 Expect.isFalse(reflectClass(ConcreteMA2).superclass.isAbstract);
125 Expect.isFalse(reflectClass(ConcreteMA2).superclass.superclass.isAbstract);
126 }
127 }
128
129 abstract class NamedMA = S with M;
130 class SubNamedMA extends NamedMA {
131 mixinFoo() {}
132 }
133 class ConcreteNamedMA = S with M;
134
135 abstract class NamedMA2 = S with M2;
136 class SubNamedMA2 extends NamedMA2 {
137 mixinFoo() {}
138 }
139 class ConcreteNamedMA2 = S with M2;
140
141 testNamedMixinApplication() {
142 // Application is abstract.
143 {
144 // Mixin is abstract.
145 Expect.isFalse(reflectClass(SubNamedMA).isAbstract);
146 Expect.isTrue(reflectClass(SubNamedMA).superclass.isAbstract);
147 Expect.isFalse(reflectClass(SubNamedMA).superclass.superclass.isAbstract);
148 Expect.isTrue(reflectClass(NamedMA).isAbstract);
149 Expect.isFalse(reflectClass(NamedMA).superclass.isAbstract);
150
151 // Mixin is concrete.
152 Expect.isFalse(reflectClass(SubNamedMA2).isAbstract);
153 Expect.isTrue(reflectClass(SubNamedMA2).superclass.isAbstract);
154 Expect.isFalse(reflectClass(SubNamedMA2).superclass.superclass.isAbstract);
155 Expect.isTrue(reflectClass(NamedMA2).isAbstract);
156 Expect.isFalse(reflectClass(NamedMA2).superclass.isAbstract);
157 }
158
159 // Application is concrete.
160 {
161 // Mixin is abstract.
162 Expect.isFalse(reflectClass(ConcreteNamedMA).isAbstract);
163 Expect.isFalse(reflectClass(ConcreteNamedMA).superclass.isAbstract);
164
165 // Mixin is concrete.
166 Expect.isFalse(reflectClass(ConcreteNamedMA2).isAbstract);
167 Expect.isFalse(reflectClass(ConcreteNamedMA2).superclass.isAbstract);
168 }
169 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698