| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// | 6 /// |
| 7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks | 7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks |
| 8 /// that the output is what we expected. | 8 /// that the output is what we expected. |
| 9 library dev_compiler.test.codegen_test; | 9 library dev_compiler.test.codegen_test; |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // Collect any other files we've imported. | 151 // Collect any other files we've imported. |
| 152 var files = new Set<String>(); | 152 var files = new Set<String>(); |
| 153 _collectTransitiveImports(contents, files, from: testFile); | 153 _collectTransitiveImports(contents, files, from: testFile); |
| 154 var unit = new BuildUnit( | 154 var unit = new BuildUnit( |
| 155 name, path.dirname(testFile), files.toList(), _moduleForLibrary); | 155 name, path.dirname(testFile), files.toList(), _moduleForLibrary); |
| 156 | 156 |
| 157 var compiler = sharedCompiler; | 157 var compiler = sharedCompiler; |
| 158 if (analyzerOptions.declaredVariables.isNotEmpty) { | 158 if (analyzerOptions.declaredVariables.isNotEmpty) { |
| 159 compiler = new ModuleCompiler(analyzerOptions); | 159 compiler = new ModuleCompiler(analyzerOptions); |
| 160 } | 160 } |
| 161 var module = compiler.compile(unit, options); | 161 JSModuleFile module = null; |
| 162 try { |
| 163 module = compiler.compile(unit, options); |
| 164 } catch (e) {} |
| 162 | 165 |
| 163 bool notStrong = notYetStrongTests.contains(name); | 166 bool notStrong = notYetStrongTests.contains(name); |
| 164 if (module.isValid) { | 167 bool crashing = _crashingTests.contains(name); |
| 168 |
| 169 if (module == null) { |
| 170 expect(crashing, isTrue, |
| 171 reason: "test $name crashes during compilation."); |
| 172 } else if (module.isValid) { |
| 165 _writeModule( | 173 _writeModule( |
| 166 path.join(codegenOutputDir, name), | 174 path.join(codegenOutputDir, name), |
| 167 isTopLevelTest ? path.join(codegenExpectDir, name) : null, | 175 isTopLevelTest ? path.join(codegenExpectDir, name) : null, |
| 168 moduleFormat, | 176 moduleFormat, |
| 169 module); | 177 module); |
| 170 | 178 |
| 179 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
| 171 expect(notStrong, isFalse, | 180 expect(notStrong, isFalse, |
| 172 reason: "test $name expected strong mode errors, but compiled."); | 181 reason: "test $name expected strong mode errors, but compiled."); |
| 173 } else { | 182 } else { |
| 183 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
| 174 expect(notStrong, isTrue, | 184 expect(notStrong, isTrue, |
| 175 reason: "test $name failed to compile due to strong mode errors:" | 185 reason: "test $name failed to compile due to strong mode errors:" |
| 176 "\n\n${module.errors.join('\n')}."); | 186 "\n\n${module.errors.join('\n')}."); |
| 177 } | 187 } |
| 178 }); | 188 }); |
| 179 } | 189 } |
| 180 | 190 |
| 181 if (filePattern.hasMatch('sunflower')) { | 191 if (filePattern.hasMatch('sunflower')) { |
| 182 test('sunflower', () { | 192 test('sunflower', () { |
| 183 _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir); | 193 _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 StringLiteral uriLiteral = directive.uri; | 368 StringLiteral uriLiteral = directive.uri; |
| 359 String uriContent = uriLiteral.stringValue; | 369 String uriContent = uriLiteral.stringValue; |
| 360 if (uriContent != null) { | 370 if (uriContent != null) { |
| 361 uriContent = uriContent.trim(); | 371 uriContent = uriContent.trim(); |
| 362 directive.uriContent = uriContent; | 372 directive.uriContent = uriContent; |
| 363 } | 373 } |
| 364 return (directive as UriBasedDirectiveImpl).validate() == null | 374 return (directive as UriBasedDirectiveImpl).validate() == null |
| 365 ? uriContent | 375 ? uriContent |
| 366 : null; | 376 : null; |
| 367 } | 377 } |
| 378 |
| 379 final _crashingTests = new Set<String>.from([ |
| 380 'language/mixin_illegal_syntax_test_none_multi', |
| 381 'language/mixin_illegal_syntax_test_01_multi', |
| 382 'language/mixin_illegal_syntax_test_02_multi', |
| 383 'language/mixin_illegal_syntax_test_03_multi', |
| 384 'language/mixin_illegal_syntax_test_04_multi', |
| 385 'language/mixin_illegal_syntax_test_05_multi', |
| 386 'language/mixin_illegal_syntax_test_06_multi', |
| 387 'language/mixin_illegal_syntax_test_07_multi', |
| 388 'language/mixin_illegal_syntax_test_08_multi', |
| 389 'language/mixin_illegal_syntax_test_09_multi', |
| 390 'language/mixin_illegal_syntax_test_10_multi', |
| 391 'language/mixin_illegal_syntax_test_11_multi', |
| 392 'language/mixin_illegal_syntax_test_12_multi', |
| 393 'language/mixin_illegal_syntax_test_13_multi', |
| 394 'language/mixin_illegal_syntax_test_14_multi' |
| 395 ]); |
| OLD | NEW |