summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/harmony/async-iterators-resolve.js
blob: 182c5b7e204e4a2ed1da0f78de61dcb9399d4fe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --allow-natives-syntax

let actual = [];

async function f() {
  var p = Promise.resolve(0);
  Object.defineProperty(p, "constructor", {
    get() {
      throw new Error();
    }
  });
  actual.push("start");
  for await (var x of [p]);
  actual.push("never reached");
}

Promise.resolve(0)
  .then(() => actual.push("tick 1"))
  .then(() => actual.push("tick 2"))

f().catch(() => actual.push("catch"));

%PerformMicrotaskCheckpoint();

assertSame(["start", "tick 1", "tick 2", "catch"].join(), actual.join());