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

Side by Side Diff: tests/compiler/dart2js/kernel/compile_from_dill_test_helper.dart

Issue 2969073002: Add most equivalence tests to js_model/model_test (Closed)
Patch Set: Created 3 years, 5 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 // Helper to test compilation equivalence between source and .dill based 5 // Helper to test compilation equivalence between source and .dill based
6 // compilation. 6 // compilation.
7 library dart2js.kernel.compile_from_dill_test_helper; 7 library dart2js.kernel.compile_from_dill_test_helper;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 expectIdenticalOutput: test.expectIdenticalOutput); 179 expectIdenticalOutput: test.expectIdenticalOutput);
180 } 180 }
181 } 181 }
182 182
183 Future<ResultKind> runTest( 183 Future<ResultKind> runTest(
184 Uri entryPoint, Map<String, String> memorySourceFiles, 184 Uri entryPoint, Map<String, String> memorySourceFiles,
185 {bool skipWarnings: false, 185 {bool skipWarnings: false,
186 bool skipErrors: false, 186 bool skipErrors: false,
187 bool verbose: false, 187 bool verbose: false,
188 List<String> options: const <String>[], 188 List<String> options: const <String>[],
189 bool expectAstEquivalence: false,
189 bool expectIdenticalOutput: true}) async { 190 bool expectIdenticalOutput: true}) async {
190 enableDebugMode(); 191 enableDebugMode();
191 EnumCreator.matchKernelRepresentationForTesting = true; 192 EnumCreator.matchKernelRepresentationForTesting = true;
192 Elements.usePatchedDart2jsSdkSorting = true; 193 Elements.usePatchedDart2jsSdkSorting = true;
193 194
194 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill'); 195 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill');
195 print('--- create temp directory $dir -------------------------------'); 196 print('--- create temp directory $dir -------------------------------');
196 memorySourceFiles.forEach((String name, String source) { 197 memorySourceFiles.forEach((String name, String source) {
197 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source); 198 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source);
198 }); 199 });
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 elementFilter: elementFilter, 275 elementFilter: elementFilter,
275 verbose: verbose); 276 verbose: verbose);
276 277
277 checkEmitters(compiler1.backend.emitter, compiler2.backend.emitter, 278 checkEmitters(compiler1.backend.emitter, compiler2.backend.emitter,
278 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), 279 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b),
279 typeEquivalence: (DartType a, DartType b) { 280 typeEquivalence: (DartType a, DartType b) {
280 return equivalence.typeEquivalence(unalias(a), b); 281 return equivalence.typeEquivalence(unalias(a), b);
281 }, 282 },
282 verbose: verbose); 283 verbose: verbose);
283 284
284 checkGeneratedCode(compiler1.backend, compiler2.backend, 285 if (expectAstEquivalence) {
285 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b)); 286 checkGeneratedCode(compiler1.backend, compiler2.backend,
287 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b));
288 }
286 289
287 if (expectIdenticalOutput) { 290 if (expectIdenticalOutput) {
288 print('--- checking output------- ---------------------------------------'); 291 print('--- checking output------- ---------------------------------------');
289 collector1.outputMap 292 collector1.outputMap
290 .forEach((OutputType outputType, Map<String, BufferedOutputSink> map1) { 293 .forEach((OutputType outputType, Map<String, BufferedOutputSink> map1) {
291 if (outputType == OutputType.sourceMap) { 294 if (outputType == OutputType.sourceMap) {
292 // TODO(johnniwinther): Support source map from .dill. 295 // TODO(johnniwinther): Support source map from .dill.
293 return; 296 return;
294 } 297 }
295 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; 298 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType];
296 checkSets(map1.keys, map2.keys, 'output', equality); 299 checkSets(map1.keys, map2.keys, 'output', equality);
297 map1.forEach((String name, BufferedOutputSink output1) { 300 map1.forEach((String name, BufferedOutputSink output1) {
298 BufferedOutputSink output2 = map2[name]; 301 BufferedOutputSink output2 = map2[name];
299 Expect.stringEquals(output1.text, output2.text); 302 Expect.stringEquals(output1.text, output2.text);
300 }); 303 });
301 }); 304 });
302 } 305 }
303 return ResultKind.success; 306 return ResultKind.success;
304 } 307 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698