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

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

Issue 16580014: Don't create part.js when there is no deferred loading. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 years, 6 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
« no previous file with comments | « dart/tests/compiler/dart2js/unneeded_part_js_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:async'; 9 import 'dart:async';
10 @lazy import 'deferred_function_library.dart'; 10 @lazy import 'deferred_function_library.dart';
11 11
12 const lazy = const DeferredLibrary('deferred_function_library'); 12 const lazy = const DeferredLibrary('deferred_function_library');
13 13
14 isNoSuchMethodError(e) => e is NoSuchMethodError; 14 isNoSuchMethodError(e) => e is NoSuchMethodError;
15 15
16 readFoo() {
17 // TODO(ahe): There is a problem with type inference of deferred
18 // function closures. We think they are never null.
19 if (new DateTime.now().millisecondsSinceEpoch == 87) return null;
20 return foo;
21 }
22
16 main() { 23 main() {
17 print('unittest-suite-wait-for-done'); 24 print('unittest-suite-wait-for-done');
18 25
19 Expect.throws(() { foo('a'); }, isNoSuchMethodError); 26 Expect.throws(() { foo('a'); }, isNoSuchMethodError);
27 Expect.isNull(readFoo());
20 int counter = 0; 28 int counter = 0;
21 lazy.load().then((bool didLoad) { 29 lazy.load().then((bool didLoad) {
22 Expect.isTrue(didLoad); 30 Expect.isTrue(didLoad);
23 Expect.equals(1, ++counter); 31 Expect.equals(1, ++counter);
24 print('lazy was loaded'); 32 print('lazy was loaded');
25 Expect.equals(42, foo('b')); 33 Expect.equals(42, foo('b'));
34 Expect.isNotNull(readFoo());
26 }); 35 });
27 Expect.equals(0, counter); 36 Expect.equals(0, counter);
28 lazy.load().then((bool didLoad) { 37 lazy.load().then((bool didLoad) {
29 Expect.isFalse(didLoad); 38 Expect.isFalse(didLoad);
30 Expect.equals(2, ++counter); 39 Expect.equals(2, ++counter);
31 print('lazy was loaded'); 40 print('lazy was loaded');
32 Expect.equals(42, foo('b')); 41 Expect.equals(42, foo('b'));
42 Expect.isNotNull(readFoo());
33 print('unittest-suite-success'); 43 print('unittest-suite-success');
34 }); 44 });
35 Expect.equals(0, counter); 45 Expect.equals(0, counter);
36 Expect.throws(() { foo('a'); }, isNoSuchMethodError); 46 Expect.throws(() { foo('a'); }, isNoSuchMethodError);
47 Expect.isNull(readFoo());
37 } 48 }
OLDNEW
« no previous file with comments | « dart/tests/compiler/dart2js/unneeded_part_js_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698