OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // Test that loading of a library (with top-level functions only) can | |
6 // be deferred. | |
7 | |
8 import 'dart:async'; | |
9 | |
10 @DeferLoad('deferred_function_library') | |
kasperl
2013/02/05 08:30:53
If we had support for it, would it make sense to m
ahe
2013/02/05 13:54:22
Not sure about the "didLoad" parameter below. I th
| |
11 import 'deferred_function_library.dart'; | |
12 | |
13 isNoSuchMethodError(e) => e is NoSuchMethodError; | |
14 | |
15 main() { | |
16 print('unittest-suite-wait-for-done'); | |
17 | |
18 Expect.throws(() { foo('a'); }, isNoSuchMethodError); | |
19 int counter = 0; | |
20 load('deferred_function_library').then((bool didLoad) { | |
21 Expect.isTrue(didLoad); | |
22 Expect.equals(1, ++counter); | |
23 print('lazy was loaded'); | |
24 Expect.equals(42, foo('b')); | |
25 }); | |
26 Expect.equals(0, counter); | |
27 load('deferred_function_library').then((bool didLoad) { | |
28 Expect.isFalse(didLoad); | |
29 Expect.equals(2, ++counter); | |
30 print('lazy was loaded'); | |
31 Expect.equals(42, foo('b')); | |
32 print('unittest-suite-success'); | |
33 }); | |
34 Expect.equals(0, counter); | |
35 Expect.throws(() { foo('a'); }, isNoSuchMethodError); | |
36 } | |
OLD | NEW |