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

Side by Side Diff: tests/lib_strong/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_strong/math/rectangle_test.dart ('k') | tests/lib_strong/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 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
23 class Bar extends Foo {
24 foo() {}
25 }
26
27 testSimple() {
28 Expect.isTrue(reflectClass(Foo).isAbstract);
29 Expect.isFalse(reflectClass(Bar).isAbstract);
30 Expect.isTrue(reflect(new Bar()).type.superclass.isAbstract);
31 Expect.isFalse(reflect(new Bar()).type.isAbstract);
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
44 class FunctionBar extends FunctionFoo {
45 call() {}
46 }
47
48 testFakeFunction() {
49 Expect.isTrue(reflectClass(FunctionFoo).isAbstract);
50 Expect.isFalse(reflectClass(FunctionBar).isAbstract);
51 Expect.isTrue(reflect(new FunctionBar()).type.superclass.isAbstract);
52 Expect.isFalse(reflect(new FunctionBar()).type.isAbstract);
53 }
54
55 abstract class GenericFoo<T> {
56 T genericFoo();
57 }
58
59 class GenericBar<T> extends GenericFoo<T> {
60 T genericFoo() {}
61 }
62
63 testGeneric() {
64 // Unbound.
65 Expect.isTrue(reflectClass(GenericFoo).isAbstract);
66 Expect.isFalse(reflectClass(GenericBar).isAbstract);
67 // Bound.
68 Expect.isTrue(reflect(new GenericBar<int>()).type.superclass.isAbstract);
69 Expect.isFalse(reflect(new GenericBar<int>()).type.isAbstract);
70 }
71
72 class S {}
73
74 abstract class M {
75 mixinFoo();
76 }
77
78 abstract class MA extends S with M {}
79
80 class SubMA extends MA {
81 mixinFoo() {}
82 }
83
84 class ConcreteMA extends S with M {
85 mixinFoo() {}
86 }
87
88 class M2 {
89 mixin2Foo() {}
90 }
91
92 abstract class MA2 extends S with M2 {
93 mixinBar();
94 }
95
96 class SubMA2 extends MA2 {
97 mixinBar() {}
98 }
99
100 class ConcreteMA2 extends S with M2 {
101 mixin2Foo() {}
102 }
103
104 testAnonMixinApplication() {
105 // Application is abstract.
106 {
107 // Mixin is abstract.
108 Expect.isFalse(reflectClass(SubMA).isAbstract);
109 Expect.isTrue(reflectClass(SubMA).superclass.isAbstract);
110 Expect.isFalse(reflectClass(SubMA).superclass.superclass.isAbstract);
111 Expect.isTrue(reflectClass(MA).isAbstract);
112 Expect.isFalse(reflectClass(MA).superclass.isAbstract);
113
114 // Mixin is concrete.
115 Expect.isFalse(reflectClass(SubMA2).isAbstract);
116 Expect.isTrue(reflectClass(SubMA2).superclass.isAbstract);
117 Expect.isFalse(reflectClass(SubMA2).superclass.superclass.isAbstract);
118 Expect.isTrue(reflectClass(MA2).isAbstract);
119 Expect.isFalse(reflectClass(MA2).superclass.isAbstract);
120 }
121
122 // Application is concrete.
123 {
124 // Mixin is abstract.
125 Expect.isFalse(reflectClass(ConcreteMA).isAbstract);
126 Expect.isFalse(reflectClass(ConcreteMA).superclass.isAbstract);
127 Expect.isFalse(reflectClass(ConcreteMA).superclass.superclass.isAbstract);
128
129 // Mixin is concrete.
130 Expect.isFalse(reflectClass(ConcreteMA2).isAbstract);
131 Expect.isFalse(reflectClass(ConcreteMA2).superclass.isAbstract);
132 Expect.isFalse(reflectClass(ConcreteMA2).superclass.superclass.isAbstract);
133 }
134 }
135
136 abstract class NamedMA = S with M;
137
138 class SubNamedMA extends NamedMA {
139 mixinFoo() {}
140 }
141 class ConcreteNamedMA = S with M; //# 00: static type warning
142
143 abstract class NamedMA2 = S with M2;
144
145 class SubNamedMA2 extends NamedMA2 {
146 mixinFoo() {}
147 }
148
149 class ConcreteNamedMA2 = S with M2;
150
151 testNamedMixinApplication() {
152 // Application is abstract.
153 {
154 // Mixin is abstract.
155 Expect.isFalse(reflectClass(SubNamedMA).isAbstract);
156 Expect.isTrue(reflectClass(SubNamedMA).superclass.isAbstract);
157 Expect.isFalse(reflectClass(SubNamedMA).superclass.superclass.isAbstract);
158 Expect.isTrue(reflectClass(NamedMA).isAbstract);
159 Expect.isFalse(reflectClass(NamedMA).superclass.isAbstract);
160
161 // Mixin is concrete.
162 Expect.isFalse(reflectClass(SubNamedMA2).isAbstract);
163 Expect.isTrue(reflectClass(SubNamedMA2).superclass.isAbstract);
164 Expect.isFalse(reflectClass(SubNamedMA2).superclass.superclass.isAbstract);
165 Expect.isTrue(reflectClass(NamedMA2).isAbstract);
166 Expect.isFalse(reflectClass(NamedMA2).superclass.isAbstract);
167 }
168
169 // Application is concrete.
170 {
171 // Mixin is abstract.
172 Expect.isFalse(reflectClass(ConcreteNamedMA).isAbstract); //# 00: ok
173 Expect.isFalse(reflectClass(ConcreteNamedMA).superclass.isAbstract); //# 00: o k
174
175 // Mixin is concrete.
176 Expect.isFalse(reflectClass(ConcreteNamedMA2).isAbstract);
177 Expect.isFalse(reflectClass(ConcreteNamedMA2).superclass.isAbstract);
178 }
179 }
OLDNEW
« no previous file with comments | « tests/lib_strong/math/rectangle_test.dart ('k') | tests/lib_strong/mirrors/abstract_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698