| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library utils; | 5 library utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:stack_trace/stack_trace.dart'; |
| 10 |
| 9 /// A pair of values. | 11 /// A pair of values. |
| 10 class Pair<E, F> { | 12 class Pair<E, F> { |
| 11 E first; | 13 E first; |
| 12 F last; | 14 F last; |
| 13 | 15 |
| 14 Pair(this.first, this.last); | 16 Pair(this.first, this.last); |
| 15 | 17 |
| 16 String toString() => '($first, $last)'; | 18 String toString() => '($first, $last)'; |
| 17 | 19 |
| 18 bool operator==(other) { | 20 bool operator==(other) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 return map; | 177 return map; |
| 176 }); | 178 }); |
| 177 } | 179 } |
| 178 | 180 |
| 179 /// Returns whether [pattern] matches all of [string]. | 181 /// Returns whether [pattern] matches all of [string]. |
| 180 bool fullMatch(String string, Pattern pattern) { | 182 bool fullMatch(String string, Pattern pattern) { |
| 181 var matches = pattern.allMatches(string); | 183 var matches = pattern.allMatches(string); |
| 182 if (matches.isEmpty) return false; | 184 if (matches.isEmpty) return false; |
| 183 return matches.first.start == 0 && matches.first.end == string.length; | 185 return matches.first.start == 0 && matches.first.end == string.length; |
| 184 } | 186 } |
| 187 |
| 188 /// Returns a string representation of [trace] that has the core and test frames |
| 189 /// folded together. |
| 190 String terseTraceString(StackTrace trace) { |
| 191 return new Trace.from(trace).terse.foldFrames((frame) { |
| 192 return frame.package == 'scheduled_test' || frame.package == 'unittest' || |
| 193 frame.isCore; |
| 194 }).toString().trim(); |
| 195 } |
| OLD | NEW |