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

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

Issue 2997283003: Migrated test lock 217 to Dart 2.0. (Closed)
Patch Set: Addressed comments Created 3 years, 3 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
« no previous file with comments | « tests/lib/math/rectangle_test.dart ('k') | tests/lib/mirrors/abstract_test.dart » ('j') | 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 @MirrorsUsed(targets: "test.abstract_class_test")
8 import 'dart:mirrors';
9 import 'package:expect/expect.dart';
10
11 void main() {
12 testSimple();
13 testFunctionType();
14 testFakeFunction();
15 testGeneric();
16 testAnonMixinApplication();
17 testNamedMixinApplication();
18 }
19
20 abstract class Foo {
21 foo();
22 }
23
24 class Bar extends Foo {
25 foo() {}
26 }
27
28 testSimple() {
29 Expect.isTrue(reflectClass(Foo).isAbstract);
30 Expect.isFalse(reflectClass(Bar).isAbstract);
31 Expect.isTrue(reflect(new Bar()).type.superclass.isAbstract);
32 Expect.isFalse(reflect(new Bar()).type.isAbstract);
33 }
34
35 void baz() {}
36
37 testFunctionType() {
38 Expect.isFalse(reflect(baz).type.isAbstract);
39 }
40
41 abstract class FunctionFoo implements Function {
42 call();
43 }
44
45 class FunctionBar extends FunctionFoo {
46 call() {}
47 }
48
49 testFakeFunction() {
50 Expect.isTrue(reflectClass(FunctionFoo).isAbstract);
51 Expect.isFalse(reflectClass(FunctionBar).isAbstract);
52 Expect.isTrue(reflect(new FunctionBar()).type.superclass.isAbstract);
53 Expect.isFalse(reflect(new FunctionBar()).type.isAbstract);
54 }
55
56 abstract class GenericFoo<T> {
57 T genericFoo();
58 }
59
60 class GenericBar<T> extends GenericFoo<T> {
61 T genericFoo() {}
62 }
63
64 testGeneric() {
65 // Unbound.
66 Expect.isTrue(reflectClass(GenericFoo).isAbstract);
67 Expect.isFalse(reflectClass(GenericBar).isAbstract);
68 // Bound.
69 Expect.isTrue(reflect(new GenericBar<int>()).type.superclass.isAbstract);
70 Expect.isFalse(reflect(new GenericBar<int>()).type.isAbstract);
71 }
72
73 class S {}
74
75 abstract class M {
76 mixinFoo();
77 }
78
79 abstract class MA extends S with M {}
80
81 class SubMA extends MA {
82 mixinFoo() {}
83 }
84
85 class ConcreteMA extends S with M {
86 mixinFoo() {}
87 }
88
89 class M2 {
90 mixin2Foo() {}
91 }
92
93 abstract class MA2 extends S with M2 {
94 mixinBar();
95 }
96
97 class SubMA2 extends MA2 {
98 mixinBar() {}
99 }
100
101 class ConcreteMA2 extends S with M2 {
102 mixin2Foo() {}
103 }
104
105 testAnonMixinApplication() {
106 // Application is abstract.
107 {
108 // Mixin is abstract.
109 Expect.isFalse(reflectClass(SubMA).isAbstract);
110 Expect.isTrue(reflectClass(SubMA).superclass.isAbstract);
111 Expect.isFalse(reflectClass(SubMA).superclass.superclass.isAbstract);
112 Expect.isTrue(reflectClass(MA).isAbstract);
113 Expect.isFalse(reflectClass(MA).superclass.isAbstract);
114
115 // Mixin is concrete.
116 Expect.isFalse(reflectClass(SubMA2).isAbstract);
117 Expect.isTrue(reflectClass(SubMA2).superclass.isAbstract);
118 Expect.isFalse(reflectClass(SubMA2).superclass.superclass.isAbstract);
119 Expect.isTrue(reflectClass(MA2).isAbstract);
120 Expect.isFalse(reflectClass(MA2).superclass.isAbstract);
121 }
122
123 // Application is concrete.
124 {
125 // Mixin is abstract.
126 Expect.isFalse(reflectClass(ConcreteMA).isAbstract);
127 Expect.isFalse(reflectClass(ConcreteMA).superclass.isAbstract);
128 Expect.isFalse(reflectClass(ConcreteMA).superclass.superclass.isAbstract);
129
130 // Mixin is concrete.
131 Expect.isFalse(reflectClass(ConcreteMA2).isAbstract);
132 Expect.isFalse(reflectClass(ConcreteMA2).superclass.isAbstract);
133 Expect.isFalse(reflectClass(ConcreteMA2).superclass.superclass.isAbstract);
134 }
135 }
136
137 abstract class NamedMA = S with M;
138
139 class SubNamedMA extends NamedMA {
140 mixinFoo() {}
141 }
142 class ConcreteNamedMA = S with M; //# 00: static type warning
143
144 abstract class NamedMA2 = S with M2;
145
146 class SubNamedMA2 extends NamedMA2 {
147 mixinFoo() {}
148 }
149
150 class ConcreteNamedMA2 = S with M2;
151
152 testNamedMixinApplication() {
153 // Application is abstract.
154 {
155 // Mixin is abstract.
156 Expect.isFalse(reflectClass(SubNamedMA).isAbstract);
157 Expect.isTrue(reflectClass(SubNamedMA).superclass.isAbstract);
158 Expect.isFalse(reflectClass(SubNamedMA).superclass.superclass.isAbstract);
159 Expect.isTrue(reflectClass(NamedMA).isAbstract);
160 Expect.isFalse(reflectClass(NamedMA).superclass.isAbstract);
161
162 // Mixin is concrete.
163 Expect.isFalse(reflectClass(SubNamedMA2).isAbstract);
164 Expect.isTrue(reflectClass(SubNamedMA2).superclass.isAbstract);
165 Expect.isFalse(reflectClass(SubNamedMA2).superclass.superclass.isAbstract);
166 Expect.isTrue(reflectClass(NamedMA2).isAbstract);
167 Expect.isFalse(reflectClass(NamedMA2).superclass.isAbstract);
168 }
169
170 // Application is concrete.
171 {
172 // Mixin is abstract.
173 Expect.isFalse(reflectClass(ConcreteNamedMA).isAbstract); //# 00: ok
174 Expect.isFalse(reflectClass(ConcreteNamedMA).superclass.isAbstract); //# 00: o k
175
176 // Mixin is concrete.
177 Expect.isFalse(reflectClass(ConcreteNamedMA2).isAbstract);
178 Expect.isFalse(reflectClass(ConcreteNamedMA2).superclass.isAbstract);
179 }
180 }
OLDNEW
« no previous file with comments | « tests/lib/math/rectangle_test.dart ('k') | tests/lib/mirrors/abstract_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698