Debian Codegraph @

js/src/tests/test262/built-ins/Promise/any/reject-element-function-property-order.js

raw
1 // Copyright (C) 2020 ExE Boss. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-createbuiltinfunction
5 description: Promise.any resolve element function property order
6 info: |
7 Set order: "length", "name"
8 features: [Promise.any]
9 ---*/
10
11 var rejectElementFunction;
12 var thenable = {
13 then: function(_, reject) {
14 rejectElementFunction = reject;
15 }
16 };
17
18 function NotPromise(executor) {
19 executor(function() {}, function() {});
20 }
21 NotPromise.resolve = function(v) {
22 return v;
23 };
24 Promise.any.call(NotPromise, [thenable]);
25
26 var propNames = Object.getOwnPropertyNames(rejectElementFunction);
27 var lengthIndex = propNames.indexOf("length");
28 var nameIndex = propNames.indexOf("name");
29
30 assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
31 "The `length` property comes before the `name` property on built-in functions");
32
33 reportCompare(0, 0);