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 { | |
12 throw 0; | |
13 } catch (e, s) { | |
14 stack = s; | |
15 } | |
16 var string = "$stack"; | |
17 StackTrace stringTrace = new StackTrace.fromString(string); | |
18 Expect.isTrue(stringTrace is StackTrace); | |
19 Expect.equals(stack.toString(), stringTrace.toString()); | |
20 | |
21 string = "some random string, nothing like a StackTrace"; | |
22 stringTrace = new StackTrace.fromString(string); | |
23 Expect.isTrue(stringTrace is StackTrace); | |
24 Expect.equals(string, stringTrace.toString()); | |
25 | |
26 // Use stacktrace asynchronously. | |
27 asyncStart(); | |
28 var c = new Completer(); | |
29 c.completeError(0, stringTrace); | |
30 c.future.then((v) { | |
31 throw "Unexpected value: $v"; | |
32 }, onError: (e, s) { | |
33 Expect.equals(string, s.toString()); | |
34 }).then((_) { | |
35 var c = new StreamController(); | |
36 c.stream.listen((v) { | |
37 throw "Unexpected value: $v"; | |
38 }, onError: (e, s) { | |
39 Expect.equals(string, s.toString()); | |
40 asyncEnd(); | |
41 }); | |
42 c.addError(0, stringTrace); | |
43 c.close(); | |
44 }); | |
45 } | |
OLD | NEW |