Index: test/mjsunit/harmony/debug-async-break-on-stack.js |
diff --git a/test/mjsunit/harmony/async-arrow-lexical-super.js b/test/mjsunit/harmony/debug-async-break-on-stack.js |
similarity index 50% |
copy from test/mjsunit/harmony/async-arrow-lexical-super.js |
copy to test/mjsunit/harmony/debug-async-break-on-stack.js |
index 78f5d555b607d2dc3ad5e9245330b775f5d9b006..d3d9d8bef63809fb880f98f478613b0f40c22b20 100644 |
--- a/test/mjsunit/harmony/async-arrow-lexical-super.js |
+++ b/test/mjsunit/harmony/debug-async-break-on-stack.js |
@@ -2,8 +2,11 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+// Flags: --expose-debug-as debug |
// Flags: --harmony-async-await --allow-natives-syntax |
+var Debug = debug.Debug; |
+ |
function assertEqualsAsync(expected, run, msg) { |
var actual; |
var hadValue = false; |
@@ -13,7 +16,7 @@ function assertEqualsAsync(expected, run, msg) { |
if (typeof promise !== "object" || typeof promise.then !== "function") { |
throw new MjsUnitAssertionError( |
"Expected " + run.toString() + |
- " to return a Promise, but it returned " + PrettyPrint(promise)); |
+ " to return a Promise, but it returned " + promise); |
} |
promise.then(function(value) { hadValue = true; actual = value; }, |
@@ -29,30 +32,47 @@ function assertEqualsAsync(expected, run, msg) { |
hadValue, "Expected '" + run.toString() + "' to produce a value"); |
assertEquals(expected, actual, msg); |
-}; |
+} |
-class BaseClass { |
- constructor(x) { |
- this.name_ = x; |
- } |
- get name() { return this.name_; } |
-}; |
+var break_count = 0; |
+var exception = null; |
-class DeferredSuperCall extends BaseClass { |
- constructor(x) { |
- return async() => super(x); |
+function listener(event, exec_state, event_data, data) { |
+ if (event != Debug.DebugEvent.Break) return; |
+ try { |
+ break_count++; |
+ var line = exec_state.frame(0).sourceLineText(); |
+ print(line); |
+ assertTrue(line.indexOf(`B${break_count}`) > 0); |
+ } catch (e) { |
+ exception = e; |
} |
-}; |
+} |
+ |
+ |
+async function g() { |
+ setbreaks(); |
+ throw 1; // B1 |
+} |
+ |
+async function f() { |
+ try { |
+ await g(); |
+ } catch (e) {} |
+ return 2; // B2 |
+} |
+ |
+function setbreaks() { |
+ Debug.setListener(listener); |
+ Debug.setBreakPoint(g, 2); |
+ Debug.setBreakPoint(f, 4); |
+} |
-assertEqualsAsync( |
- "LexicalSuperCall", |
- () => new DeferredSuperCall("LexicalSuperCall")().then(x => x.name)); |
+f(); |
+%RunMicrotasks(); |
-class DeferredSuperProperty extends BaseClass { |
- deferredName() { return async() => super.name; } |
-}; |
+assertEqualsAsync(2, async () => break_count); |
+assertEqualsAsync(null, async () => exception); |
-assertEqualsAsync( |
- "LexicalSuperProperty", |
- () => new DeferredSuperProperty("LexicalSuperProperty").deferredName()()); |
+Debug.setListener(null); |