Debian Codegraph @

js/src/tests/test262/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 info: |
7 1. Let C be the this value.
8 [...]
9 3. Let promiseCapability be ? NewPromiseCapability(C).
10 4. Perform ? Call(promiseCapability.[[Reject]], undefined, « r »).
11 [...]
12
13 25.4.1.5 NewPromiseCapability
14 [...]
15 6. Let promise be Construct(C, «executor»).
16 7. ReturnIfAbrupt(promise).
17 ---*/
18
19 var expectedThis = (function() {
20 return this;
21 })();
22 var resolveCount = 0;
23 var thisValue, args;
24 var P = function(executor) {
25 return new Promise(function() {
26 executor(
27 function() {
28 resolveCount += 1;
29 },
30 function() {
31 thisValue = this;
32 args = arguments;
33 }
34 );
35 });
36 };
37
38 Promise.reject.call(P, 24601);
39
40 assert.sameValue(resolveCount, 0);
41
42 assert.sameValue(thisValue, expectedThis);
43 assert.sameValue(typeof args, 'object');
44 assert.sameValue(args.length, 1);
45 assert.sameValue(args[0], 24601);
46
47 reportCompare(0, 0);