dartfmt
diff --git a/pkgs/stack_trace/lib/src/chain.dart b/pkgs/stack_trace/lib/src/chain.dart index 4543eff..04a153a 100644 --- a/pkgs/stack_trace/lib/src/chain.dart +++ b/pkgs/stack_trace/lib/src/chain.dart
@@ -70,7 +70,7 @@ /// considered unhandled. /// /// If [callback] returns a value, it will be returned by [capture] as well. - static /*=T*/ capture/*<T>*/(/*=T*/ callback(), + static/*=T*/ capture/*<T>*/(/*=T*/ callback(), {void onError(error, Chain chain), bool when: true}) { if (!when) { var newOnError; @@ -106,13 +106,9 @@ /// [callback] in a [Zone] in which chain capturing is disabled. /// /// If [callback] returns a value, it will be returned by [disable] as well. - static /*=T*/ disable/*<T>*/(/*=T*/ callback(), {bool when: true}) { - var zoneValues = when - ? { - _specKey: null, - StackZoneSpecification.disableKey: true - } - : null; + static/*=T*/ disable/*<T>*/(/*=T*/ callback(), {bool when: true}) { + var zoneValues = + when ? {_specKey: null, StackZoneSpecification.disableKey: true} : null; return runZoned(callback, zoneValues: zoneValues); } @@ -133,15 +129,15 @@ /// /// If this is called outside of a [capture] zone, it just returns a /// single-trace chain. - factory Chain.current([int level=0]) { + factory Chain.current([int level = 0]) { if (_currentSpec != null) return _currentSpec.currentChain(level + 1); var chain = new Chain.forTrace(StackTrace.current); return new LazyChain(() { // JS includes a frame for the call to StackTrace.current, but the VM // doesn't, so we skip an extra frame in a JS context. - var first = new Trace( - chain.traces.first.frames.skip(level + (inJS ? 2 : 1))); + var first = + new Trace(chain.traces.first.frames.skip(level + (inJS ? 2 : 1))); return new Chain([first]..addAll(chain.traces.skip(1))); }); } @@ -178,8 +174,7 @@ } /// Returns a new [Chain] comprised of [traces]. - Chain(Iterable<Trace> traces) - : traces = new List<Trace>.unmodifiable(traces); + Chain(Iterable<Trace> traces) : traces = new List<Trace>.unmodifiable(traces); /// Returns a terser version of [this]. /// @@ -208,8 +203,8 @@ /// library or from this package, and simplify core library frames as in /// [Trace.terse]. Chain foldFrames(bool predicate(Frame frame), {bool terse: false}) { - var foldedTraces = traces.map( - (trace) => trace.foldFrames(predicate, terse: terse)); + var foldedTraces = + traces.map((trace) => trace.foldFrames(predicate, terse: terse)); var nonEmptyTraces = foldedTraces.where((trace) { // Ignore traces that contain only folded frames. if (trace.frames.length > 1) return true; @@ -240,7 +235,8 @@ String toString() { // Figure out the longest path so we know how much to pad. var longest = traces.map((trace) { - return trace.frames.map((frame) => frame.location.length) + return trace.frames + .map((frame) => frame.location.length) .fold(0, math.max); }).fold(0, math.max);
diff --git a/pkgs/stack_trace/lib/src/frame.dart b/pkgs/stack_trace/lib/src/frame.dart index 8599245..bbe5c79 100644 --- a/pkgs/stack_trace/lib/src/frame.dart +++ b/pkgs/stack_trace/lib/src/frame.dart
@@ -17,8 +17,8 @@ // at VW.call$0 (eval as fn // (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28) // at http://pub.dartlang.org/stuff.dart.js:560:28 -final _v8Frame = new RegExp( - r'^\s*at (?:(\S.*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$'); +final _v8Frame = + new RegExp(r'^\s*at (?:(\S.*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$'); // http://pub.dartlang.org/stuff.dart.js:560:28 final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)|native$'); @@ -27,36 +27,34 @@ // eval as function (http://pub.dartlang.org/stuff.dart.js:560:28) // eval as function (eval as otherFunction // (http://pub.dartlang.org/stuff.dart.js:560:28)) -final _v8EvalLocation = new RegExp( - r'^eval at (?:\S.*?) \((.*)\)(?:, .*?:\d+:\d+)?$'); +final _v8EvalLocation = + new RegExp(r'^eval at (?:\S.*?) \((.*)\)(?:, .*?:\d+:\d+)?$'); // .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560 // .VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560 // .VW.call$0/name<@http://pub.dartlang.org/stuff.dart.js:560 // .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560:36 // http://pub.dartlang.org/stuff.dart.js:560 -final _firefoxSafariFrame = new RegExp( - r'^' +final _firefoxSafariFrame = new RegExp(r'^' r'(?:' // Member description. Not present in some Safari frames. - r'([^@(/]*)' // The actual name of the member. - r'(?:\(.*\))?' // Arguments to the member, sometimes captured by Firefox. - r'((?:/[^/]*)*)' // Extra characters indicating a nested closure. - r'(?:\(.*\))?' // Arguments to the closure. - r'@' + r'([^@(/]*)' // The actual name of the member. + r'(?:\(.*\))?' // Arguments to the member, sometimes captured by Firefox. + r'((?:/[^/]*)*)' // Extra characters indicating a nested closure. + r'(?:\(.*\))?' // Arguments to the closure. + r'@' r')?' r'(.*?)' // The frame's URL. r':' r'(\d*)' // The line number. Empty in Safari if it's unknown. r'(?::(\d*))?' // The column number. Not present in older browsers and - // empty in Safari if it's unknown. + // empty in Safari if it's unknown. r'$'); // foo/bar.dart 10:11 Foo._bar // foo/bar.dart 10:11 (anonymous function).dart.fn // http://dartlang.org/foo/bar.dart Foo._bar // data:... 10:11 Foo._bar -final _friendlyFrame = new RegExp( - r'^(\S+)(?: (\d+)(?::(\d+))?)?\s+([^\d].*)$'); +final _friendlyFrame = new RegExp(r'^(\S+)(?: (\d+)(?::(\d+))?)?\s+([^\d].*)$'); /// A regular expression that matches asynchronous member names generated by the /// VM. @@ -120,7 +118,7 @@ /// By default, this will return the frame above the current method. If /// [level] is `0`, it will return the current method's frame; if [level] is /// higher than `1`, it will return higher frames. - factory Frame.caller([int level=1]) { + factory Frame.caller([int level = 1]) { if (level < 0) { throw new ArgumentError("Argument [level] must be greater than or equal " "to 0."); @@ -131,71 +129,72 @@ /// Parses a string representation of a Dart VM stack frame. factory Frame.parseVM(String frame) => _catchFormatException(frame, () { - // The VM sometimes folds multiple stack frames together and replaces them - // with "...". - if (frame == '...') { - return new Frame(new Uri(), null, null, '...'); - } + // The VM sometimes folds multiple stack frames together and replaces them + // with "...". + if (frame == '...') { + return new Frame(new Uri(), null, null, '...'); + } - var match = _vmFrame.firstMatch(frame); - if (match == null) return new UnparsedFrame(frame); + var match = _vmFrame.firstMatch(frame); + if (match == null) return new UnparsedFrame(frame); - // Get the pieces out of the regexp match. Function, URI and line should - // always be found. The column is optional. - var member = match[1] - .replaceAll(_asyncBody, "<async>") - .replaceAll("<anonymous closure>", "<fn>"); - var uri = Uri.parse(match[2]); + // Get the pieces out of the regexp match. Function, URI and line should + // always be found. The column is optional. + var member = match[1] + .replaceAll(_asyncBody, "<async>") + .replaceAll("<anonymous closure>", "<fn>"); + var uri = Uri.parse(match[2]); - var lineAndColumn = match[3].split(':'); - var line = lineAndColumn.length > 1 ? int.parse(lineAndColumn[1]) : null; - var column = lineAndColumn.length > 2 ? int.parse(lineAndColumn[2]) : null; - return new Frame(uri, line, column, member); - }); + var lineAndColumn = match[3].split(':'); + var line = + lineAndColumn.length > 1 ? int.parse(lineAndColumn[1]) : null; + var column = + lineAndColumn.length > 2 ? int.parse(lineAndColumn[2]) : null; + return new Frame(uri, line, column, member); + }); /// Parses a string representation of a Chrome/V8 stack frame. factory Frame.parseV8(String frame) => _catchFormatException(frame, () { - var match = _v8Frame.firstMatch(frame); - if (match == null) return new UnparsedFrame(frame); + var match = _v8Frame.firstMatch(frame); + if (match == null) return new UnparsedFrame(frame); - // v8 location strings can be arbitrarily-nested, since it adds a layer of - // nesting for each eval performed on that line. - parseLocation(location, member) { - var evalMatch = _v8EvalLocation.firstMatch(location); - while (evalMatch != null) { - location = evalMatch[1]; - evalMatch = _v8EvalLocation.firstMatch(location); - } + // v8 location strings can be arbitrarily-nested, since it adds a layer of + // nesting for each eval performed on that line. + parseLocation(location, member) { + var evalMatch = _v8EvalLocation.firstMatch(location); + while (evalMatch != null) { + location = evalMatch[1]; + evalMatch = _v8EvalLocation.firstMatch(location); + } - if (location == 'native') { - return new Frame(Uri.parse('native'), null, null, member); - } + if (location == 'native') { + return new Frame(Uri.parse('native'), null, null, member); + } - var urlMatch = _v8UrlLocation.firstMatch(location); - if (urlMatch == null) return new UnparsedFrame(frame); + var urlMatch = _v8UrlLocation.firstMatch(location); + if (urlMatch == null) return new UnparsedFrame(frame); - return new Frame( - _uriOrPathToUri(urlMatch[1]), - int.parse(urlMatch[2]), - int.parse(urlMatch[3]), - member); - } + return new Frame(_uriOrPathToUri(urlMatch[1]), int.parse(urlMatch[2]), + int.parse(urlMatch[3]), member); + } - // V8 stack frames can be in two forms. - if (match[2] != null) { - // The first form looks like " at FUNCTION (LOCATION)". V8 proper lists - // anonymous functions within eval as "<anonymous>", while IE10 lists them - // as "Anonymous function". - return parseLocation(match[2], - match[1].replaceAll("<anonymous>", "<fn>") + // V8 stack frames can be in two forms. + if (match[2] != null) { + // The first form looks like " at FUNCTION (LOCATION)". V8 proper lists + // anonymous functions within eval as "<anonymous>", while IE10 lists them + // as "Anonymous function". + return parseLocation( + match[2], + match[1] + .replaceAll("<anonymous>", "<fn>") .replaceAll("Anonymous function", "<fn>") .replaceAll("(anonymous function)", "<fn>")); - } else { - // The second form looks like " at LOCATION", and is used for anonymous - // functions. - return parseLocation(match[3], "<fn>"); - } - }); + } else { + // The second form looks like " at LOCATION", and is used for anonymous + // functions. + return parseLocation(match[3], "<fn>"); + } + }); /// Parses a string representation of a JavaScriptCore stack trace. factory Frame.parseJSCore(String frame) => new Frame.parseV8(frame); @@ -208,31 +207,31 @@ /// Parses a string representation of a Firefox stack frame. factory Frame.parseFirefox(String frame) => _catchFormatException(frame, () { - var match = _firefoxSafariFrame.firstMatch(frame); - if (match == null) return new UnparsedFrame(frame); + var match = _firefoxSafariFrame.firstMatch(frame); + if (match == null) return new UnparsedFrame(frame); - // Normally this is a URI, but in a jsshell trace it can be a path. - var uri = _uriOrPathToUri(match[3]); + // Normally this is a URI, but in a jsshell trace it can be a path. + var uri = _uriOrPathToUri(match[3]); - var member; - if (match[1] != null) { - member = match[1]; - member += - new List.filled('/'.allMatches(match[2]).length, ".<fn>").join(); - if (member == '') member = '<fn>'; + var member; + if (match[1] != null) { + member = match[1]; + member += + new List.filled('/'.allMatches(match[2]).length, ".<fn>").join(); + if (member == '') member = '<fn>'; - // Some Firefox members have initial dots. We remove them for consistency - // with other platforms. - member = member.replaceFirst(_initialDot, ''); - } else { - member = '<fn>'; - } + // Some Firefox members have initial dots. We remove them for consistency + // with other platforms. + member = member.replaceFirst(_initialDot, ''); + } else { + member = '<fn>'; + } - var line = match[4] == '' ? null : int.parse(match[4]); - var column = match[5] == null || match[5] == '' ? - null : int.parse(match[5]); - return new Frame(uri, line, column, member); - }); + var line = match[4] == '' ? null : int.parse(match[4]); + var column = + match[5] == null || match[5] == '' ? null : int.parse(match[5]); + return new Frame(uri, line, column, member); + }); /// Parses a string representation of a Safari 6.0 stack frame. @Deprecated("Use Frame.parseSafari instead.") @@ -247,26 +246,26 @@ /// Parses this package's string representation of a stack frame. factory Frame.parseFriendly(String frame) => _catchFormatException(frame, () { - var match = _friendlyFrame.firstMatch(frame); - if (match == null) { - throw new FormatException( - "Couldn't parse package:stack_trace stack trace line '$frame'."); - } - // Fake truncated data urls generated by the friendly stack trace format - // cause Uri.parse to throw an exception so we have to special case them. - var uri = match[1] == 'data:...' - ? new Uri.dataFromString('') - : Uri.parse(match[1]); - // If there's no scheme, this is a relative URI. We should interpret it as - // relative to the current working directory. - if (uri.scheme == '') { - uri = path.toUri(path.absolute(path.fromUri(uri))); - } + var match = _friendlyFrame.firstMatch(frame); + if (match == null) { + throw new FormatException( + "Couldn't parse package:stack_trace stack trace line '$frame'."); + } + // Fake truncated data urls generated by the friendly stack trace format + // cause Uri.parse to throw an exception so we have to special case them. + var uri = match[1] == 'data:...' + ? new Uri.dataFromString('') + : Uri.parse(match[1]); + // If there's no scheme, this is a relative URI. We should interpret it as + // relative to the current working directory. + if (uri.scheme == '') { + uri = path.toUri(path.absolute(path.fromUri(uri))); + } - var line = match[2] == null ? null : int.parse(match[2]); - var column = match[3] == null ? null : int.parse(match[3]); - return new Frame(uri, line, column, match[4]); - }); + var line = match[2] == null ? null : int.parse(match[2]); + var column = match[3] == null ? null : int.parse(match[3]); + return new Frame(uri, line, column, match[4]); + }); /// A regular expression matching an absolute URI. static final _uriRegExp = new RegExp(r'^[a-zA-Z][-+.a-zA-Z\d]*://');
diff --git a/pkgs/stack_trace/lib/src/lazy_trace.dart b/pkgs/stack_trace/lib/src/lazy_trace.dart index 618f007..97bb391 100644 --- a/pkgs/stack_trace/lib/src/lazy_trace.dart +++ b/pkgs/stack_trace/lib/src/lazy_trace.dart
@@ -26,7 +26,7 @@ StackTrace get vmTrace => _trace.vmTrace; Trace get terse => new LazyTrace(() => _trace.terse); Trace foldFrames(bool predicate(Frame frame), {bool terse: false}) => - new LazyTrace(() => _trace.foldFrames(predicate, terse: terse)); + new LazyTrace(() => _trace.foldFrames(predicate, terse: terse)); String toString() => _trace.toString(); // Work around issue 14075.
diff --git a/pkgs/stack_trace/lib/src/stack_zone_specification.dart b/pkgs/stack_trace/lib/src/stack_zone_specification.dart index 948ef30..1cccd3a 100644 --- a/pkgs/stack_trace/lib/src/stack_zone_specification.dart +++ b/pkgs/stack_trace/lib/src/stack_zone_specification.dart
@@ -77,7 +77,7 @@ /// By default, the first frame of the first trace will be the line where /// [currentChain] is called. If [level] is passed, the first trace will start /// that many frames up instead. - Chain currentChain([int level=0]) => _createNode(level + 1).toChain(); + Chain currentChain([int level = 0]) => _createNode(level + 1).toChain(); /// Returns the stack chain associated with [trace], if one exists. /// @@ -92,8 +92,8 @@ /// Tracks the current stack chain so it can be set to [_currentChain] when /// [f] is run. - ZoneCallback _registerCallback(Zone self, ZoneDelegate parent, Zone zone, - Function f) { + ZoneCallback _registerCallback( + Zone self, ZoneDelegate parent, Zone zone, Function f) { if (f == null || _disabled) return parent.registerCallback(zone, f); var node = _createNode(1); return parent.registerCallback(zone, () => _run(f, node)); @@ -101,8 +101,8 @@ /// Tracks the current stack chain so it can be set to [_currentChain] when /// [f] is run. - ZoneUnaryCallback _registerUnaryCallback(Zone self, ZoneDelegate parent, - Zone zone, Function f) { + ZoneUnaryCallback _registerUnaryCallback( + Zone self, ZoneDelegate parent, Zone zone, Function f) { if (f == null || _disabled) return parent.registerUnaryCallback(zone, f); var node = _createNode(1); return parent.registerUnaryCallback(zone, (arg) { @@ -112,8 +112,8 @@ /// Tracks the current stack chain so it can be set to [_currentChain] when /// [f] is run. - ZoneBinaryCallback _registerBinaryCallback(Zone self, ZoneDelegate parent, - Zone zone, Function f) { + ZoneBinaryCallback _registerBinaryCallback( + Zone self, ZoneDelegate parent, Zone zone, Function f) { if (f == null || _disabled) return parent.registerBinaryCallback(zone, f); var node = _createNode(1); @@ -124,8 +124,8 @@ /// Looks up the chain associated with [stackTrace] and passes it either to /// [_onError] or [parent]'s error handler. - _handleUncaughtError(Zone self, ZoneDelegate parent, Zone zone, error, - StackTrace stackTrace) { + _handleUncaughtError( + Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) { if (_disabled) { return parent.handleUncaughtError(zone, error, stackTrace); } @@ -171,8 +171,8 @@ /// By default, the first frame of the first trace will be the line where /// [_createNode] is called. If [level] is passed, the first trace will start /// that many frames up instead. - _Node _createNode([int level=0]) => - new _Node(_currentTrace(level + 1), _currentNode); + _Node _createNode([int level = 0]) => + new _Node(_currentTrace(level + 1), _currentNode); // TODO(nweiz): use a more robust way of detecting and tracking errors when // issue 15105 is fixed.
diff --git a/pkgs/stack_trace/lib/src/trace.dart b/pkgs/stack_trace/lib/src/trace.dart index 9edee6e..6296df5 100644 --- a/pkgs/stack_trace/lib/src/trace.dart +++ b/pkgs/stack_trace/lib/src/trace.dart
@@ -43,16 +43,17 @@ final _firefoxSafariTrace = new RegExp( r"^" r"(" // Member description. Not present in some Safari frames. - r"([.0-9A-Za-z_$/<]|\(.*\))*" // Member name and arguments. - r"@" + r"([.0-9A-Za-z_$/<]|\(.*\))*" // Member name and arguments. + r"@" r")?" r"[^\s]*" // Frame URL. r":\d*" // Line or column number. Some older frames only have a line number. - r"$", multiLine: true); + r"$", + multiLine: true); /// A RegExp to match this package's stack traces. -final _friendlyTrace = new RegExp(r"^[^\s<][^\s]*( \d+(:\d+)?)?[ \t]+[^\s]+$", - multiLine: true); +final _friendlyTrace = + new RegExp(r"^[^\s<][^\s]*( \d+(:\d+)?)?[ \t]+[^\s]+$", multiLine: true); /// A stack trace, comprised of a list of stack frames. class Trace implements StackTrace { @@ -74,7 +75,7 @@ /// By default, the first frame of this trace will be the line where /// [Trace.current] is called. If [level] is passed, the trace will start that /// many frames up instead. - factory Trace.current([int level=0]) { + factory Trace.current([int level = 0]) { if (level < 0) { throw new ArgumentError("Argument [level] must be greater than or equal " "to 0."); @@ -133,14 +134,14 @@ } /// Parses a string representation of a Dart VM stack trace. - Trace.parseVM(String trace) - : this(_parseVM(trace)); + Trace.parseVM(String trace) : this(_parseVM(trace)); static List<Frame> _parseVM(String trace) { // Ignore [vmChainGap]. This matches the behavior of // `Chain.parse().toTrace()`. var lines = trace.trim().replaceAll(vmChainGap, '').split("\n"); - var frames = lines.take(lines.length - 1) + var frames = lines + .take(lines.length - 1) .map((line) => new Frame.parseVM(line)) .toList(); @@ -154,16 +155,19 @@ /// Parses a string representation of a Chrome/V8 stack trace. Trace.parseV8(String trace) - : this(trace.split("\n").skip(1) - // It's possible that an Exception's description contains a line that - // looks like a V8 trace line, which will screw this up. - // Unfortunately, that's impossible to detect. - .skipWhile((line) => !line.startsWith(_v8TraceLine)) - .map((line) => new Frame.parseV8(line))); + : this(trace + .split("\n") + .skip(1) + // It's possible that an Exception's description contains a line that + // looks like a V8 trace line, which will screw this up. + // Unfortunately, that's impossible to detect. + .skipWhile((line) => !line.startsWith(_v8TraceLine)) + .map((line) => new Frame.parseV8(line))); /// Parses a string representation of a JavaScriptCore stack trace. Trace.parseJSCore(String trace) - : this(trace.split("\n") + : this(trace + .split("\n") .where((line) => line != "\tat ") .map((line) => new Frame.parseV8(line))); @@ -171,30 +175,31 @@ /// /// IE10+ traces look just like V8 traces. Prior to IE10, stack traces can't /// be retrieved. - Trace.parseIE(String trace) - : this.parseV8(trace); + Trace.parseIE(String trace) : this.parseV8(trace); /// Parses a string representation of a Firefox stack trace. Trace.parseFirefox(String trace) - : this(trace.trim().split("\n") - .where((line) => line.isNotEmpty && line != '[native code]') - .map((line) => new Frame.parseFirefox(line))); + : this(trace + .trim() + .split("\n") + .where((line) => line.isNotEmpty && line != '[native code]') + .map((line) => new Frame.parseFirefox(line))); /// Parses a string representation of a Safari stack trace. - Trace.parseSafari(String trace) - : this.parseFirefox(trace); + Trace.parseSafari(String trace) : this.parseFirefox(trace); /// Parses a string representation of a Safari 6.1+ stack trace. @Deprecated("Use Trace.parseSafari instead.") - Trace.parseSafari6_1(String trace) - : this.parseSafari(trace); + Trace.parseSafari6_1(String trace) : this.parseSafari(trace); /// Parses a string representation of a Safari 6.0 stack trace. @Deprecated("Use Trace.parseSafari instead.") Trace.parseSafari6_0(String trace) - : this(trace.trim().split("\n") - .where((line) => line != '[native code]') - .map((line) => new Frame.parseFirefox(line))); + : this(trace + .trim() + .split("\n") + .where((line) => line != '[native code]') + .map((line) => new Frame.parseFirefox(line))); /// Parses this package's string representation of a stack trace. /// @@ -203,14 +208,15 @@ Trace.parseFriendly(String trace) : this(trace.isEmpty ? [] - : trace.trim().split("\n") + : trace + .trim() + .split("\n") // Filter out asynchronous gaps from [Chain]s. .where((line) => !line.startsWith('=====')) .map((line) => new Frame.parseFriendly(line))); /// Returns a new [Trace] comprised of [frames]. - Trace(Iterable<Frame> frames) - : frames = new List<Frame>.unmodifiable(frames); + Trace(Iterable<Frame> frames) : frames = new List<Frame>.unmodifiable(frames); /// Returns a VM-style [StackTrace] object. /// @@ -274,8 +280,8 @@ if (frame is UnparsedFrame || !predicate(frame)) { newFrames.add(frame); } else if (newFrames.isEmpty || !predicate(newFrames.last)) { - newFrames.add(new Frame( - frame.uri, frame.line, frame.column, frame.member)); + newFrames + .add(new Frame(frame.uri, frame.line, frame.column, frame.member)); } } @@ -297,8 +303,8 @@ /// Returns a human-readable string representation of [this]. String toString() { // Figure out the longest path so we know how much to pad. - var longest = frames.map((frame) => frame.location.length) - .fold(0, math.max); + var longest = + frames.map((frame) => frame.location.length).fold(0, math.max); // Print out the stack trace nicely formatted. return frames.map((frame) {
diff --git a/pkgs/stack_trace/lib/src/unparsed_frame.dart b/pkgs/stack_trace/lib/src/unparsed_frame.dart index 7ba9a63..78ac738 100644 --- a/pkgs/stack_trace/lib/src/unparsed_frame.dart +++ b/pkgs/stack_trace/lib/src/unparsed_frame.dart
@@ -21,4 +21,4 @@ UnparsedFrame(this.member); String toString() => member; -} \ No newline at end of file +}
diff --git a/pkgs/stack_trace/test/chain/chain_test.dart b/pkgs/stack_trace/test/chain/chain_test.dart index b974aa9..407cc2b 100644 --- a/pkgs/stack_trace/test/chain/chain_test.dart +++ b/pkgs/stack_trace/test/chain/chain_test.dart
@@ -28,9 +28,9 @@ }); test('parses a chain containing empty traces', () { - var chain = new Chain.parse( - '===== asynchronous gap ===========================\n' - '===== asynchronous gap ===========================\n'); + var chain = + new Chain.parse('===== asynchronous gap ===========================\n' + '===== asynchronous gap ===========================\n'); expect(chain.traces, hasLength(3)); expect(chain.traces[0].frames, isEmpty); expect(chain.traces[1].frames, isEmpty); @@ -136,67 +136,63 @@ new Trace.parse('loooooooooooong 10:11 Zop.zoop') ]); - expect(chain.toString(), equals( - 'short 10:11 Foo.bar\n' - '===== asynchronous gap ===========================\n' - 'loooooooooooong 10:11 Zop.zoop\n')); + expect( + chain.toString(), + equals('short 10:11 Foo.bar\n' + '===== asynchronous gap ===========================\n' + 'loooooooooooong 10:11 Zop.zoop\n')); }); var userSlashCode = p.join('user', 'code.dart'); group('Chain.terse', () { test('makes each trace terse', () { var chain = new Chain([ - new Trace.parse( - 'dart:core 10:11 Foo.bar\n' + new Trace.parse('dart:core 10:11 Foo.bar\n' 'dart:core 10:11 Bar.baz\n' 'user/code.dart 10:11 Bang.qux\n' 'dart:core 10:11 Zip.zap\n' 'dart:core 10:11 Zop.zoop'), - new Trace.parse( - 'user/code.dart 10:11 Bang.qux\n' + new Trace.parse('user/code.dart 10:11 Bang.qux\n' 'dart:core 10:11 Foo.bar\n' 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' 'dart:core 10:11 Zip.zap\n' 'user/code.dart 10:11 Zop.zoop') ]); - expect(chain.terse.toString(), equals( - 'dart:core Bar.baz\n' - '$userSlashCode 10:11 Bang.qux\n' - '===== asynchronous gap ===========================\n' - '$userSlashCode 10:11 Bang.qux\n' - 'dart:core Zip.zap\n' - '$userSlashCode 10:11 Zop.zoop\n')); + expect( + chain.terse.toString(), + equals('dart:core Bar.baz\n' + '$userSlashCode 10:11 Bang.qux\n' + '===== asynchronous gap ===========================\n' + '$userSlashCode 10:11 Bang.qux\n' + 'dart:core Zip.zap\n' + '$userSlashCode 10:11 Zop.zoop\n')); }); test('eliminates internal-only traces', () { var chain = new Chain([ - new Trace.parse( - 'user/code.dart 10:11 Foo.bar\n' + new Trace.parse('user/code.dart 10:11 Foo.bar\n' 'dart:core 10:11 Bar.baz'), - new Trace.parse( - 'dart:core 10:11 Foo.bar\n' + new Trace.parse('dart:core 10:11 Foo.bar\n' 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' 'dart:core 10:11 Zip.zap'), - new Trace.parse( - 'user/code.dart 10:11 Foo.bar\n' + new Trace.parse('user/code.dart 10:11 Foo.bar\n' 'dart:core 10:11 Bar.baz') ]); - expect(chain.terse.toString(), equals( - '$userSlashCode 10:11 Foo.bar\n' - '===== asynchronous gap ===========================\n' - '$userSlashCode 10:11 Foo.bar\n')); + expect( + chain.terse.toString(), + equals('$userSlashCode 10:11 Foo.bar\n' + '===== asynchronous gap ===========================\n' + '$userSlashCode 10:11 Foo.bar\n')); }); test("doesn't return an empty chain", () { var chain = new Chain([ - new Trace.parse( - 'dart:core 10:11 Foo.bar\n' + new Trace.parse('dart:core 10:11 Foo.bar\n' 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' 'dart:core 10:11 Zip.zap'), - new Trace.parse( - 'dart:core 10:11 A.b\n' + new Trace.parse('dart:core 10:11 A.b\n' 'package:stack_trace/stack_trace.dart 10:11 C.d\n' 'dart:core 10:11 E.f') ]); @@ -212,24 +208,23 @@ new Trace.parse('user/code.dart 10:11 Bang.qux') ]); - expect(chain.terse.toString(), equals( - '$userSlashCode 10:11 Bang.qux\n' - '===== asynchronous gap ===========================\n' - '$userSlashCode 10:11 Bang.qux\n')); + expect( + chain.terse.toString(), + equals('$userSlashCode 10:11 Bang.qux\n' + '===== asynchronous gap ===========================\n' + '$userSlashCode 10:11 Bang.qux\n')); }); }); group('Chain.foldFrames', () { test('folds each trace', () { var chain = new Chain([ - new Trace.parse( - 'a.dart 10:11 Foo.bar\n' + new Trace.parse('a.dart 10:11 Foo.bar\n' 'a.dart 10:11 Bar.baz\n' 'b.dart 10:11 Bang.qux\n' 'a.dart 10:11 Zip.zap\n' 'a.dart 10:11 Zop.zoop'), - new Trace.parse( - 'a.dart 10:11 Foo.bar\n' + new Trace.parse('a.dart 10:11 Foo.bar\n' 'a.dart 10:11 Bar.baz\n' 'a.dart 10:11 Bang.qux\n' 'a.dart 10:11 Zip.zap\n' @@ -237,67 +232,64 @@ ]); var folded = chain.foldFrames((frame) => frame.library == 'a.dart'); - expect(folded.toString(), equals( - 'a.dart 10:11 Bar.baz\n' - 'b.dart 10:11 Bang.qux\n' - 'a.dart 10:11 Zop.zoop\n' - '===== asynchronous gap ===========================\n' - 'a.dart 10:11 Zip.zap\n' - 'b.dart 10:11 Zop.zoop\n')); + expect( + folded.toString(), + equals('a.dart 10:11 Bar.baz\n' + 'b.dart 10:11 Bang.qux\n' + 'a.dart 10:11 Zop.zoop\n' + '===== asynchronous gap ===========================\n' + 'a.dart 10:11 Zip.zap\n' + 'b.dart 10:11 Zop.zoop\n')); }); test('with terse: true, folds core frames as well', () { var chain = new Chain([ - new Trace.parse( - 'a.dart 10:11 Foo.bar\n' + new Trace.parse('a.dart 10:11 Foo.bar\n' 'dart:async-patch/future.dart 10:11 Zip.zap\n' 'b.dart 10:11 Bang.qux\n' 'dart:core 10:11 Bar.baz\n' 'a.dart 10:11 Zop.zoop'), - new Trace.parse( - 'a.dart 10:11 Foo.bar\n' + new Trace.parse('a.dart 10:11 Foo.bar\n' 'a.dart 10:11 Bar.baz\n' 'a.dart 10:11 Bang.qux\n' 'a.dart 10:11 Zip.zap\n' 'b.dart 10:11 Zop.zoop') ]); - var folded = chain.foldFrames((frame) => frame.library == 'a.dart', - terse: true); - expect(folded.toString(), equals( - 'dart:async Zip.zap\n' - 'b.dart 10:11 Bang.qux\n' - '===== asynchronous gap ===========================\n' - 'a.dart Zip.zap\n' - 'b.dart 10:11 Zop.zoop\n')); + var folded = + chain.foldFrames((frame) => frame.library == 'a.dart', terse: true); + expect( + folded.toString(), + equals('dart:async Zip.zap\n' + 'b.dart 10:11 Bang.qux\n' + '===== asynchronous gap ===========================\n' + 'a.dart Zip.zap\n' + 'b.dart 10:11 Zop.zoop\n')); }); test('eliminates completely-folded traces', () { var chain = new Chain([ - new Trace.parse( - 'a.dart 10:11 Foo.bar\n' + new Trace.parse('a.dart 10:11 Foo.bar\n' 'b.dart 10:11 Bang.qux'), - new Trace.parse( - 'a.dart 10:11 Foo.bar\n' + new Trace.parse('a.dart 10:11 Foo.bar\n' 'a.dart 10:11 Bang.qux'), - new Trace.parse( - 'a.dart 10:11 Zip.zap\n' + new Trace.parse('a.dart 10:11 Zip.zap\n' 'b.dart 10:11 Zop.zoop') ]); var folded = chain.foldFrames((frame) => frame.library == 'a.dart'); - expect(folded.toString(), equals( - 'a.dart 10:11 Foo.bar\n' - 'b.dart 10:11 Bang.qux\n' - '===== asynchronous gap ===========================\n' - 'a.dart 10:11 Zip.zap\n' - 'b.dart 10:11 Zop.zoop\n')); + expect( + folded.toString(), + equals('a.dart 10:11 Foo.bar\n' + 'b.dart 10:11 Bang.qux\n' + '===== asynchronous gap ===========================\n' + 'a.dart 10:11 Zip.zap\n' + 'b.dart 10:11 Zop.zoop\n')); }); test("doesn't return an empty trace", () { var chain = new Chain([ - new Trace.parse( - 'a.dart 10:11 Foo.bar\n' + new Trace.parse('a.dart 10:11 Foo.bar\n' 'a.dart 10:11 Bang.qux') ]); @@ -308,18 +300,17 @@ test('Chain.toTrace eliminates asynchronous gaps', () { var trace = new Chain([ - new Trace.parse( - 'user/code.dart 10:11 Foo.bar\n' + new Trace.parse('user/code.dart 10:11 Foo.bar\n' 'dart:core 10:11 Bar.baz'), - new Trace.parse( - 'user/code.dart 10:11 Foo.bar\n' + new Trace.parse('user/code.dart 10:11 Foo.bar\n' 'dart:core 10:11 Bar.baz') ]).toTrace(); - expect(trace.toString(), equals( - '$userSlashCode 10:11 Foo.bar\n' - 'dart:core 10:11 Bar.baz\n' - '$userSlashCode 10:11 Foo.bar\n' - 'dart:core 10:11 Bar.baz\n')); + expect( + trace.toString(), + equals('$userSlashCode 10:11 Foo.bar\n' + 'dart:core 10:11 Bar.baz\n' + '$userSlashCode 10:11 Foo.bar\n' + 'dart:core 10:11 Bar.baz\n')); }); }
diff --git a/pkgs/stack_trace/test/chain/dart2js_test.dart b/pkgs/stack_trace/test/chain/dart2js_test.dart index b8d3a82..df3d07b 100644 --- a/pkgs/stack_trace/test/chain/dart2js_test.dart +++ b/pkgs/stack_trace/test/chain/dart2js_test.dart
@@ -28,14 +28,14 @@ }); test('thrown in a one-shot timer', () async { - var chain = await captureFuture( - () => inOneShotTimer(() => throw 'error')); + var chain = + await captureFuture(() => inOneShotTimer(() => throw 'error')); expect(chain.traces, hasLength(2)); }); test('thrown in a periodic timer', () async { - var chain = await captureFuture( - () => inPeriodicTimer(() => throw 'error')); + var chain = + await captureFuture(() => inPeriodicTimer(() => throw 'error')); expect(chain.traces, hasLength(2)); }); @@ -238,7 +238,8 @@ }); }); - test('current() outside of capture() returns a chain wrapping the current ' + test( + 'current() outside of capture() returns a chain wrapping the current ' 'trace', () { // The test runner runs all tests with chains enabled. return Chain.disable(() async { @@ -281,7 +282,8 @@ expect(chain.traces, hasLength(3)); }); - test('called for a stack trace from a nested series of asynchronous ' + test( + 'called for a stack trace from a nested series of asynchronous ' 'operations', () async { var chain = await Chain.capture(() { return chainForTrace((callback) { @@ -300,7 +302,8 @@ expect(chain.traces, hasLength(3)); }); - test('called for an unregistered stack trace returns a chain wrapping that ' + test( + 'called for an unregistered stack trace returns a chain wrapping that ' 'trace', () { var trace; var chain = Chain.capture(() { @@ -318,7 +321,8 @@ }); }); - test('forTrace() outside of capture() returns a chain wrapping the given ' + test( + 'forTrace() outside of capture() returns a chain wrapping the given ' 'trace', () { var trace; var chain = Chain.capture(() {
diff --git a/pkgs/stack_trace/test/chain/utils.dart b/pkgs/stack_trace/test/chain/utils.dart index f345fc0..bf82158 100644 --- a/pkgs/stack_trace/test/chain/utils.dart +++ b/pkgs/stack_trace/test/chain/utils.dart
@@ -70,7 +70,8 @@ // [new Future.sync] because those methods don't pass the exception through // the zone specification before propagating it, so there's no chance to // attach a chain to its stack trace. See issue 15105. - new Future.value().then((_) => callback()) + new Future.value() + .then((_) => callback()) .catchError(completer.completeError); });
diff --git a/pkgs/stack_trace/test/chain/vm_test.dart b/pkgs/stack_trace/test/chain/vm_test.dart index 716b146..daf7f8f 100644 --- a/pkgs/stack_trace/test/chain/vm_test.dart +++ b/pkgs/stack_trace/test/chain/vm_test.dart
@@ -17,11 +17,10 @@ void main() { group('capture() with onError catches exceptions', () { test('thrown synchronously', () { - return captureFuture(() => throw 'error') - .then((chain) { + return captureFuture(() => throw 'error').then((chain) { expect(chain.traces, hasLength(1)); - expect(chain.traces.single.frames.first, - frameMember(startsWith('main'))); + expect( + chain.traces.single.frames.first, frameMember(startsWith('main'))); }); }); @@ -349,7 +348,8 @@ }); }); - test('current() outside of capture() returns a chain wrapping the current ' + test( + 'current() outside of capture() returns a chain wrapping the current ' 'trace', () { // The test runner runs all tests with chains enabled. return Chain.disable(() { @@ -361,8 +361,8 @@ // chain isn't available and it just returns the current stack when // called. expect(chain.traces, hasLength(1)); - expect(chain.traces.first.frames.first, - frameMember(startsWith('main'))); + expect( + chain.traces.first.frames.first, frameMember(startsWith('main'))); }); }); }); @@ -410,7 +410,8 @@ }); }); - test('called for a stack trace from a nested series of asynchronous ' + test( + 'called for a stack trace from a nested series of asynchronous ' 'operations', () { return Chain.capture(() { return chainForTrace((callback) { @@ -443,7 +444,8 @@ }); }); - test('called for an unregistered stack trace returns a chain wrapping that ' + test( + 'called for an unregistered stack trace returns a chain wrapping that ' 'trace', () { var trace; var chain = Chain.capture(() { @@ -461,7 +463,8 @@ }); }); - test('forTrace() outside of capture() returns a chain wrapping the given ' + test( + 'forTrace() outside of capture() returns a chain wrapping the given ' 'trace', () { var trace; var chain = Chain.capture(() {
diff --git a/pkgs/stack_trace/test/frame_test.dart b/pkgs/stack_trace/test/frame_test.dart index a5f8b23..42df4cd 100644 --- a/pkgs/stack_trace/test/frame_test.dart +++ b/pkgs/stack_trace/test/frame_test.dart
@@ -11,8 +11,8 @@ test('parses a stack frame with column correctly', () { var frame = new Frame.parseVM("#1 Foo._bar " "(file:///home/nweiz/code/stuff.dart:42:21)"); - expect(frame.uri, - equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); + expect( + frame.uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); expect(frame.line, equals(42)); expect(frame.column, equals(21)); expect(frame.member, equals('Foo._bar')); @@ -21,8 +21,8 @@ test('parses a stack frame without column correctly', () { var frame = new Frame.parseVM("#1 Foo._bar " "(file:///home/nweiz/code/stuff.dart:24)"); - expect(frame.uri, - equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); + expect( + frame.uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); expect(frame.line, equals(24)); expect(frame.column, null); expect(frame.member, equals('Foo._bar')); @@ -32,8 +32,8 @@ test('parses a stack frame without line or column correctly', () { var frame = new Frame.parseVM("#1 Foo._bar " "(file:///home/nweiz/code/stuff.dart)"); - expect(frame.uri, - equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); + expect( + frame.uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); expect(frame.line, isNull); expect(frame.column, isNull); expect(frame.member, equals('Foo._bar')); @@ -55,8 +55,8 @@ }); test('converts "<function_name_async_body>" to "<async>"', () { - var frame = new Frame.parseVM( - '#0 Foo.<function_name_async_body> (foo:0:0)'); + var frame = + new Frame.parseVM('#0 Foo.<function_name_async_body> (foo:0:0)'); expect(frame.member, equals('Foo.<async>')); }); @@ -112,8 +112,8 @@ test('parses a stack frame with a Windows UNC path correctly', () { var frame = new Frame.parseV8(" at VW.call\$0 " r"(\\mount\path\to\stuff.dart.js:560:28)"); - expect(frame.uri, - equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); + expect( + frame.uri, equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); expect(frame.line, equals(560)); expect(frame.column, equals(28)); expect(frame.member, equals('VW.call\$0')); @@ -148,8 +148,7 @@ }); test('parses a native stack frame correctly', () { - var frame = new Frame.parseV8( - " at Object.stringify (native)"); + var frame = new Frame.parseV8(" at Object.stringify (native)"); expect(frame.uri, Uri.parse('native')); expect(frame.line, isNull); expect(frame.column, isNull); @@ -213,8 +212,8 @@ new Frame.parseV8(' at $member (foo:0:0)').member; expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>')); - expect(parsedMember('<anonymous>.<anonymous>.bar'), - equals('<fn>.<fn>.bar')); + expect( + parsedMember('<anonymous>.<anonymous>.bar'), equals('<fn>.<fn>.bar')); }); test('returns an UnparsedFrame for malformed frames', () { @@ -227,12 +226,12 @@ ' at (dart:async/future.dart:10:15)'); expectIsUnparsed((text) => new Frame.parseV8(text), 'Foo (dart:async/future.dart:10:15)'); - expectIsUnparsed((text) => new Frame.parseV8(text), - ' at dart:async/future.dart'); + expectIsUnparsed( + (text) => new Frame.parseV8(text), ' at dart:async/future.dart'); expectIsUnparsed((text) => new Frame.parseV8(text), ' at dart:async/future.dart:10'); - expectIsUnparsed((text) => new Frame.parseV8(text), - 'dart:async/future.dart:10:15'); + expectIsUnparsed( + (text) => new Frame.parseV8(text), 'dart:async/future.dart:10:15'); }); }); @@ -248,8 +247,8 @@ }); test('parses a stack frame with an absolute POSIX path correctly', () { - var frame = new Frame.parseFirefox( - ".VW.call\$0@/path/to/stuff.dart.js:560"); + var frame = + new Frame.parseFirefox(".VW.call\$0@/path/to/stuff.dart.js:560"); expect(frame.uri, equals(Uri.parse("file:///path/to/stuff.dart.js"))); expect(frame.line, equals(560)); expect(frame.column, isNull); @@ -257,8 +256,8 @@ }); test('parses a stack frame with an absolute Windows path correctly', () { - var frame = new Frame.parseFirefox( - r".VW.call$0@C:\path\to\stuff.dart.js:560"); + var frame = + new Frame.parseFirefox(r".VW.call$0@C:\path\to\stuff.dart.js:560"); expect(frame.uri, equals(Uri.parse("file:///C:/path/to/stuff.dart.js"))); expect(frame.line, equals(560)); expect(frame.column, isNull); @@ -268,16 +267,16 @@ test('parses a stack frame with a Windows UNC path correctly', () { var frame = new Frame.parseFirefox( r".VW.call$0@\\mount\path\to\stuff.dart.js:560"); - expect(frame.uri, - equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); + expect( + frame.uri, equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); expect(frame.line, equals(560)); expect(frame.column, isNull); expect(frame.member, equals('VW.call\$0')); }); test('parses a stack frame with a relative POSIX path correctly', () { - var frame = new Frame.parseFirefox( - ".VW.call\$0@path/to/stuff.dart.js:560"); + var frame = + new Frame.parseFirefox(".VW.call\$0@path/to/stuff.dart.js:560"); expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); expect(frame.line, equals(560)); expect(frame.column, isNull); @@ -285,8 +284,8 @@ }); test('parses a stack frame with a relative Windows path correctly', () { - var frame = new Frame.parseFirefox( - r".VW.call$0@path\to\stuff.dart.js:560"); + var frame = + new Frame.parseFirefox(r".VW.call$0@path\to\stuff.dart.js:560"); expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); expect(frame.line, equals(560)); expect(frame.column, isNull); @@ -294,8 +293,8 @@ }); test('parses a simple anonymous stack frame correctly', () { - var frame = new Frame.parseFirefox( - "@http://pub.dartlang.org/stuff.dart.js:560"); + var frame = + new Frame.parseFirefox("@http://pub.dartlang.org/stuff.dart.js:560"); expect(frame.uri, equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); expect(frame.line, equals(560)); @@ -350,8 +349,7 @@ }); test('parses a nested anonymous stack frame with parameters correctly', () { - var frame = new Frame.parseFirefox( - '.foo(12, "@)()/<")/.fn<@' + var frame = new Frame.parseFirefox('.foo(12, "@)()/<")/.fn<@' 'http://pub.dartlang.org/stuff.dart.js:560'); expect(frame.uri, equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); @@ -360,11 +358,12 @@ expect(frame.member, equals("foo.<fn>")); }); - test('parses a deeply-nested anonymous stack frame with parameters ' + test( + 'parses a deeply-nested anonymous stack frame with parameters ' 'correctly', () { - var frame = new Frame.parseFirefox( - '.convertDartClosureToJS/\$function</<@' - 'http://pub.dartlang.org/stuff.dart.js:560'); + var frame = + new Frame.parseFirefox('.convertDartClosureToJS/\$function</<@' + 'http://pub.dartlang.org/stuff.dart.js:560'); expect(frame.uri, equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); expect(frame.line, equals(560)); @@ -379,8 +378,8 @@ '.foo@dart:async/future.dart'); expectIsUnparsed((text) => new Frame.parseFirefox(text), '.foo(@dart:async/future.dart:10'); - expectIsUnparsed((text) => new Frame.parseFirefox(text), - '@dart:async/future.dart'); + expectIsUnparsed( + (text) => new Frame.parseFirefox(text), '@dart:async/future.dart'); }); test('parses a simple stack frame correctly', () { @@ -393,8 +392,8 @@ }); test('parses an anonymous stack frame correctly', () { - var frame = new Frame.parseFirefox( - "http://dartlang.org/foo/bar.dart:10:11"); + var frame = + new Frame.parseFirefox("http://dartlang.org/foo/bar.dart:10:11"); expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); expect(frame.line, equals(10)); expect(frame.column, equals(11)); @@ -459,8 +458,8 @@ test('parses a stack frame with a relative path correctly', () { var frame = new Frame.parseFriendly("foo/bar.dart 10:11 Foo.<fn>.bar"); - expect(frame.uri, equals( - path.toUri(path.absolute(path.join('foo', 'bar.dart'))))); + expect(frame.uri, + equals(path.toUri(path.absolute(path.join('foo', 'bar.dart'))))); expect(frame.line, equals(10)); expect(frame.column, equals(11)); expect(frame.member, equals('Foo.<fn>.bar')); @@ -469,13 +468,12 @@ test('returns an UnparsedFrame for malformed frames', () { expectIsUnparsed((text) => new Frame.parseFriendly(text), ''); expectIsUnparsed((text) => new Frame.parseFriendly(text), 'foo/bar.dart'); - expectIsUnparsed((text) => new Frame.parseFriendly(text), - 'foo/bar.dart 10:11'); + expectIsUnparsed( + (text) => new Frame.parseFriendly(text), 'foo/bar.dart 10:11'); }); test('parses a data url stack frame with no line or column correctly', () { - var frame = new Frame.parseFriendly( - "data:... main"); + var frame = new Frame.parseFriendly("data:... main"); expect(frame.uri.scheme, equals('data')); expect(frame.line, isNull); expect(frame.column, isNull); @@ -483,8 +481,7 @@ }); test('parses a data url stack frame correctly', () { - var frame = new Frame.parseFriendly( - "data:... 10:11 main"); + var frame = new Frame.parseFriendly("data:... 10:11 main"); expect(frame.uri.scheme, equals('data')); expect(frame.line, equals(10)); expect(frame.column, equals(11)); @@ -501,12 +498,12 @@ expect(frame.member, equals('(anonymous function).dart.fn')); }); - test('parses a stack frame with spaces in the member name and no line or ' - 'column correctly', () { + test( + 'parses a stack frame with spaces in the member name and no line or ' + 'column correctly', () { var frame = new Frame.parseFriendly( "http://dartlang.org/foo/bar.dart (anonymous function).dart.fn"); - expect( - frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); + expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); expect(frame.line, isNull); expect(frame.column, isNull); expect(frame.member, equals('(anonymous function).dart.fn')); @@ -515,7 +512,7 @@ test('only considers dart URIs to be core', () { bool isCore(String library) => - new Frame.parseVM('#0 Foo ($library:0:0)').isCore; + new Frame.parseVM('#0 Foo ($library:0:0)').isCore; expect(isCore('dart:core'), isTrue); expect(isCore('dart:async'), isTrue); @@ -531,8 +528,10 @@ test('returns the URI string for non-file URIs', () { expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').library, equals('dart:async/future.dart')); - expect(new Frame.parseVM('#0 Foo ' - '(http://dartlang.org/stuff/thing.dart:0:0)').library, + expect( + new Frame.parseVM('#0 Foo ' + '(http://dartlang.org/stuff/thing.dart:0:0)') + .library, equals('http://dartlang.org/stuff/thing.dart')); }); @@ -549,10 +548,13 @@ }); group('.location', () { - test('returns the library and line/column numbers for non-core ' + test( + 'returns the library and line/column numbers for non-core ' 'libraries', () { - expect(new Frame.parseVM('#0 Foo ' - '(http://dartlang.org/thing.dart:5:10)').location, + expect( + new Frame.parseVM('#0 Foo ' + '(http://dartlang.org/thing.dart:5:10)') + .location, equals('http://dartlang.org/thing.dart 5:10')); expect(new Frame.parseVM('#0 Foo (foo/bar.dart:1:2)').location, equals('${path.join('foo', 'bar.dart')} 1:2')); @@ -563,8 +565,10 @@ test('returns null for non-package URIs', () { expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').package, isNull); - expect(new Frame.parseVM('#0 Foo ' - '(http://dartlang.org/stuff/thing.dart:0:0)').package, + expect( + new Frame.parseVM('#0 Foo ' + '(http://dartlang.org/stuff/thing.dart:0:0)') + .package, isNull); }); @@ -577,16 +581,20 @@ }); group('.toString()', () { - test('returns the library and line/column numbers for non-core ' + test( + 'returns the library and line/column numbers for non-core ' 'libraries', () { - expect(new Frame.parseVM('#0 Foo (http://dartlang.org/thing.dart:5:10)') + expect( + new Frame.parseVM('#0 Foo (http://dartlang.org/thing.dart:5:10)') .toString(), equals('http://dartlang.org/thing.dart 5:10 in Foo')); }); test('converts "<anonymous closure>" to "<fn>"', () { - expect(new Frame.parseVM('#0 Foo.<anonymous closure> ' - '(dart:core/uri.dart:5:10)').toString(), + expect( + new Frame.parseVM('#0 Foo.<anonymous closure> ' + '(dart:core/uri.dart:5:10)') + .toString(), equals('dart:core/uri.dart 5:10 in Foo.<fn>')); });
diff --git a/pkgs/stack_trace/test/trace_test.dart b/pkgs/stack_trace/test/trace_test.dart index 1297932..33d4f4e 100644 --- a/pkgs/stack_trace/test/trace_test.dart +++ b/pkgs/stack_trace/test/trace_test.dart
@@ -20,7 +20,7 @@ '#0 Foo._bar (file:///home/nweiz/code/stuff.dart:42:21)\n' '#1 zip.<anonymous closure>.zap (dart:async/future.dart:0:2)\n' '#2 zip.<anonymous closure>.zap (http://pub.dartlang.org/thing.' - 'dart:1:100)'); + 'dart:1:100)'); expect(trace.frames[0].uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); @@ -30,12 +30,11 @@ }); test('parses a V8 stack trace correctly', () { - var trace = new Trace.parse( - 'Error\n' + var trace = new Trace.parse('Error\n' ' at Foo._bar (http://pub.dartlang.org/stuff.js:42:21)\n' ' at http://pub.dartlang.org/stuff.js:0:2\n' ' at zip.<anonymous>.zap ' - '(http://pub.dartlang.org/thing.js:1:100)'); + '(http://pub.dartlang.org/thing.js:1:100)'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -44,12 +43,11 @@ expect(trace.frames[2].uri, equals(Uri.parse("http://pub.dartlang.org/thing.js"))); - trace = new Trace.parse( - "Exception: foo\n" + trace = new Trace.parse("Exception: foo\n" ' at Foo._bar (http://pub.dartlang.org/stuff.js:42:21)\n' ' at http://pub.dartlang.org/stuff.js:0:2\n' ' at zip.<anonymous>.zap ' - '(http://pub.dartlang.org/thing.js:1:100)'); + '(http://pub.dartlang.org/thing.js:1:100)'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -58,13 +56,12 @@ expect(trace.frames[2].uri, equals(Uri.parse("http://pub.dartlang.org/thing.js"))); - trace = new Trace.parse( - 'Exception: foo\n' + trace = new Trace.parse('Exception: foo\n' ' bar\n' ' at Foo._bar (http://pub.dartlang.org/stuff.js:42:21)\n' ' at http://pub.dartlang.org/stuff.js:0:2\n' ' at zip.<anonymous>.zap ' - '(http://pub.dartlang.org/thing.js:1:100)'); + '(http://pub.dartlang.org/thing.js:1:100)'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -73,13 +70,12 @@ expect(trace.frames[2].uri, equals(Uri.parse("http://pub.dartlang.org/thing.js"))); - trace = new Trace.parse( - 'Exception: foo\n' + trace = new Trace.parse('Exception: foo\n' ' bar\n' ' at Foo._bar (http://pub.dartlang.org/stuff.js:42:21)\n' ' at http://pub.dartlang.org/stuff.js:0:2\n' ' at (anonymous function).zip.zap ' - '(http://pub.dartlang.org/thing.js:1:100)'); + '(http://pub.dartlang.org/thing.js:1:100)'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -98,7 +94,7 @@ '\tat Foo._bar (http://pub.dartlang.org/stuff.js:42:21)\n' '\tat http://pub.dartlang.org/stuff.js:0:2\n' '\tat zip.<anonymous>.zap ' - '(http://pub.dartlang.org/thing.js:1:100)'); + '(http://pub.dartlang.org/thing.js:1:100)'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -111,7 +107,7 @@ '\tat Foo._bar (http://pub.dartlang.org/stuff.js:42:21)\n' '\tat \n' '\tat zip.<anonymous>.zap ' - '(http://pub.dartlang.org/thing.js:1:100)'); + '(http://pub.dartlang.org/thing.js:1:100)'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -120,10 +116,10 @@ }); test('parses a Firefox/Safari stack trace correctly', () { - var trace = new Trace.parse( - 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' - 'zip/<@http://pub.dartlang.org/stuff.js:0\n' - 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); + var trace = + new Trace.parse('Foo._bar@http://pub.dartlang.org/stuff.js:42\n' + 'zip/<@http://pub.dartlang.org/stuff.js:0\n' + 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -132,8 +128,7 @@ expect(trace.frames[2].uri, equals(Uri.parse("http://pub.dartlang.org/thing.js"))); - trace = new Trace.parse( - 'zip/<@http://pub.dartlang.org/stuff.js:0\n' + trace = new Trace.parse('zip/<@http://pub.dartlang.org/stuff.js:0\n' 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); @@ -159,11 +154,11 @@ test('parses a Firefox/Safari stack trace containing native code correctly', () { - var trace = new Trace.parse( - 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' - 'zip/<@http://pub.dartlang.org/stuff.js:0\n' - 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1\n' - '[native code]'); + var trace = + new Trace.parse('Foo._bar@http://pub.dartlang.org/stuff.js:42\n' + 'zip/<@http://pub.dartlang.org/stuff.js:0\n' + 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1\n' + '[native code]'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -176,8 +171,7 @@ test('parses a Firefox/Safari stack trace without a method name correctly', () { - var trace = new Trace.parse( - 'http://pub.dartlang.org/stuff.js:42\n' + var trace = new Trace.parse('http://pub.dartlang.org/stuff.js:42\n' 'zip/<@http://pub.dartlang.org/stuff.js:0\n' 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); @@ -192,11 +186,11 @@ test('parses a Firefox/Safari stack trace with an empty line correctly', () { - var trace = new Trace.parse( - 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' - '\n' - 'zip/<@http://pub.dartlang.org/stuff.js:0\n' - 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); + var trace = + new Trace.parse('Foo._bar@http://pub.dartlang.org/stuff.js:42\n' + '\n' + 'zip/<@http://pub.dartlang.org/stuff.js:0\n' + 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -208,10 +202,10 @@ test('parses a Firefox/Safari stack trace with a column number correctly', () { - var trace = new Trace.parse( - 'Foo._bar@http://pub.dartlang.org/stuff.js:42:2\n' - 'zip/<@http://pub.dartlang.org/stuff.js:0\n' - 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); + var trace = + new Trace.parse('Foo._bar@http://pub.dartlang.org/stuff.js:42:2\n' + 'zip/<@http://pub.dartlang.org/stuff.js:0\n' + 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); expect(trace.frames[0].uri, equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); @@ -286,10 +280,11 @@ new Frame(Uri.parse('dart:async'), 15, null, 'baz'), ]); - expect(trace.vmTrace.toString(), equals( - '#1 Foo.<anonymous closure> ($uri:10:20)\n' - '#2 bar (http://dartlang.org/foo.dart:0:0)\n' - '#3 baz (dart:async:15:0)\n')); + expect( + trace.vmTrace.toString(), + equals('#1 Foo.<anonymous closure> ($uri:10:20)\n' + '#2 bar (http://dartlang.org/foo.dart:0:0)\n' + '#3 baz (dart:async:15:0)\n')); }); group("folding", () { @@ -335,7 +330,7 @@ #4 bottom (dart:async-patch/future.dart:9:11) '''); - expect(trace.terse.toString(), equals(''' + expect(trace.terse.toString(), equals(''' foo.dart 42:21 notCore ''')); }); @@ -367,7 +362,8 @@ #5 fooBottom (dart:async-patch/future.dart:9:11) '''); - var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); + var folded = + trace.foldFrames((frame) => frame.member.startsWith('foo')); expect(folded.toString(), equals(''' foo.dart 42:21 notFoo foo.dart 1:100 fooBottom @@ -401,14 +397,15 @@ #5 coreBottom (dart:async-patch/future.dart:9:11) '''); - var folded = trace.foldFrames((frame) => frame.member.startsWith('foo'), + var folded = trace.foldFrames( + (frame) => frame.member.startsWith('foo'), terse: true); expect(folded.toString(), equals(''' foo.dart 42:21 notFoo dart:async coreBottom bar.dart 10:20 alsoNotFoo ''')); - }); + }); test('shortens folded frames', () { var trace = new Trace.parse(''' @@ -421,7 +418,8 @@ #6 againNotFoo (bar.dart:20:20) '''); - var folded = trace.foldFrames((frame) => frame.member.startsWith('foo'), + var folded = trace.foldFrames( + (frame) => frame.member.startsWith('foo'), terse: true); expect(folded.toString(), equals(''' foo.dart 42:21 notFoo @@ -439,7 +437,8 @@ #5 fooBottom (foo/bar.dart:9:11) '''); - var folded = trace.foldFrames((frame) => frame.member.startsWith('foo'), + var folded = trace.foldFrames( + (frame) => frame.member.startsWith('foo'), terse: true); expect(folded.toString(), equals(''' package:foo fooTop
diff --git a/pkgs/stack_trace/test/utils.dart b/pkgs/stack_trace/test/utils.dart index afa384c..0241b37 100644 --- a/pkgs/stack_trace/test/utils.dart +++ b/pkgs/stack_trace/test/utils.dart
@@ -6,11 +6,11 @@ /// Returns a matcher that runs [matcher] against a [Frame]'s `member` field. Matcher frameMember(matcher) => - transform((frame) => frame.member, matcher, 'member'); + transform((frame) => frame.member, matcher, 'member'); /// Returns a matcher that runs [matcher] against a [Frame]'s `library` field. Matcher frameLibrary(matcher) => - transform((frame) => frame.library, matcher, 'library'); + transform((frame) => frame.library, matcher, 'library'); /// Returns a matcher that runs [transformation] on its input, then matches /// the output against [matcher]. @@ -18,7 +18,7 @@ /// [description] should be a noun phrase that describes the relation of the /// output of [transformation] to its input. Matcher transform(transformation(value), matcher, String description) => - new _TransformMatcher(transformation, wrapMatcher(matcher), description); + new _TransformMatcher(transformation, wrapMatcher(matcher), description); class _TransformMatcher extends Matcher { final Function _transformation; @@ -28,8 +28,8 @@ _TransformMatcher(this._transformation, this._matcher, this._description); bool matches(item, Map matchState) => - _matcher.matches(_transformation(item), matchState); + _matcher.matches(_transformation(item), matchState); Description describe(Description description) => - description.add(_description).add(' ').addDescriptionOf(_matcher); + description.add(_description).add(' ').addDescriptionOf(_matcher); }