Closed hax closed 8 years ago
Don't worry about the Symbol
, the comparison graph is based on Node v5.0+, and will always use the lastest version of Node.
The readme is updated. You lib passed all tests. Thanks for your report.
Test case "subclass PromiseCapability promise.then TypeError" is still incorrect. It should not throw error. To throw error you need to specify Symbol.species
for fake constructor 😈
But, I read the https://tc39.github.io/ecma262/#sec-newpromisecapability
If IsCallable(promiseCapability.[[Resolve]]) is false, throw a TypeError exception.
The newly created promiseCapability
should have a resolve
handler.
The test case call promise.then(function () {})
with promise.constructor = function () {}
.
See 25.4.5.3 Promise.prototype.then
3 . Let C be ? SpeciesConstructor(promise, %Promise%).
Step 3 passes promise
with %Promise%
(the original Promise constructor) as defaultConstructor
- Assert: Type(O) is Object.
- Let C be ? Get(O, "constructor").
- If C is undefined, return defaultConstructor.
- If Type(C) is not Object, throw a TypeError exception.
- Let S be ? Get(C,
@@species
).- If S is either undefined or null, return defaultConstructor.
- If IsConstructor(S) is true, return S.
- Throw a TypeError exception.
Step 2: C = function () {}
Step 5: S = undefined
Step 6: return %Promise%
Then NewPromiseCapability
is called with original Promise constructor.
You are right, I added a global Symbol.species
to make the test possible: https://github.com/ysmood/yaku/commit/ccd5a01646641625d53abac2950ea26c2c190c22#diff-e2686e2925145c11799d638b2f4706dcR8
But I don't know why my-promise
still has 1 failure:
$ npm run no -- test-basic -s my-promise
junit cli > x basic - subclass (21ms)
<<<<<<< actual
[ 'subclass',
undefined,
'subclass',
undefined,
'subclass',
true,
true,
5,
6 ]
=======
[ 'subclass',
'subclass',
'subclass',
'subclass',
'subclass',
true,
true,
5,
6 ]
>>>>>>> expected
Error: Assertion
I will check it later.
See my comments in https://github.com/ysmood/yaku/commit/0383fa02e711eec363b85c299a45004986ecb249