| OLD | NEW |
| 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 /// Common test code that is run by 3 tests: mirrors_test.dart, | 5 /// Common test code that is run by 3 tests: mirrors_test.dart, |
| 6 /// mirrors_used_test.dart, and static_test.dart. | 6 /// mirrors_used_test.dart, and static_test.dart. |
| 7 library smoke.test.common; | 7 library smoke.test.common; |
| 8 | 8 |
| 9 import 'package:smoke/smoke.dart' as smoke; | 9 import 'package:smoke/smoke.dart' as smoke; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 expect(smoke.isSubclassOf(A, Object), isTrue); | 208 expect(smoke.isSubclassOf(A, Object), isTrue); |
| 209 expect(smoke.isSubclassOf(AnnotB, Annot), isTrue); | 209 expect(smoke.isSubclassOf(AnnotB, Annot), isTrue); |
| 210 | 210 |
| 211 expect(smoke.isSubclassOf(D, A), isFalse); | 211 expect(smoke.isSubclassOf(D, A), isFalse); |
| 212 expect(smoke.isSubclassOf(H, B), isFalse); | 212 expect(smoke.isSubclassOf(H, B), isFalse); |
| 213 expect(smoke.isSubclassOf(B, A), isFalse); | 213 expect(smoke.isSubclassOf(B, A), isFalse); |
| 214 expect(smoke.isSubclassOf(Object, A), isFalse); | 214 expect(smoke.isSubclassOf(Object, A), isFalse); |
| 215 }); | 215 }); |
| 216 | 216 |
| 217 group('query', () { | 217 group('query', () { |
| 218 _checkQuery(result, names) { |
| 219 expect(result.map((e) => e.name), unorderedEquals(names)); |
| 220 } |
| 221 |
| 218 test('default', () { | 222 test('default', () { |
| 219 var options = new smoke.QueryOptions(); | 223 var options = new smoke.QueryOptions(); |
| 220 var res = smoke.query(A, options); | 224 var res = smoke.query(A, options); |
| 221 expect(res.map((e) => e.name), [#i, #j, #j2]); | 225 _checkQuery(res, [#i, #j, #j2]); |
| 222 }); | 226 }); |
| 223 | 227 |
| 224 test('only fields', () { | 228 test('only fields', () { |
| 225 var options = new smoke.QueryOptions(includeProperties: false); | 229 var options = new smoke.QueryOptions(includeProperties: false); |
| 226 var res = smoke.query(A, options); | 230 var res = smoke.query(A, options); |
| 227 expect(res.map((e) => e.name), [#i, #j]); | 231 _checkQuery(res, [#i, #j]); |
| 228 }); | 232 }); |
| 229 | 233 |
| 230 test('only properties', () { | 234 test('only properties', () { |
| 231 var options = new smoke.QueryOptions(includeFields: false); | 235 var options = new smoke.QueryOptions(includeFields: false); |
| 232 var res = smoke.query(A, options); | 236 var res = smoke.query(A, options); |
| 233 expect(res.map((e) => e.name), [#j2]); | 237 _checkQuery(res, [#j2]); |
| 234 }); | 238 }); |
| 235 | 239 |
| 236 test('properties and methods', () { | 240 test('properties and methods', () { |
| 237 var options = new smoke.QueryOptions(includeMethods: true); | 241 var options = new smoke.QueryOptions(includeMethods: true); |
| 238 var res = smoke.query(A, options); | 242 var res = smoke.query(A, options); |
| 239 expect(res.map((e) => e.name), [#i, #j, #j2, #inc0, #inc1, #inc2]); | 243 _checkQuery(res, [#i, #j, #j2, #inc0, #inc1, #inc2]); |
| 240 }); | 244 }); |
| 241 | 245 |
| 242 test('inherited properties and fields', () { | 246 test('inherited properties and fields', () { |
| 243 var options = new smoke.QueryOptions(includeInherited: true); | 247 var options = new smoke.QueryOptions(includeInherited: true); |
| 244 var res = smoke.query(D, options); | 248 var res = smoke.query(D, options); |
| 245 expect(res.map((e) => e.name), [#x, #y, #b, #i, #j, #j2, #x2, #i2]); | 249 _checkQuery(res, [#x, #y, #b, #i, #j, #j2, #x2, #i2]); |
| 246 }); | 250 }); |
| 247 | 251 |
| 248 test('inherited fields only', () { | 252 test('inherited fields only', () { |
| 249 var options = new smoke.QueryOptions(includeInherited: true, | 253 var options = new smoke.QueryOptions(includeInherited: true, |
| 250 includeProperties: false); | 254 includeProperties: false); |
| 251 var res = smoke.query(D, options); | 255 var res = smoke.query(D, options); |
| 252 expect(res.map((e) => e.name), [#x, #y, #b, #i, #j]); | 256 _checkQuery(res, [#x, #y, #b, #i, #j]); |
| 253 }); | 257 }); |
| 254 | 258 |
| 255 test('exact annotation', () { | 259 test('exact annotation', () { |
| 256 var options = new smoke.QueryOptions(includeInherited: true, | 260 var options = new smoke.QueryOptions(includeInherited: true, |
| 257 withAnnotations: const [a1]); | 261 withAnnotations: const [a1]); |
| 258 var res = smoke.query(H, options); | 262 var res = smoke.query(H, options); |
| 259 expect(res.map((e) => e.name), [#b, #f, #g]); | 263 _checkQuery(res, [#b, #f, #g]); |
| 260 | 264 |
| 261 options = new smoke.QueryOptions(includeInherited: true, | 265 options = new smoke.QueryOptions(includeInherited: true, |
| 262 withAnnotations: const [a2]); | 266 withAnnotations: const [a2]); |
| 263 res = smoke.query(H, options); | 267 res = smoke.query(H, options); |
| 264 expect(res.map((e) => e.name), [#d, #h]); | 268 _checkQuery(res, [#d, #h]); |
| 265 | 269 |
| 266 options = new smoke.QueryOptions(includeInherited: true, | 270 options = new smoke.QueryOptions(includeInherited: true, |
| 267 withAnnotations: const [a1, a2]); | 271 withAnnotations: const [a1, a2]); |
| 268 res = smoke.query(H, options); | 272 res = smoke.query(H, options); |
| 269 expect(res.map((e) => e.name), [#b, #d, #f, #g, #h]); | 273 _checkQuery(res, [#b, #d, #f, #g, #h]); |
| 270 }); | 274 }); |
| 271 | 275 |
| 272 test('type annotation', () { | 276 test('type annotation', () { |
| 273 var options = new smoke.QueryOptions(includeInherited: true, | 277 var options = new smoke.QueryOptions(includeInherited: true, |
| 274 withAnnotations: const [Annot]); | 278 withAnnotations: const [Annot]); |
| 275 var res = smoke.query(H, options); | 279 var res = smoke.query(H, options); |
| 276 expect(res.map((e) => e.name), [#b, #f, #g, #i]); | 280 _checkQuery(res, [#b, #f, #g, #i]); |
| 277 }); | 281 }); |
| 278 | 282 |
| 279 test('mixed annotations (type and exact)', () { | 283 test('mixed annotations (type and exact)', () { |
| 280 var options = new smoke.QueryOptions(includeInherited: true, | 284 var options = new smoke.QueryOptions(includeInherited: true, |
| 281 withAnnotations: const [a2, Annot]); | 285 withAnnotations: const [a2, Annot]); |
| 282 var res = smoke.query(H, options); | 286 var res = smoke.query(H, options); |
| 283 expect(res.map((e) => e.name), [#b, #d, #f, #g, #h, #i]); | 287 _checkQuery(res, [#b, #d, #f, #g, #h, #i]); |
| 284 }); | 288 }); |
| 285 | 289 |
| 286 test('symbol to name', () { | 290 test('symbol to name', () { |
| 287 expect(smoke.symbolToName(#i), 'i'); | 291 expect(smoke.symbolToName(#i), 'i'); |
| 288 }); | 292 }); |
| 289 | 293 |
| 290 test('name to symbol', () { | 294 test('name to symbol', () { |
| 291 expect(smoke.nameToSymbol('i'), #i); | 295 expect(smoke.nameToSymbol('i'), #i); |
| 292 }); | 296 }); |
| 293 }); | 297 }); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 @a2 int d; | 371 @a2 int d; |
| 368 } | 372 } |
| 369 | 373 |
| 370 class H extends G { | 374 class H extends G { |
| 371 int e; | 375 int e; |
| 372 @a1 int f; | 376 @a1 int f; |
| 373 @a1 int g; | 377 @a1 int g; |
| 374 @a2 int h; | 378 @a2 int h; |
| 375 @a3 int i; | 379 @a3 int i; |
| 376 } | 380 } |
| OLD | NEW |