Run dartfmt --fix (#60)
- Use function type syntax for typedefs.
- Use `=` for argument default values.
- Drop optional `new` and `const`.
- Use triple slash for doc comments.
diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 0000000..7472eb0
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1,7 @@
+linter:
+ rules:
+ - prefer_equal_for_default_values
+ - prefer_generic_function_type_aliases
+ - slash_for_doc_comments
+ - unnecessary_const
+ - unnecessary_new
diff --git a/lib/src/chain.dart b/lib/src/chain.dart
index 8685a9e..da6fb6f 100644
--- a/lib/src/chain.dart
+++ b/lib/src/chain.dart
@@ -13,10 +13,10 @@
/// A function that handles errors in the zone wrapped by [Chain.capture].
@Deprecated("Will be removed in stack_trace 2.0.0.")
-typedef void ChainHandler(error, Chain chain);
+typedef ChainHandler = void Function(dynamic error, Chain chain);
/// An opaque key used to track the current [StackZoneSpecification].
-final _specKey = new Object();
+final _specKey = Object();
/// A chain of stack traces.
///
@@ -73,10 +73,10 @@
/// If [callback] returns a value, it will be returned by [capture] as well.
static T capture<T>(T callback(),
{void onError(error, Chain chain),
- bool when: true,
- bool errorZone: true}) {
+ bool when = true,
+ bool errorZone = true}) {
if (!errorZone && onError != null) {
- throw new ArgumentError.value(
+ throw ArgumentError.value(
onError, "onError", "must be null if errorZone is false");
}
@@ -87,15 +87,15 @@
onError(
error,
stackTrace == null
- ? new Chain.current()
- : new Chain.forTrace(stackTrace));
+ ? Chain.current()
+ : Chain.forTrace(stackTrace));
};
}
return runZoned(callback, onError: newOnError);
}
- var spec = new StackZoneSpecification(onError, errorZone: errorZone);
+ var spec = StackZoneSpecification(onError, errorZone: errorZone);
return runZoned(() {
try {
return callback();
@@ -113,7 +113,7 @@
/// [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}) {
+ static T disable<T>(T callback(), {bool when = true}) {
var zoneValues =
when ? {_specKey: null, StackZoneSpecification.disableKey: true} : null;
@@ -139,14 +139,13 @@
factory Chain.current([int level = 0]) {
if (_currentSpec != null) return _currentSpec.currentChain(level + 1);
- var chain = new Chain.forTrace(StackTrace.current);
- return new LazyChain(() {
+ var chain = Chain.forTrace(StackTrace.current);
+ return 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 = Trace(chain.traces.first.frames.skip(level + (inJS ? 2 : 1)),
original: chain.traces.first.original.toString());
- return new Chain([first]..addAll(chain.traces.skip(1)));
+ return Chain([first]..addAll(chain.traces.skip(1)));
});
}
@@ -161,8 +160,8 @@
factory Chain.forTrace(StackTrace trace) {
if (trace is Chain) return trace;
if (_currentSpec != null) return _currentSpec.chainFor(trace);
- if (trace is Trace) return new Chain([trace]);
- return new LazyChain(() => new Chain.parse(trace.toString()));
+ if (trace is Trace) return Chain([trace]);
+ return LazyChain(() => Chain.parse(trace.toString()));
}
/// Parses a string representation of a stack chain.
@@ -171,19 +170,19 @@
/// as a full stack chain. Otherwise, it will be parsed as in [Trace.parse]
/// and returned as a single-trace chain.
factory Chain.parse(String chain) {
- if (chain.isEmpty) return new Chain([]);
+ if (chain.isEmpty) return Chain([]);
if (chain.contains(vmChainGap)) {
- return new Chain(
- chain.split(vmChainGap).map((trace) => new Trace.parseVM(trace)));
+ return Chain(
+ chain.split(vmChainGap).map((trace) => Trace.parseVM(trace)));
}
- if (!chain.contains(chainGap)) return new Chain([new Trace.parse(chain)]);
+ if (!chain.contains(chainGap)) return Chain([Trace.parse(chain)]);
- return new Chain(
- chain.split(chainGap).map((trace) => new Trace.parseFriendly(trace)));
+ return Chain(
+ chain.split(chainGap).map((trace) => Trace.parseFriendly(trace)));
}
/// Returns a new [Chain] comprised of [traces].
- Chain(Iterable<Trace> traces) : traces = new List<Trace>.unmodifiable(traces);
+ Chain(Iterable<Trace> traces) : traces = List<Trace>.unmodifiable(traces);
/// Returns a terser version of [this].
///
@@ -211,7 +210,7 @@
/// If [terse] is true, this will also fold together frames from the core
/// library or from this package, and simplify core library frames as in
/// [Trace.terse].
- Chain foldFrames(bool predicate(Frame frame), {bool terse: false}) {
+ Chain foldFrames(bool predicate(Frame frame), {bool terse = false}) {
var foldedTraces =
traces.map((trace) => trace.foldFrames(predicate, terse: terse));
var nonEmptyTraces = foldedTraces.where((trace) {
@@ -229,17 +228,17 @@
// If all the traces contain only internal processing, preserve the last
// (top-most) one so that the chain isn't empty.
if (nonEmptyTraces.isEmpty && foldedTraces.isNotEmpty) {
- return new Chain([foldedTraces.last]);
+ return Chain([foldedTraces.last]);
}
- return new Chain(nonEmptyTraces);
+ return Chain(nonEmptyTraces);
}
/// Converts [this] to a [Trace].
///
/// The trace version of a chain is just the concatenation of all the traces
/// in the chain.
- Trace toTrace() => new Trace(traces.expand((trace) => trace.frames));
+ Trace toTrace() => Trace(traces.expand((trace) => trace.frames));
String toString() {
// Figure out the longest path so we know how much to pad.
diff --git a/lib/src/frame.dart b/lib/src/frame.dart
index 23909f8..752dcb7 100644
--- a/lib/src/frame.dart
+++ b/lib/src/frame.dart
@@ -10,7 +10,7 @@
// #1 Foo._bar (file:///home/nweiz/code/stuff.dart:42:21)
// #1 Foo._bar (file:///home/nweiz/code/stuff.dart:42)
// #1 Foo._bar (file:///home/nweiz/code/stuff.dart)
-final _vmFrame = new RegExp(r'^#\d+\s+(\S.*) \((.+?)((?::\d+){0,2})\)$');
+final _vmFrame = RegExp(r'^#\d+\s+(\S.*) \((.+?)((?::\d+){0,2})\)$');
// at Object.stringify (native)
// at VW.call$0 (http://pub.dartlang.org/stuff.dart.js:560:28)
@@ -18,29 +18,29 @@
// (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 [^\]]+\])? \((.*)\)|(.*))$');
+ RegExp(r'^\s*at (?:(\S.*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$');
// http://pub.dartlang.org/stuff.dart.js:560:28
-final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)|native$');
+final _v8UrlLocation = RegExp(r'^(.*):(\d+):(\d+)|native$');
// eval as function (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28
// 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+)?$');
+ RegExp(r'^eval at (?:\S.*?) \((.*)\)(?:, .*?:\d+:\d+)?$');
// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > Function:3:40
// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > eval:3:40
final _firefoxEvalLocation =
- new RegExp(r"(\S+)@(\S+) line (\d+) >.* (Function|eval):\d+:\d+");
+ RegExp(r"(\S+)@(\S+) line (\d+) >.* (Function|eval):\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 = 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.
@@ -59,13 +59,13 @@
// 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 = RegExp(r'^(\S+)(?: (\d+)(?::(\d+))?)?\s+([^\d].*)$');
/// A regular expression that matches asynchronous member names generated by the
/// VM.
-final _asyncBody = new RegExp(r'<(<anonymous closure>|[^>]+)_async_body>');
+final _asyncBody = RegExp(r'<(<anonymous closure>|[^>]+)_async_body>');
-final _initialDot = new RegExp(r"^\.");
+final _initialDot = RegExp(r"^\.");
/// A single stack frame. Each frame points to a precise location in Dart code.
class Frame {
@@ -125,11 +125,11 @@
/// higher than `1`, it will return higher frames.
factory Frame.caller([int level = 1]) {
if (level < 0) {
- throw new ArgumentError("Argument [level] must be greater than or equal "
+ throw ArgumentError("Argument [level] must be greater than or equal "
"to 0.");
}
- return new Trace.current(level + 1).frames.first;
+ return Trace.current(level + 1).frames.first;
}
/// Parses a string representation of a Dart VM stack frame.
@@ -137,11 +137,11 @@
// The VM sometimes folds multiple stack frames together and replaces
// them with "...".
if (frame == '...') {
- return new Frame(new Uri(), null, null, '...');
+ return Frame(Uri(), null, null, '...');
}
var match = _vmFrame.firstMatch(frame);
- if (match == null) return new UnparsedFrame(frame);
+ if (match == null) return UnparsedFrame(frame);
// Get the pieces out of the regexp match. Function, URI and line should
// always be found. The column is optional.
@@ -155,13 +155,13 @@
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);
+ return 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);
+ if (match == null) return UnparsedFrame(frame);
// v8 location strings can be arbitrarily-nested, since it adds a layer
// of nesting for each eval performed on that line.
@@ -173,13 +173,13 @@
}
if (location == 'native') {
- return new Frame(Uri.parse('native'), null, null, member);
+ return Frame(Uri.parse('native'), null, null, member);
}
var urlMatch = _v8UrlLocation.firstMatch(location);
- if (urlMatch == null) return new UnparsedFrame(frame);
+ if (urlMatch == null) return UnparsedFrame(frame);
- return new Frame(_uriOrPathToUri(urlMatch[1]), int.parse(urlMatch[2]),
+ return Frame(_uriOrPathToUri(urlMatch[1]), int.parse(urlMatch[2]),
int.parse(urlMatch[3]), member);
}
@@ -202,13 +202,13 @@
});
/// Parses a string representation of a JavaScriptCore stack trace.
- factory Frame.parseJSCore(String frame) => new Frame.parseV8(frame);
+ factory Frame.parseJSCore(String frame) => Frame.parseV8(frame);
/// Parses a string representation of an IE stack frame.
///
/// IE10+ frames look just like V8 frames. Prior to IE10, stack traces can't
/// be retrieved.
- factory Frame.parseIE(String frame) => new Frame.parseV8(frame);
+ factory Frame.parseIE(String frame) => Frame.parseV8(frame);
/// Parses a Firefox 'eval' or 'function' stack frame.
///
@@ -218,20 +218,20 @@
factory Frame._parseFirefoxEval(String frame) =>
_catchFormatException(frame, () {
final match = _firefoxEvalLocation.firstMatch(frame);
- if (match == null) return new UnparsedFrame(frame);
+ if (match == null) return UnparsedFrame(frame);
var member = match[1].replaceAll('/<', '');
final uri = _uriOrPathToUri(match[2]);
final line = int.parse(match[3]);
if (member.isEmpty || member == 'anonymous') {
member = '<fn>';
}
- return new Frame(uri, line, null, member);
+ return Frame(uri, line, null, member);
});
/// 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);
+ if (match == null) return UnparsedFrame(frame);
if (match[3].contains(' line ')) {
return Frame._parseFirefoxEval(frame);
@@ -244,7 +244,7 @@
if (match[1] != null) {
member = match[1];
member +=
- new List.filled('/'.allMatches(match[2]).length, ".<fn>").join();
+ List.filled('/'.allMatches(match[2]).length, ".<fn>").join();
if (member == '') member = '<fn>';
// Some Firefox members have initial dots. We remove them for
@@ -257,32 +257,32 @@
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);
+ return Frame(uri, line, column, member);
});
/// Parses a string representation of a Safari 6.0 stack frame.
@Deprecated("Use Frame.parseSafari instead.")
- factory Frame.parseSafari6_0(String frame) => new Frame.parseFirefox(frame);
+ factory Frame.parseSafari6_0(String frame) => Frame.parseFirefox(frame);
/// Parses a string representation of a Safari 6.1+ stack frame.
@Deprecated("Use Frame.parseSafari instead.")
- factory Frame.parseSafari6_1(String frame) => new Frame.parseFirefox(frame);
+ factory Frame.parseSafari6_1(String frame) => Frame.parseFirefox(frame);
/// Parses a string representation of a Safari stack frame.
- factory Frame.parseSafari(String frame) => new Frame.parseFirefox(frame);
+ factory Frame.parseSafari(String frame) => Frame.parseFirefox(frame);
/// 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(
+ throw 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.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.
@@ -292,14 +292,14 @@
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]);
+ return 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]*://');
+ static final _uriRegExp = RegExp(r'^[a-zA-Z][-+.a-zA-Z\d]*://');
/// A regular expression matching a Windows path.
- static final _windowsRegExp = new RegExp(r'^([a-zA-Z]:[\\/]|\\\\)');
+ static final _windowsRegExp = RegExp(r'^([a-zA-Z]:[\\/]|\\\\)');
/// Converts [uriOrPath], which can be a URI, a Windows path, or a Posix path,
/// to a URI (absolute if possible).
@@ -307,9 +307,9 @@
if (uriOrPath.contains(_uriRegExp)) {
return Uri.parse(uriOrPath);
} else if (uriOrPath.contains(_windowsRegExp)) {
- return new Uri.file(uriOrPath, windows: true);
+ return Uri.file(uriOrPath, windows: true);
} else if (uriOrPath.startsWith('/')) {
- return new Uri.file(uriOrPath, windows: false);
+ return Uri.file(uriOrPath, windows: false);
}
// As far as I've seen, Firefox and V8 both always report absolute paths in
@@ -327,7 +327,7 @@
try {
return body();
} on FormatException catch (_) {
- return new UnparsedFrame(text);
+ return UnparsedFrame(text);
}
}
diff --git a/lib/src/lazy_chain.dart b/lib/src/lazy_chain.dart
index 55b9897..5dbe1c0 100644
--- a/lib/src/lazy_chain.dart
+++ b/lib/src/lazy_chain.dart
@@ -8,7 +8,7 @@
import 'trace.dart';
/// A thunk for lazily constructing a [Chain].
-typedef Chain ChainThunk();
+typedef ChainThunk = Chain Function();
/// A wrapper around a [ChainThunk]. This works around issue 9579 by avoiding
/// the conversion of native [StackTrace]s to strings until it's absolutely
@@ -26,8 +26,8 @@
List<Trace> get traces => _chain.traces;
Chain get terse => _chain.terse;
- Chain foldFrames(bool predicate(Frame frame), {bool terse: false}) =>
- new LazyChain(() => _chain.foldFrames(predicate, terse: terse));
- Trace toTrace() => new LazyTrace(() => _chain.toTrace());
+ Chain foldFrames(bool predicate(Frame frame), {bool terse = false}) =>
+ LazyChain(() => _chain.foldFrames(predicate, terse: terse));
+ Trace toTrace() => LazyTrace(() => _chain.toTrace());
String toString() => _chain.toString();
}
diff --git a/lib/src/lazy_trace.dart b/lib/src/lazy_trace.dart
index a31b75f..9cd53ee 100644
--- a/lib/src/lazy_trace.dart
+++ b/lib/src/lazy_trace.dart
@@ -6,7 +6,7 @@
import 'trace.dart';
/// A thunk for lazily constructing a [Trace].
-typedef Trace TraceThunk();
+typedef TraceThunk = Trace Function();
/// A wrapper around a [TraceThunk]. This works around issue 9579 by avoiding
/// the conversion of native [StackTrace]s to strings until it's absolutely
@@ -25,11 +25,11 @@
List<Frame> get frames => _trace.frames;
StackTrace get original => _trace.original;
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));
+ Trace get terse => LazyTrace(() => _trace.terse);
+ Trace foldFrames(bool predicate(Frame frame), {bool terse = false}) =>
+ LazyTrace(() => _trace.foldFrames(predicate, terse: terse));
String toString() => _trace.toString();
// Work around issue 14075.
- set frames(_) => throw new UnimplementedError();
+ set frames(_) => throw UnimplementedError();
}
diff --git a/lib/src/stack_zone_specification.dart b/lib/src/stack_zone_specification.dart
index 6c31d12..4ef4eae 100644
--- a/lib/src/stack_zone_specification.dart
+++ b/lib/src/stack_zone_specification.dart
@@ -11,7 +11,7 @@
import 'utils.dart';
/// A function that handles errors in the zone wrapped by [Chain.capture].
-typedef void _ChainHandler(error, Chain chain);
+typedef _ChainHandler = void Function(dynamic error, Chain chain);
/// A class encapsulating the zone specification for a [Chain.capture] zone.
///
@@ -37,7 +37,7 @@
/// zone.
///
/// If `Zone.current[disableKey]` is `true`, no stack chains will be tracked.
- static final disableKey = new Object();
+ static final disableKey = Object();
/// Whether chain-tracking is disabled in the current zone.
bool get _disabled => Zone.current[disableKey] == true;
@@ -50,7 +50,7 @@
///
/// The chain associated with a given stack trace doesn't contain a node for
/// that stack trace.
- final _chains = new Expando<_Node>("stack chains");
+ final _chains = Expando<_Node>("stack chains");
/// The error handler for the zone.
///
@@ -64,12 +64,12 @@
/// Whether this is an error zone.
final bool _errorZone;
- StackZoneSpecification(this._onError, {bool errorZone: true})
+ StackZoneSpecification(this._onError, {bool errorZone = true})
: _errorZone = errorZone;
/// Converts [this] to a real [ZoneSpecification].
ZoneSpecification toSpec() {
- return new ZoneSpecification(
+ return ZoneSpecification(
handleUncaughtError: _errorZone ? _handleUncaughtError : null,
registerCallback: _registerCallback,
registerUnaryCallback: _registerUnaryCallback,
@@ -98,15 +98,15 @@
// If there's no [_currentNode], we're running synchronously beneath
// [Chain.capture] and we should fall back to the VM's stack chaining. We
// can't use [Chain.from] here because it'll just call [chainFor] again.
- if (trace is Trace) return new Chain([trace]);
- return new LazyChain(() => new Chain.parse(trace.toString()));
+ if (trace is Trace) return Chain([trace]);
+ return LazyChain(() => Chain.parse(trace.toString()));
} else {
if (trace is! Trace) {
var original = trace;
- trace = new LazyTrace(() => new Trace.parse(_trimVMChain(original)));
+ trace = LazyTrace(() => Trace.parse(_trimVMChain(original)));
}
- return new _Node(trace, previous).toChain();
+ return _Node(trace, previous).toChain();
}
}
@@ -184,7 +184,7 @@
}
var asyncError = parent.errorCallback(zone, error, stackTrace);
- return asyncError == null ? new AsyncError(error, stackTrace) : asyncError;
+ return asyncError == null ? AsyncError(error, stackTrace) : asyncError;
}
/// Creates a [_Node] with the current stack trace and linked to
@@ -194,7 +194,7 @@
/// [_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(_currentTrace(level + 1), _currentNode);
// TODO(nweiz): use a more robust way of detecting and tracking errors when
// issue 15105 is fixed.
@@ -223,13 +223,12 @@
Trace _currentTrace([int level]) {
level ??= 0;
var stackTrace = StackTrace.current;
- return new LazyTrace(() {
+ return LazyTrace(() {
var text = _trimVMChain(stackTrace);
- var trace = new Trace.parse(text);
+ var trace = Trace.parse(text);
// 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.
- return new Trace(trace.frames.skip(level + (inJS ? 2 : 1)),
- original: text);
+ return Trace(trace.frames.skip(level + (inJS ? 2 : 1)), original: text);
});
}
@@ -250,7 +249,7 @@
/// The previous node in the chain.
final _Node previous;
- _Node(StackTrace trace, [this.previous]) : trace = new Trace.from(trace);
+ _Node(StackTrace trace, [this.previous]) : trace = Trace.from(trace);
/// Converts this to a [Chain].
Chain toChain() {
@@ -260,6 +259,6 @@
nodes.add(node.trace);
node = node.previous;
}
- return new Chain(nodes);
+ return Chain(nodes);
}
}
diff --git a/lib/src/trace.dart b/lib/src/trace.dart
index 09c1ca1..4a90874 100644
--- a/lib/src/trace.dart
+++ b/lib/src/trace.dart
@@ -11,7 +11,7 @@
import 'utils.dart';
import 'vm_trace.dart';
-final _terseRegExp = new RegExp(r"(-patch)?([/\\].*)?$");
+final _terseRegExp = RegExp(r"(-patch)?([/\\].*)?$");
/// A RegExp to match V8's stack traces.
///
@@ -19,13 +19,13 @@
/// description of the exception that occurred. That description can be multiple
/// lines, so we just look for any line other than the first that begins with
/// three or four spaces and "at".
-final _v8Trace = new RegExp(r"\n ?at ");
+final _v8Trace = RegExp(r"\n ?at ");
/// A RegExp to match indidual lines of V8's stack traces.
///
/// This is intended to filter out the leading exception details of the trace
/// though it is possible for the message to match this as well.
-final _v8TraceLine = new RegExp(r" ?at ");
+final _v8TraceLine = RegExp(r" ?at ");
/// A RegExp to match Firefox's eval and Function stack traces.
///
@@ -34,8 +34,7 @@
/// These stack traces looks like:
/// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > Function:3:40
/// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > eval:3:40
-final _firefoxEvalTrace =
- new RegExp(r"@\S+ line \d+ >.* (Function|eval):\d+:\d+");
+final _firefoxEvalTrace = RegExp(r"@\S+ line \d+ >.* (Function|eval):\d+:\d+");
/// A RegExp to match Firefox and Safari's stack traces.
///
@@ -50,7 +49,7 @@
/// "@", and they always have both the line and column number (or just a
/// trailing colon if no column number is available). They can also contain
/// empty lines or lines consisting only of `[native code]`.
-final _firefoxSafariTrace = new RegExp(
+final _firefoxSafariTrace = RegExp(
r"^"
r"(" // Member description. Not present in some Safari frames.
r"([.0-9A-Za-z_$/<]|\(.*\))*" // Member name and arguments.
@@ -63,7 +62,7 @@
/// A RegExp to match this package's stack traces.
final _friendlyTrace =
- new RegExp(r"^[^\s<][^\s]*( \d+(:\d+)?)?[ \t]+[^\s]+$", multiLine: true);
+ RegExp(r"^[^\s<][^\s]*( \d+(:\d+)?)?[ \t]+[^\s]+$", multiLine: true);
/// A stack trace, comprised of a list of stack frames.
class Trace implements StackTrace {
@@ -77,8 +76,8 @@
/// set, this folds together multiple stack frames from the Dart core
/// libraries, so that only the core library method directly called from user
/// code is visible (see [Trace.terse]).
- static String format(StackTrace stackTrace, {bool terse: true}) {
- var trace = new Trace.from(stackTrace);
+ static String format(StackTrace stackTrace, {bool terse = true}) {
+ var trace = Trace.from(stackTrace);
if (terse) trace = trace.terse;
return trace.toString();
}
@@ -90,15 +89,15 @@
/// many frames up instead.
factory Trace.current([int level = 0]) {
if (level < 0) {
- throw new ArgumentError("Argument [level] must be greater than or equal "
+ throw ArgumentError("Argument [level] must be greater than or equal "
"to 0.");
}
- var trace = new Trace.from(StackTrace.current);
- return new LazyTrace(() {
+ var trace = Trace.from(StackTrace.current);
+ return LazyTrace(() {
// 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.
- return new Trace(trace.frames.skip(level + (inJS ? 2 : 1)),
+ return Trace(trace.frames.skip(level + (inJS ? 2 : 1)),
original: trace.original.toString());
});
}
@@ -112,12 +111,12 @@
// the natural failure will only occur when the LazyTrace is materialized,
// and we want to provide an error that's more local to the actual problem.
if (trace == null) {
- throw new ArgumentError("Cannot create a Trace from null.");
+ throw ArgumentError("Cannot create a Trace from null.");
}
if (trace is Trace) return trace;
if (trace is Chain) return trace.toTrace();
- return new LazyTrace(() => new Trace.parse(trace.toString()));
+ return LazyTrace(() => Trace.parse(trace.toString()));
}
/// Parses a string representation of a stack trace.
@@ -127,24 +126,24 @@
/// of [Chain.toTrace].
factory Trace.parse(String trace) {
try {
- if (trace.isEmpty) return new Trace(<Frame>[]);
- if (trace.contains(_v8Trace)) return new Trace.parseV8(trace);
- if (trace.contains("\tat ")) return new Trace.parseJSCore(trace);
+ if (trace.isEmpty) return Trace(<Frame>[]);
+ if (trace.contains(_v8Trace)) return Trace.parseV8(trace);
+ if (trace.contains("\tat ")) return Trace.parseJSCore(trace);
if (trace.contains(_firefoxSafariTrace) ||
trace.contains(_firefoxEvalTrace)) {
- return new Trace.parseFirefox(trace);
+ return Trace.parseFirefox(trace);
}
- if (trace.contains(chainGap)) return new Chain.parse(trace).toTrace();
+ if (trace.contains(chainGap)) return Chain.parse(trace).toTrace();
if (trace.contains(_friendlyTrace)) {
- return new Trace.parseFriendly(trace);
+ return Trace.parseFriendly(trace);
}
// Default to parsing the stack trace as a VM trace. This is also hit on
// IE and Safari, where the stack trace is just an empty string (issue
// 11257).
- return new Trace.parseVM(trace);
+ return Trace.parseVM(trace);
} on FormatException catch (error) {
- throw new FormatException('${error.message}\nStack trace:\n$trace');
+ throw FormatException('${error.message}\nStack trace:\n$trace');
}
}
@@ -157,12 +156,12 @@
var lines = trace.trim().replaceAll(vmChainGap, '').split("\n");
var frames = lines
.take(lines.length - 1)
- .map((line) => new Frame.parseVM(line))
+ .map((line) => Frame.parseVM(line))
.toList();
// TODO(nweiz): Remove this when issue 23614 is fixed.
if (!lines.last.endsWith(".da")) {
- frames.add(new Frame.parseVM(lines.last));
+ frames.add(Frame.parseVM(lines.last));
}
return frames;
@@ -178,7 +177,7 @@
// 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)),
+ .map((line) => Frame.parseV8(line)),
original: trace);
/// Parses a string representation of a JavaScriptCore stack trace.
@@ -187,7 +186,7 @@
trace
.split("\n")
.where((line) => line != "\tat ")
- .map((line) => new Frame.parseV8(line)),
+ .map((line) => Frame.parseV8(line)),
original: trace);
/// Parses a string representation of an Internet Explorer stack trace.
@@ -203,7 +202,7 @@
.trim()
.split("\n")
.where((line) => line.isNotEmpty && line != '[native code]')
- .map((line) => new Frame.parseFirefox(line)),
+ .map((line) => Frame.parseFirefox(line)),
original: trace);
/// Parses a string representation of a Safari stack trace.
@@ -221,7 +220,7 @@
.trim()
.split("\n")
.where((line) => line != '[native code]')
- .map((line) => new Frame.parseFirefox(line)),
+ .map((line) => Frame.parseFirefox(line)),
original: trace);
/// Parses this package's string representation of a stack trace.
@@ -237,20 +236,20 @@
.split("\n")
// Filter out asynchronous gaps from [Chain]s.
.where((line) => !line.startsWith('====='))
- .map((line) => new Frame.parseFriendly(line)),
+ .map((line) => Frame.parseFriendly(line)),
original: trace);
/// Returns a new [Trace] comprised of [frames].
Trace(Iterable<Frame> frames, {String original})
- : frames = new List<Frame>.unmodifiable(frames),
- original = new StackTrace.fromString(original);
+ : frames = List<Frame>.unmodifiable(frames),
+ original = StackTrace.fromString(original);
/// Returns a VM-style [StackTrace] object.
///
/// The return value's [toString] method will always return a string
/// representation in the Dart VM's stack trace format, regardless of what
/// platform is being used.
- StackTrace get vmTrace => new VMTrace(frames);
+ StackTrace get vmTrace => VMTrace(frames);
/// Returns a terser version of [this].
///
@@ -281,7 +280,7 @@
/// If [terse] is true, this will also fold together frames from the core
/// library or from this package, simplify core library frames, and
/// potentially remove the outermost frame as in [Trace.terse].
- Trace foldFrames(bool predicate(Frame frame), {bool terse: false}) {
+ Trace foldFrames(bool predicate(Frame frame), {bool terse = false}) {
if (terse) {
var oldPredicate = predicate;
predicate = (frame) {
@@ -307,8 +306,7 @@
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(Frame(frame.uri, frame.line, frame.column, frame.member));
}
}
@@ -316,7 +314,7 @@
newFrames = newFrames.map((frame) {
if (frame is UnparsedFrame || !predicate(frame)) return frame;
var library = frame.library.replaceAll(_terseRegExp, '');
- return new Frame(Uri.parse(library), null, null, frame.member);
+ return Frame(Uri.parse(library), null, null, frame.member);
}).toList();
if (newFrames.length > 1 && predicate(newFrames.first)) {
@@ -324,7 +322,7 @@
}
}
- return new Trace(newFrames.reversed, original: this.original.toString());
+ return Trace(newFrames.reversed, original: this.original.toString());
}
/// Returns a human-readable string representation of [this].
diff --git a/lib/src/unparsed_frame.dart b/lib/src/unparsed_frame.dart
index 78ac738..3f7ffe2 100644
--- a/lib/src/unparsed_frame.dart
+++ b/lib/src/unparsed_frame.dart
@@ -8,7 +8,7 @@
///
/// The [member] property contains the original frame's contents.
class UnparsedFrame implements Frame {
- final Uri uri = new Uri(path: "unparsed");
+ final Uri uri = Uri(path: "unparsed");
final int line = null;
final int column = null;
final bool isCore = false;
diff --git a/lib/src/vm_trace.dart b/lib/src/vm_trace.dart
index 7086df7..74ffbca 100644
--- a/lib/src/vm_trace.dart
+++ b/lib/src/vm_trace.dart
@@ -20,7 +20,7 @@
return frames.map((frame) {
var number = "#${i++}".padRight(8);
var member = frame.member
- .replaceAllMapped(new RegExp(r"[^.]+\.<async>"),
+ .replaceAllMapped(RegExp(r"[^.]+\.<async>"),
(match) => "${match[1]}.<${match[1]}_async_body>")
.replaceAll("<fn>", "<anonymous closure>");
var line = frame.line == null ? 0 : frame.line;
diff --git a/lib/stack_trace.dart b/lib/stack_trace.dart
index 1e6f0b0..8a6ba9b 100644
--- a/lib/stack_trace.dart
+++ b/lib/stack_trace.dart
@@ -2,25 +2,23 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-/**
- * Stack trace generation and parsing.
- *
- * ## Installing ##
- *
- * Use [pub][] to install this package. Add the following to your `pubspec.yaml`
- * file.
- *
- * dependencies:
- * stack_trace: any
- *
- * Then run `pub install`.
- *
- * For more information, see the
- * [stack_trace package on pub.dartlang.org][pkg].
- *
- * [pub]: http://pub.dartlang.org
- * [pkg]: http://pub.dartlang.org/packages/stack_trace
- */
+/// Stack trace generation and parsing.
+///
+/// ## Installing ##
+///
+/// Use [pub][] to install this package. Add the following to your `pubspec.yaml`
+/// file.
+///
+/// dependencies:
+/// stack_trace: any
+///
+/// Then run `pub install`.
+///
+/// For more information, see the
+/// [stack_trace package on pub.dartlang.org][pkg].
+///
+/// [pub]: http://pub.dartlang.org
+/// [pkg]: http://pub.dartlang.org/packages/stack_trace
export 'src/chain.dart';
export 'src/frame.dart';
export 'src/trace.dart';
diff --git a/test/chain/chain_test.dart b/test/chain/chain_test.dart
index 9de7d53..40c2954 100644
--- a/test/chain/chain_test.dart
+++ b/test/chain/chain_test.dart
@@ -10,26 +10,26 @@
import 'utils.dart';
-typedef void ChainErrorCallback(stack, Chain chain);
+typedef ChainErrorCallback = void Function(dynamic stack, Chain chain);
void main() {
group('Chain.parse()', () {
test('parses a real Chain', () {
return captureFuture(() => inMicrotask(() => throw 'error'))
.then((chain) {
- expect(new Chain.parse(chain.toString()).toString(),
- equals(chain.toString()));
+ expect(
+ Chain.parse(chain.toString()).toString(), equals(chain.toString()));
});
});
test('parses an empty string', () {
- var chain = new Chain.parse('');
+ var chain = Chain.parse('');
expect(chain.traces, isEmpty);
});
test('parses a chain containing empty traces', () {
var chain =
- new Chain.parse('===== asynchronous gap ===========================\n'
+ Chain.parse('===== asynchronous gap ===========================\n'
'===== asynchronous gap ===========================\n');
expect(chain.traces, hasLength(3));
expect(chain.traces[0].frames, isEmpty);
@@ -41,7 +41,7 @@
group("Chain.capture()", () {
test("with onError blocks errors", () {
Chain.capture(() {
- return new Future.error("oh no");
+ return Future.error("oh no");
}, onError: expectAsync2((error, chain) {
expect(error, equals("oh no"));
expect(chain, TypeMatcher<Chain>());
@@ -50,8 +50,7 @@
test("with no onError blocks errors", () {
runZoned(() {
- var future =
- Chain.capture(() => new Future.error("oh no"), when: false);
+ var future = Chain.capture(() => Future.error("oh no"), when: false);
future.then(expectAsync1((_) {}, count: 0));
}, onError: expectAsync2((error, chain) {
expect(error, equals("oh no"));
@@ -60,7 +59,7 @@
});
test("with errorZone: false doesn't block errors", () {
- expect(Chain.capture(() => new Future.error("oh no"), errorZone: false),
+ expect(Chain.capture(() => Future.error("oh no"), errorZone: false),
throwsA("oh no"));
});
@@ -71,13 +70,13 @@
group("with when: false", () {
test("with no onError doesn't block errors", () {
- expect(Chain.capture(() => new Future.error("oh no"), when: false),
+ expect(Chain.capture(() => Future.error("oh no"), when: false),
throwsA("oh no"));
});
test("with onError blocks errors", () {
Chain.capture(() {
- return new Future.error("oh no");
+ return Future.error("oh no");
}, onError: expectAsync2((error, chain) {
expect(error, equals("oh no"));
expect(chain, TypeMatcher<Chain>());
@@ -87,9 +86,9 @@
test("doesn't enable chain-tracking", () {
return Chain.disable(() {
return Chain.capture(() {
- var completer = new Completer();
+ var completer = Completer();
inMicrotask(() {
- completer.complete(new Chain.current());
+ completer.complete(Chain.current());
});
return completer.future.then((chain) {
@@ -104,8 +103,8 @@
group("Chain.disable()", () {
test("disables chain-tracking", () {
return Chain.disable(() {
- var completer = new Completer();
- inMicrotask(() => completer.complete(new Chain.current()));
+ var completer = Completer();
+ inMicrotask(() => completer.complete(Chain.current()));
return completer.future.then((chain) {
expect(chain.traces, hasLength(1));
@@ -116,8 +115,8 @@
test("Chain.capture() re-enables chain-tracking", () {
return Chain.disable(() {
return Chain.capture(() {
- var completer = new Completer();
- inMicrotask(() => completer.complete(new Chain.current()));
+ var completer = Completer();
+ inMicrotask(() => completer.complete(Chain.current()));
return completer.future.then((chain) {
expect(chain.traces, hasLength(2));
@@ -151,8 +150,8 @@
test("with when: false doesn't disable", () {
return Chain.capture(() {
return Chain.disable(() {
- var completer = new Completer();
- inMicrotask(() => completer.complete(new Chain.current()));
+ var completer = Completer();
+ inMicrotask(() => completer.complete(Chain.current()));
return completer.future.then((chain) {
expect(chain.traces, hasLength(2));
@@ -163,9 +162,9 @@
});
test("toString() ensures that all traces are aligned", () {
- var chain = new Chain([
- new Trace.parse('short 10:11 Foo.bar\n'),
- new Trace.parse('loooooooooooong 10:11 Zop.zoop')
+ var chain = Chain([
+ Trace.parse('short 10:11 Foo.bar\n'),
+ Trace.parse('loooooooooooong 10:11 Zop.zoop')
]);
expect(
@@ -178,13 +177,13 @@
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'
+ var chain = Chain([
+ 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'
+ 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'
@@ -202,13 +201,13 @@
});
test('eliminates internal-only traces', () {
- var chain = new Chain([
- new Trace.parse('user/code.dart 10:11 Foo.bar\n'
+ var chain = Chain([
+ 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'
+ 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'
+ Trace.parse('user/code.dart 10:11 Foo.bar\n'
'dart:core 10:11 Bar.baz')
]);
@@ -220,11 +219,11 @@
});
test("doesn't return an empty chain", () {
- var chain = new Chain([
- new Trace.parse('dart:core 10:11 Foo.bar\n'
+ var chain = Chain([
+ 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'
+ 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')
]);
@@ -234,10 +233,10 @@
// Regression test for #9
test("doesn't crash on empty traces", () {
- var chain = new Chain([
- new Trace.parse('user/code.dart 10:11 Bang.qux'),
- new Trace([]),
- new Trace.parse('user/code.dart 10:11 Bang.qux')
+ var chain = Chain([
+ Trace.parse('user/code.dart 10:11 Bang.qux'),
+ Trace([]),
+ Trace.parse('user/code.dart 10:11 Bang.qux')
]);
expect(
@@ -250,13 +249,13 @@
group('Chain.foldFrames', () {
test('folds each trace', () {
- var chain = new Chain([
- new Trace.parse('a.dart 10:11 Foo.bar\n'
+ var chain = Chain([
+ 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'
+ 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'
@@ -275,13 +274,13 @@
});
test('with terse: true, folds core frames as well', () {
- var chain = new Chain([
- new Trace.parse('a.dart 10:11 Foo.bar\n'
+ var chain = Chain([
+ 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'
+ 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'
@@ -300,12 +299,12 @@
});
test('eliminates completely-folded traces', () {
- var chain = new Chain([
- new Trace.parse('a.dart 10:11 Foo.bar\n'
+ var chain = Chain([
+ 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'
+ 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'
+ Trace.parse('a.dart 10:11 Zip.zap\n'
'b.dart 10:11 Zop.zoop')
]);
@@ -320,8 +319,8 @@
});
test("doesn't return an empty trace", () {
- var chain = new Chain([
- new Trace.parse('a.dart 10:11 Foo.bar\n'
+ var chain = Chain([
+ Trace.parse('a.dart 10:11 Foo.bar\n'
'a.dart 10:11 Bang.qux')
]);
@@ -331,10 +330,10 @@
});
test('Chain.toTrace eliminates asynchronous gaps', () {
- var trace = new Chain([
- new Trace.parse('user/code.dart 10:11 Foo.bar\n'
+ var trace = Chain([
+ 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'
+ Trace.parse('user/code.dart 10:11 Foo.bar\n'
'dart:core 10:11 Bar.baz')
]).toTrace();
diff --git a/test/chain/dart2js_test.dart b/test/chain/dart2js_test.dart
index 8cceded..fbbad56 100644
--- a/test/chain/dart2js_test.dart
+++ b/test/chain/dart2js_test.dart
@@ -73,7 +73,7 @@
});
test('multiple times', () {
- var completer = new Completer();
+ var completer = Completer();
var first = true;
Chain.capture(() {
@@ -99,7 +99,7 @@
});
test('passed to a completer', () async {
- var trace = new Trace.current();
+ var trace = Trace.current();
var chain = await captureFuture(() {
inMicrotask(() => completerErrorFuture(trace));
});
@@ -120,7 +120,7 @@
});
test('passed to a stream controller', () async {
- var trace = new Trace.current();
+ var trace = Trace.current();
var chain = await captureFuture(() {
inMicrotask(() => controllerErrorStream(trace).listen(null));
});
@@ -138,7 +138,7 @@
});
test('and relays them to the parent zone', () {
- var completer = new Completer();
+ var completer = Completer();
runZoned(() {
Chain.capture(() {
@@ -164,7 +164,7 @@
});
test('capture() without onError passes exceptions to parent zone', () {
- var completer = new Completer();
+ var completer = Completer();
runZoned(() {
Chain.capture(() => inMicrotask(() => throw 'error'));
@@ -184,9 +184,9 @@
group('current() within capture()', () {
test('called in a microtask', () async {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
- inMicrotask(() => completer.complete(new Chain.current()));
+ inMicrotask(() => completer.complete(Chain.current()));
});
var chain = await completer.future;
@@ -194,9 +194,9 @@
});
test('called in a one-shot timer', () async {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
- inOneShotTimer(() => completer.complete(new Chain.current()));
+ inOneShotTimer(() => completer.complete(Chain.current()));
});
var chain = await completer.future;
@@ -204,9 +204,9 @@
});
test('called in a periodic timer', () async {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
- inPeriodicTimer(() => completer.complete(new Chain.current()));
+ inPeriodicTimer(() => completer.complete(Chain.current()));
});
var chain = await completer.future;
@@ -214,11 +214,11 @@
});
test('called in a nested series of asynchronous operations', () async {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
inPeriodicTimer(() {
inOneShotTimer(() {
- inMicrotask(() => completer.complete(new Chain.current()));
+ inMicrotask(() => completer.complete(Chain.current()));
});
});
});
@@ -228,9 +228,9 @@
});
test('called in a long future chain', () async {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
- inFutureChain(() => completer.complete(new Chain.current()));
+ inFutureChain(() => completer.complete(Chain.current()));
});
var chain = await completer.future;
@@ -243,8 +243,8 @@
'trace', () {
// The test runner runs all tests with chains enabled.
return Chain.disable(() async {
- var completer = new Completer();
- inMicrotask(() => completer.complete(new Chain.current()));
+ var completer = Completer();
+ inMicrotask(() => completer.complete(Chain.current()));
var chain = await completer.future;
// Since the chain wasn't loaded within [Chain.capture], the full stack
@@ -311,13 +311,13 @@
throw 'error';
} catch (_, stackTrace) {
trace = stackTrace;
- return new Chain.forTrace(stackTrace);
+ return Chain.forTrace(stackTrace);
}
});
expect(chain.traces, hasLength(1));
- expect(chain.traces.first.toString(),
- equals(new Trace.from(trace).toString()));
+ expect(
+ chain.traces.first.toString(), equals(Trace.from(trace).toString()));
});
});
@@ -330,12 +330,11 @@
throw 'error';
} catch (_, stackTrace) {
trace = stackTrace;
- return new Chain.forTrace(stackTrace);
+ return Chain.forTrace(stackTrace);
}
});
expect(chain.traces, hasLength(1));
- expect(chain.traces.first.toString(),
- equals(new Trace.from(trace).toString()));
+ expect(chain.traces.first.toString(), equals(Trace.from(trace).toString()));
});
}
diff --git a/test/chain/utils.dart b/test/chain/utils.dart
index 0c5c983..c1f98e4 100644
--- a/test/chain/utils.dart
+++ b/test/chain/utils.dart
@@ -16,7 +16,7 @@
/// Runs [callback] once in a periodic timer callback.
void inPeriodicTimer(callback()) {
var count = 0;
- new Timer.periodic(new Duration(milliseconds: 1), (timer) {
+ Timer.periodic(Duration(milliseconds: 1), (timer) {
count++;
if (count != 5) return;
timer.cancel();
@@ -26,28 +26,28 @@
/// Runs [callback] within a long asynchronous Future chain.
void inFutureChain(callback()) {
- new Future(() {})
- .then((_) => new Future(() {}))
- .then((_) => new Future(() {}))
- .then((_) => new Future(() {}))
- .then((_) => new Future(() {}))
+ Future(() {})
+ .then((_) => Future(() {}))
+ .then((_) => Future(() {}))
+ .then((_) => Future(() {}))
+ .then((_) => Future(() {}))
.then((_) => callback())
- .then((_) => new Future(() {}));
+ .then((_) => Future(() {}));
}
void inNewFuture(callback()) {
- new Future(callback);
+ Future(callback);
}
void inSyncFuture(callback()) {
- new Future.sync(callback);
+ Future.sync(callback);
}
/// Returns a Future that completes to an error using a completer.
///
/// If [trace] is passed, it's used as the stack trace for the error.
Future completerErrorFuture([StackTrace trace]) {
- var completer = new Completer();
+ var completer = Completer();
completer.completeError('error', trace);
return completer.future;
}
@@ -56,7 +56,7 @@
///
/// If [trace] is passed, it's used as the stack trace for the error.
Stream controllerErrorStream([StackTrace trace]) {
- var controller = new StreamController();
+ var controller = StreamController();
controller.addError('error', trace);
return controller.stream;
}
@@ -64,19 +64,17 @@
/// Runs [callback] within [asyncFn], then converts any errors raised into a
/// [Chain] with [Chain.forTrace].
Future<Chain> chainForTrace(asyncFn(callback()), callback()) {
- var completer = new Completer<Chain>();
+ var completer = Completer<Chain>();
asyncFn(() {
// We use `new Future.value().then(...)` here as opposed to [new Future] or
// [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())
- .catchError(completer.completeError);
+ Future.value().then((_) => callback()).catchError(completer.completeError);
});
return completer.future
- .catchError((_, stackTrace) => new Chain.forTrace(stackTrace));
+ .catchError((_, stackTrace) => Chain.forTrace(stackTrace));
}
/// Runs [callback] in a [Chain.capture] zone and returns a Future that
@@ -84,7 +82,7 @@
///
/// [callback] is expected to throw the string `"error"`.
Future<Chain> captureFuture(callback()) {
- var completer = new Completer<Chain>();
+ var completer = Completer<Chain>();
Chain.capture(callback, onError: (error, chain) {
expect(error, equals('error'));
completer.complete(chain);
diff --git a/test/chain/vm_test.dart b/test/chain/vm_test.dart
index 4f8aa95..c006d88 100644
--- a/test/chain/vm_test.dart
+++ b/test/chain/vm_test.dart
@@ -31,8 +31,8 @@
// Because there's no chain context for a synchronous error, we fall back
// on the VM's stack chain tracking.
- expect(chain.toString(),
- equals(new Chain.parse(vmTrace.toString()).toString()));
+ expect(
+ chain.toString(), equals(Chain.parse(vmTrace.toString()).toString()));
});
test('thrown in a microtask', () {
@@ -137,7 +137,7 @@
});
test('multiple times', () {
- var completer = new Completer();
+ var completer = Completer();
var first = true;
Chain.capture(() {
@@ -165,7 +165,7 @@
});
test('passed to a completer', () {
- var trace = new Trace.current();
+ var trace = Trace.current();
return captureFuture(() {
inMicrotask(() => completerErrorFuture(trace));
}).then((chain) {
@@ -206,7 +206,7 @@
});
test('passed to a stream controller', () {
- var trace = new Trace.current();
+ var trace = Trace.current();
return captureFuture(() {
inMicrotask(() => controllerErrorStream(trace).listen(null));
}).then((chain) {
@@ -232,7 +232,7 @@
});
test('and relays them to the parent zone', () {
- var completer = new Completer();
+ var completer = Completer();
runZoned(() {
Chain.capture(() {
@@ -260,7 +260,7 @@
});
test('capture() without onError passes exceptions to parent zone', () {
- var completer = new Completer();
+ var completer = Completer();
runZoned(() {
Chain.capture(() => inMicrotask(() => throw 'error'));
@@ -281,9 +281,9 @@
group('current() within capture()', () {
test('called in a microtask', () {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
- inMicrotask(() => completer.complete(new Chain.current()));
+ inMicrotask(() => completer.complete(Chain.current()));
});
return completer.future.then((chain) {
@@ -295,9 +295,9 @@
});
test('called in a one-shot timer', () {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
- inOneShotTimer(() => completer.complete(new Chain.current()));
+ inOneShotTimer(() => completer.complete(Chain.current()));
});
return completer.future.then((chain) {
@@ -309,9 +309,9 @@
});
test('called in a periodic timer', () {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
- inPeriodicTimer(() => completer.complete(new Chain.current()));
+ inPeriodicTimer(() => completer.complete(Chain.current()));
});
return completer.future.then((chain) {
@@ -323,11 +323,11 @@
});
test('called in a nested series of asynchronous operations', () {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
inPeriodicTimer(() {
inOneShotTimer(() {
- inMicrotask(() => completer.complete(new Chain.current()));
+ inMicrotask(() => completer.complete(Chain.current()));
});
});
});
@@ -345,9 +345,9 @@
});
test('called in a long future chain', () {
- var completer = new Completer();
+ var completer = Completer();
Chain.capture(() {
- inFutureChain(() => completer.complete(new Chain.current()));
+ inFutureChain(() => completer.complete(Chain.current()));
});
return completer.future.then((chain) {
@@ -364,8 +364,8 @@
'trace', () {
// The test runner runs all tests with chains enabled.
return Chain.disable(() {
- var completer = new Completer();
- inMicrotask(() => completer.complete(new Chain.current()));
+ var completer = Completer();
+ inMicrotask(() => completer.complete(Chain.current()));
return completer.future.then((chain) {
// Since the chain wasn't loaded within [Chain.capture], the full stack
@@ -463,7 +463,7 @@
throw 'error';
} catch (_, stackTrace) {
trace = stackTrace;
- return new Chain.forTrace(stackTrace);
+ return Chain.forTrace(stackTrace);
}
});
@@ -472,7 +472,7 @@
// Assert that we've trimmed the VM's stack chains here to avoid
// duplication.
expect(chain.traces.first.toString(),
- equals(new Chain.parse(trace.toString()).traces.first.toString()));
+ equals(Chain.parse(trace.toString()).traces.first.toString()));
});
});
@@ -490,7 +490,7 @@
}
});
- var chain = new Chain.forTrace(trace);
+ var chain = Chain.forTrace(trace);
expect(chain.traces,
hasLength(vmChainGap.allMatches(trace.toString()).length + 1));
expect(
diff --git a/test/frame_test.dart b/test/frame_test.dart
index 22e9318..685603e 100644
--- a/test/frame_test.dart
+++ b/test/frame_test.dart
@@ -9,7 +9,7 @@
void main() {
group('.parseVM', () {
test('parses a stack frame with column correctly', () {
- var frame = new Frame.parseVM("#1 Foo._bar "
+ var frame = 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")));
@@ -19,7 +19,7 @@
});
test('parses a stack frame without column correctly', () {
- var frame = new Frame.parseVM("#1 Foo._bar "
+ var frame = Frame.parseVM("#1 Foo._bar "
"(file:///home/nweiz/code/stuff.dart:24)");
expect(
frame.uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart")));
@@ -30,7 +30,7 @@
// This can happen with async stack traces. See issue 22009.
test('parses a stack frame without line or column correctly', () {
- var frame = new Frame.parseVM("#1 Foo._bar "
+ var frame = Frame.parseVM("#1 Foo._bar "
"(file:///home/nweiz/code/stuff.dart)");
expect(
frame.uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart")));
@@ -41,7 +41,7 @@
test('converts "<anonymous closure>" to "<fn>"', () {
String parsedMember(String member) =>
- new Frame.parseVM('#0 $member (foo:0:0)').member;
+ Frame.parseVM('#0 $member (foo:0:0)').member;
expect(parsedMember('Foo.<anonymous closure>'), equals('Foo.<fn>'));
expect(parsedMember('<anonymous closure>.<anonymous closure>.bar'),
@@ -49,22 +49,21 @@
});
test('converts "<<anonymous closure>_async_body>" to "<async>"', () {
- var frame = new Frame.parseVM(
- '#0 Foo.<<anonymous closure>_async_body> (foo:0:0)');
+ var frame =
+ Frame.parseVM('#0 Foo.<<anonymous closure>_async_body> (foo:0:0)');
expect(frame.member, equals('Foo.<async>'));
});
test('converts "<function_name_async_body>" to "<async>"', () {
- var frame =
- new Frame.parseVM('#0 Foo.<function_name_async_body> (foo:0:0)');
+ var frame = Frame.parseVM('#0 Foo.<function_name_async_body> (foo:0:0)');
expect(frame.member, equals('Foo.<async>'));
});
test('parses a folded frame correctly', () {
- var frame = new Frame.parseVM('...');
+ var frame = Frame.parseVM('...');
expect(frame.member, equals('...'));
- expect(frame.uri, equals(new Uri()));
+ expect(frame.uri, equals(Uri()));
expect(frame.line, isNull);
expect(frame.column, isNull);
});
@@ -72,17 +71,17 @@
group('.parseV8', () {
test('returns an UnparsedFrame for malformed frames', () {
- expectIsUnparsed((text) => new Frame.parseV8(text), '');
- expectIsUnparsed((text) => new Frame.parseV8(text), '#1');
- expectIsUnparsed((text) => new Frame.parseV8(text), '#1 Foo');
- expectIsUnparsed((text) => new Frame.parseV8(text),
+ expectIsUnparsed((text) => Frame.parseV8(text), '');
+ expectIsUnparsed((text) => Frame.parseV8(text), '#1');
+ expectIsUnparsed((text) => Frame.parseV8(text), '#1 Foo');
+ expectIsUnparsed((text) => Frame.parseV8(text),
'#1 (dart:async/future.dart:10:15)');
- expectIsUnparsed((text) => new Frame.parseV8(text),
- 'Foo (dart:async/future.dart:10:15)');
+ expectIsUnparsed(
+ (text) => Frame.parseV8(text), 'Foo (dart:async/future.dart:10:15)');
});
test('parses a stack frame correctly', () {
- var frame = new Frame.parseV8(" at VW.call\$0 "
+ var frame = Frame.parseV8(" at VW.call\$0 "
"(http://pub.dartlang.org/stuff.dart.js:560:28)");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -92,7 +91,7 @@
});
test('parses a stack frame with an absolute POSIX path correctly', () {
- var frame = new Frame.parseV8(" at VW.call\$0 "
+ var frame = Frame.parseV8(" at VW.call\$0 "
"(/path/to/stuff.dart.js:560:28)");
expect(frame.uri, equals(Uri.parse("file:///path/to/stuff.dart.js")));
expect(frame.line, equals(560));
@@ -101,7 +100,7 @@
});
test('parses a stack frame with an absolute Windows path correctly', () {
- var frame = new Frame.parseV8(" at VW.call\$0 "
+ var frame = Frame.parseV8(" at VW.call\$0 "
r"(C:\path\to\stuff.dart.js:560:28)");
expect(frame.uri, equals(Uri.parse("file:///C:/path/to/stuff.dart.js")));
expect(frame.line, equals(560));
@@ -110,7 +109,7 @@
});
test('parses a stack frame with a Windows UNC path correctly', () {
- var frame = new Frame.parseV8(" at VW.call\$0 "
+ var frame = 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")));
@@ -120,7 +119,7 @@
});
test('parses a stack frame with a relative POSIX path correctly', () {
- var frame = new Frame.parseV8(" at VW.call\$0 "
+ var frame = Frame.parseV8(" at VW.call\$0 "
"(path/to/stuff.dart.js:560:28)");
expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js")));
expect(frame.line, equals(560));
@@ -129,7 +128,7 @@
});
test('parses a stack frame with a relative Windows path correctly', () {
- var frame = new Frame.parseV8(" at VW.call\$0 "
+ var frame = Frame.parseV8(" at VW.call\$0 "
r"(path\to\stuff.dart.js:560:28)");
expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js")));
expect(frame.line, equals(560));
@@ -138,8 +137,8 @@
});
test('parses an anonymous stack frame correctly', () {
- var frame = new Frame.parseV8(
- " at http://pub.dartlang.org/stuff.dart.js:560:28");
+ var frame =
+ Frame.parseV8(" at http://pub.dartlang.org/stuff.dart.js:560:28");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
expect(frame.line, equals(560));
@@ -148,7 +147,7 @@
});
test('parses a native stack frame correctly', () {
- var frame = new Frame.parseV8(" at Object.stringify (native)");
+ var frame = Frame.parseV8(" at Object.stringify (native)");
expect(frame.uri, Uri.parse('native'));
expect(frame.line, isNull);
expect(frame.column, isNull);
@@ -158,7 +157,7 @@
test('parses a stack frame with [as ...] correctly', () {
// Ignore "[as ...]", since other stack trace formats don't support a
// similar construct.
- var frame = new Frame.parseV8(" at VW.call\$0 [as call\$4] "
+ var frame = Frame.parseV8(" at VW.call\$0 [as call\$4] "
"(http://pub.dartlang.org/stuff.dart.js:560:28)");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -168,7 +167,7 @@
});
test('parses a basic eval stack frame correctly', () {
- var frame = new Frame.parseV8(" at eval (eval at <anonymous> "
+ var frame = Frame.parseV8(" at eval (eval at <anonymous> "
"(http://pub.dartlang.org/stuff.dart.js:560:28))");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -178,7 +177,7 @@
});
test('parses an IE10 eval stack frame correctly', () {
- var frame = new Frame.parseV8(" at eval (eval at Anonymous function "
+ var frame = Frame.parseV8(" at eval (eval at Anonymous function "
"(http://pub.dartlang.org/stuff.dart.js:560:28))");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -188,7 +187,7 @@
});
test('parses an eval stack frame with inner position info correctly', () {
- var frame = new Frame.parseV8(" at eval (eval at <anonymous> "
+ var frame = Frame.parseV8(" at eval (eval at <anonymous> "
"(http://pub.dartlang.org/stuff.dart.js:560:28), <anonymous>:3:28)");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -198,7 +197,7 @@
});
test('parses a nested eval stack frame correctly', () {
- var frame = new Frame.parseV8(" at eval (eval at <anonymous> "
+ var frame = Frame.parseV8(" at eval (eval at <anonymous> "
"(eval at sub (http://pub.dartlang.org/stuff.dart.js:560:28)))");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -209,7 +208,7 @@
test('converts "<anonymous>" to "<fn>"', () {
String parsedMember(String member) =>
- new Frame.parseV8(' at $member (foo:0:0)').member;
+ Frame.parseV8(' at $member (foo:0:0)').member;
expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>'));
expect(
@@ -217,27 +216,27 @@
});
test('returns an UnparsedFrame for malformed frames', () {
- expectIsUnparsed((text) => new Frame.parseV8(text), '');
- expectIsUnparsed((text) => new Frame.parseV8(text), ' at');
- expectIsUnparsed((text) => new Frame.parseV8(text), ' at Foo');
- expectIsUnparsed((text) => new Frame.parseV8(text),
- ' at Foo (dart:async/future.dart)');
- expectIsUnparsed((text) => new Frame.parseV8(text),
+ expectIsUnparsed((text) => Frame.parseV8(text), '');
+ expectIsUnparsed((text) => Frame.parseV8(text), ' at');
+ expectIsUnparsed((text) => Frame.parseV8(text), ' at Foo');
+ expectIsUnparsed(
+ (text) => Frame.parseV8(text), ' at Foo (dart:async/future.dart)');
+ expectIsUnparsed((text) => Frame.parseV8(text),
' 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:10');
+ (text) => Frame.parseV8(text), 'Foo (dart:async/future.dart:10:15)');
expectIsUnparsed(
- (text) => new Frame.parseV8(text), 'dart:async/future.dart:10:15');
+ (text) => Frame.parseV8(text), ' at dart:async/future.dart');
+ expectIsUnparsed(
+ (text) => Frame.parseV8(text), ' at dart:async/future.dart:10');
+ expectIsUnparsed(
+ (text) => Frame.parseV8(text), 'dart:async/future.dart:10:15');
});
});
group('.parseFirefox/.parseSafari', () {
test('parses a Firefox stack trace with anonymous function', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
Foo._bar@http://pub.dartlang.org/stuff.js:18056:12
anonymous/<@http://pub.dartlang.org/stuff.js line 693 > Function:3:40
baz@http://pub.dartlang.org/buz.js:56355:55
@@ -261,7 +260,7 @@
test('parses a Firefox stack trace with nested evals in anonymous function',
() {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
Foo._bar@http://pub.dartlang.org/stuff.js:18056:12
anonymous@file:///C:/example.html line 7 > eval line 1 > eval:1:1
anonymous@file:///C:/example.html line 45 > Function:1:1
@@ -282,7 +281,7 @@
});
test('parses a simple stack frame correctly', () {
- var frame = new Frame.parseFirefox(
+ var frame = Frame.parseFirefox(
".VW.call\$0@http://pub.dartlang.org/stuff.dart.js:560");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -292,8 +291,7 @@
});
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 = 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);
@@ -302,7 +300,7 @@
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");
+ 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);
@@ -310,8 +308,8 @@
});
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");
+ var frame =
+ 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.line, equals(560));
@@ -320,8 +318,7 @@
});
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 = 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);
@@ -329,8 +326,7 @@
});
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 = 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);
@@ -339,7 +335,7 @@
test('parses a simple anonymous stack frame correctly', () {
var frame =
- new Frame.parseFirefox("@http://pub.dartlang.org/stuff.dart.js:560");
+ 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));
@@ -348,7 +344,7 @@
});
test('parses a nested anonymous stack frame correctly', () {
- var frame = new Frame.parseFirefox(
+ var frame = Frame.parseFirefox(
".foo/<@http://pub.dartlang.org/stuff.dart.js:560");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -356,8 +352,8 @@
expect(frame.column, isNull);
expect(frame.member, equals("foo.<fn>"));
- frame = new Frame.parseFirefox(
- ".foo/@http://pub.dartlang.org/stuff.dart.js:560");
+ frame =
+ Frame.parseFirefox(".foo/@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));
@@ -366,7 +362,7 @@
});
test('parses a named nested anonymous stack frame correctly', () {
- var frame = new Frame.parseFirefox(
+ var frame = Frame.parseFirefox(
".foo/.name<@http://pub.dartlang.org/stuff.dart.js:560");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -374,7 +370,7 @@
expect(frame.column, isNull);
expect(frame.member, equals("foo.<fn>"));
- frame = new Frame.parseFirefox(
+ frame = Frame.parseFirefox(
".foo/.name@http://pub.dartlang.org/stuff.dart.js:560");
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -384,7 +380,7 @@
});
test('parses a stack frame with parameters correctly', () {
- var frame = new Frame.parseFirefox(
+ var frame = Frame.parseFirefox(
'.foo(12, "@)()/<")@http://pub.dartlang.org/stuff.dart.js:560');
expect(frame.uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js")));
@@ -394,7 +390,7 @@
});
test('parses a nested anonymous stack frame with parameters correctly', () {
- var frame = new Frame.parseFirefox('.foo(12, "@)()/<")/.fn<@'
+ var frame = 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")));
@@ -406,9 +402,8 @@
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 = 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));
@@ -417,19 +412,19 @@
});
test('returns an UnparsedFrame for malformed frames', () {
- expectIsUnparsed((text) => new Frame.parseFirefox(text), '');
- expectIsUnparsed((text) => new Frame.parseFirefox(text), '.foo');
- expectIsUnparsed((text) => new Frame.parseFirefox(text),
- '.foo@dart:async/future.dart');
- expectIsUnparsed((text) => new Frame.parseFirefox(text),
+ expectIsUnparsed((text) => Frame.parseFirefox(text), '');
+ expectIsUnparsed((text) => Frame.parseFirefox(text), '.foo');
+ expectIsUnparsed(
+ (text) => Frame.parseFirefox(text), '.foo@dart:async/future.dart');
+ expectIsUnparsed((text) => Frame.parseFirefox(text),
'.foo(@dart:async/future.dart:10');
expectIsUnparsed(
- (text) => new Frame.parseFirefox(text), '@dart:async/future.dart');
+ (text) => Frame.parseFirefox(text), '@dart:async/future.dart');
});
test('parses a simple stack frame correctly', () {
- var frame = new Frame.parseFirefox(
- "foo\$bar@http://dartlang.org/foo/bar.dart:10:11");
+ var frame =
+ Frame.parseFirefox("foo\$bar@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));
@@ -437,8 +432,7 @@
});
test('parses an anonymous stack frame correctly', () {
- var frame =
- new Frame.parseFirefox("http://dartlang.org/foo/bar.dart:10:11");
+ var frame = 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));
@@ -446,8 +440,8 @@
});
test('parses a stack frame with no line correctly', () {
- var frame = new Frame.parseFirefox(
- "foo\$bar@http://dartlang.org/foo/bar.dart::11");
+ var frame =
+ Frame.parseFirefox("foo\$bar@http://dartlang.org/foo/bar.dart::11");
expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
expect(frame.line, isNull);
expect(frame.column, equals(11));
@@ -455,8 +449,8 @@
});
test('parses a stack frame with no column correctly', () {
- var frame = new Frame.parseFirefox(
- "foo\$bar@http://dartlang.org/foo/bar.dart:10:");
+ var frame =
+ Frame.parseFirefox("foo\$bar@http://dartlang.org/foo/bar.dart:10:");
expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
expect(frame.line, equals(10));
expect(frame.column, isNull);
@@ -464,8 +458,8 @@
});
test('parses a stack frame with no line or column correctly', () {
- var frame = new Frame.parseFirefox(
- "foo\$bar@http://dartlang.org/foo/bar.dart:10:11");
+ var frame =
+ Frame.parseFirefox("foo\$bar@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));
@@ -475,7 +469,7 @@
group('.parseFriendly', () {
test('parses a simple stack frame correctly', () {
- var frame = new Frame.parseFriendly(
+ var frame = Frame.parseFriendly(
"http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar");
expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
expect(frame.line, equals(10));
@@ -484,8 +478,8 @@
});
test('parses a stack frame with no line or column correctly', () {
- var frame = new Frame.parseFriendly(
- "http://dartlang.org/foo/bar.dart Foo.<fn>.bar");
+ var frame =
+ Frame.parseFriendly("http://dartlang.org/foo/bar.dart Foo.<fn>.bar");
expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
expect(frame.line, isNull);
expect(frame.column, isNull);
@@ -493,7 +487,7 @@
});
test('parses a stack frame with no column correctly', () {
- var frame = new Frame.parseFriendly(
+ var frame = Frame.parseFriendly(
"http://dartlang.org/foo/bar.dart 10 Foo.<fn>.bar");
expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
expect(frame.line, equals(10));
@@ -502,7 +496,7 @@
});
test('parses a stack frame with a relative path correctly', () {
- var frame = new Frame.parseFriendly("foo/bar.dart 10:11 Foo.<fn>.bar");
+ var frame = 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.line, equals(10));
@@ -511,14 +505,14 @@
});
test('returns an UnparsedFrame for malformed frames', () {
- expectIsUnparsed((text) => new Frame.parseFriendly(text), '');
- expectIsUnparsed((text) => new Frame.parseFriendly(text), 'foo/bar.dart');
+ expectIsUnparsed((text) => Frame.parseFriendly(text), '');
+ expectIsUnparsed((text) => Frame.parseFriendly(text), 'foo/bar.dart');
expectIsUnparsed(
- (text) => new Frame.parseFriendly(text), 'foo/bar.dart 10:11');
+ (text) => 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 = Frame.parseFriendly("data:... main");
expect(frame.uri.scheme, equals('data'));
expect(frame.line, isNull);
expect(frame.column, isNull);
@@ -526,7 +520,7 @@
});
test('parses a data url stack frame correctly', () {
- var frame = new Frame.parseFriendly("data:... 10:11 main");
+ var frame = Frame.parseFriendly("data:... 10:11 main");
expect(frame.uri.scheme, equals('data'));
expect(frame.line, equals(10));
expect(frame.column, equals(11));
@@ -534,7 +528,7 @@
});
test('parses a stack frame with spaces in the member name correctly', () {
- var frame = new Frame.parseFriendly(
+ var frame = Frame.parseFriendly(
"foo/bar.dart 10:11 (anonymous function).dart.fn");
expect(frame.uri,
equals(path.toUri(path.absolute(path.join('foo', 'bar.dart')))));
@@ -546,7 +540,7 @@
test(
'parses a stack frame with spaces in the member name and no line or '
'column correctly', () {
- var frame = new Frame.parseFriendly(
+ var frame = 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.line, isNull);
@@ -557,7 +551,7 @@
test('only considers dart URIs to be core', () {
bool isCore(String library) =>
- new Frame.parseVM('#0 Foo ($library:0:0)').isCore;
+ Frame.parseVM('#0 Foo ($library:0:0)').isCore;
expect(isCore('dart:core'), isTrue);
expect(isCore('dart:async'), isTrue);
@@ -571,22 +565,22 @@
group('.library', () {
test('returns the URI string for non-file URIs', () {
- expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').library,
+ expect(Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').library,
equals('dart:async/future.dart'));
expect(
- new Frame.parseVM('#0 Foo '
+ Frame.parseVM('#0 Foo '
'(http://dartlang.org/stuff/thing.dart:0:0)')
.library,
equals('http://dartlang.org/stuff/thing.dart'));
});
test('returns the relative path for file URIs', () {
- expect(new Frame.parseVM('#0 Foo (foo/bar.dart:0:0)').library,
+ expect(Frame.parseVM('#0 Foo (foo/bar.dart:0:0)').library,
equals(path.join('foo', 'bar.dart')));
});
test('truncates data: URIs', () {
- var frame = new Frame.parseVM(
+ var frame = Frame.parseVM(
'#0 Foo (data:application/dart;charset=utf-8,blah:0:0)');
expect(frame.library, equals('data:...'));
});
@@ -597,30 +591,30 @@
'returns the library and line/column numbers for non-core '
'libraries', () {
expect(
- new Frame.parseVM('#0 Foo '
+ 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,
+ expect(Frame.parseVM('#0 Foo (foo/bar.dart:1:2)').location,
equals('${path.join('foo', 'bar.dart')} 1:2'));
});
});
group('.package', () {
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 '
+ Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').package, isNull);
+ expect(
+ Frame.parseVM('#0 Foo '
'(http://dartlang.org/stuff/thing.dart:0:0)')
.package,
isNull);
});
test('returns the package name for package: URIs', () {
- expect(new Frame.parseVM('#0 Foo (package:foo/foo.dart:0:0)').package,
+ expect(Frame.parseVM('#0 Foo (package:foo/foo.dart:0:0)').package,
equals('foo'));
- expect(new Frame.parseVM('#0 Foo (package:foo/zap/bar.dart:0:0)').package,
+ expect(Frame.parseVM('#0 Foo (package:foo/zap/bar.dart:0:0)').package,
equals('foo'));
});
});
@@ -630,27 +624,27 @@
'returns the library and line/column numbers for non-core '
'libraries', () {
expect(
- new Frame.parseVM('#0 Foo (http://dartlang.org/thing.dart:5:10)')
+ 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> '
+ Frame.parseVM('#0 Foo.<anonymous closure> '
'(dart:core/uri.dart:5:10)')
.toString(),
equals('dart:core/uri.dart 5:10 in Foo.<fn>'));
});
test('prints a frame without a column correctly', () {
- expect(new Frame.parseVM('#0 Foo (dart:core/uri.dart:5)').toString(),
+ expect(Frame.parseVM('#0 Foo (dart:core/uri.dart:5)').toString(),
equals('dart:core/uri.dart 5 in Foo'));
});
test('prints relative paths as relative', () {
var relative = path.normalize('relative/path/to/foo.dart');
- expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(),
+ expect(Frame.parseFriendly('$relative 5:10 Foo').toString(),
equals('$relative 5:10 in Foo'));
});
});
diff --git a/test/trace_test.dart b/test/trace_test.dart
index 33d4f4e..61abe5d 100644
--- a/test/trace_test.dart
+++ b/test/trace_test.dart
@@ -6,17 +6,17 @@
import 'package:stack_trace/stack_trace.dart';
import 'package:test/test.dart';
-Trace getCurrentTrace([int level]) => new Trace.current(level);
+Trace getCurrentTrace([int level]) => Trace.current(level);
Trace nestedGetCurrentTrace(int level) => getCurrentTrace(level);
void main() {
// This just shouldn't crash.
- test('a native stack trace is parseable', () => new Trace.current());
+ test('a native stack trace is parseable', () => Trace.current());
group('.parse', () {
test('.parse parses a VM stack trace correctly', () {
- var trace = new Trace.parse(
+ var trace = Trace.parse(
'#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.'
@@ -30,7 +30,7 @@
});
test('parses a V8 stack trace correctly', () {
- var trace = new Trace.parse('Error\n'
+ var trace = 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 '
@@ -43,7 +43,7 @@
expect(trace.frames[2].uri,
equals(Uri.parse("http://pub.dartlang.org/thing.js")));
- trace = new Trace.parse("Exception: foo\n"
+ trace = 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 '
@@ -56,7 +56,7 @@
expect(trace.frames[2].uri,
equals(Uri.parse("http://pub.dartlang.org/thing.js")));
- trace = new Trace.parse('Exception: foo\n'
+ trace = 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'
@@ -70,7 +70,7 @@
expect(trace.frames[2].uri,
equals(Uri.parse("http://pub.dartlang.org/thing.js")));
- trace = new Trace.parse('Exception: foo\n'
+ trace = 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'
@@ -90,11 +90,11 @@
// JavaScriptCore traces are just like V8, except that it doesn't have a
// header and it starts with a tab rather than spaces.
test('parses a JavaScriptCore stack trace correctly', () {
- var trace = new Trace.parse(
- '\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)');
+ var trace =
+ Trace.parse('\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)');
expect(trace.frames[0].uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.js")));
@@ -103,11 +103,11 @@
expect(trace.frames[2].uri,
equals(Uri.parse("http://pub.dartlang.org/thing.js")));
- trace = new Trace.parse(
- '\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)');
+ trace =
+ Trace.parse('\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)');
expect(trace.frames[0].uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.js")));
@@ -116,10 +116,9 @@
});
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 = 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")));
@@ -128,7 +127,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 = 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');
@@ -139,7 +138,7 @@
expect(trace.frames[2].uri,
equals(Uri.parse("http://pub.dartlang.org/thing.js")));
- trace = new Trace.parse(
+ trace = Trace.parse(
'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1\n'
'zip/<@http://pub.dartlang.org/stuff.js:0\n'
'Foo._bar@http://pub.dartlang.org/stuff.js:42');
@@ -154,11 +153,10 @@
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 = 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")));
@@ -171,7 +169,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 = 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');
@@ -186,11 +184,10 @@
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 = 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")));
@@ -202,10 +199,9 @@
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 = 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")));
@@ -218,9 +214,9 @@
});
test('parses a package:stack_trace stack trace correctly', () {
- var trace = new Trace.parse(
- 'http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar\n'
- 'http://dartlang.org/foo/baz.dart Foo.<fn>.bar');
+ var trace =
+ Trace.parse('http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar\n'
+ 'http://dartlang.org/foo/baz.dart Foo.<fn>.bar');
expect(trace.frames[0].uri,
equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
@@ -229,12 +225,12 @@
});
test('parses a package:stack_trace stack chain correctly', () {
- var trace = new Trace.parse(
- 'http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar\n'
- 'http://dartlang.org/foo/baz.dart Foo.<fn>.bar\n'
- '===== asynchronous gap ===========================\n'
- 'http://dartlang.org/foo/bang.dart 10:11 Foo.<fn>.bar\n'
- 'http://dartlang.org/foo/quux.dart Foo.<fn>.bar');
+ var trace =
+ Trace.parse('http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar\n'
+ 'http://dartlang.org/foo/baz.dart Foo.<fn>.bar\n'
+ '===== asynchronous gap ===========================\n'
+ 'http://dartlang.org/foo/bang.dart 10:11 Foo.<fn>.bar\n'
+ 'http://dartlang.org/foo/quux.dart Foo.<fn>.bar');
expect(trace.frames[0].uri,
equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
@@ -247,19 +243,19 @@
});
test('parses a real package:stack_trace stack trace correctly', () {
- var traceString = new Trace.current().toString();
- expect(new Trace.parse(traceString).toString(), equals(traceString));
+ var traceString = Trace.current().toString();
+ expect(Trace.parse(traceString).toString(), equals(traceString));
});
test('parses an empty string correctly', () {
- var trace = new Trace.parse('');
+ var trace = Trace.parse('');
expect(trace.frames, isEmpty);
expect(trace.toString(), equals(''));
});
});
test('.toString() nicely formats the stack trace', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#0 Foo._bar (foo/bar.dart:42:21)
#1 zip.<anonymous closure>.zap (dart:async/future.dart:0:2)
#2 zip.<anonymous closure>.zap (http://pub.dartlang.org/thing.dart:1:100)
@@ -274,10 +270,10 @@
test('.vmTrace returns a native-style trace', () {
var uri = path.toUri(path.absolute('foo'));
- var trace = new Trace([
- new Frame(uri, 10, 20, 'Foo.<fn>'),
- new Frame(Uri.parse('http://dartlang.org/foo.dart'), null, null, 'bar'),
- new Frame(Uri.parse('dart:async'), 15, null, 'baz'),
+ var trace = Trace([
+ Frame(uri, 10, 20, 'Foo.<fn>'),
+ Frame(Uri.parse('http://dartlang.org/foo.dart'), null, null, 'bar'),
+ Frame(Uri.parse('dart:async'), 15, null, 'baz'),
]);
expect(
@@ -290,7 +286,7 @@
group("folding", () {
group(".terse", () {
test('folds core frames together bottom-up', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#1 top (dart:async/future.dart:0:2)
#2 bottom (dart:core/uri.dart:1:100)
#0 notCore (foo.dart:42:21)
@@ -308,7 +304,7 @@
});
test('folds empty async frames', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#0 top (dart:async/future.dart:0:2)
#1 empty.<<anonymous closure>_async_body> (bar.dart)
#2 bottom (dart:async-patch/future.dart:9:11)
@@ -322,7 +318,7 @@
});
test('removes the bottom-most async frame', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#0 notCore (foo.dart:42:21)
#1 top (dart:async/future.dart:0:2)
#2 bottom (dart:core/uri.dart:1:100)
@@ -336,7 +332,7 @@
});
test("won't make a trace empty", () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#1 top (dart:async/future.dart:0:2)
#2 bottom (dart:core/uri.dart:1:100)
''');
@@ -347,13 +343,13 @@
});
test("won't panic on an empty trace", () {
- expect(new Trace.parse("").terse.toString(), equals(""));
+ expect(Trace.parse("").terse.toString(), equals(""));
});
});
group(".foldFrames", () {
test('folds frames together bottom-up', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#0 notFoo (foo.dart:42:21)
#1 fooTop (bar.dart:0:2)
#2 fooBottom (foo.dart:1:100)
@@ -373,7 +369,7 @@
});
test('will never fold unparsed frames', () {
- var trace = new Trace.parse(r'''
+ var trace = Trace.parse(r'''
.g"cs$#:b";a#>sw{*{ul$"$xqwr`p
%+j-?uppx<([j@#nu{{>*+$%x-={`{
!e($b{nj)zs?cgr%!;bmw.+$j+pfj~
@@ -388,7 +384,7 @@
group("with terse: true", () {
test('folds core frames as well', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#0 notFoo (foo.dart:42:21)
#1 fooTop (bar.dart:0:2)
#2 coreBottom (dart:async/future.dart:0:2)
@@ -408,7 +404,7 @@
});
test('shortens folded frames', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#0 notFoo (foo.dart:42:21)
#1 fooTop (bar.dart:0:2)
#2 fooBottom (package:foo/bar.dart:0:2)
@@ -431,7 +427,7 @@
});
test('removes the bottom-most folded frame', () {
- var trace = new Trace.parse('''
+ var trace = Trace.parse('''
#2 fooTop (package:foo/bar.dart:0:2)
#3 notFoo (bar.dart:10:20)
#5 fooBottom (foo/bar.dart:9:11)
diff --git a/test/utils.dart b/test/utils.dart
index 0241b37..41a79c6 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -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);
+ _TransformMatcher(transformation, wrapMatcher(matcher), description);
class _TransformMatcher extends Matcher {
final Function _transformation;
diff --git a/test/vm_test.dart b/test/vm_test.dart
index 1b53458..9d5e77b 100644
--- a/test/vm_test.dart
+++ b/test/vm_test.dart
@@ -19,13 +19,13 @@
StackTrace getStackTraceObject() => StackTrace.current;
Frame getCaller([int level]) {
- if (level == null) return new Frame.caller();
- return new Frame.caller(level);
+ if (level == null) return Frame.caller();
+ return Frame.caller(level);
}
Frame nestedGetCaller(int level) => getCaller(level);
-Trace getCurrentTrace([int level]) => new Trace.current(level);
+Trace getCurrentTrace([int level]) => Trace.current(level);
Trace nestedGetCurrentTrace(int level) => getCurrentTrace(level);
@@ -33,14 +33,14 @@
group('Trace', () {
test('.parse parses a real stack trace correctly', () {
var string = getStackTraceString();
- var trace = new Trace.parse(string);
+ var trace = Trace.parse(string);
expect(path.url.basename(trace.frames.first.uri.path),
equals('vm_test.dart'));
expect(trace.frames.first.member, equals('getStackTraceString'));
});
test('converts from a native stack trace correctly', () {
- var trace = new Trace.from(getStackTraceObject());
+ var trace = Trace.from(getStackTraceObject());
expect(path.url.basename(trace.frames.first.uri.path),
equals('vm_test.dart'));
expect(trace.frames.first.member, equals('getStackTraceObject'));
@@ -53,7 +53,7 @@
try {
overflow();
} catch (_, stackTrace) {
- trace = new Trace.from(stackTrace);
+ trace = Trace.from(stackTrace);
}
expect(trace.frames.first.member, equals('main.<fn>.<fn>.overflow'));
@@ -62,12 +62,12 @@
group('.current()', () {
test('with no argument returns a trace starting at the current frame',
() {
- var trace = new Trace.current();
+ var trace = Trace.current();
expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
});
test('at level 0 returns a trace starting at the current frame', () {
- var trace = new Trace.current(0);
+ var trace = Trace.current(0);
expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
});
@@ -82,7 +82,7 @@
});
test('throws an ArgumentError for negative levels', () {
- expect(() => new Trace.current(-1), throwsArgumentError);
+ expect(() => Trace.current(-1), throwsArgumentError);
});
});
});
@@ -105,7 +105,7 @@
});
test('throws an ArgumentError for negative levels', () {
- expect(() => new Frame.caller(-1), throwsArgumentError);
+ expect(() => Frame.caller(-1), throwsArgumentError);
});
});
}