| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 var files = new Set<String>(); | 149 var files = new Set<String>(); |
| 150 _collectTransitiveImports(contents, files, from: testFile); | 150 _collectTransitiveImports(contents, files, from: testFile); |
| 151 var unit = new BuildUnit( | 151 var unit = new BuildUnit( |
| 152 name, path.dirname(testFile), files.toList(), _moduleForLibrary); | 152 name, path.dirname(testFile), files.toList(), _moduleForLibrary); |
| 153 | 153 |
| 154 var compiler = sharedCompiler; | 154 var compiler = sharedCompiler; |
| 155 if (analyzerOptions.declaredVariables.isNotEmpty) { | 155 if (analyzerOptions.declaredVariables.isNotEmpty) { |
| 156 compiler = new ModuleCompiler(analyzerOptions); | 156 compiler = new ModuleCompiler(analyzerOptions); |
| 157 } | 157 } |
| 158 JSModuleFile module = null; | 158 JSModuleFile module = null; |
| 159 var exception = null; |
| 159 try { | 160 try { |
| 160 module = compiler.compile(unit, options); | 161 module = compiler.compile(unit, options); |
| 161 } catch (e) {} | 162 } catch (e) { |
| 163 exception = e; |
| 164 } |
| 162 | 165 |
| 163 bool expectedCompileTimeError = | 166 bool expectedCompileTimeError = |
| 164 contents.contains(': compile-time error\n'); | 167 contents.contains(': compile-time error\n'); |
| 165 bool notStrong = notYetStrongTests.contains(name); | 168 bool notStrong = notYetStrongTests.contains(name); |
| 166 bool crashing = _crashingTests.contains(name); | 169 bool crashing = _crashingTests.contains(name); |
| 167 | 170 |
| 168 if (module == null) { | 171 if (module == null) { |
| 169 expect(crashing, isTrue, | 172 expect(crashing, isTrue, |
| 170 reason: "test $name crashes during compilation."); | 173 reason: "test $name crashes during compilation:\n $exception"); |
| 171 } else if (module.isValid) { | 174 } else if (module.isValid) { |
| 172 _writeModule( | 175 _writeModule( |
| 173 path.join(codegenOutputDir, name), | 176 path.join(codegenOutputDir, name), |
| 174 isTopLevelTest ? path.join(codegenExpectDir, name) : null, | 177 isTopLevelTest ? path.join(codegenExpectDir, name) : null, |
| 175 moduleFormat, | 178 moduleFormat, |
| 176 module); | 179 module); |
| 177 | 180 |
| 178 expect(crashing, isFalse, reason: "test $name no longer crashes."); | 181 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
| 179 // TODO(vsm): We don't seem to trip on non-strong errors? | 182 // TODO(vsm): We don't seem to trip on non-strong errors? |
| 180 // expect(expectedCompileTimeError, isFalse, | 183 // expect(expectedCompileTimeError, isFalse, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 392 |
| 390 // TODO(vsm): Fix these - they import files from a different directory | 393 // TODO(vsm): Fix these - they import files from a different directory |
| 391 // - this triggers an invalid library root build error. | 394 // - this triggers an invalid library root build error. |
| 392 'lib/html/custom/attribute_changed_callback_test', | 395 'lib/html/custom/attribute_changed_callback_test', |
| 393 'lib/html/custom/constructor_calls_created_synchronously_test', | 396 'lib/html/custom/constructor_calls_created_synchronously_test', |
| 394 'lib/html/custom/entered_left_view_test', | 397 'lib/html/custom/entered_left_view_test', |
| 395 'lib/html/custom/js_custom_test', | 398 'lib/html/custom/js_custom_test', |
| 396 'lib/html/custom/mirrors_test', | 399 'lib/html/custom/mirrors_test', |
| 397 'lib/html/custom/regress_194523002_test', | 400 'lib/html/custom/regress_194523002_test', |
| 398 ]); | 401 ]); |
| OLD | NEW |