Skip to content

Commit bdc0f92

Browse files
committed
harness: Simplify verifyCallableProperty
Ref tc39#4468 Match the data property defaults from https://tc39.es/ecma262/multipage/ecmascript-standard-built-in-objects.html (writable true, enumerable false, configurable true).
1 parent 081cbfc commit bdc0f92

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

harness/propertyHelper.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function isWritable(obj, name, verifyProp, value) {
213213
* @param {string|symbol} name
214214
* @param {string} [functionName] defaults to name for strings, `[${name.description}]` for symbols
215215
* @param {number} functionLength
216-
* @param {PropertyDescriptor} desc
216+
* @param {PropertyDescriptor} [desc]
217217
* @param {object} [options]
218218
* @param {boolean} [options.restore] revert mutations from verifying writable/configurable
219219
*/
@@ -223,7 +223,21 @@ function verifyCallableProperty(obj, name, functionName, functionLength, desc, o
223223
assert.sameValue(typeof value, "function",
224224
"obj['" + String(name) + "'] descriptor should be a function");
225225

226-
if (!__hasOwnProperty(desc, "value")) desc.value = value;
226+
// Every other data property described in clauses 19 through 28 and in
227+
// Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
228+
// [[Configurable]]: true } unless otherwise specified.
229+
// https://tc39.es/ecma262/multipage/ecmascript-standard-built-in-objects.html
230+
if (desc === undefined) {
231+
desc = {
232+
writable: true,
233+
enumerable: false,
234+
configurable: true,
235+
value: value
236+
};
237+
} else if (!__hasOwnProperty(desc, "value") && !__hasOwnProperty(desc, "get")) {
238+
desc.value = value;
239+
}
240+
227241
verifyProperty(obj, name, desc, options);
228242

229243
if (functionName === undefined) {

test/built-ins/isFinite/prop-desc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@ description: >
88
includes: [propertyHelper.js]
99
---*/
1010

11-
verifyPrimordialCallableProperty(this, "isFinite", "isFinite", 1, {
12-
writable: true,
13-
enumerable: false,
14-
configurable: true
15-
});
11+
verifyPrimordialCallableProperty(this, "isFinite", "isFinite", 1);

test/built-ins/isNaN/prop-desc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@ description: >
88
includes: [propertyHelper.js]
99
---*/
1010

11-
verifyPrimordialCallableProperty(this, "isNaN", "isNaN", 1, {
12-
writable: true,
13-
enumerable: false,
14-
configurable: true
15-
});
11+
verifyPrimordialCallableProperty(this, "isNaN", "isNaN", 1);

test/built-ins/parseFloat/prop-desc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,4 @@ info: |
1212
includes: [propertyHelper.js]
1313
---*/
1414

15-
verifyPrimordialCallableProperty(this, "parseFloat", "parseFloat", 1, {
16-
writable: true,
17-
enumerable: false,
18-
configurable: true
19-
});
15+
verifyPrimordialCallableProperty(this, "parseFloat", "parseFloat", 1);

test/built-ins/parseInt/prop-desc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@ info: |
1111
includes: [propertyHelper.js]
1212
---*/
1313

14-
verifyPrimordialCallableProperty(this, "parseInt", "parseInt", 2, {
15-
writable: true,
16-
enumerable: false,
17-
configurable: true
18-
});
14+
verifyPrimordialCallableProperty(this, "parseInt", "parseInt", 2);

0 commit comments

Comments
 (0)