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

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

Issue 2690063002: Refactor CompilerOutput (Closed)
Patch Set: Updated cf. comments Created 3 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 options '--source-map' and '--out' correctly adds 5 // Test that options '--source-map' and '--out' correctly adds
6 // `sourceMappingURL` and "file" attributes to source file and source map file. 6 // `sourceMappingURL` and "file" attributes to source file and source map file.
7 7
8 library test.source_map; 8 library test.source_map;
9 9
10 import 'package:async_helper/async_helper.dart'; 10 import 'package:async_helper/async_helper.dart';
11 import 'package:compiler/compiler_new.dart';
11 import 'package:expect/expect.dart'; 12 import 'package:expect/expect.dart';
12 import 'memory_compiler.dart'; 13 import 'memory_compiler.dart';
13 14
14 const SOURCE = const { 15 const SOURCE = const {
15 '/main.dart': """ 16 '/main.dart': """
16 main() {} 17 main() {}
17 """, 18 """,
18 }; 19 };
19 20
20 void find(String text, String substring, bool expected) { 21 void find(String text, String substring, bool expected) {
(...skipping 19 matching lines...) Expand all
40 if (sourceMap != null) { 41 if (sourceMap != null) {
41 options.add("--source-map=$sourceMap"); 42 options.add("--source-map=$sourceMap");
42 } 43 }
43 44
44 await runCompiler( 45 await runCompiler(
45 entryPoint: Uri.parse('memory:/main.dart'), 46 entryPoint: Uri.parse('memory:/main.dart'),
46 memorySourceFiles: SOURCE, 47 memorySourceFiles: SOURCE,
47 showDiagnostics: true, 48 showDiagnostics: true,
48 outputProvider: collector, 49 outputProvider: collector,
49 options: options); 50 options: options);
50 String jsOutput = collector.getOutput('', 'js'); 51 String jsOutput = collector.getOutput('', OutputType.js);
51 Expect.isNotNull(jsOutput); 52 Expect.isNotNull(jsOutput);
52 if (mapping != null) { 53 if (mapping != null) {
53 find(jsOutput, '//# sourceMappingURL=$mapping', true); 54 find(jsOutput, '//# sourceMappingURL=$mapping', true);
54 } else { 55 } else {
55 find(jsOutput, '//# sourceMappingURL=', false); 56 find(jsOutput, '//# sourceMappingURL=', false);
56 } 57 }
57 String jsSourceMapOutput = collector.getOutput('', 'js.map'); 58 String jsSourceMapOutput = collector.getOutput('', OutputType.sourceMap);
58 Expect.isNotNull(jsSourceMapOutput); 59 Expect.isNotNull(jsSourceMapOutput);
59 if (file != null) { 60 if (file != null) {
60 find(jsSourceMapOutput, '"file": "$file"', true); 61 find(jsSourceMapOutput, '"file": "$file"', true);
61 } else { 62 } else {
62 find(jsSourceMapOutput, '"file": ', false); 63 find(jsSourceMapOutput, '"file": ', false);
63 } 64 }
64 } 65 }
65 66
66 void main() { 67 void main() {
67 asyncTest(() async { 68 asyncTest(() async {
68 await test(); 69 await test();
69 await test(sourceMap: 'file:/out.js.map'); 70 await test(sourceMap: 'file:/out.js.map');
70 await test(out: 'file:/out.js'); 71 await test(out: 'file:/out.js');
71 await test( 72 await test(
72 out: 'file:/out.js', 73 out: 'file:/out.js',
73 sourceMap: 'file:/out.js.map', 74 sourceMap: 'file:/out.js.map',
74 file: 'out.js', 75 file: 'out.js',
75 mapping: 'out.js.map'); 76 mapping: 'out.js.map');
76 await test( 77 await test(
77 out: 'file:/dir/out.js', 78 out: 'file:/dir/out.js',
78 sourceMap: 'file:/dir/out.js.map', 79 sourceMap: 'file:/dir/out.js.map',
79 file: 'out.js', 80 file: 'out.js',
80 mapping: 'out.js.map'); 81 mapping: 'out.js.map');
81 }); 82 });
82 } 83 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/serialization/helper.dart ('k') | tests/compiler/dart2js/sourcemaps/mapping_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698