Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/reject/capability-executor-called-twice.js

raw
1 // Copyright (C) 2015 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 es6id: 25.4.4.4
6 description: >
7 Throws a TypeError if capabilities executor already called with non-undefined values.
8 info: |
9 Promise.reject ( r )
10
11 ...
12 3. Let promiseCapability be NewPromiseCapability(C).
13 4. ReturnIfAbrupt(promiseCapability).
14 ...
15
16 25.4.1.5.1 GetCapabilitiesExecutor Functions
17 ...
18 3. If promiseCapability.[[Resolve]] is not undefined, throw a TypeError exception.
19 4. If promiseCapability.[[Reject]] is not undefined, throw a TypeError exception.
20 5. Set promiseCapability.[[Resolve]] to resolve.
21 6. Set promiseCapability.[[Reject]] to reject.
22 ...
23 ---*/
24
25 var checkPoint = "";
26 Promise.reject.call(function(executor) {
27 checkPoint += "a";
28 executor();
29 checkPoint += "b";
30 executor(function() {}, function() {});
31 checkPoint += "c";
32 }, {});
33 assert.sameValue(checkPoint, "abc", "executor initially called with no arguments");
34
35 var checkPoint = "";
36 Promise.reject.call(function(executor) {
37 checkPoint += "a";
38 executor(undefined, undefined);
39 checkPoint += "b";
40 executor(function() {}, function() {});
41 checkPoint += "c";
42 }, {});
43 assert.sameValue(checkPoint, "abc", "executor initially called with (undefined, undefined)");
44
45 var checkPoint = "";
46 assert.throws(TypeError, function() {
47 Promise.reject.call(function(executor) {
48 checkPoint += "a";
49 executor(undefined, function() {});
50 checkPoint += "b";
51 executor(function() {}, function() {});
52 checkPoint += "c";
53 }, {});
54 }, "executor initially called with (undefined, function)");
55 assert.sameValue(checkPoint, "ab", "executor initially called with (undefined, function)");
56
57 var checkPoint = "";
58 assert.throws(TypeError, function() {
59 Promise.reject.call(function(executor) {
60 checkPoint += "a";
61 executor(function() {}, undefined);
62 checkPoint += "b";
63 executor(function() {}, function() {});
64 checkPoint += "c";
65 }, {});
66 }, "executor initially called with (function, undefined)");
67 assert.sameValue(checkPoint, "ab", "executor initially called with (function, undefined)");
68
69 var checkPoint = "";
70 assert.throws(TypeError, function() {
71 Promise.reject.call(function(executor) {
72 checkPoint += "a";
73 executor("invalid value", 123);
74 checkPoint += "b";
75 executor(function() {}, function() {});
76 checkPoint += "c";
77 }, {});
78 }, "executor initially called with (String, Number)");
79 assert.sameValue(checkPoint, "ab", "executor initially called with (String, Number)");