Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: tests/corelib/stacktrace_fromstring_test.dart

Issue 1088433004: Add StackTrace.fromString constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/isolate/isolate.dart ('k') | tests/language/custom_await_stack_trace_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « sdk/lib/isolate/isolate.dart ('k') | tests/language/custom_await_stack_trace_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698