mirror of
https://github.com/nodejs/node.git
synced 2025-05-21 12:25:12 +00:00

PR-URL: https://github.com/nodejs/node/pull/27375 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
34 lines
845 B
JavaScript
34 lines
845 B
JavaScript
// 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
|
|
|
|
const actual = [];
|
|
|
|
function createIterator() {
|
|
return {
|
|
[Symbol.iterator]() { return this; },
|
|
|
|
throw() {
|
|
return { value: Promise.resolve(1), done: true};
|
|
}
|
|
};
|
|
}
|
|
|
|
actual.push("start");
|
|
iter = %CreateAsyncFromSyncIterator(createIterator());
|
|
|
|
Promise.resolve(0)
|
|
.then(() => actual.push("tick 1"))
|
|
.then(() => actual.push("tick 2"))
|
|
.then(() => actual.push("tick 3"))
|
|
.then(() => actual.push("tick 4"))
|
|
.then(() => actual.push("tick 5"));
|
|
|
|
let p = iter.throw();
|
|
p.then(_ => { actual.push("done"); } );
|
|
|
|
%PerformMicrotaskCheckpoint();
|
|
assertSame("start,tick 1,tick 2,done,tick 3,tick 4,tick 5", actual.join(","))
|