| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import 'package:compiler/compiler_new.dart'; | 10 import 'package:compiler/compiler_new.dart'; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (useNewSourceInfo) { | 70 if (useNewSourceInfo) { |
| 71 options.add(Flags.useNewSourceInfo); | 71 options.add(Flags.useNewSourceInfo); |
| 72 } | 72 } |
| 73 CompilationResult compilationResult = await runCompiler( | 73 CompilationResult compilationResult = await runCompiler( |
| 74 entryPoint: Uri.parse('memory:main.dart'), | 74 entryPoint: Uri.parse('memory:main.dart'), |
| 75 memorySourceFiles: {'main.dart': code}, | 75 memorySourceFiles: {'main.dart': code}, |
| 76 outputProvider: collector, | 76 outputProvider: collector, |
| 77 options: options); | 77 options: options); |
| 78 Expect.isTrue(compilationResult.isSuccess, | 78 Expect.isTrue(compilationResult.isSuccess, |
| 79 "Unsuccessful compilation of test:\n${code}"); | 79 "Unsuccessful compilation of test:\n${code}"); |
| 80 String sourceMapText = collector.getOutput('', 'js.map'); | 80 String sourceMapText = collector.getOutput('', OutputType.sourceMap); |
| 81 SingleMapping sourceMap = parse(sourceMapText); | 81 SingleMapping sourceMap = parse(sourceMapText); |
| 82 if (writeJs) { | 82 if (writeJs) { |
| 83 new File('out.js').writeAsStringSync(collector.getOutput('', 'js')); | 83 new File('out.js') |
| 84 .writeAsStringSync(collector.getOutput('', OutputType.js)); |
| 84 new File('out.js.map').writeAsStringSync(sourceMapText); | 85 new File('out.js.map').writeAsStringSync(sourceMapText); |
| 85 } | 86 } |
| 86 Expect.isTrue(sourceMap.lines.isNotEmpty); | 87 Expect.isTrue(sourceMap.lines.isNotEmpty); |
| 87 TargetLineEntry firstLineEntry = sourceMap.lines.first; | 88 TargetLineEntry firstLineEntry = sourceMap.lines.first; |
| 88 Expect.isTrue(firstLineEntry.entries.isNotEmpty); | 89 Expect.isTrue(firstLineEntry.entries.isNotEmpty); |
| 89 TargetEntry firstEntry = firstLineEntry.entries.first; | 90 TargetEntry firstEntry = firstLineEntry.entries.first; |
| 90 Expect.isNull( | 91 Expect.isNull( |
| 91 firstEntry.sourceUrlId, | 92 firstEntry.sourceUrlId, |
| 92 "Unexpected first entry: " | 93 "Unexpected first entry: " |
| 93 "${entryToString(firstLineEntry, firstEntry, sourceMap)}"); | 94 "${entryToString(firstLineEntry, firstEntry, sourceMap)}"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 120 } | 121 } |
| 121 if (entry.sourceLine != null) { | 122 if (entry.sourceLine != null) { |
| 122 sb.write('sourceLine='); | 123 sb.write('sourceLine='); |
| 123 sb.write(entry.sourceLine); | 124 sb.write(entry.sourceLine); |
| 124 sb.write(',sourceColumn='); | 125 sb.write(',sourceColumn='); |
| 125 sb.write(entry.sourceColumn); | 126 sb.write(entry.sourceColumn); |
| 126 } | 127 } |
| 127 sb.write(']'); | 128 sb.write(']'); |
| 128 return sb.toString(); | 129 return sb.toString(); |
| 129 } | 130 } |
| OLD | NEW |