Debian Codegraph @

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

raw
1 // Copyright 2014 Cubane Canada, Inc. All rights reserved.
2 // See LICENSE for details.
3
4 /*---
5 info: |
6 Promise.resolve
7 es6id: S25.4.4.5_A3.1_T1
8 author: Sam Mikes
9 description: Promise.resolve delegates to foreign thenable
10 includes: [promiseHelper.js]
11 flags: [async]
12 ---*/
13
14 var sequence = [];
15
16 var thenable = {
17 then: function(onResolve, onReject) {
18 sequence.push(3);
19 checkSequence(sequence, "thenable.then called");
20
21 assert.sameValue(this, thenable);
22
23 onResolve('resolved');
24
25 sequence.push(4);
26 checkSequence(sequence, "after resolved");
27
28 throw new Error('interrupt flow');
29
30 sequence.push(4);
31 checkSequence(sequence, "duplicate sequence point not pushed");
32 }
33 };
34
35 sequence.push(1);
36 checkSequence(sequence, "no async calls yet");
37
38 var p1 = Promise.resolve(thenable);
39
40 sequence.push(2);
41 checkSequence(sequence, "thenable.then queued but not yet called");
42
43 p1.then(function(q) {
44 sequence.push(5);
45 checkSequence(sequence, "all done");
46
47 assert.sameValue(q, 'resolved');
48
49 }).then($DONE, $DONE);