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

Side by Side Diff: test/mjsunit/harmony/async-debug-caught-exception-cases.js

Issue 2317383002: Async/await Promise dependency graph (Closed)
Patch Set: Remove irrelevant whitespace change 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
« src/js/promise.js ('K') | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --allow-natives-syntax --harmony-async-await --expose-debug-as debug 5 // Flags: --allow-natives-syntax --harmony-async-await --expose-debug-as debug
6 6
7 Debug = debug.Debug 7 Debug = debug.Debug
8 8
9 let events = 0; 9 let events = 0;
10 10
(...skipping 13 matching lines...) Expand all
24 async function scalar() { return 1; } 24 async function scalar() { return 1; }
25 25
26 function nothing() { return 1; } 26 function nothing() { return 1; }
27 27
28 function rejectConstructor() { 28 function rejectConstructor() {
29 return new Promise((resolve, reject) => reject("c")); // Exception c 29 return new Promise((resolve, reject) => reject("c")); // Exception c
30 } 30 }
31 31
32 async function argThrower(x = (() => { throw "d"; })()) { } // Exception d 32 async function argThrower(x = (() => { throw "d"; })()) { } // Exception d
33 33
34 async function awaitThrow() {
35 await undefined;
36 throw "e"; // Exception e
37 }
38
39 function constructorThrow() {
40 return new Promise((resolve, reject) =>
41 Promise.resolve().then(() =>
42 reject("f") // Exception f
43 )
44 );
45 }
46
34 function suppressThrow() { 47 function suppressThrow() {
35 return thrower(); 48 return thrower();
36 } 49 }
37 50
38 async function caught(producer) { 51 async function caught(producer) {
39 try { 52 try {
40 await producer(); 53 await producer();
41 } catch (e) { 54 } catch (e) {
42 } 55 }
43 } 56 }
(...skipping 29 matching lines...) Expand all
73 Promise.resolve(producer()).then().catch(() => {}); 86 Promise.resolve(producer()).then().catch(() => {});
74 } 87 }
75 88
76 async function indirectAwaitCatch(producer) { 89 async function indirectAwaitCatch(producer) {
77 try { 90 try {
78 await (() => producer())(); 91 await (() => producer())();
79 } catch (e) { 92 } catch (e) {
80 } 93 }
81 } 94 }
82 95
83 let catches = [caught, indirectCaught, indirectAwaitCatch]; 96 function switchCatch(producer) {
97 let resolve;
98 let promise = new Promise(r => resolve = r);
99 async function localCaught() {
100 try {
101 await promise; // force switching to localUncaught and back
102 await producer();
103 } catch (e) { }
104 }
105 async function localUncaught() {
106 await undefined;
107 resolve();
108 }
109 localCaught();
110 localUncaught();
111 }
112
113 function switchDotCatch(producer) {
114 let resolve;
115 let promise = new Promise(r => resolve = r);
116 async function localCaught() {
117 await promise; // force switching to localUncaught and back
118 await producer();
119 }
120 async function localUncaught() {
121 await undefined;
122 resolve();
123 }
124 localCaught().catch(() => {});
125 localUncaught();
126 }
127
128 let catches = [caught,
129 indirectCaught,
130 indirectAwaitCatch,
131 switchCatch,
132 switchDotCatch];
84 let noncatches = [uncaught, indirectUncaught]; 133 let noncatches = [uncaught, indirectUncaught];
85 let lateCatches = [dotCatch, 134 let lateCatches = [dotCatch,
86 indirectReturnDotCatch, 135 indirectReturnDotCatch,
87 indirectAwaitDotCatch, 136 indirectAwaitDotCatch,
88 nestedDotCatch]; 137 nestedDotCatch];
89 138
90 let throws = [thrower, reject, argThrower, suppressThrow]; 139 let throws = [thrower, reject, argThrower, suppressThrow];
91 let nonthrows = [awaitReturn, scalar, nothing]; 140 let nonthrows = [awaitReturn, scalar, nothing];
141 let lateThrows = [awaitThrow, constructorThrow];
92 let uncatchable = [rejectConstructor]; 142 let uncatchable = [rejectConstructor];
93 143
94 let cases = []; 144 let cases = [];
95 145
96 for (let producer of throws) { 146 for (let producer of throws.concat(lateThrows)) {
97 for (let consumer of catches) { 147 for (let consumer of catches) {
98 cases.push({ producer, consumer, expectedEvents: 1, caught: true }); 148 cases.push({ producer, consumer, expectedEvents: 1, caught: true });
99 cases.push({ producer, consumer, expectedEvents: 0, caught: false }); 149 cases.push({ producer, consumer, expectedEvents: 0, caught: false });
100 } 150 }
101 } 151 }
102 152
103 for (let producer of throws) { 153 for (let producer of throws.concat(lateThrows)) {
104 for (let consumer of noncatches) { 154 for (let consumer of noncatches) {
105 cases.push({ producer, consumer, expectedEvents: 1, caught: true }); 155 cases.push({ producer, consumer, expectedEvents: 1, caught: true });
106 cases.push({ producer, consumer, expectedEvents: 1, caught: false }); 156 cases.push({ producer, consumer, expectedEvents: 1, caught: false });
107 } 157 }
108 } 158 }
109 159
110 for (let producer of nonthrows) { 160 for (let producer of nonthrows) {
111 for (let consumer of catches.concat(noncatches, lateCatches)) { 161 for (let consumer of catches.concat(noncatches, lateCatches)) {
112 cases.push({ producer, consumer, expectedEvents: 0, caught: true }); 162 cases.push({ producer, consumer, expectedEvents: 0, caught: true });
113 cases.push({ producer, consumer, expectedEvents: 0, caught: false }); 163 cases.push({ producer, consumer, expectedEvents: 0, caught: false });
114 } 164 }
115 } 165 }
116 166
117 for (let producer of uncatchable) { 167 for (let producer of uncatchable) {
118 for (let consumer of catches.concat(noncatches, lateCatches)) { 168 for (let consumer of catches.concat(noncatches, lateCatches)) {
119 cases.push({ producer, consumer, expectedEvents: 1, caught: true }); 169 cases.push({ producer, consumer, expectedEvents: 1, caught: true });
120 cases.push({ producer, consumer, expectedEvents: 1, caught: false }); 170 cases.push({ producer, consumer, expectedEvents: 1, caught: false });
121 } 171 }
122 } 172 }
123 173
174 for (let producer of lateThrows) {
175 for (let consumer of lateCatches) {
176 cases.push({ producer, consumer, expectedEvents: 1, caught: true });
177 cases.push({ producer, consumer, expectedEvents: 0, caught: false });
178 }
179 }
180
124 for (let producer of throws) { 181 for (let producer of throws) {
125 for (let consumer of lateCatches) { 182 for (let consumer of lateCatches) {
126 cases.push({ producer, consumer, expectedEvents: 1, caught: true }); 183 cases.push({ producer, consumer, expectedEvents: 1, caught: true });
127 cases.push({ producer, consumer, expectedEvents: 1, caught: false }); 184 cases.push({ producer, consumer, expectedEvents: 1, caught: false });
128 } 185 }
129 } 186 }
130 187
131 for (let {producer, consumer, expectedEvents, caught} of cases) { 188 for (let {producer, consumer, expectedEvents, caught} of cases) {
132 Debug.setListener(listener); 189 Debug.setListener(listener);
133 if (caught) { 190 if (caught) {
(...skipping 11 matching lines...) Expand all
145 Debug.clearBreakOnException(); 202 Debug.clearBreakOnException();
146 } else { 203 } else {
147 Debug.clearBreakOnUncaughtException(); 204 Debug.clearBreakOnUncaughtException();
148 } 205 }
149 if (expectedEvents != events) { 206 if (expectedEvents != events) {
150 print(`producer ${producer} consumer ${consumer} expectedEvents ` + 207 print(`producer ${producer} consumer ${consumer} expectedEvents ` +
151 `${expectedEvents} caught ${caught} events ${events}`); 208 `${expectedEvents} caught ${caught} events ${events}`);
152 quit(1); 209 quit(1);
153 } 210 }
154 } 211 }
OLDNEW
« src/js/promise.js ('K') | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698