blob: 4973229b40496fc8973c98846d3ea0a0e65362e9 [file] [log] [blame]
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
class DerivedPromise extends Promise {
constructor(executor) {
super(executor);
}
then(onFulfilled, onRejected) {
return super.then(onFulfilled, onRejected);
}
}
var array = [];
for (var i = 0; i < 1e4; ++i) {
let value = i;
array.push(new DerivedPromise(function (resolve) { resolve(DerivedPromise.resolve(value)); }));
}
drainMicrotasks();
for (var i = 0; i < 1e4; ++i) {
let expected = i;
array[i].then(function (value) {
shouldBe(value, expected);
array[expected] = true;
});
}
drainMicrotasks();
for (var i = 0; i < 1e4; ++i)
shouldBe(array[i], true);