Skip to content

Add missing tests for 'length' value of Intl.Locale.prototype methods #4515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/intl402/DisplayNames/prototype/of/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.DisplayNames.prototype.of
description: >
Intl.DisplayNames.prototype.of.length is 1.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.DisplayNames]
---*/

verifyProperty(Intl.DisplayNames.prototype.of, "length", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you instead update the other tests to use verifyPrimordialCallableProperty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifyPrimordialCallableProperty doesn't support accessor methods, therefore I've instead used plain verifyProperty throughout this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifyPrimordialCallableProperty doesn't support accessor methods, therefore I've instead used plain verifyProperty throughout this PR.

Yes it does, and I'm specifically planning for uses like test/intl402/Locale/prototype/baseName/descriptor.js:

var desc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "baseName");
var isHardened = Object.isFrozen(Object);
if (isHardened && desc.get) {
  Object.defineProperty(desc, "get", { configurable: false });
}

assert.sameValue(desc.value, undefined);
assert.sameValue(desc.set, undefined);
verifyCallableProperty(desc, "get", "get baseName", 0, { configurable: !isHardened });

verifyPrimordialProperty(Intl.Locale.prototype, "baseName", {
  enumerable: false,
  configurable: true,
});

I'm also open to making even better accommodations, e.g.

var desc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "baseName");

assert.sameValue(desc.value, undefined);
assert.sameValue(desc.set, undefined);
verifyPrimordialCallable(desc.get, "get baseName", 0);

verifyPrimordialProperty(Intl.Locale.prototype, "baseName", {
  enumerable: false,
  configurable: true,
});

value: 1,
enumerable: false,
writable: false,
configurable: true,
});
27 changes: 27 additions & 0 deletions test/intl402/DisplayNames/prototype/of/name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.DisplayNames.prototype.of
description: >
Intl.DisplayNames.prototype.of.name is "of".
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "name" property
whose value is a String. Unless otherwise specified, this value is the name
that is given to the function in this specification.

Unless otherwise specified, the "name" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.DisplayNames]
---*/

verifyProperty(Intl.DisplayNames.prototype.of, "name", {
value: "of",
writable: false,
enumerable: false,
configurable: true,
});
30 changes: 30 additions & 0 deletions test/intl402/Locale/prototype/baseName/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.baseName
description: >
get Intl.Locale.prototype.baseName.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale]
---*/

const getter = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "baseName").get;
verifyProperty(getter, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
30 changes: 30 additions & 0 deletions test/intl402/Locale/prototype/calendar/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.calendar
description: >
get Intl.Locale.prototype.calendar.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale]
---*/

const getter = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "calendar").get;
verifyProperty(getter, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
33 changes: 33 additions & 0 deletions test/intl402/Locale/prototype/caseFirst/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.caseFirst
description: >
get Intl.Locale.prototype.caseFirst.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "caseFirst");
if (propdesc !== undefined) {
const getter = propdesc.get;
verifyProperty(getter, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
}
30 changes: 30 additions & 0 deletions test/intl402/Locale/prototype/collation/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.collation
description: >
get Intl.Locale.prototype.collation.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale]
---*/

const getter = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "collation").get;
verifyProperty(getter, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
30 changes: 30 additions & 0 deletions test/intl402/Locale/prototype/firstDayOfWeek/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.firstDayOfWeek
description: >
get Intl.Locale.prototype.firstDayOfWeek.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale, Intl.Locale-info]
---*/

const getter = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "firstDayOfWeek").get;
verifyProperty(getter, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
29 changes: 29 additions & 0 deletions test/intl402/Locale/prototype/getCalendars/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getCalendars
description: >
Intl.Locale.prototype.getCalendars.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale, Intl.Locale-info]
---*/

verifyProperty(Intl.Locale.prototype.getCalendars, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
29 changes: 29 additions & 0 deletions test/intl402/Locale/prototype/getCollations/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getCollations
description: >
Intl.Locale.prototype.getCollations.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale, Intl.Locale-info]
---*/

verifyProperty(Intl.Locale.prototype.getCollations, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
29 changes: 29 additions & 0 deletions test/intl402/Locale/prototype/getHourCycles/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getHourCycles
description: >
Intl.Locale.prototype.getHourCycles.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale, Intl.Locale-info]
---*/

verifyProperty(Intl.Locale.prototype.getHourCycles, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
29 changes: 29 additions & 0 deletions test/intl402/Locale/prototype/getNumberingSystems/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getNumberingSystems
description: >
Intl.Locale.prototype.getNumberingSystems.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale, Intl.Locale-info]
---*/

verifyProperty(Intl.Locale.prototype.getNumberingSystems, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
29 changes: 29 additions & 0 deletions test/intl402/Locale/prototype/getTextInfo/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getTextInfo
description: >
Intl.Locale.prototype.getTextInfo.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale, Intl.Locale-info]
---*/

verifyProperty(Intl.Locale.prototype.getTextInfo, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
29 changes: 29 additions & 0 deletions test/intl402/Locale/prototype/getTimeZones/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2025 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getTimeZones
description: >
Intl.Locale.prototype.getTimeZones.length is 0.
info: |
ECMAScript Standard Built-in Objects

Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified,
this value is the number of required parameters shown in the subclause heading
for the function description. Optional parameters and rest parameters are not
included in the parameter count.

Unless otherwise specified, the "length" property of a built-in function object
has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.Locale, Intl.Locale-info]
---*/

verifyProperty(Intl.Locale.prototype.getTimeZones, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});
Loading