| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Visualization of source mappings generated and tested in | 5 /// Visualization of source mappings generated and tested in |
| 6 /// 'source_mapping_test.dart'. | 6 /// 'source_mapping_test.dart'. |
| 7 | 7 |
| 8 library source_mapping.test.viewer; | 8 library source_mapping.test.viewer; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 Future<Measurement> runTest( | 127 Future<Measurement> runTest( |
| 128 String config, | 128 String config, |
| 129 String filename, | 129 String filename, |
| 130 List<String> options, | 130 List<String> options, |
| 131 {Uri outputUri, | 131 {Uri outputUri, |
| 132 bool verbose}) async { | 132 bool verbose}) async { |
| 133 TestResult result = | 133 TestResult result = |
| 134 await runTests(config, filename, options, verbose: verbose); | 134 await runTests(config, filename, options, verbose: verbose); |
| 135 if (outputUri != null) { | 135 if (outputUri != null) { |
| 136 if (result.failureMap.isNotEmpty) { | 136 if (result.missingCodePointsMap.isNotEmpty) { |
| 137 result.failureMap.forEach((info, missingCodePoints) { | 137 result.printMissingCodePoints(); |
| 138 print("Missing code points for ${info.element} in '$filename' " | 138 } |
| 139 "in config '$config':"); | 139 if (result.multipleNodesMap.isNotEmpty) { |
| 140 for (CodePoint codePoint in missingCodePoints) { | 140 result.printMultipleNodes(); |
| 141 print(" $codePoint"); | 141 } |
| 142 } | 142 if (result.multipleOffsetsMap.isNotEmpty) { |
| 143 }); | 143 result.printMultipleOffsets(); |
| 144 } | 144 } |
| 145 createTraceSourceMapHtml(outputUri, result.processor, result.userInfoList); | 145 createTraceSourceMapHtml(outputUri, result.processor, result.userInfoList); |
| 146 } | 146 } |
| 147 return new Measurement(config, filename, | 147 return new Measurement(config, filename, |
| 148 result.failureMap.values.fold(0, (s, i) => s + i.length), | 148 result.missingCodePointsMap.values.fold(0, (s, i) => s + i.length), |
| 149 result.userInfoList.fold(0, (s, i) => s + i.codePoints.length)); | 149 result.userInfoList.fold(0, (s, i) => s + i.codePoints.length)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 class Measurement { | 152 class Measurement { |
| 153 final String config; | 153 final String config; |
| 154 final String filename; | 154 final String filename; |
| 155 | 155 |
| 156 final int missing; | 156 final int missing; |
| 157 final int count; | 157 final int count; |
| 158 | 158 |
| 159 Measurement(this.config, this.filename, this.missing, this.count); | 159 Measurement(this.config, this.filename, this.missing, this.count); |
| 160 | 160 |
| 161 String toString() { | 161 String toString() { |
| 162 double percentage = 100 * missing / count; | 162 double percentage = 100 * missing / count; |
| 163 return "Config '${config}', file: '${filename}': " | 163 return "Config '${config}', file: '${filename}': " |
| 164 "$missing of $count ($percentage%) missing"; | 164 "$missing of $count ($percentage%) missing"; |
| 165 } | 165 } |
| 166 } | 166 } |
| OLD | NEW |