Make stack frames without columns print correctly. This works around issue 14233. R=alanknight@google.com Review URL: https://codereview.chromium.org//29323004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/stack_trace@28884 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/stack_trace/lib/src/frame.dart b/pkgs/stack_trace/lib/src/frame.dart index 797bef1..b6b5962 100644 --- a/pkgs/stack_trace/lib/src/frame.dart +++ b/pkgs/stack_trace/lib/src/frame.dart
@@ -28,7 +28,7 @@ // foo/bar.dart 10:11 in Foo._bar // http://dartlang.org/foo/bar.dart in Foo._bar final _friendlyFrame = new RegExp( - r'^([^\s]+)(?: (\d+):(\d+))?\s+([^\d][^\s]*)$'); + r'^([^\s]+)(?: (\d+)(?::(\d+))?)?\s+([^\d][^\s]*)$'); final _initialDot = new RegExp(r"^\."); @@ -78,7 +78,8 @@ /// A human-friendly description of the code location. String get location { - if (line == null || column == null) return library; + if (line == null) return library; + if (column == null) return '$library $line'; return '$library $line:$column'; }
diff --git a/pkgs/stack_trace/test/frame_test.dart b/pkgs/stack_trace/test/frame_test.dart index 62cfd2e..75b92a4 100644 --- a/pkgs/stack_trace/test/frame_test.dart +++ b/pkgs/stack_trace/test/frame_test.dart
@@ -233,6 +233,15 @@ expect(frame.member, equals('Foo.<fn>.bar')); }); + test('parses a stack frame with no line correctly', () { + var frame = new 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)); + expect(frame.column, isNull); + expect(frame.member, equals('Foo.<fn>.bar')); + }); + 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( @@ -321,5 +330,10 @@ '(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(), + equals('dart:core/uri.dart 5 in Foo')); + }); }); }