Properly handle empty stack traces in package:stack_trace.

R=sigmund@google.com

Review URL: https://codereview.chromium.org//18170002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/stack_trace@24571 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/stack_trace/lib/src/trace.dart b/pkgs/stack_trace/lib/src/trace.dart
index 4abf55a..db7a404 100644
--- a/pkgs/stack_trace/lib/src/trace.dart
+++ b/pkgs/stack_trace/lib/src/trace.dart
@@ -143,10 +143,9 @@
 
   /// Returns a human-readable string representation of [this].
   String toString() {
-    if (frames.length == '') return '';
-
     // Figure out the longest path so we know how much to pad.
-    var longest = frames.map((frame) => frame.location.length).reduce(math.max);
+    var longest = frames.map((frame) => frame.location.length)
+        .fold(0, math.max);
 
     // Print out the stack trace nicely formatted.
     return frames.map((frame) {
diff --git a/pkgs/stack_trace/test/trace_test.dart b/pkgs/stack_trace/test/trace_test.dart
index 5d34de5..95753a0 100644
--- a/pkgs/stack_trace/test/trace_test.dart
+++ b/pkgs/stack_trace/test/trace_test.dart
@@ -102,7 +102,9 @@
     });
 
     test('parses an empty string correctly', () {
-      expect(new Trace.parse('').frames, isEmpty);
+      var trace = new Trace.parse('');
+      expect(trace.frames, isEmpty);
+      expect(trace.toString(), equals(''));
     });
   });