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

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

Issue 429883002: Remove support for the DeferredLibrary annotation and remove tests of it (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Deprecated until sdk 1.8 remove cruft from unused DeferredLibrary Created 6 years, 3 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
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 loading of a library (with top-level functions only) can 5 // Test that loading of a library (with top-level functions only) can
6 // be deferred. 6 // be deferred.
7 7
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 10
11 import 'dart:async'; 11 import 'deferred_function_library.dart' deferred as lib;
12
13 @lazy import 'deferred_function_library.dart' as lib;
14
15 const lazy = const DeferredLibrary('deferred_function_library');
16 12
17 isError(e) => e is Error; 13 isError(e) => e is Error;
18 14
19 readFoo() { 15 readFoo() {
20 return lib.foo; 16 return lib.foo;
21 } 17 }
22 18
23 main() { 19 main() {
24 Expect.throws(() { lib.foo('a'); }, isError); 20 Expect.throws(() { lib.foo('a'); }, isError);
25 Expect.throws(readFoo, isError); 21 Expect.throws(readFoo, isError);
26 int counter = 0; 22 int counter = 0;
27 asyncStart(); 23 asyncStart();
28 lazy.load().then((_) { 24 lib.loadLibrary().then((_) {
29 Expect.equals(1, ++counter); 25 Expect.equals(1, ++counter);
30 print('lazy was loaded'); 26 print('lazy was loaded');
31 Expect.equals(42, lib.foo('b')); 27 Expect.equals(42, lib.foo('b'));
32 Expect.isNotNull(readFoo()); 28 Expect.isNotNull(readFoo());
33 asyncEnd(); 29 asyncEnd();
34 }); 30 });
35 Expect.equals(0, counter); 31 Expect.equals(0, counter);
36 asyncStart(); 32 asyncStart();
37 lazy.load().then((_) { 33 lib.loadLibrary().then((_) {
38 Expect.equals(2, ++counter); 34 Expect.equals(2, ++counter);
39 print('lazy was loaded'); 35 print('lazy was loaded');
40 Expect.equals(42, lib.foo('b')); 36 Expect.equals(42, lib.foo('b'));
41 Expect.isNotNull(readFoo()); 37 Expect.isNotNull(readFoo());
42 asyncEnd(); 38 asyncEnd();
43 }); 39 });
44 Expect.equals(0, counter); 40 Expect.equals(0, counter);
45 Expect.throws(() { lib.foo('a'); }, isError); 41 Expect.throws(() { lib.foo('a'); }, isError);
46 Expect.throws(readFoo, isError); 42 Expect.throws(readFoo, isError);
47 } 43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698