summaryrefslogtreecommitdiff
path: root/test/built-ins/Promise/prototype/catch/S25.4.5.1_A3.1_T1.js
blob: a13171c31427e1eb959d5e643c1d61205ff0b8eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2014 Cubane Canada, Inc.  All rights reserved.
// See LICENSE for details.

/*---
info: |
    catch(arg) is equivalent to then(undefined, arg)
es6id: S25.4.5.1_A3.1_T1
author: Sam Mikes
description: catch is implemented in terms of then
flags: [async]
---*/

var obj = {};

var p = Promise.resolve(obj);

p.catch(function () {
    $ERROR("Should not be called - promise is fulfilled");
}).then(function (arg) {
    if (arg !== obj) {
        $ERROR("Expected promise to be fulfilled with obj, got " + arg);
    }
}).then($DONE, $DONE);