summaryrefslogtreecommitdiff
path: root/test/built-ins/Promise/reject/S25.4.4.4_A2.1_T1.js
blob: 0b189e52ae32d4caa29666ba5008c25c0fca9e26 (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
25
26
27
28
29
30
31
// Copyright 2014 Cubane Canada, Inc.  All rights reserved.
// See LICENSE for details.

/*---
info: >
    [...]
    5. Let rejectResult be Call(promiseCapability.[[Reject]], undefined, «r»).
    [...]

    25.4.1.3.1 Promise Reject Functions
    [...]
    6. Return RejectPromise(promise, reason).
es6id: 25.4.4.4
author: Sam Mikes
description: Promise.reject creates a new settled promise
flags: [async]
---*/

var p = Promise.reject(3);

if (!(p instanceof Promise)) {
    $ERROR("Expected Promise.reject to return a promise.");
}

p.then(function () {
    $ERROR("Promise should not be fulfilled.");
}, function (arg) {
    if (arg !== 3) {
        $ERROR("Expected promise to be rejected with supplied arg, got " + arg);
    }
}).then($DONE, $DONE);