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 |
| 5 // TODO(jakemac): swap this to @TestOn('pub-serve') once |
| 6 // https://github.com/dart-lang/test/issues/388 is completed. |
| 7 @TestOn('!js') |
4 library initialize.initializer_custom_filter_test; | 8 library initialize.initializer_custom_filter_test; |
5 | 9 |
6 import 'dart:async'; | 10 import 'dart:async'; |
7 import 'package:initialize/initialize.dart'; | 11 import 'package:initialize/initialize.dart'; |
8 import 'package:unittest/unittest.dart'; | 12 import 'package:test/test.dart'; |
9 import 'package:unittest/compact_vm_config.dart'; | |
10 import 'package:initialize/src/initialize_tracker.dart'; | 13 import 'package:initialize/src/initialize_tracker.dart'; |
11 | 14 |
12 main() { | 15 main() { |
13 useCompactVMConfiguration(); | |
14 | |
15 test('filter option limits which types of annotations will be ran', () { | 16 test('filter option limits which types of annotations will be ran', () { |
16 var originalSize; | 17 var originalSize; |
17 return runPhase(1).then((_) { | 18 return runPhase(1).then((_) { |
18 // Even though Baz extends Bar, only Baz should be run. | 19 // Even though Baz extends Bar, only Baz should be run. |
19 expect(InitializeTracker.seen, [Baz]); | 20 expect(InitializeTracker.seen, [Baz]); |
20 }).then((_) => runPhase(2)).then((_) { | 21 }).then((_) => runPhase(2)).then((_) { |
21 expect(InitializeTracker.seen, [Baz, foo]); | 22 expect(InitializeTracker.seen, [Baz, foo]); |
22 }).then((_) => runPhase(3)).then((_) { | 23 }).then((_) => runPhase(3)).then((_) { |
23 expect(InitializeTracker.seen, [Baz, foo, Foo]); | 24 expect(InitializeTracker.seen, [Baz, foo, Foo]); |
24 }).then((_) => runPhase(4)).then((_) { | 25 }).then((_) => runPhase(4)).then((_) { |
(...skipping 28 matching lines...) Expand all Loading... |
53 @PhasedInitializer(1) | 54 @PhasedInitializer(1) |
54 class Baz extends Bar {} | 55 class Baz extends Bar {} |
55 | 56 |
56 // Initializer that has a phase associated with it, this can be used in | 57 // Initializer that has a phase associated with it, this can be used in |
57 // combination with a custom filter to run intialization in phases. | 58 // combination with a custom filter to run intialization in phases. |
58 class PhasedInitializer extends InitializeTracker { | 59 class PhasedInitializer extends InitializeTracker { |
59 final int phase; | 60 final int phase; |
60 | 61 |
61 const PhasedInitializer(this.phase); | 62 const PhasedInitializer(this.phase); |
62 } | 63 } |
OLD | NEW |