| 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.init_method_test; | 8 library initialize.init_method_test; |
| 5 | 9 |
| 6 import 'package:initialize/initialize.dart'; | 10 import 'package:initialize/initialize.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 11 import 'package:test/test.dart'; |
| 8 import 'package:unittest/compact_vm_config.dart'; | |
| 9 | 12 |
| 10 int calledFoo = 0; | 13 int calledFoo = 0; |
| 11 int calledBar = 0; | 14 int calledBar = 0; |
| 12 | 15 |
| 13 main() { | 16 main() { |
| 14 useCompactVMConfiguration(); | |
| 15 | |
| 16 // Run all initializers. | 17 // Run all initializers. |
| 17 run().then((_) { | 18 return run().then((_) { |
| 18 test('initMethod annotation invokes functions once', () { | 19 test('initMethod annotation invokes functions once', () { |
| 19 expect(calledFoo, 1); | 20 expect(calledFoo, 1); |
| 20 expect(calledBar, 1); | 21 expect(calledBar, 1); |
| 21 // Re-run all initializers, should be a no-op. | 22 // Re-run all initializers, should be a no-op. |
| 22 return run().then((_) { | 23 return run().then((_) { |
| 23 expect(calledFoo, 1); | 24 expect(calledFoo, 1); |
| 24 expect(calledBar, 1); | 25 expect(calledBar, 1); |
| 25 }); | 26 }); |
| 26 }); | 27 }); |
| 27 }); | 28 }); |
| 28 } | 29 } |
| 29 | 30 |
| 30 @initMethod | 31 @initMethod |
| 31 foo() => calledFoo++; | 32 foo() => calledFoo++; |
| 32 | 33 |
| 33 @initMethod | 34 @initMethod |
| 34 bar() => calledBar++; | 35 bar() => calledBar++; |
| OLD | NEW |