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