- From: Takeshi Yoshino <notifications@github.com>
- Date: Thu, 05 Feb 2015 20:51:59 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Message-ID: <whatwg/streams/pull/272/r24222598@github.com>
> + }
> + });
> +
> + t.equal(rs.state, 'waiting', 'stream starts out waiting');
> +
> + rs.ready.then(() => {
> + t.equal(rs.state, 'readable', 'stream becomes readable (even before promise fulfills)');
> + t.equal(timesCalled, 1, 'pull is not yet called a second time');
> + t.equal(rs.read(), 1, 'read() returns enqueued value');
> +
> + setTimeout(() => {
> + t.equal(timesCalled, 1, 'after 30 ms, pull has still only been called once');
> +
> + resolve();
> +
> + returnedPromise.then(() => {
Yes, it works. But we don't have to use `returnedPromise`. As we're fulfilling `returnedPromise` on L315, we're sure that `returnedPromise` is fulfilled at L317. So, L317 is just putting the closure into the microtask queue. We can also use Promise.resolve(undefined).then(...) there.
Here what we want to test is
> `pull()` will be called once the returnedPromise is resolved.
`Once ...` corresponds to L315. Yes, it's relevant to `returnedPromise`.
`pull() ...` is what we want to verify on L317. This is irrelevant to `returnedPromise`.
Use of `returnedPromise` at L317 (though it works) makes the verification step look depending on `returnedPromise`. So, it looked misleading to me.
---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/272/files#r24222598
Received on Friday, 6 February 2015 04:52:27 UTC