Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise.prototype.finally #866

Closed
1 task
leobalter opened this issue Feb 15, 2017 · 5 comments
Closed
1 task

Promise.prototype.finally #866

leobalter opened this issue Feb 15, 2017 · 5 comments

Comments

@leobalter
Copy link
Member

leobalter commented Feb 15, 2017

@ljharb I guess you already have some tests for this method, right? We want to make a plan to bring these tests as soon as you get the proposal to stage 3.


@ljharb
Copy link
Member

ljharb commented Feb 15, 2017

My intention is to write the PR as soon as I reach stage 3, since it's a stage 4 requirement. However, I won't be seeking that until May or July at a minimum, so there's plenty of time.

@gsathya
Copy link
Member

gsathya commented Feb 25, 2017

There's a bunch of tests in V8 for this FYI

@gsathya
Copy link
Member

gsathya commented Sep 11, 2017

Some more tests if someone wants to write up a PR --

var count = 0;
class FooPromise extends Promise {
  constructor(resolve, reject) {
    count++;
    return super(resolve, reject);
  }
}

testAsync(assert => {
  assert.plan(1);
  count = 0;

  new FooPromise(r => r()).finally(() => {}).then(() => {
    assert.equals(6, count);
  });
}, "finally/speciesconstructor");

testAsync(assert => {
  assert.plan(1);
  count = 0;

  FooPromise.resolve().finally(() => {}).then(() => {
    assert.equals(6, count);
  })
}, "resolve/finally/speciesconstructor");

testAsync(assert => {
  assert.plan(1);
  count = 0;

  FooPromise.reject().finally(() => {}).catch(() => {
    assert.equals(6, count);
  })
}, "reject/finally/speciesconstructor");

testAsync(assert => {
  assert.plan(2);

  class MyPromise extends Promise {
    static get [Symbol.species]() { return Promise; }
  }

  var p = Promise
      .resolve()
      .finally(() => MyPromise.resolve());

  assert.equals(true, p instanceof Promise);
  assert.equals(false, p instanceof MyPromise);
}, "finally/Symbol.Species");

@gsathya
Copy link
Member

gsathya commented Jan 24, 2018

Another test for tc39/proposal-promise-finally@a162888 that's missing:


(function testIsObject() {
  var called = false;
  var p = new Proxy(Promise.resolve(), {});
  var oldThen = Promise.prototype.then;
  Promise.prototype.then = () => called = true;
  Promise.prototype.finally.call(p);
  assertTrue(called);
  Promise.prototype.then = oldThen;
})();

@ljharb
Copy link
Member

ljharb commented Jan 25, 2018

test262 doesn't seem to have a testAsync helper of any kind.

ljharb added a commit to ljharb/test262 that referenced this issue Jan 25, 2018
ljharb added a commit to ljharb/test262 that referenced this issue Jan 25, 2018
ljharb added a commit to ljharb/test262 that referenced this issue Jan 25, 2018
ljharb added a commit to ljharb/test262 that referenced this issue Jan 25, 2018
ljharb added a commit to ljharb/test262 that referenced this issue Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants