| OLD | NEW |
| 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 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 main() { | 158 main() { |
| 159 var x; | 159 var x; |
| 160 int i = 0; | 160 int i = 0; |
| 161 do { | 161 do { |
| 162 if (i == 5) continue; | 162 if (i == 5) continue; |
| 163 x = i; | 163 x = i; |
| 164 if (i == 7) break; | 164 if (i == 7) break; |
| 165 i++; | 165 i++; |
| 166 } while (i < 10); | 166 } while (i < 10); |
| 167 outer: for (var a in [3, 5]) { | 167 outer1: for (var a in [3, 5]) { |
| 168 for (var b in [2, 4]) { | 168 for (var b in [2, 4]) { |
| 169 if (a == b) break outer; | 169 if (a == b) break outer1; |
| 170 } |
| 171 } |
| 172 outer2: for (var a in [3, 5]) { |
| 173 for (var b in [2, 4]) { |
| 174 if (a != b) continue outer2; |
| 175 } |
| 176 } |
| 177 outer3: for (var a in [3, 5]) { |
| 178 for (var b in [2, 4]) { |
| 179 if (a == b) break outer3; |
| 180 if (a != b) continue outer3; |
| 170 } | 181 } |
| 171 } | 182 } |
| 172 print(x); | 183 print(x); |
| 173 } | 184 } |
| 174 ''' | 185 ''' |
| 175 }, expectIdenticalOutput: false), | 186 }, expectIdenticalOutput: false), |
| 176 const Test(const { | 187 const Test(const { |
| 177 'main.dart': ''' | 188 'main.dart': ''' |
| 178 class A<U,V> { | 189 class A<U,V> { |
| 179 var a = U; | 190 var a = U; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 ClosedWorld closedWorld1 = | 305 ClosedWorld closedWorld1 = |
| 295 compiler1.resolutionWorldBuilder.closedWorldForTesting; | 306 compiler1.resolutionWorldBuilder.closedWorldForTesting; |
| 296 | 307 |
| 297 OutputCollector collector2 = new OutputCollector(); | 308 OutputCollector collector2 = new OutputCollector(); |
| 298 Compiler compiler2 = await compileWithDill( | 309 Compiler compiler2 = await compileWithDill( |
| 299 entryPoint: entryPoint, | 310 entryPoint: entryPoint, |
| 300 options: <String>[]..addAll(commonOptions)..addAll(options), | 311 options: <String>[]..addAll(commonOptions)..addAll(options), |
| 301 printSteps: true, | 312 printSteps: true, |
| 302 compilerOutput: collector2); | 313 compilerOutput: collector2); |
| 303 | 314 |
| 315 // Print the middle section of the outputs if they are not line-wise |
| 316 // identical. |
| 317 collector1.outputMap |
| 318 .forEach((OutputType outputType, Map<String, BufferedOutputSink> map1) { |
| 319 if (outputType == OutputType.sourceMap) { |
| 320 return; |
| 321 } |
| 322 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; |
| 323 checkSets(map1.keys, map2.keys, 'output', equality); |
| 324 map1.forEach((String name, BufferedOutputSink output1) { |
| 325 BufferedOutputSink output2 = map2[name]; |
| 326 if (output1.text == output2.text) return; |
| 327 List<String> lines1 = output1.text.split('\n'); |
| 328 List<String> lines2 = output2.text.split('\n'); |
| 329 int prefix = 0; |
| 330 while (prefix < lines1.length && prefix < lines2.length) { |
| 331 if (lines1[prefix] != lines2[prefix]) { |
| 332 break; |
| 333 } |
| 334 prefix++; |
| 335 } |
| 336 int suffix1 = lines1.length - 1; |
| 337 int suffix2 = lines2.length - 1; |
| 338 while (suffix1 >= 0 && suffix2 >= 0) { |
| 339 if (lines1[suffix1] != lines2[suffix2]) { |
| 340 break; |
| 341 } |
| 342 suffix1--; |
| 343 suffix2--; |
| 344 } |
| 345 print('--- from source, lines [${prefix}-${suffix1}] ------------------'); |
| 346 lines1.sublist(prefix, suffix1 + 1).forEach(print); |
| 347 print('--- from dill, lines [${prefix}-${suffix2}] --------------------'); |
| 348 lines2.sublist(prefix, suffix2 + 1).forEach(print); |
| 349 }); |
| 350 }); |
| 351 |
| 304 KernelFrontEndStrategy frontendStrategy = compiler2.frontendStrategy; | 352 KernelFrontEndStrategy frontendStrategy = compiler2.frontendStrategy; |
| 305 KernelToElementMap elementMap = frontendStrategy.elementMap; | 353 KernelToElementMap elementMap = frontendStrategy.elementMap; |
| 306 | 354 |
| 307 Expect.isFalse(compiler2.compilationFailed); | 355 Expect.isFalse(compiler2.compilationFailed); |
| 308 | 356 |
| 309 KernelEquivalence equivalence1 = new KernelEquivalence(elementMap); | 357 KernelEquivalence equivalence1 = new KernelEquivalence(elementMap); |
| 310 | 358 |
| 311 ClosedWorld closedWorld2 = | 359 ClosedWorld closedWorld2 = |
| 312 compiler2.resolutionWorldBuilder.closedWorldForTesting; | 360 compiler2.resolutionWorldBuilder.closedWorldForTesting; |
| 313 | 361 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; | 422 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; |
| 375 checkSets(map1.keys, map2.keys, 'output', equality); | 423 checkSets(map1.keys, map2.keys, 'output', equality); |
| 376 map1.forEach((String name, BufferedOutputSink output1) { | 424 map1.forEach((String name, BufferedOutputSink output1) { |
| 377 BufferedOutputSink output2 = map2[name]; | 425 BufferedOutputSink output2 = map2[name]; |
| 378 Expect.stringEquals(output1.text, output2.text); | 426 Expect.stringEquals(output1.text, output2.text); |
| 379 }); | 427 }); |
| 380 }); | 428 }); |
| 381 } | 429 } |
| 382 return ResultKind.success; | 430 return ResultKind.success; |
| 383 } | 431 } |
| OLD | NEW |