Adapters are not called with promises, are they?
Opened this issue · 4 comments
The adapters section of the readme says:
Note that the tests will never pass a promise or a thenable as a resolution. That means that we never use the promise- or thenable-accepting forms of the resolve operation directly, and instead only use the direct fulfillment operation, since fulfill and resolve are equivalent when not given a thenable.
I'm not sure whether this is wrong, outdated or uses outdated terminology after #39 ?
The implementation that I'm currently testing does not (yet?) have a Promise
constructor with a resolve
callback, it only offers a fulfill
callback which accepts any value and does not [[resolve]]
its arguments recursively (yes, I'm allowing algebraic nesting of promises). I also did pass the monadic Promise.of
for adapter.resolve
.
However, this has bitten me heavily, and it took me some time to figure out that deferred.resolve
is indeed called a few times with one of my Promise
s. Is this a bug in the test cases? An error in the documentation? Or did I just misunderstand that sentence?
It sounds like a bug in the test cases, hmm. What tests in particular trigger this?
Note that we do pass promises to deferred.reject
.
What tests in particular trigger this?
The 2.3.3 testcase for
2.3.3.3: If `then` is a function, call it with `x` as `this`, first argument `resolvePromise`, and second argument `rejectPromise`
2.3.3.3.1: If/when `resolvePromise` is called with value `y`, run `[[Resolve]](promise, y)`
`y` is a thenable for a thenable
[…]
with its various y is a promise for …
combinations. From my counts, a complete run will call both adapter.resolved
and deferred.resolve
56 times each.
Note that we do pass promises to deferred.reject
That's OK, the spec expects nesting behaviour for that anyway :-)
+1 on this. I'm facing the same problem.
Promises/A+ Tests
2.3.3: Otherwise, if `x` is an object or function,
2.3.3.3: If `then` is a function, call it with `x` as `this`, first argument `resolvePromise`, and second argument `rejectPromise`
2.3.3.3.1: If/when `resolvePromise` is called with value `y`, run `[[Resolve]](promise, y)`
`y` is a thenable for a thenable
`y` is an asynchronously-fulfilled custom thenable for a thenable that fulfills but then throws
`then` calls `resolvePromise` synchronously
via return from a fulfilled promise
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
at onPromiseFulfilled (promiseTest.js:2871:13)
...
https://saucelabs.com/jobs/7065f290c8aa403fb50c0f677d98b9e9
I meet the same problem on android 4.4 default browser. but other browsers all pass.