Implement other routines of Promise (#1729)

Add Promise.resolve, Promise.reject, Promise.race, Promise.all and
Promise.prototype.catch

Also it fixes the issue 1763

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
This commit is contained in:
Zidong Jiang
2017-04-26 19:47:51 +08:00
committed by GitHub
parent 9d4123c3c4
commit 078f6e101d
20 changed files with 1044 additions and 138 deletions
@@ -13,14 +13,37 @@
* limitations under the License.
*/
var a = new Promise(function(f, r){
f("a");
var a = Promise.resolve('a');
var b = Promise.reject('b');
Promise.race([a, b]).then(function(x)
{
assert (x === 'a');
}, function(x)
{
assert (false); // should not run here.
});
var b = new Promise(function(f, r){
f(a);
})
Promise.race([b, a]).then(function(x)
{
assert (false); // should not run here.
}, function(x)
{
assert (x === 'b');
});
b.then(function(x) {
assert (x === "a");
})
Promise.race([ ,b, a]).then(function(x)
{
assert (x === undefined);
}, function(x)
{
assert (false); // should not run here.
});
Promise.race(a).then(function(x)
{
assert (false); // should not run here.
}, function(x)
{
assert(x.name === "TypeError");
});