Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/resolve/S25.4.4.5_A2.3_T1.js

raw
1 // Copyright 2014 Cubane Canada, Inc. All rights reserved.
2 // See LICENSE for details.
3
4 /*---
5 es6id: S25.4.4.5_A2.3_T1
6 author: Sam Mikes
7 description: Promise.resolve passes through an unsettled promise w/ same Constructor
8 flags: [async]
9 ---*/
10
11 var rejectP1,
12 p1 = new Promise(function(resolve, reject) {
13 rejectP1 = reject;
14 }),
15 p2 = Promise.resolve(p1),
16 obj = {};
17
18 if (p1 !== p2) {
19 $ERROR("Expected p1 === Promise.resolve(p1) because they have same constructor");
20 }
21
22 p2.then(function() {
23 $ERROR("Expected p2 to be rejected, not fulfilled.");
24 }, function(arg) {
25 if (arg !== obj) {
26 $ERROR("Expected promise to be rejected with reason obj, actually " + arg);
27 }
28 }).then($DONE, $DONE);
29
30 rejectP1(obj);