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

Side by Side Diff: test/mjsunit/harmony/async-function-stacktrace.js

Issue 1997453004: Revert of [test] add tests for async function stacktraces (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-async-await
6
7 async function test(func, funcs) {
8 try {
9 await func();
10 throw new Error("Expected " + func.toString() + " to throw");
11 } catch (e) {
12 var stack = e.stack.split('\n').
13 slice(1).
14 map(line => line.trim()).
15 map(line => line.match(/at (?:(.*) )?.*$/)[1]).
16 filter(x => typeof x === 'string' && x.length);
17
18 assertEquals(funcs, stack, `Unexpected stack trace ${e.stack}`);
19 }
20 }
21
22 function thrower() { throw new Error("NOPE"); }
23 function reject() { return Promise.reject(new Error("NOPE")); }
24
25 async function runTests() {
26 await test(async function a() {
27 throw new Error("FAIL");
28 },
29 ["a", "test", "runTests"]);
30
31 await test(async function a2() {
32 await 1;
33 throw new Error("FAIL");
34 }, ["a2"]);
35
36 await test(async function a3() {
37 await 1;
38 try { await thrower(); } catch (e) { throw new Error("FAIL"); }
39 }, ["a3"]);
40
41 await test(async function a4() {
42 await 1;
43 try { await reject(); } catch (e) { throw new Error("FAIL"); }
44 }, ["a4"]);
45
46 await test({ async b() {
47 throw new Error("FAIL");
48 }}.b,
49 ["b", "test", "runTests"]);
50
51 await test({ async b2() {
52 await 1;
53 throw new Error("FAIL");
54 }}.b2, ["b2"]);
55
56 await test({ async b3() {
57 await 1;
58 try { await thrower(); } catch (e) { throw new Error("FAIL"); }
59 } }.b3, ["b3"]);
60
61 await test({ async b4() {
62 await 1;
63 try { await reject(); } catch (e) { throw new Error("FAIL"); }
64 } }.b4, ["b4"]);
65
66 await test((new class { async c() {
67 throw new Error("FAIL");
68 } }).c,
69 ["c", "test", "runTests"]);
70
71 await test((new class { async c2() {
72 await 1;
73 throw new Error("FAIL");
74 } }).c2, ["c2"]);
75
76 await test((new class { async c3() {
77 await 1;
78 try { await thrower(); } catch (e) { throw new Error("FAIL"); }
79 } }).c3, ["c3"]);
80
81 await test((new class { async c4() {
82 await 1;
83 try { await reject(); } catch (e) { throw new Error("FAIL"); }
84 } }).c4, ["c4"]);
85
86 // TODO(caitp): `async` probably shouldn't be the inferred name for async
87 // arrow functions...
88 await test(async() => { throw new Error("FAIL") },
89 ["async", "test", "runTests"]);
90
91 await test(async() => { await 1; throw new Error("FAIL") }, ["async"]);
92
93 await test(async() => {
94 await 1;
95 try {
96 await thrower();
97 } catch (e) {
98 throw new Error("FAIL");
99 }
100 }, ["e"]); // TODO(caitp): FuncNameInferer is doing some weird stuff...
101
102 await test(async() => {
103 await 1;
104 try {
105 await reject();
106 } catch (e) {
107 throw new Error("FAIL");
108 }
109 }, ["e"]);
110 }
111
112 runTests().catch(e => {
113 print(e);
114 quit(1);
115 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698