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

Side by Side Diff: test/codegen_test.dart

Issue 1677863002: Use default params when --destructure-named-params + fix renaming of reserved destructured params (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 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) 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 68 {bool checkSdk: false,
69 bool sourceMaps: false, 69 bool sourceMaps: false,
70 bool destructureNamedParams: false,
70 bool closure: false, 71 bool closure: false,
71 ModuleFormat moduleFormat: ModuleFormat.legacy}) { 72 ModuleFormat moduleFormat: ModuleFormat.legacy}) {
72 // TODO(jmesserly): add a way to specify flags in the test file, so 73 // TODO(jmesserly): add a way to specify flags in the test file, so
73 // they're more self-contained. 74 // they're more self-contained.
74 var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime'); 75 var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime');
75 var options = new CompilerOptions( 76 var options = new CompilerOptions(
76 codegenOptions: new CodegenOptions( 77 codegenOptions: new CodegenOptions(
77 outputDir: expectDir, 78 outputDir: expectDir,
78 emitSourceMaps: sourceMaps, 79 emitSourceMaps: sourceMaps,
79 closure: closure, 80 closure: closure,
81 destructureNamedParams: destructureNamedParams,
80 forceCompile: checkSdk, 82 forceCompile: checkSdk,
81 moduleFormat: moduleFormat), 83 moduleFormat: moduleFormat),
82 useColors: false, 84 useColors: false,
83 checkSdk: checkSdk, 85 checkSdk: checkSdk,
84 runtimeDir: runtimeDir, 86 runtimeDir: runtimeDir,
85 inputBaseDir: inputDir); 87 inputBaseDir: inputDir);
86 var reporter = createErrorReporter(context, options); 88 var reporter = createErrorReporter(context, options);
87 return new BatchCompiler(context, options, reporter: reporter); 89 return new BatchCompiler(context, options, reporter: reporter);
88 } 90 }
89 91
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (multitests.contains(filePath)) continue; 146 if (multitests.contains(filePath)) continue;
145 147
146 var filename = path.basenameWithoutExtension(filePath); 148 var filename = path.basenameWithoutExtension(filePath);
147 149
148 test('$filename.dart', () { 150 test('$filename.dart', () {
149 // TODO(jmesserly): this was added to get some coverage of source maps 151 // TODO(jmesserly): this was added to get some coverage of source maps
150 // and closure annotations. 152 // and closure annotations.
151 // We need a more comprehensive strategy to test them. 153 // We need a more comprehensive strategy to test them.
152 var sourceMaps = filename == 'map_keys'; 154 var sourceMaps = filename == 'map_keys';
153 var closure = filename == 'closure'; 155 var closure = filename == 'closure';
156 var destructureNamedParams = filename == 'destructuring' || closure;
154 var moduleFormat = filename == 'es6_modules' 157 var moduleFormat = filename == 'es6_modules'
155 ? ModuleFormat.es6 158 ? ModuleFormat.es6
156 : filename == 'node_modules' 159 : filename == 'node_modules'
157 ? ModuleFormat.node 160 ? ModuleFormat.node
158 : ModuleFormat.legacy; 161 : ModuleFormat.legacy;
159 var success; 162 var success;
160 // TODO(vsm): Is it okay to reuse the same context here? If there is 163 // TODO(vsm): Is it okay to reuse the same context here? If there is
161 // overlap between test files, we may need separate ones for each 164 // overlap between test files, we may need separate ones for each
162 // compiler. 165 // compiler.
163 var compiler = 166 var compiler = (sourceMaps ||
164 (sourceMaps || closure || moduleFormat != ModuleFormat.legacy) 167 closure ||
165 ? createCompiler(realSdkContext, 168 destructureNamedParams ||
166 sourceMaps: sourceMaps, 169 moduleFormat != ModuleFormat.legacy)
167 closure: closure, 170 ? createCompiler(realSdkContext,
168 moduleFormat: moduleFormat) 171 sourceMaps: sourceMaps,
169 : batchCompiler; 172 destructureNamedParams: destructureNamedParams,
173 closure: closure,
174 moduleFormat: moduleFormat)
175 : batchCompiler;
170 success = compile(compiler, filePath); 176 success = compile(compiler, filePath);
171 177
172 var outFile = new File(path.join(outDir.path, '$filename.js')); 178 var outFile = new File(path.join(outDir.path, '$filename.js'));
173 expect(!success || outFile.existsSync(), true, 179 expect(!success || outFile.existsSync(), true,
174 reason: '${outFile.path} was created if compilation succeeds'); 180 reason: '${outFile.path} was created if compilation succeeds');
175 }); 181 });
176 } 182 }
177 }); 183 });
178 } 184 }
179 185
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 255
250 /// An implementation of analysis engine's [Logger] that prints. 256 /// An implementation of analysis engine's [Logger] that prints.
251 class PrintLogger implements Logger { 257 class PrintLogger implements Logger {
252 @override void logError(String message, [CaughtException exception]) { 258 @override void logError(String message, [CaughtException exception]) {
253 print('[AnalysisEngine] error $message $exception'); 259 print('[AnalysisEngine] error $message $exception');
254 } 260 }
255 261
256 void logInformation(String message, [CaughtException exception]) {} 262 void logInformation(String message, [CaughtException exception]) {}
257 void logInformation2(String message, Object exception) {} 263 void logInformation2(String message, Object exception) {}
258 } 264 }
OLDNEW
« lib/src/js/printer.dart ('K') | « test/codegen/expect/destructuring.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698