Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/reject/capability-invocation.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: Invocation of "reject" capability
5 esid: sec-promise.reject
6 es6id: 25.4.4.4
7 info: |
8 1. Let C be the this value.
9 [...]
10 3. Let promiseCapability be ? NewPromiseCapability(C).
11 4. Perform ? Call(promiseCapability.[[Reject]], undefined, « r »).
12 [...]
13
14 25.4.1.5 NewPromiseCapability
15 [...]
16 6. Let promise be Construct(C, «executor»).
17 7. ReturnIfAbrupt(promise).
18 ---*/
19
20 var expectedThis = (function() {
21 return this;
22 })();
23 var resolveCount = 0;
24 var thisValue, args;
25 var P = function(executor) {
26 return new Promise(function() {
27 executor(
28 function() {
29 resolveCount += 1;
30 },
31 function() {
32 thisValue = this;
33 args = arguments;
34 }
35 );
36 });
37 };
38
39 Promise.reject.call(P, 24601);
40
41 assert.sameValue(resolveCount, 0);
42
43 assert.sameValue(thisValue, expectedThis);
44 assert.sameValue(typeof args, 'object');
45 assert.sameValue(args.length, 1);
46 assert.sameValue(args[0], 24601);