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

Side by Side Diff: tests/compiler/dart2js/deferred_load_mapping_test.dart

Issue 785303003: Add option for outputting a deferred loading mapping. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated format Created 5 years, 11 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) 2015, 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 import 'package:expect/expect.dart';
6 import "package:async_helper/async_helper.dart";
7 import 'memory_source_file_helper.dart';
8 import "memory_compiler.dart";
9
10 void main() {
11 var collector = new OutputCollector();
12 Compiler compiler = compilerFor(MEMORY_SOURCE_FILES,
13 options: ['--deferred-map=deferred_map.json'],
14 outputProvider: collector);
15 asyncTest(() {
16 return compiler.run(Uri.parse('memory:main.dart')).then((success) {
17 // Ensure a mapping file is output.
18 Expect.isNotNull(
19 collector.getOutput("deferred_map.json", "deferred_map"));
20
21 Map mapping = compiler.deferredLoadTask.computeDeferredMap();
22 // Test structure of mapping.
23 Expect.equals("<unnamed>", mapping["main.dart"]["name"]);
24 Expect.equals(2, mapping["main.dart"]["imports"]["lib1"].length);
25 Expect.equals(2, mapping["main.dart"]["imports"]["lib2"].length);
26 Expect.equals(1, mapping["main.dart"]["imports"]["convert"].length);
27 Expect.equals("lib1", mapping["memory:lib1.dart"]["name"]);
28 Expect.equals(1, mapping["memory:lib1.dart"]["imports"]["lib4_1"].length);
29 Expect.equals(1, mapping["memory:lib2.dart"]["imports"]["lib4_2"].length);
30 });
31 });
32 }
33
34 const Map MEMORY_SOURCE_FILES = const {
35 "main.dart":"""
36 import 'dart:convert' deferred as convert;
37 import 'lib1.dart' deferred as lib1;
38 import 'lib2.dart' deferred as lib2;
39
40 void main() {
41 lib1.loadLibrary().then((_) {
42 lib1.foo1();
43 new lib1.C();
44 lib2.loadLibrary().then((_) {
45 lib2.foo2();
46 });
47 });
48 convert.loadLibrary().then((_) {
49 new convert.JsonCodec();
50 });
51 }
52 """,
53 "lib1.dart":"""
54 library lib1;
55 import "dart:async";
56 import "dart:html";
57
58 import "lib3.dart" as l3;
59 import "lib4.dart" deferred as lib4_1;
60
61 class C {}
62
63 foo1() {
64 new InputElement();
65 lib4_1.loadLibrary().then((_) {
66 lib4_1.bar1();
67 });
68 return () {return 1 + l3.foo3();} ();
69 }
70 """,
71 "lib2.dart":"""
72 library lib2;
73 import "dart:async";
74 import "lib3.dart" as l3;
75 import "lib4.dart" deferred as lib4_2;
76
77 foo2() {
78 lib4_2.loadLibrary().then((_) {
79 lib4_2.bar2();
80 });
81 return () {return 2+l3.foo3();} ();
82 }
83 """,
84 "lib3.dart":"""
85 library lib3;
86
87 foo3() {
88 return () {return 3;} ();
89 }
90 """,
91 "lib4.dart":"""
92 library lib4;
93
94 bar1() {
95 return "hello";
96 }
97
98 bar2() {
99 return 2;
100 }
101 """,
102 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698