OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 import "package:async_helper/async_helper.dart"; |
| 7 import "dart:async"; |
| 8 |
| 9 void main() { |
| 10 StackTrace stack; |
| 11 try { throw 0; } catch (e, s) { stack = s; } |
| 12 var string = "$stack"; |
| 13 StackTrace stringTrace = new StackTrace.fromString(string); |
| 14 Expect.isTrue(stringTrace is StackTrace); |
| 15 Expect.equals(stack.toString(), stringTrace.toString()); |
| 16 |
| 17 string = "some random string, nothing like a StackTrace"; |
| 18 stringTrace = new StackTrace.fromString(string); |
| 19 Expect.isTrue(stringTrace is StackTrace); |
| 20 Expect.equals(string, stringTrace.toString()); |
| 21 |
| 22 // Use stacktrace asynchronously. |
| 23 asyncStart(); |
| 24 var c = new Completer(); |
| 25 c.completeError(0, stringTrace); |
| 26 c.future.then((v) { |
| 27 throw "Unexpected value: $v"; |
| 28 }, onError: (e, s) { |
| 29 Expect.equals(string, s.toString()); |
| 30 }).then((_) { |
| 31 var c = new StreamController(); |
| 32 c.stream.listen((v) { |
| 33 throw "Unexpected value: $v"; |
| 34 }, onError: (e, s) { |
| 35 Expect.equals(string, s.toString()); |
| 36 asyncEnd(); |
| 37 }); |
| 38 c.addError(0, stringTrace); |
| 39 c.close(); |
| 40 }); |
| 41 } |
OLD | NEW |