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

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

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

Powered by Google App Engine
This is Rietveld 408576698