2020-04-30 13:09:58 +00:00
|
|
|
// Copyright 2020 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 --harmony-promise-any
|
|
|
|
|
|
|
|
load('test/mjsunit/test-async.js');
|
|
|
|
|
|
|
|
// Promise.any should call IteratorClose if Promise.resolve is not callable.
|
|
|
|
|
2020-06-05 12:51:25 +00:00
|
|
|
let getIteratorCount = 0;
|
2020-04-30 13:09:58 +00:00
|
|
|
let iter = {
|
2020-06-05 12:51:25 +00:00
|
|
|
get [Symbol.iterator]() {
|
|
|
|
++getIteratorCount;
|
2020-04-30 13:09:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Promise.resolve = "certainly not callable";
|
|
|
|
|
|
|
|
testAsync(assert => {
|
|
|
|
assert.plan(2);
|
|
|
|
Promise.any(iter).then(assert.unreachable, reason => {
|
|
|
|
assert.equals(true, reason instanceof TypeError);
|
2020-06-05 12:51:25 +00:00
|
|
|
assert.equals(0, getIteratorCount);
|
2020-04-30 13:09:58 +00:00
|
|
|
});
|
|
|
|
});
|