reject-element-function-nonconstructor.js (1024B)
1 // Copyright (C) 2019 Leo Balter, 2020 Rick Waldron. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-promise.any-reject-element-functions 6 description: Promise.any Reject Element functions are not constructors 7 info: | 8 17 ECMAScript Standard Built-in Objects: 9 Built-in function objects that are not identified as constructors do not 10 implement the [[Construct]] internal method unless otherwise specified 11 in the description of a particular function. 12 features: [Promise.any] 13 ---*/ 14 15 var rejectElementFunction; 16 var thenable = { 17 then(_, reject) { 18 rejectElementFunction = reject; 19 } 20 }; 21 22 function NotPromise(executor) { 23 executor(function() {}, function() {}); 24 } 25 NotPromise.resolve = function(v) { 26 return v; 27 }; 28 Promise.any.call(NotPromise, [thenable]); 29 30 assert.sameValue(Object.prototype.hasOwnProperty.call(rejectElementFunction, 'prototype'), false); 31 assert.throws(TypeError, function() { 32 new rejectElementFunction(); 33 }); 34 35 reportCompare(0, 0);