| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 163 } |
| 164 | 164 |
| 165 void _writeModule(String outPath, String expectPath, ModuleFormat format, | 165 void _writeModule(String outPath, String expectPath, ModuleFormat format, |
| 166 JSModuleFile result) { | 166 JSModuleFile result) { |
| 167 _ensureDirectory(path.dirname(outPath)); | 167 _ensureDirectory(path.dirname(outPath)); |
| 168 | 168 |
| 169 String errors = result.errors.join('\n'); | 169 String errors = result.errors.join('\n'); |
| 170 if (errors.isNotEmpty && !errors.endsWith('\n')) errors += '\n'; | 170 if (errors.isNotEmpty && !errors.endsWith('\n')) errors += '\n'; |
| 171 new File(outPath + '.txt').writeAsStringSync(errors); | 171 new File(outPath + '.txt').writeAsStringSync(errors); |
| 172 | 172 |
| 173 result.writeCodeSync(format, outPath + '.js'); | 173 result.writeCodeSync(format, false, outPath + '.js'); |
| 174 | 174 |
| 175 if (result.summaryBytes != null) { | 175 if (result.summaryBytes != null) { |
| 176 new File(outPath + '.sum').writeAsBytesSync(result.summaryBytes); | 176 new File(outPath + '.sum').writeAsBytesSync(result.summaryBytes); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Write the expectation file if needed. | 179 // Write the expectation file if needed. |
| 180 // Generally speaking we try to avoid these tests, but they are occasionally | 180 // Generally speaking we try to avoid these tests, but they are occasionally |
| 181 // useful. | 181 // useful. |
| 182 if (expectPath != null) { | 182 if (expectPath != null) { |
| 183 _ensureDirectory(path.dirname(expectPath)); | 183 _ensureDirectory(path.dirname(expectPath)); |
| 184 | 184 |
| 185 var expectFile = new File(expectPath + '.js'); | 185 var expectFile = new File(expectPath + '.js'); |
| 186 if (result.isValid) { | 186 if (result.isValid) { |
| 187 result.writeCodeSync(format, expectFile.path); | 187 result.writeCodeSync(format, false, expectFile.path); |
| 188 } else { | 188 } else { |
| 189 expectFile.writeAsStringSync("//FAILED TO COMPILE"); | 189 expectFile.writeAsStringSync("//FAILED TO COMPILE"); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 void _buildSunflower( | 194 void _buildSunflower( |
| 195 ModuleCompiler compiler, String outputDir, String expectDir) { | 195 ModuleCompiler compiler, String outputDir, String expectDir) { |
| 196 var baseDir = path.join(codegenDir, 'sunflower'); | 196 var baseDir = path.join(codegenDir, 'sunflower'); |
| 197 var files = ['sunflower', 'circle', 'painter'] | 197 var files = ['sunflower', 'circle', 'painter'] |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 /// Simplified from ParseDartTask.resolveDirective. | 321 /// Simplified from ParseDartTask.resolveDirective. |
| 322 String _resolveDirective(UriBasedDirective directive) { | 322 String _resolveDirective(UriBasedDirective directive) { |
| 323 StringLiteral uriLiteral = directive.uri; | 323 StringLiteral uriLiteral = directive.uri; |
| 324 String uriContent = uriLiteral.stringValue; | 324 String uriContent = uriLiteral.stringValue; |
| 325 if (uriContent != null) { | 325 if (uriContent != null) { |
| 326 uriContent = uriContent.trim(); | 326 uriContent = uriContent.trim(); |
| 327 directive.uriContent = uriContent; | 327 directive.uriContent = uriContent; |
| 328 } | 328 } |
| 329 return directive.validate() == null ? uriContent : null; | 329 return directive.validate() == null ? uriContent : null; |
| 330 } | 330 } |
| OLD | NEW |