Chromium Code Reviews| 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 // Test that that the basic API for deferred/lazy loading works. This | 5 // Test that that the basic API for deferred/lazy loading works. This |
| 6 // test deliberately does not test that the deferred elements throw a | 6 // test deliberately does not test that the deferred elements throw a |
| 7 // NoSuchMethodError before the deferred library is loaded. This | 7 // NoSuchMethodError before the deferred library is loaded. This |
| 8 // makes it possible to pass this test without having implemented | 8 // makes it possible to pass this test without having implemented |
| 9 // deferred loading correctly. | 9 // deferred loading correctly. |
| 10 | 10 |
| 11 import "package:expect/expect.dart"; | 11 import "package:expect/expect.dart"; |
| 12 import 'dart:async'; | 12 import 'dart:async'; |
| 13 | 13 |
| 14 @lazy | 14 @lazy |
| 15 import 'deferred_api_library.dart' as lib; | 15 import 'deferred_api_library.dart' as lib; |
| 16 | 16 |
| 17 const lazy = const DeferredLibrary('deferred_api_library'); | 17 const lazy = const DeferredLibrary('deferred_api_library'); |
| 18 | 18 |
| 19 main() { | 19 main() { |
| 20 print('unittest-suite-wait-for-done'); | 20 print('unittest-suite-wait-for-done'); |
| 21 | 21 |
| 22 int counter = 0; | 22 int counter = 0; |
| 23 lazy.load().then((bool didLoad) { | 23 lazy.load().then((_) { |
|
Johnni Winther
2014/04/11 07:34:54
Why this change?
sigurdm
2014/04/11 09:11:38
I removed the bool from the future in a previous C
| |
| 24 Expect.isTrue(didLoad); | |
| 25 Expect.equals(1, ++counter); | 24 Expect.equals(1, ++counter); |
| 26 Expect.equals(42, lib.foo('b')); | 25 Expect.equals(42, lib.foo('b')); |
| 27 print('lazy was loaded'); | 26 print('lazy was loaded'); |
| 28 }); | 27 }); |
| 29 Expect.equals(0, counter); | 28 Expect.equals(0, counter); |
| 30 lazy.load().then((bool didLoad) { | 29 lazy.load().then((_) { |
| 31 Expect.isFalse(didLoad); | |
| 32 Expect.equals(2, ++counter); | 30 Expect.equals(2, ++counter); |
| 33 Expect.equals(42, lib.foo('b')); | 31 Expect.equals(42, lib.foo('b')); |
| 34 print('lazy was loaded'); | 32 print('lazy was loaded'); |
| 35 print('unittest-suite-success'); | 33 print('unittest-suite-success'); |
| 36 }); | 34 }); |
| 37 Expect.equals(0, counter); | 35 Expect.equals(0, counter); |
| 38 } | 36 } |
| OLD | NEW |