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

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: addressed comments (legacy, doc) + test enum utils 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') | test/utils_test.dart » ('j') | 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,
69 bool sourceMaps: false,
70 bool closure: false,
71 ModuleFormat moduleFormat: ModuleFormat.legacy}) {
69 // TODO(jmesserly): add a way to specify flags in the test file, so 72 // TODO(jmesserly): add a way to specify flags in the test file, so
70 // they're more self-contained. 73 // they're more self-contained.
71 var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime'); 74 var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime');
72 var options = new CompilerOptions( 75 var options = new CompilerOptions(
73 codegenOptions: new CodegenOptions( 76 codegenOptions: new CodegenOptions(
74 outputDir: expectDir, 77 outputDir: expectDir,
75 emitSourceMaps: sourceMaps, 78 emitSourceMaps: sourceMaps,
76 closure: closure, 79 closure: closure,
77 forceCompile: checkSdk), 80 forceCompile: checkSdk,
81 moduleFormat: moduleFormat),
78 useColors: false, 82 useColors: false,
79 checkSdk: checkSdk, 83 checkSdk: checkSdk,
80 runtimeDir: runtimeDir, 84 runtimeDir: runtimeDir,
81 inputBaseDir: inputDir); 85 inputBaseDir: inputDir);
82 var reporter = createErrorReporter(context, options); 86 var reporter = createErrorReporter(context, options);
83 return new BatchCompiler(context, options, reporter: reporter); 87 return new BatchCompiler(context, options, reporter: reporter);
84 } 88 }
85 89
86 bool compile(BatchCompiler compiler, String filePath) { 90 bool compile(BatchCompiler compiler, String filePath) {
87 compiler.compileFromUriString(filePath, (String url) { 91 compiler.compileFromUriString(filePath, (String url) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (multitests.contains(filePath)) continue; 144 if (multitests.contains(filePath)) continue;
141 145
142 var filename = path.basenameWithoutExtension(filePath); 146 var filename = path.basenameWithoutExtension(filePath);
143 147
144 test('$filename.dart', () { 148 test('$filename.dart', () {
145 // TODO(jmesserly): this was added to get some coverage of source maps 149 // TODO(jmesserly): this was added to get some coverage of source maps
146 // and closure annotations. 150 // and closure annotations.
147 // We need a more comprehensive strategy to test them. 151 // We need a more comprehensive strategy to test them.
148 var sourceMaps = filename == 'map_keys'; 152 var sourceMaps = filename == 'map_keys';
149 var closure = filename == 'closure'; 153 var closure = filename == 'closure';
154 var moduleFormat =
155 filename == 'es6_modules' ? ModuleFormat.es6 : ModuleFormat.legacy ;
150 var success; 156 var success;
151 // TODO(vsm): Is it okay to reuse the same context here? If there is 157 // 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 158 // overlap between test files, we may need separate ones for each
153 // compiler. 159 // compiler.
154 var compiler = (sourceMaps || closure) 160 var compiler =
155 ? createCompiler(realSdkContext, 161 (sourceMaps || closure || moduleFormat != ModuleFormat.legacy)
156 sourceMaps: sourceMaps, closure: closure) 162 ? createCompiler(realSdkContext,
157 : batchCompiler; 163 sourceMaps: sourceMaps,
164 closure: closure,
165 moduleFormat: moduleFormat)
166 : batchCompiler;
158 success = compile(compiler, filePath); 167 success = compile(compiler, filePath);
159 168
160 var outFile = new File(path.join(outDir.path, '$filename.js')); 169 var outFile = new File(path.join(outDir.path, '$filename.js'));
161 expect(!success || outFile.existsSync(), true, 170 expect(!success || outFile.existsSync(), true,
162 reason: '${outFile.path} was created if compilation succeeds'); 171 reason: '${outFile.path} was created if compilation succeeds');
163 }); 172 });
164 } 173 }
165 }); 174 });
166 } 175 }
167 176
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 print('[AnalysisEngine] error $message $exception'); 250 print('[AnalysisEngine] error $message $exception');
242 } 251 }
243 252
244 @override void logError2(String message, Object exception) { 253 @override void logError2(String message, Object exception) {
245 print('[AnalysisEngine] error $message $exception'); 254 print('[AnalysisEngine] error $message $exception');
246 } 255 }
247 256
248 void logInformation(String message, [CaughtException exception]) {} 257 void logInformation(String message, [CaughtException exception]) {}
249 void logInformation2(String message, Object exception) {} 258 void logInformation2(String message, Object exception) {}
250 } 259 }
OLDNEW
« no previous file with comments | « test/codegen/expect/es6_modules.txt ('k') | test/utils_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698