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

Side by Side Diff: test/codegen_test.dart

Issue 1612083002: Initial --modules=es6 support (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 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
« no previous file with comments | « test/codegen/expect/es6_modules.txt ('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) 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 /// Tests code generation. 5 /// Tests code generation.
6 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks 6 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks
7 /// that the output is what we expected. 7 /// that the output is what we expected.
8 library dev_compiler.test.codegen_test; 8 library dev_compiler.test.codegen_test;
9 9
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 tearDown(() { 58 tearDown(() {
59 if (loggerSub != null) { 59 if (loggerSub != null) {
60 loggerSub.cancel(); 60 loggerSub.cancel();
61 loggerSub = null; 61 loggerSub = null;
62 } 62 }
63 }); 63 });
64 64
65 var expectDir = path.join(inputDir, 'expect'); 65 var expectDir = path.join(inputDir, 'expect');
66 66
67 BatchCompiler createCompiler(AnalysisContext context, 67 BatchCompiler createCompiler(AnalysisContext context,
68 {bool checkSdk: false, bool sourceMaps: false, bool closure: false}) { 68 {bool checkSdk: false, bool sourceMaps: false, bool closure: false,
69 ModuleFormat moduleFormat: ModuleFormat.dart}) {
69 // TODO(jmesserly): add a way to specify flags in the test file, so 70 // TODO(jmesserly): add a way to specify flags in the test file, so
70 // they're more self-contained. 71 // they're more self-contained.
71 var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime'); 72 var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime');
72 var options = new CompilerOptions( 73 var options = new CompilerOptions(
73 codegenOptions: new CodegenOptions( 74 codegenOptions: new CodegenOptions(
74 outputDir: expectDir, 75 outputDir: expectDir,
75 emitSourceMaps: sourceMaps, 76 emitSourceMaps: sourceMaps,
76 closure: closure, 77 closure: closure,
77 forceCompile: checkSdk), 78 forceCompile: checkSdk,
79 moduleFormat: moduleFormat),
78 useColors: false, 80 useColors: false,
79 checkSdk: checkSdk, 81 checkSdk: checkSdk,
80 runtimeDir: runtimeDir, 82 runtimeDir: runtimeDir,
81 inputBaseDir: inputDir); 83 inputBaseDir: inputDir);
82 var reporter = createErrorReporter(context, options); 84 var reporter = createErrorReporter(context, options);
83 return new BatchCompiler(context, options, reporter: reporter); 85 return new BatchCompiler(context, options, reporter: reporter);
84 } 86 }
85 87
86 bool compile(BatchCompiler compiler, String filePath) { 88 bool compile(BatchCompiler compiler, String filePath) {
87 compiler.compileFromUriString(filePath, (String url) { 89 compiler.compileFromUriString(filePath, (String url) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (multitests.contains(filePath)) continue; 142 if (multitests.contains(filePath)) continue;
141 143
142 var filename = path.basenameWithoutExtension(filePath); 144 var filename = path.basenameWithoutExtension(filePath);
143 145
144 test('$filename.dart', () { 146 test('$filename.dart', () {
145 // TODO(jmesserly): this was added to get some coverage of source maps 147 // TODO(jmesserly): this was added to get some coverage of source maps
146 // and closure annotations. 148 // and closure annotations.
147 // We need a more comprehensive strategy to test them. 149 // We need a more comprehensive strategy to test them.
148 var sourceMaps = filename == 'map_keys'; 150 var sourceMaps = filename == 'map_keys';
149 var closure = filename == 'closure'; 151 var closure = filename == 'closure';
152 var moduleFormat = filename == 'es6_modules'
153 ? ModuleFormat.es6 : ModuleFormat.dart;
150 var success; 154 var success;
151 // TODO(vsm): Is it okay to reuse the same context here? If there is 155 // TODO(vsm): Is it okay to reuse the same context here? If there is
152 // overlap between test files, we may need separate ones for each 156 // overlap between test files, we may need separate ones for each
153 // compiler. 157 // compiler.
154 var compiler = (sourceMaps || closure) 158 var compiler = (sourceMaps || closure || moduleFormat != ModuleFormat. dart)
155 ? createCompiler(realSdkContext, 159 ? createCompiler(realSdkContext,
156 sourceMaps: sourceMaps, closure: closure) 160 sourceMaps: sourceMaps, closure: closure,
161 moduleFormat: moduleFormat)
157 : batchCompiler; 162 : batchCompiler;
158 success = compile(compiler, filePath); 163 success = compile(compiler, filePath);
159 164
160 var outFile = new File(path.join(outDir.path, '$filename.js')); 165 var outFile = new File(path.join(outDir.path, '$filename.js'));
161 expect(!success || outFile.existsSync(), true, 166 expect(!success || outFile.existsSync(), true,
162 reason: '${outFile.path} was created if compilation succeeds'); 167 reason: '${outFile.path} was created if compilation succeeds');
163 }); 168 });
164 } 169 }
165 }); 170 });
166 } 171 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 print('[AnalysisEngine] error $message $exception'); 246 print('[AnalysisEngine] error $message $exception');
242 } 247 }
243 248
244 @override void logError2(String message, Object exception) { 249 @override void logError2(String message, Object exception) {
245 print('[AnalysisEngine] error $message $exception'); 250 print('[AnalysisEngine] error $message $exception');
246 } 251 }
247 252
248 void logInformation(String message, [CaughtException exception]) {} 253 void logInformation(String message, [CaughtException exception]) {}
249 void logInformation2(String message, Object exception) {} 254 void logInformation2(String message, Object exception) {}
250 } 255 }
OLDNEW
« no previous file with comments | « test/codegen/expect/es6_modules.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698