Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: dart/tests/compiler/dart2js_extra/deferred/deferred_function_test.dart

Issue 12033003: Deferred (aka lazy) loading of static functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Missing imports Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 @lazy import 'deferred_function_library.dart';
10
11 const lazy = const DeferredLibrary('deferred_function_library');
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 lazy.load().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 lazy.load().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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698