aboutsummaryrefslogtreecommitdiff
path: root/test/js/promise_s27.t.js
blob: 7a5ac583b5b3b14cb8c8f1a9286011a4fe2604c0 (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
32
33
34
/*---
includes: []
flags: [async]
---*/

var inherits = (child, parent) => {
    child.prototype = Object.create(parent.prototype, {
        constructor: {
        value: child,
        enumerable: false,
        writable: true,
        configurable: true
        }
    });
    Object.setPrototypeOf(child, parent);
};

function BoxedPromise(executor) {
    var context, args;
    new Promise(wrappedExecutor);
    executor.apply(context, args);

    function wrappedExecutor(resolve, reject) {
        context = this;
        args = [v => resolve(v),v => reject(v)];
    }
}

inherits(BoxedPromise, Promise);

Promise.resolve()
.then(() => BoxedPromise.resolve())
.catch(e => assert.sameValue(e.constructor, TypeError))
.then($DONE, $DONE);