Promise.p.finally: test SpeciesConstructor and Symbol.species lookup

This commit is contained in:
Sathya Gunasekaran 2017-10-28 14:01:13 -07:00
parent f8456c6dac
commit a392f6ced8
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// Copyright (C) 2017 V8. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Sathya Gunasekaran
description: finally calls the SpeciesConstructor
esid: sec-promise.prototype.finally
features: [Promise.prototype.finally]
flags: [async]
---*/
var count = 0;
class FooPromise extends Promise {
constructor(resolve, reject) {
count++;
return super(resolve, reject);
}
}
new FooPromise(r => r())
.finally(() => {})
.then(() => {
assert.sameValue(count, 6, "6 new promises were created");
$DONE();
});

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 V8. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Sathya Gunasekaran
description: finally calls the SpeciesConstructor
esid: sec-promise.prototype.finally
features: [Promise.prototype.finally]
---*/
class MyPromise extends Promise {
static get [Symbol.species]() { return Promise; }
}
var p = Promise
.resolve()
.finally(() => MyPromise.resolve());
assert.sameValue(true, p instanceof Promise);
assert.sameValue(false, p instanceof MyPromise);