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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import "package:async_helper/async_helper.dart"; 6 import "package:async_helper/async_helper.dart";
7 import 'memory_source_file_helper.dart'; 7 import 'memory_source_file_helper.dart';
8 import "memory_compiler.dart"; 8 import "memory_compiler.dart";
9 9
10 void main() { 10 void main() {
11 asyncTest(() async { 11 asyncTest(() async {
12 var collector = new OutputCollector(); 12 var collector = new OutputCollector();
13 CompilationResult result = await runCompiler( 13 CompilationResult result = await runCompiler(
14 memorySourceFiles: MEMORY_SOURCE_FILES, 14 memorySourceFiles: MEMORY_SOURCE_FILES,
15 options: ['--deferred-map=deferred_map.json'], 15 options: ['--deferred-map=deferred_map.json'],
16 outputProvider: collector); 16 outputProvider: collector);
17 CompilerImpl compiler = result.compiler; 17 CompilerImpl compiler = result.compiler;
18 // Ensure a mapping file is output. 18 // Ensure a mapping file is output.
19 Expect.isNotNull( 19 Expect.isNotNull(collector.getOutput("deferred_map.json", "deferred_map"));
20 collector.getOutput("deferred_map.json", "deferred_map"));
21 20
22 Map mapping = compiler.deferredLoadTask.computeDeferredMap(); 21 Map mapping = compiler.deferredLoadTask.computeDeferredMap();
23 // Test structure of mapping. 22 // Test structure of mapping.
24 Expect.equals("<unnamed>", mapping["main.dart"]["name"]); 23 Expect.equals("<unnamed>", mapping["main.dart"]["name"]);
25 Expect.equals(2, mapping["main.dart"]["imports"]["lib1"].length); 24 Expect.equals(2, mapping["main.dart"]["imports"]["lib1"].length);
26 Expect.equals(2, mapping["main.dart"]["imports"]["lib2"].length); 25 Expect.equals(2, mapping["main.dart"]["imports"]["lib2"].length);
27 Expect.equals(1, mapping["main.dart"]["imports"]["convert"].length); 26 Expect.equals(1, mapping["main.dart"]["imports"]["convert"].length);
28 Expect.equals("lib1", mapping["memory:lib1.dart"]["name"]); 27 Expect.equals("lib1", mapping["memory:lib1.dart"]["name"]);
29 Expect.equals(1, mapping["memory:lib1.dart"]["imports"]["lib4_1"].length); 28 Expect.equals(1, mapping["memory:lib1.dart"]["imports"]["lib4_1"].length);
30 Expect.equals(1, mapping["memory:lib2.dart"]["imports"]["lib4_2"].length); 29 Expect.equals(1, mapping["memory:lib2.dart"]["imports"]["lib4_2"].length);
31 }); 30 });
32 } 31 }
33 32
34 const Map MEMORY_SOURCE_FILES = const { 33 const Map MEMORY_SOURCE_FILES = const {
35 "main.dart":""" 34 "main.dart": """
36 import 'dart:convert' deferred as convert; 35 import 'dart:convert' deferred as convert;
37 import 'lib1.dart' deferred as lib1; 36 import 'lib1.dart' deferred as lib1;
38 import 'lib2.dart' deferred as lib2; 37 import 'lib2.dart' deferred as lib2;
39 38
40 void main() { 39 void main() {
41 lib1.loadLibrary().then((_) { 40 lib1.loadLibrary().then((_) {
42 lib1.foo1(); 41 lib1.foo1();
43 new lib1.C(); 42 new lib1.C();
44 lib2.loadLibrary().then((_) { 43 lib2.loadLibrary().then((_) {
45 lib2.foo2(); 44 lib2.foo2();
46 }); 45 });
47 }); 46 });
48 convert.loadLibrary().then((_) { 47 convert.loadLibrary().then((_) {
49 new convert.JsonCodec(); 48 new convert.JsonCodec();
50 }); 49 });
51 } 50 }
52 """, 51 """,
53 "lib1.dart":""" 52 "lib1.dart": """
54 library lib1; 53 library lib1;
55 import "dart:async"; 54 import "dart:async";
56 import "dart:html"; 55 import "dart:html";
57 56
58 import "lib3.dart" as l3; 57 import "lib3.dart" as l3;
59 import "lib4.dart" deferred as lib4_1; 58 import "lib4.dart" deferred as lib4_1;
60 59
61 class C {} 60 class C {}
62 61
63 foo1() { 62 foo1() {
64 new InputElement(); 63 new InputElement();
65 lib4_1.loadLibrary().then((_) { 64 lib4_1.loadLibrary().then((_) {
66 lib4_1.bar1(); 65 lib4_1.bar1();
67 }); 66 });
68 return () {return 1 + l3.foo3();} (); 67 return () {return 1 + l3.foo3();} ();
69 } 68 }
70 """, 69 """,
71 "lib2.dart":""" 70 "lib2.dart": """
72 library lib2; 71 library lib2;
73 import "dart:async"; 72 import "dart:async";
74 import "lib3.dart" as l3; 73 import "lib3.dart" as l3;
75 import "lib4.dart" deferred as lib4_2; 74 import "lib4.dart" deferred as lib4_2;
76 75
77 foo2() { 76 foo2() {
78 lib4_2.loadLibrary().then((_) { 77 lib4_2.loadLibrary().then((_) {
79 lib4_2.bar2(); 78 lib4_2.bar2();
80 }); 79 });
81 return () {return 2+l3.foo3();} (); 80 return () {return 2+l3.foo3();} ();
82 } 81 }
83 """, 82 """,
84 "lib3.dart":""" 83 "lib3.dart": """
85 library lib3; 84 library lib3;
86 85
87 foo3() { 86 foo3() {
88 return () {return 3;} (); 87 return () {return 3;} ();
89 } 88 }
90 """, 89 """,
91 "lib4.dart":""" 90 "lib4.dart": """
92 library lib4; 91 library lib4;
93 92
94 bar1() { 93 bar1() {
95 return "hello"; 94 return "hello";
96 } 95 }
97 96
98 bar2() { 97 bar2() {
99 return 2; 98 return 2;
100 } 99 }
101 """, 100 """,
102 }; 101 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/deferred_load_graph_segmentation_test.dart ('k') | tests/compiler/dart2js/deferred_mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698