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

Side by Side Diff: tests/compiler/dart2js_extra/async_stacktrace_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:async"; 5 import "dart:async";
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import "package:async_helper/async_helper.dart"; 8 import "package:async_helper/async_helper.dart";
9 9
10 class Tracer { 10 class Tracer {
11 final String expected; 11 final String expected;
12 final String name; 12 final String name;
13 String _trace = ""; 13 String _trace = "";
14 14
15 Tracer(this.expected, [this.name]); 15 Tracer(this.expected, [this.name]);
16 16
17 void trace(msg) { 17 void trace(msg) {
18 if (name != null) { 18 if (name != null) {
19 print("Tracing $name: $msg"); 19 print("Tracing $name: $msg");
20 } 20 }
21 _trace += msg; 21 _trace += msg;
22 } 22 }
23 23
24 void done() { 24 void done() {
25 Expect.equals(expected, _trace); 25 Expect.equals(expected, _trace);
26 } 26 }
27 } 27 }
28 28
29 test1(Tracer tracer) { 29 test1(Tracer tracer) {
30 foo() async 30 foo() async*
31 * /// asyncStar: ok 31
32 { 32 /// asyncStar: ok
33 {
33 var savedStackTrace; 34 var savedStackTrace;
34 try { 35 try {
35 try { 36 try {
36 tracer.trace("a"); 37 tracer.trace("a");
37 throw "Error"; 38 throw "Error";
38 } catch (e, st) { 39 } catch (e, st) {
39 tracer.trace("b"); 40 tracer.trace("b");
40 savedStackTrace = st; 41 savedStackTrace = st;
41 } 42 }
42 tracer.trace("c"); 43 tracer.trace("c");
43 await new Future.error("Error 2", savedStackTrace); 44 await new Future.error("Error 2", savedStackTrace);
44 tracer.trace("d"); 45 tracer.trace("d");
45 } catch (e, st) { 46 } catch (e, st) {
46 tracer.trace("e"); 47 tracer.trace("e");
47 Expect.equals(savedStackTrace.toString(), st.toString()); 48 Expect.equals(savedStackTrace.toString(), st.toString());
48 } 49 }
49 tracer.trace("f"); 50 tracer.trace("f");
50 } 51 }
51 return foo() 52
52 .toList() /// asyncStar: continued 53 return foo().toList()
53 ; 54
55 /// asyncStar: continued
56 ;
54 } 57 }
55 58
56 test2(Tracer tracer) { 59 test2(Tracer tracer) {
57 var savedStackTrace; 60 var savedStackTrace;
58 foo() async 61 foo() async*
59 * /// asyncStar: continued 62
60 { 63 /// asyncStar: continued
64 {
61 try { 65 try {
62 tracer.trace("a"); 66 tracer.trace("a");
63 throw "Error"; 67 throw "Error";
64 } catch (e, st) { 68 } catch (e, st) {
65 tracer.trace("b"); 69 tracer.trace("b");
66 savedStackTrace = st; 70 savedStackTrace = st;
67 } 71 }
68 tracer.trace("c"); 72 tracer.trace("c");
69 await new Future.error("Error 2", savedStackTrace); 73 await new Future.error("Error 2", savedStackTrace);
70 tracer.trace("d"); 74 tracer.trace("d");
71 } 75 }
72 return foo() 76
73 .toList() /// asyncStar: continued 77 return foo().toList()
78
79 /// asyncStar: continued
74 .catchError((e, st) { 80 .catchError((e, st) {
75 tracer.trace("e"); 81 tracer.trace("e");
76 Expect.equals(savedStackTrace.toString(), st.toString()); 82 Expect.equals(savedStackTrace.toString(), st.toString());
77 }); 83 });
78 } 84 }
79 85
80 test3(Tracer tracer) { 86 test3(Tracer tracer) {
81 var savedStackTrace; 87 var savedStackTrace;
82 foo() async 88 foo() async*
83 * /// asyncStar: continued 89
84 { 90 /// asyncStar: continued
91 {
85 try { 92 try {
86 tracer.trace("a"); 93 tracer.trace("a");
87 throw "Error"; 94 throw "Error";
88 } catch (e, st) { 95 } catch (e, st) {
89 tracer.trace("b"); 96 tracer.trace("b");
90 savedStackTrace = st; 97 savedStackTrace = st;
91 rethrow; 98 rethrow;
92 } 99 }
93 } 100 }
94 return foo() 101
95 .toList() /// asyncStar: continued 102 return foo().toList()
103
104 /// asyncStar: continued
96 .catchError((e, st) { 105 .catchError((e, st) {
97 tracer.trace("c"); 106 tracer.trace("c");
98 Expect.equals(savedStackTrace.toString(), st.toString()); 107 Expect.equals(savedStackTrace.toString(), st.toString());
99 }); 108 });
100 } 109 }
101 110
102 runTest(String expectedTrace, Future test(Tracer tracer)) async { 111 runTest(String expectedTrace, Future test(Tracer tracer)) async {
103 Tracer tracer = new Tracer(expectedTrace); 112 Tracer tracer = new Tracer(expectedTrace);
104 await test(tracer); 113 await test(tracer);
105 tracer.done(); 114 tracer.done();
106 } 115 }
107 116
108 runTests() async { 117 runTests() async {
109 await runTest("abcef", test1); 118 await runTest("abcef", test1);
110 await runTest("abce", test2); 119 await runTest("abce", test2);
111 await runTest("abc", test3); 120 await runTest("abc", test3);
112 } 121 }
113 122
114 main() { 123 main() {
115 asyncTest(runTests); 124 asyncTest(runTests);
116 } 125 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_extra/async_helper.dart ('k') | tests/compiler/dart2js_extra/bailout_aborting_if_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698