Skip to content
Snippets Groups Projects
Commit 7c5b5bf7 authored by Jordan Harband's avatar Jordan Harband Committed by Rick Waldron
Browse files
parent 8b71c5fe
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Sathya Gunasekaran
description: finally calls the SpeciesConstructor
description: finally calls the SpeciesConstructor and creates the right amount of promises
esid: sec-promise.prototype.finally
features: [Promise.prototype.finally]
flags: [async]
......@@ -22,4 +22,4 @@ new FooPromise(r => r())
.then(() => {
assert.sameValue(count, 6, "6 new promises were created");
$DONE();
});
}, $ERROR);
// Copyright (C) 2018 Jordan Harband. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Jordan Harband
description: Promise subclass finally on rejected creates the proper number of subclassed promises
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);
}
}
FooPromise.reject().finally(() => {}).then($ERROR).catch(() => {
assert.sameValue(7, count);
$DONE();
});
// Copyright (C) 2018 Jordan Harband. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Jordan Harband
description: Promise subclass finally on resolved creates the proper number of subclassed promises
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);
}
}
FooPromise.resolve().finally(() => {}).then(() => {
assert.sameValue(6, count);
$DONE();
}, $ERROR);
// Copyright (C) 2018 Jordan Harband. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Jordan Harband
description: finally on rejected Promise calls the SpeciesConstructor
esid: sec-promise.prototype.finally
features: [Promise.prototype.finally]
---*/
class FooPromise extends Promise {
static get [Symbol.species]() { return Promise; }
}
var p = Promise.reject().finally(() => FooPromise.reject());
assert.sameValue(p instanceof Promise, true);
assert.sameValue(p instanceof FooPromise, false);
// Copyright (C) 2018 Jordan Harband. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Jordan Harband
description: finally on resolved Promise calls the SpeciesConstructor
esid: sec-promise.prototype.finally
features: [Promise.prototype.finally]
flags: [async]
---*/
class FooPromise extends Promise {
static get [Symbol.species]() { return Promise; }
}
var p = Promise.resolve().finally(() => FooPromise.resolve());
assert.sameValue(p instanceof Promise, true);
assert.sameValue(p instanceof FooPromise, false);
// Copyright (C) 2018 Jordan Harband. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Jordan Harband
description: >
Promise.prototype.finally called with a non-branded Promise does not throw
esid: sec-promise.prototype.finally
features: [Promise.prototype.finally]
---*/
var called = false;
var p = new Proxy(Promise.resolve(), {});
var oldThen = Promise.prototype.then;
Promise.prototype.then = () => { called = true; };
Promise.prototype.finally.call(p);
assert.sameValue(called, true);
Promise.prototype.then = oldThen;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment