<div dir="ltr"><div><div><div>Dear all,<br><br>I'm working on JS Promise implementation: <a href="https://codereview.qt-project.org/#/c/122066/">https://codereview.qt-project.org/#/c/122066/</a><a href="https://codereview.qt-project.org/#/c/122066/">https://codereview.qt-project.org/#/c/122066/</a><br><br></div>I also would like the implementation to pass official <a href="https://github.com/tc39/test262">ECMAScript test suite</a>. Though I faced some difficulty to understand certain test cases.<br><br></div>E.g. notion of "IsCallable" seems to be a bit unclear to me.<br><br>It is stated <a href="https://github.com/tc39/test262/blob/master/test/built-ins/Promise/all/capability-executor-not-callable.js">here:</a><br>"<span class="gmail-pl-c">8. If IsCallable(promiseCapability.[[Resolve]]) is false, throw a TypeError exception.</span>"<br>"<span class="gmail-pl-c">9. If IsCallable(promiseCapability.[[Reject]]) is false, throw a TypeError exception.</span>"<br><br></div><div>Presumably the statement is supposed to be proved by test cases in the file. E.g.<br>var checkPoint = "";<br>assert.throws(TypeError, function() {<br>  Promise.all.call(function(executor) {<br>    checkPoint += "a";<br>    executor(undefined, undefined);<br>    checkPoint += "b";<br>  }, []);<br>}, "executor called with (undefined, undefined)");<br>assert.sameValue(checkPoint, "ab", "executor called with (undefined, undefined)");<br><br></div><div>The conclusion I could make looking at this, both check points should pass and no exception should be raised during "executor(undefined, undefined)" call. <br>But does that mean "IsCallable(undefined) === true"?<br><br></div><div>Which is a bit confusing, sine one could get completely opposite conclusion for example from the test <a href="https://github.com/tc39/test262/blob/da4f4385fdf88ff2c8acf036efaaa62f8cd6bd58/test/built-ins/Set/prototype/forEach/callback-not-callable-undefined.js">here</a>.<br></div><div>To be honest, ECMAScript spec does not seem to be very helpful as well since notion of callable object is a bit vague: <a href="https://www.ecma-international.org/ecma-262/8.0/index.html#sec-iscallable">https://www.ecma-international.org/ecma-262/8.0/index.html#sec-iscallable</a><a href="https://www.ecma-international.org/ecma-262/8.0/index.html#sec-iscallable">https://www.ecma-international.org/ecma-262/8.0/index.html#sec-iscallable</a><br>Also, unfortunately, I could not find clear answer in official tests for "undefined": <a href="https://github.com/tc39/test262/tree/da4f4385fdf88ff2c8acf036efaaa62f8cd6bd58/test/built-ins/undefined">https://github.com/tc39/test262/tree/da4f4385fdf88ff2c8acf036efaaa62f8cd6bd58/test/built-ins/undefined</a> <br><br></div><div>It feels a bit like a contradiction. Thus, I'm a bit puzzled how to go about it. Am I missing something?<br></div><div>I would appreciate some help or hints!<br clear="all"></div><div><div><div><div><div><div class="gmail_signature"><div dir="ltr"><font color="#666666"><br>Sincerely yours,</font><div><font color="#666666">Valery Kotov</font></div></div></div></div>
</div></div></div></div></div>