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:
@@ -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");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user