Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 // TODO(ahe): This test is sligthly broken but provides temporary test coverage | |
| 6 // for dart2js. See http://dartbug.com/12464. | |
| 7 | |
| 8 library test.mixin_test; | 5 library test.mixin_test; |
| 9 | 6 |
| 10 @MirrorsUsed(targets: 'test.mixin_test, test.model, Object', override: '*') | 7 @MirrorsUsed(targets: 'test.mixin_test, test.model, Object', override: '*') |
| 11 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
| 12 | 9 |
| 13 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| 14 | 11 |
| 15 import 'model.dart'; | 12 import 'model.dart'; |
| 16 import 'stringify.dart'; | 13 import 'stringify.dart'; |
| 17 | 14 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 Expect.equals(a, b); | 55 Expect.equals(a, b); |
| 59 expect(stringify(a), b); | 56 expect(stringify(a), b); |
| 60 expect(stringify(b), a); | 57 expect(stringify(b), a); |
| 61 } | 58 } |
| 62 | 59 |
| 63 testMixin() { | 60 testMixin() { |
| 64 checkClass(Mixin, [ | 61 checkClass(Mixin, [ |
| 65 'Class(s(Mixin) in s(test.mixin_test), top-level)', | 62 'Class(s(Mixin) in s(test.mixin_test), top-level)', |
| 66 'Class(s(Object) in s(dart.core), top-level)', | 63 'Class(s(Object) in s(dart.core), top-level)', |
| 67 ]); | 64 ]); |
| 68 | |
| 69 expect( | 65 expect( |
| 70 '{i: Variable(s(i) in s(Mixin)),' | 66 '{i: Variable(s(i) in s(Mixin)),' |
| 71 ' m: Method(s(m) in s(Mixin))}', | 67 ' m: Method(s(m) in s(Mixin))}', |
| 72 reflectClass(Mixin).members); | 68 reflectClass(Mixin).members); |
| 73 | 69 expect( |
| 74 expect('{Mixin: Method(s(Mixin) in s(Mixin), constructor)}', | 70 '{Mixin: Method(s(Mixin) in s(Mixin), constructor)}', |
| 75 reflectClass(Mixin).constructors); | 71 reflectClass(Mixin).constructors); |
| 76 } | 72 } |
| 77 | 73 |
| 78 testMixin2() { | 74 testMixin2() { |
| 79 checkClass(Mixin2, [ | 75 checkClass(Mixin2, [ |
| 80 'Class(s(Mixin2) in s(test.mixin_test), top-level)', | 76 'Class(s(Mixin2) in s(test.mixin_test), top-level)', |
| 81 'Class(s(Object) in s(dart.core), top-level)', | 77 'Class(s(Object) in s(dart.core), top-level)', |
| 82 ]); | 78 ]); |
| 83 | |
| 84 expect( | 79 expect( |
| 85 '{i2: Variable(s(i2) in s(Mixin2)),' | 80 '{i2: Variable(s(i2) in s(Mixin2)),' |
| 86 ' m2: Method(s(m2) in s(Mixin2))}', | 81 ' m2: Method(s(m2) in s(Mixin2))}', |
| 87 reflectClass(Mixin2).members); | 82 reflectClass(Mixin2).members); |
| 88 | 83 expect( |
| 89 expect('{Mixin2: Method(s(Mixin2) in s(Mixin2), constructor)}', | 84 '{Mixin2: Method(s(Mixin2) in s(Mixin2), constructor)}', |
| 90 reflectClass(Mixin2).constructors); | 85 reflectClass(Mixin2).constructors); |
| 91 } | 86 } |
| 92 | 87 |
| 93 testMixinApplication() { | 88 testMixinApplication() { |
| 94 checkClass(MixinApplication, [ | 89 checkClass(MixinApplication, [ |
| 95 'Class(s(MixinApplication) in s(test.mixin_test), top-level)', | 90 'Class(s(MixinApplication) in s(test.mixin_test), top-level)', |
| 96 'Class(s(C) in s(test.model), top-level)', | 91 'Class(s(C) in s(test.model), top-level)', |
| 97 'Class(s(B) in s(test.model), top-level)', | 92 'Class(s(B) in s(test.model), top-level)', |
| 98 'Class(s(A) in s(test.model), top-level)', | 93 'Class(s(A) in s(test.model), top-level)', |
| 99 'Class(s(Object) in s(dart.core), top-level)', | 94 'Class(s(Object) in s(dart.core), top-level)', |
| 100 ]); | 95 ]); |
| 101 | 96 |
| 102 expect( | 97 expect( |
| 103 '{i: Variable(s(i) in s(MixinApplication)),' | 98 '{i: Variable(s(i) in s(Mixin)),' |
| 104 ' m: Method(s(m) in s(MixinApplication))}', | 99 ' m: Method(s(m) in s(Mixin))}', |
| 105 reflectClass(MixinApplication).members); | 100 reflectClass(MixinApplication).members); |
| 106 | 101 expect( |
| 107 expect('{MixinApplication: Method(s(MixinApplication) in s(MixinApplication),' | 102 '{MixinApplication: Method(s(MixinApplication) in s(MixinApplication),' |
| 108 ' constructor)}', | 103 ' constructor)}', |
| 109 reflectClass(MixinApplication).constructors); | 104 reflectClass(MixinApplication).constructors); |
| 110 | 105 |
| 111 expectSame(reflectClass(C), reflectClass(MixinApplication).superclass); | 106 expectSame(reflectClass(C), reflectClass(MixinApplication).superclass); |
| 112 } | 107 } |
| 113 | 108 |
| 114 testMixinApplicationA() { | 109 testMixinApplicationA() { |
| 115 checkClass(MixinApplicationA, [ | 110 checkClass(MixinApplicationA, [ |
| 116 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)', | 111 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)', |
| 117 'Class(s(test.mixin_test.Mixin(test.model.C)), top-level)', | 112 'Class(s(test.model.C with test.mixin_test.Mixin) in s(test.mixin_test),' |
| 113 ' top-level)', | |
| 118 'Class(s(C) in s(test.model), top-level)', | 114 'Class(s(C) in s(test.model), top-level)', |
| 119 'Class(s(B) in s(test.model), top-level)', | 115 'Class(s(B) in s(test.model), top-level)', |
| 120 'Class(s(A) in s(test.model), top-level)', | 116 'Class(s(A) in s(test.model), top-level)', |
| 121 'Class(s(Object) in s(dart.core), top-level)', | 117 'Class(s(Object) in s(dart.core), top-level)', |
| 122 ]); | 118 ]); |
| 123 | 119 |
| 124 expect( | 120 expect( |
| 125 // TODO(ahe): The owner should be the mixin. | 121 '{i2: Variable(s(i2) in s(Mixin2)),' |
| 126 '{i2: Variable(s(i2) in s(MixinApplicationA)),' | 122 ' m2: Method(s(m2) in s(Mixin2))}', |
| 127 ' m2: Method(s(m2) in s(MixinApplicationA))}', | |
| 128 reflectClass(MixinApplicationA).members); | 123 reflectClass(MixinApplicationA).members); |
| 129 | |
| 130 expect( | 124 expect( |
| 131 '{MixinApplicationA: Method(s(MixinApplicationA) in s(MixinApplicationA),' | 125 '{MixinApplicationA: Method(s(MixinApplicationA) in s(MixinApplicationA),' |
| 132 ' constructor)}', | 126 ' constructor)}', |
| 133 reflectClass(MixinApplicationA).constructors); | 127 reflectClass(MixinApplicationA).constructors); |
| 134 | 128 |
| 135 expect( | 129 expect( |
| 136 '{i: Variable(s(i) in s(Mixin)),' | 130 '{i: Variable(s(i) in s(Mixin)),' |
| 137 ' m: Method(s(m) in s(Mixin))}', | 131 ' m: Method(s(m) in s(Mixin))}', |
| 138 reflectClass(MixinApplicationA).superclass.members); | 132 reflectClass(MixinApplicationA).superclass.members); |
| 139 | |
| 140 expect( | 133 expect( |
| 141 // TODO(ahe): The owner should be the mixin application. | 134 '{test.model.C with test.mixin_test.Mixin:' |
|
ahe
2013/08/15 22:56:58
Yikes :-)
| |
| 142 '{Mixin: Method(s(Mixin) in s(Mixin), constructor)}', | 135 ' Method(s(test.model.C with test.mixin_test.Mixin)' |
| 136 ' in s(test.model.C with test.mixin_test.Mixin), constructor)}', | |
| 143 reflectClass(MixinApplicationA).superclass.constructors); | 137 reflectClass(MixinApplicationA).superclass.constructors); |
| 144 | 138 |
| 145 expectSame( | 139 expectSame( |
| 146 reflectClass(C), | 140 reflectClass(C), |
| 147 reflectClass(MixinApplicationA).superclass.superclass); | 141 reflectClass(MixinApplicationA).superclass.superclass); |
| 148 } | 142 } |
| 149 | 143 |
| 150 testUnusedMixinApplication() { | 144 testUnusedMixinApplication() { |
| 151 checkClass(UnusedMixinApplication, [ | 145 checkClass(UnusedMixinApplication, [ |
| 152 'Class(s(UnusedMixinApplication) in s(test.mixin_test), top-level)', | 146 'Class(s(UnusedMixinApplication) in s(test.mixin_test), top-level)', |
| 153 'Class(s(C) in s(test.model), top-level)', | 147 'Class(s(C) in s(test.model), top-level)', |
| 154 'Class(s(B) in s(test.model), top-level)', | 148 'Class(s(B) in s(test.model), top-level)', |
| 155 'Class(s(A) in s(test.model), top-level)', | 149 'Class(s(A) in s(test.model), top-level)', |
| 156 'Class(s(Object) in s(dart.core), top-level)', | 150 'Class(s(Object) in s(dart.core), top-level)', |
| 157 ]); | 151 ]); |
| 158 | 152 |
| 159 expect( | 153 expect( |
| 160 '{i: Variable(s(i) in s(UnusedMixinApplication)),' | 154 '{i: Variable(s(i) in s(Mixin)),' |
| 161 ' m: Method(s(m) in s(UnusedMixinApplication))}', | 155 ' m: Method(s(m) in s(Mixin))}', |
| 162 reflectClass(UnusedMixinApplication).members); | 156 reflectClass(UnusedMixinApplication).members); |
| 163 | |
| 164 expect( | 157 expect( |
| 165 '{UnusedMixinApplication: Method(s(UnusedMixinApplication)' | 158 '{UnusedMixinApplication: Method(s(UnusedMixinApplication)' |
| 166 ' in s(UnusedMixinApplication), constructor)}', | 159 ' in s(UnusedMixinApplication), constructor)}', |
| 167 reflectClass(UnusedMixinApplication).constructors); | 160 reflectClass(UnusedMixinApplication).constructors); |
| 168 | 161 |
| 169 expectSame(reflectClass(C), reflectClass(UnusedMixinApplication).superclass); | 162 expectSame(reflectClass(C), reflectClass(UnusedMixinApplication).superclass); |
| 170 } | 163 } |
| 171 | 164 |
| 172 testSubclass() { | 165 testSubclass() { |
| 173 checkClass(Subclass, [ | 166 checkClass(Subclass, [ |
| 174 'Class(s(Subclass) in s(test.mixin_test), top-level)', | 167 'Class(s(Subclass) in s(test.mixin_test), top-level)', |
| 175 'Class(s(test.mixin_test.Mixin(test.model.C)), top-level)', | 168 'Class(s(test.model.C with test.mixin_test.Mixin) in s(test.mixin_test),' |
| 169 ' top-level)', | |
| 176 'Class(s(C) in s(test.model), top-level)', | 170 'Class(s(C) in s(test.model), top-level)', |
| 177 'Class(s(B) in s(test.model), top-level)', | 171 'Class(s(B) in s(test.model), top-level)', |
| 178 'Class(s(A) in s(test.model), top-level)', | 172 'Class(s(A) in s(test.model), top-level)', |
| 179 'Class(s(Object) in s(dart.core), top-level)', | 173 'Class(s(Object) in s(dart.core), top-level)', |
| 180 ]); | 174 ]); |
| 181 | 175 |
| 182 expect( | 176 expect( |
| 183 '{f: Method(s(f) in s(Subclass))}', | 177 '{f: Method(s(f) in s(Subclass))}', |
| 184 reflectClass(Subclass).members); | 178 reflectClass(Subclass).members); |
| 185 | |
| 186 expect( | 179 expect( |
| 187 '{Subclass: Method(s(Subclass) in s(Subclass), constructor)}', | 180 '{Subclass: Method(s(Subclass) in s(Subclass), constructor)}', |
| 188 reflectClass(Subclass).constructors); | 181 reflectClass(Subclass).constructors); |
| 189 | 182 |
| 190 expect( | 183 expect( |
| 191 '{i: Variable(s(i) in s(Mixin)),' | 184 '{i: Variable(s(i) in s(Mixin)),' |
| 192 ' m: Method(s(m) in s(Mixin))}', | 185 ' m: Method(s(m) in s(Mixin))}', |
| 193 reflectClass(Subclass).superclass.members); | 186 reflectClass(Subclass).superclass.members); |
| 194 | |
| 195 expect( | 187 expect( |
| 196 // TODO(ahe): The owner should be the mixin application. | 188 '{test.model.C with test.mixin_test.Mixin:' |
| 197 '{Mixin: Method(s(Mixin) in s(Mixin), constructor)}', | 189 ' Method(s(test.model.C with test.mixin_test.Mixin)' |
| 190 ' in s(test.model.C with test.mixin_test.Mixin), constructor)}', | |
| 198 reflectClass(Subclass).superclass.constructors); | 191 reflectClass(Subclass).superclass.constructors); |
| 199 | 192 |
| 200 expectSame( | 193 expectSame( |
| 201 reflectClass(C), | 194 reflectClass(C), |
| 202 reflectClass(Subclass).superclass.superclass); | 195 reflectClass(Subclass).superclass.superclass); |
| 203 } | 196 } |
| 204 | 197 |
| 205 testSubclass2() { | 198 testSubclass2() { |
| 206 checkClass(Subclass2, [ | 199 checkClass(Subclass2, [ |
| 207 'Class(s(Subclass2) in s(test.mixin_test), top-level)', | 200 'Class(s(Subclass2) in s(test.mixin_test), top-level)', |
| 208 'Class(s(MixinApplication) in s(test.mixin_test), top-level)', | 201 'Class(s(MixinApplication) in s(test.mixin_test), top-level)', |
| 209 'Class(s(C) in s(test.model), top-level)', | 202 'Class(s(C) in s(test.model), top-level)', |
| 210 'Class(s(B) in s(test.model), top-level)', | 203 'Class(s(B) in s(test.model), top-level)', |
| 211 'Class(s(A) in s(test.model), top-level)', | 204 'Class(s(A) in s(test.model), top-level)', |
| 212 'Class(s(Object) in s(dart.core), top-level)', | 205 'Class(s(Object) in s(dart.core), top-level)', |
| 213 ]); | 206 ]); |
| 214 | 207 |
| 215 expect( | 208 expect( |
| 216 '{g: Method(s(g) in s(Subclass2))}', | 209 '{g: Method(s(g) in s(Subclass2))}', |
| 217 reflectClass(Subclass2).members); | 210 reflectClass(Subclass2).members); |
| 218 | |
| 219 expect( | 211 expect( |
| 220 '{Subclass2: Method(s(Subclass2) in s(Subclass2), constructor)}', | 212 '{Subclass2: Method(s(Subclass2) in s(Subclass2), constructor)}', |
| 221 reflectClass(Subclass2).constructors); | 213 reflectClass(Subclass2).constructors); |
| 222 | 214 |
| 223 expectSame( | 215 expectSame( |
| 224 reflectClass(MixinApplication), | 216 reflectClass(MixinApplication), |
| 225 reflectClass(Subclass2).superclass); | 217 reflectClass(Subclass2).superclass); |
| 226 } | 218 } |
| 227 | 219 |
| 228 testSubclassA() { | 220 testSubclassA() { |
| 229 checkClass(SubclassA, [ | 221 checkClass(SubclassA, [ |
| 230 'Class(s(SubclassA) in s(test.mixin_test), top-level)', | 222 'Class(s(SubclassA) in s(test.mixin_test), top-level)', |
| 231 'Class(s(test.mixin_test.Mixin2(test.mixin_test.Mixin(test.model.C))),' | 223 'Class(s(test.model.C with test.mixin_test.Mixin, test.mixin_test.Mixin2)' |
| 224 ' in s(test.mixin_test), top-level)', | |
| 225 'Class(s(test.model.C with test.mixin_test.Mixin) in s(test.mixin_test),' | |
| 232 ' top-level)', | 226 ' top-level)', |
| 233 'Class(s(test.mixin_test.Mixin(test.model.C)), top-level)', | |
| 234 'Class(s(C) in s(test.model), top-level)', | 227 'Class(s(C) in s(test.model), top-level)', |
| 235 'Class(s(B) in s(test.model), top-level)', | 228 'Class(s(B) in s(test.model), top-level)', |
| 236 'Class(s(A) in s(test.model), top-level)', | 229 'Class(s(A) in s(test.model), top-level)', |
| 237 'Class(s(Object) in s(dart.core), top-level)', | 230 'Class(s(Object) in s(dart.core), top-level)', |
| 238 ]); | 231 ]); |
| 239 | 232 |
| 240 expect( | 233 expect( |
| 241 '{fa: Method(s(fa) in s(SubclassA))}', | 234 '{fa: Method(s(fa) in s(SubclassA))}', |
| 242 reflectClass(SubclassA).members); | 235 reflectClass(SubclassA).members); |
| 243 | |
| 244 expect( | 236 expect( |
| 245 '{SubclassA: Method(s(SubclassA) in s(SubclassA), constructor)}', | 237 '{SubclassA: Method(s(SubclassA) in s(SubclassA), constructor)}', |
| 246 reflectClass(SubclassA).constructors); | 238 reflectClass(SubclassA).constructors); |
| 247 | 239 |
| 248 expect( | 240 expect( |
| 249 '{i2: Variable(s(i2) in s(Mixin2)),' | 241 '{i2: Variable(s(i2) in s(Mixin2)),' |
| 250 ' m2: Method(s(m2) in s(Mixin2))}', | 242 ' m2: Method(s(m2) in s(Mixin2))}', |
| 251 reflectClass(SubclassA).superclass.members); | 243 reflectClass(SubclassA).superclass.members); |
| 252 | |
| 253 expect( | 244 expect( |
| 254 // TODO(ahe): The owner should be the mixin application. | 245 '{test.model.C with test.mixin_test.Mixin, test.mixin_test.Mixin2:' |
| 255 '{Mixin2: Method(s(Mixin2) in s(Mixin2), constructor)}', | 246 ' Method(s(test.model.C with test.mixin_test.Mixin,' |
| 247 ' test.mixin_test.Mixin2) in s(test.model.C with test.mixin_test.Mixin,' | |
| 248 ' test.mixin_test.Mixin2), constructor)}', | |
| 256 reflectClass(SubclassA).superclass.constructors); | 249 reflectClass(SubclassA).superclass.constructors); |
| 257 | 250 |
| 258 expect( | 251 expect( |
| 259 '{i: Variable(s(i) in s(Mixin)),' | 252 '{i: Variable(s(i) in s(Mixin)),' |
| 260 ' m: Method(s(m) in s(Mixin))}', | 253 ' m: Method(s(m) in s(Mixin))}', |
| 261 reflectClass(SubclassA).superclass.superclass.members); | 254 reflectClass(SubclassA).superclass.superclass.members); |
| 262 | |
| 263 expect( | 255 expect( |
| 264 // TODO(ahe): The owner should be the mixin application. | 256 '{test.model.C with test.mixin_test.Mixin:' |
| 265 '{Mixin: Method(s(Mixin) in s(Mixin), constructor)}', | 257 ' Method(s(test.model.C with test.mixin_test.Mixin)' |
| 258 ' in s(test.model.C with test.mixin_test.Mixin), constructor)}', | |
| 266 reflectClass(SubclassA).superclass.superclass.constructors); | 259 reflectClass(SubclassA).superclass.superclass.constructors); |
| 267 | 260 |
| 268 expectSame( | 261 expectSame( |
| 269 reflectClass(C), | 262 reflectClass(C), |
| 270 reflectClass(SubclassA).superclass.superclass.superclass); | 263 reflectClass(SubclassA).superclass.superclass.superclass); |
| 271 } | 264 } |
| 272 | 265 |
| 273 testSubclass2A() { | 266 testSubclass2A() { |
| 274 checkClass(Subclass2A, [ | 267 checkClass(Subclass2A, [ |
| 275 'Class(s(Subclass2A) in s(test.mixin_test), top-level)', | 268 'Class(s(Subclass2A) in s(test.mixin_test), top-level)', |
| 276 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)', | 269 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)', |
| 277 'Class(s(test.mixin_test.Mixin(test.model.C)), top-level)', | 270 'Class(s(test.model.C with test.mixin_test.Mixin) in s(test.mixin_test),' |
| 271 ' top-level)', | |
| 278 'Class(s(C) in s(test.model), top-level)', | 272 'Class(s(C) in s(test.model), top-level)', |
| 279 'Class(s(B) in s(test.model), top-level)', | 273 'Class(s(B) in s(test.model), top-level)', |
| 280 'Class(s(A) in s(test.model), top-level)', | 274 'Class(s(A) in s(test.model), top-level)', |
| 281 'Class(s(Object) in s(dart.core), top-level)', | 275 'Class(s(Object) in s(dart.core), top-level)', |
| 282 ]); | 276 ]); |
| 283 | 277 |
| 284 expect( | 278 expect( |
| 285 '{ga: Method(s(ga) in s(Subclass2A))}', | 279 '{ga: Method(s(ga) in s(Subclass2A))}', |
| 286 reflectClass(Subclass2A).members); | 280 reflectClass(Subclass2A).members); |
| 287 | |
| 288 expect( | 281 expect( |
| 289 '{Subclass2A: Method(s(Subclass2A) in s(Subclass2A), constructor)}', | 282 '{Subclass2A: Method(s(Subclass2A) in s(Subclass2A), constructor)}', |
| 290 reflectClass(Subclass2A).constructors); | 283 reflectClass(Subclass2A).constructors); |
| 291 | 284 |
| 292 expectSame(reflectClass(MixinApplicationA), | 285 expectSame(reflectClass(MixinApplicationA), |
| 293 reflectClass(Subclass2A).superclass); | 286 reflectClass(Subclass2A).superclass); |
| 294 } | 287 } |
| 295 | 288 |
| 296 main() { | 289 main() { |
| 297 testMixin(); | 290 testMixin(); |
| 298 testMixin2(); | 291 testMixin2(); |
| 299 testMixinApplication(); | 292 testMixinApplication(); |
| 300 testMixinApplicationA(); | 293 testMixinApplicationA(); |
| 301 testUnusedMixinApplication(); | 294 testUnusedMixinApplication(); |
| 302 testSubclass(); | 295 testSubclass(); |
| 303 testSubclass2(); | 296 testSubclass2(); |
| 304 testSubclassA(); | 297 testSubclassA(); |
| 305 testSubclass2A(); | 298 testSubclass2A(); |
| 306 } | 299 } |
| OLD | NEW |