OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library initialize.transformer_test; | 4 library initialize.transformer_test; |
5 | 5 |
6 import 'common.dart'; | 6 import 'common.dart'; |
7 import 'package:analyzer/src/generated/element.dart'; | 7 import 'package:analyzer/src/generated/element.dart'; |
8 import 'package:dart_style/dart_style.dart'; | 8 import 'package:dart_style/dart_style.dart'; |
9 import 'package:initialize/transformer.dart'; | 9 import 'package:initialize/transformer.dart'; |
10 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 initializers.addAll([ | 273 initializers.addAll([ |
274 new InitEntry(i2.constInit, const LibraryIdentifier(#bar, null, 'foo
/bar.dart')), | 274 new InitEntry(i2.constInit, const LibraryIdentifier(#bar, null, 'foo
/bar.dart')), |
275 new InitEntry(i2.constInit, i1.bar), | 275 new InitEntry(i2.constInit, i1.bar), |
276 new InitEntry(i2.constInit, i1.Bar), | 276 new InitEntry(i2.constInit, i1.Bar), |
277 ]); | 277 ]); |
278 | 278 |
279 i0.main(); | 279 i0.main(); |
280 } | 280 } |
281 ''') | 281 ''') |
282 }, []); | 282 }, []); |
| 283 |
| 284 testPhases('library parts and exports', phases, { |
| 285 'a|web/index.dart': ''' |
| 286 @constInit |
| 287 library index; |
| 288 |
| 289 import 'package:test_initializers/common.dart'; |
| 290 export 'export.dart'; |
| 291 |
| 292 part 'foo.dart'; |
| 293 part 'bar.dart'; |
| 294 ''', |
| 295 'a|web/foo.dart': ''' |
| 296 part of index; |
| 297 |
| 298 @constInit |
| 299 foo() {}; |
| 300 ''', |
| 301 'a|web/bar.dart': ''' |
| 302 part of index; |
| 303 |
| 304 @constInit |
| 305 bar() {}; |
| 306 ''', |
| 307 'a|web/export.dart': ''' |
| 308 @constInit |
| 309 library export; |
| 310 |
| 311 import 'package:test_initializers/common.dart'; |
| 312 ''', |
| 313 // Mock out the Initialize package plus some initializers. |
| 314 'initialize|lib/initialize.dart': mockInitialize, |
| 315 'test_initializers|lib/common.dart': commonInitializers, |
| 316 }, { |
| 317 'a|web/index.initialize.dart': formatter.format(''' |
| 318 import 'package:initialize/src/static_loader.dart'; |
| 319 import 'package:initialize/initialize.dart'; |
| 320 import 'index.dart' as i0; |
| 321 import 'export.dart' as i1; |
| 322 import 'package:test_initializers/common.dart' as i2; |
| 323 |
| 324 main() { |
| 325 initializers.addAll([ |
| 326 new InitEntry(i2.constInit, const LibraryIdentifier(#export, null, '
export.dart')), |
| 327 new InitEntry(i2.constInit, const LibraryIdentifier(#index, null, 'i
ndex.dart')), |
| 328 new InitEntry(i2.constInit, i0.foo), |
| 329 new InitEntry(i2.constInit, i0.bar), |
| 330 ]); |
| 331 |
| 332 i0.main(); |
| 333 } |
| 334 ''') |
| 335 }, []); |
283 } | 336 } |
284 | 337 |
285 class SkipConstructorsPlugin extends InitializerPlugin { | 338 class SkipConstructorsPlugin extends InitializerPlugin { |
286 bool shouldApply(InitializerPluginData data) { | 339 bool shouldApply(InitializerPluginData data) { |
287 return data.initializer.annotationElement.element is ConstructorElement; | 340 return data.initializer.annotationElement.element is ConstructorElement; |
288 } | 341 } |
289 | 342 |
290 String apply(_) => null; | 343 String apply(_) => null; |
291 } | 344 } |
292 | 345 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 initializers.addAll([ | 389 initializers.addAll([ |
337 new InitEntry(i2.initMethod, i1.foo), | 390 new InitEntry(i2.initMethod, i1.foo), |
338 new InitEntry(i2.initMethod, i0.index), | 391 new InitEntry(i2.initMethod, i0.index), |
339 ]); | 392 ]); |
340 | 393 |
341 i0.main(); | 394 i0.main(); |
342 } | 395 } |
343 ''') | 396 ''') |
344 }, []); | 397 }, []); |
345 } | 398 } |
OLD | NEW |