harness: Simplify verifyCallableProperty (#4507)

Ref #4468
This commit is contained in:
Richard Gibson 2025-05-28 16:53:15 -04:00 committed by GitHub
parent e764feb1fe
commit 99867ff618
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 22 deletions

View File

@ -209,11 +209,15 @@ function isWritable(obj, name, verifyProp, value) {
}
/**
* Verify that there is a function of specified name, length, and containing
* descriptor associated with `obj[name]` and following the conventions for
* built-in objects.
*
* @param {object} obj
* @param {string|symbol} name
* @param {string} [functionName] defaults to name for strings, `[${name.description}]` for symbols
* @param {number} functionLength
* @param {PropertyDescriptor} desc
* @param {PropertyDescriptor} [desc] defaults to data property conventions (writable, non-enumerable, configurable)
* @param {object} [options]
* @param {boolean} [options.restore] revert mutations from verifying writable/configurable
*/
@ -223,7 +227,21 @@ function verifyCallableProperty(obj, name, functionName, functionLength, desc, o
assert.sameValue(typeof value, "function",
"obj['" + String(name) + "'] descriptor should be a function");
if (!__hasOwnProperty(desc, "value")) desc.value = value;
// Every other data property described in clauses 19 through 28 and in
// Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
// [[Configurable]]: true } unless otherwise specified.
// https://tc39.es/ecma262/multipage/ecmascript-standard-built-in-objects.html
if (desc === undefined) {
desc = {
writable: true,
enumerable: false,
configurable: true,
value: value
};
} else if (!__hasOwnProperty(desc, "value") && !__hasOwnProperty(desc, "get")) {
desc.value = value;
}
verifyProperty(obj, name, desc, options);
if (functionName === undefined) {

View File

@ -8,8 +8,4 @@ description: >
includes: [propertyHelper.js]
---*/
verifyPrimordialCallableProperty(this, "isFinite", "isFinite", 1, {
writable: true,
enumerable: false,
configurable: true
});
verifyPrimordialCallableProperty(this, "isFinite", "isFinite", 1);

View File

@ -8,8 +8,4 @@ description: >
includes: [propertyHelper.js]
---*/
verifyPrimordialCallableProperty(this, "isNaN", "isNaN", 1, {
writable: true,
enumerable: false,
configurable: true
});
verifyPrimordialCallableProperty(this, "isNaN", "isNaN", 1);

View File

@ -12,8 +12,4 @@ info: |
includes: [propertyHelper.js]
---*/
verifyPrimordialCallableProperty(this, "parseFloat", "parseFloat", 1, {
writable: true,
enumerable: false,
configurable: true
});
verifyPrimordialCallableProperty(this, "parseFloat", "parseFloat", 1);

View File

@ -11,8 +11,4 @@ info: |
includes: [propertyHelper.js]
---*/
verifyPrimordialCallableProperty(this, "parseInt", "parseInt", 2, {
writable: true,
enumerable: false,
configurable: true
});
verifyPrimordialCallableProperty(this, "parseInt", "parseInt", 2);