Skip to content

Commit

Permalink
Add basic tests for proposal-intl-locale-info (#2987)
Browse files Browse the repository at this point in the history
* Add basic tests for weekInfo

* Add basic tests for textInfo

* Add basic tests for timeZones

* Add basic tests for numberingSystems

* Add basic tests for hourCycles

* Add basic tests for collations

* Add basic tests for calendars

* Add feature for Intl.Locale-info

* add validation to branding tests for locale-info

Add additional assertion to branding tests for proposal-intl-locale-info
to make sure they don't pass spuriously when the proposal is not
implemented.
  • Loading branch information
ryzokuken committed May 19, 2021
1 parent 6d353a4 commit 5e0fc43
Show file tree
Hide file tree
Showing 22 changed files with 550 additions and 0 deletions.
4 changes: 4 additions & 0 deletions features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ Intl.ListFormat
# https://github.com/tc39/proposal-intl-locale
Intl.Locale

# Intl.Locale Info
# https://github.com/tc39/proposal-intl-locale-info
Intl.Locale-info

# Intl.RelativeTimeFormat
# https://github.com/tc39/proposal-intl-relative-time
Intl.RelativeTimeFormat
Expand Down
31 changes: 31 additions & 0 deletions test/intl402/Locale/prototype/calendars/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.calendars
description: >
Verifies the branding check for the "calendars" property of the Locale prototype object.
info: |
Intl.Locale.prototype.calendars
2. If Type(loc) is not Object or loc does not have an [[InitializedLocale]] internal slot, then
a. Throw a TypeError exception.
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "calendars");
assert.sameValue(typeof propdesc.get, "function");
const invalidValues = [
undefined,
null,
true,
"",
Symbol(),
1,
{},
Intl.Locale.prototype,
];

for (const invalidValue of invalidValues) {
assert.throws(TypeError, () => propdesc.get.call(invalidValue));
}
22 changes: 22 additions & 0 deletions test/intl402/Locale/prototype/calendars/name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale.prototype.calendars
description: >
Checks the "name" property of Intl.Locale.prototype.calendars.
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function 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. Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
Unless otherwise specified, the name property of a built-in function object, if it exists, 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, "calendars").get;
verifyProperty(getter, "name", {
value: "get calendars",
writable: false,
enumerable: false,
configurable: true,
});
25 changes: 25 additions & 0 deletions test/intl402/Locale/prototype/calendars/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale
description: >
Checks the "calendars" property of the Locale prototype object.
info: |
Intl.Locale.prototype.calendars
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 script Specification, 10th edition, clause 17, or successor.
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
includes: [propertyHelper.js]
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "calendars");
assert.sameValue(propdesc.set, undefined);
assert.sameValue(typeof propdesc.get, "function");

verifyProperty(Intl.Locale.prototype, "calendars", {
enumerable: false,
configurable: true,
});
31 changes: 31 additions & 0 deletions test/intl402/Locale/prototype/collations/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.collations
description: >
Verifies the branding check for the "collations" property of the Locale prototype object.
info: |
Intl.Locale.prototype.collations
2. If Type(loc) is not Object or loc does not have an [[InitializedLocale]] internal slot, then
a. Throw a TypeError exception.
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "collations");
assert.sameValue(typeof propdesc.get, "function");
const invalidValues = [
undefined,
null,
true,
"",
Symbol(),
1,
{},
Intl.Locale.prototype,
];

for (const invalidValue of invalidValues) {
assert.throws(TypeError, () => propdesc.get.call(invalidValue));
}
22 changes: 22 additions & 0 deletions test/intl402/Locale/prototype/collations/name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale.prototype.collations
description: >
Checks the "name" property of Intl.Locale.prototype.collations.
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function 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. Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
Unless otherwise specified, the name property of a built-in function object, if it exists, 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, "collations").get;
verifyProperty(getter, "name", {
value: "get collations",
writable: false,
enumerable: false,
configurable: true,
});
25 changes: 25 additions & 0 deletions test/intl402/Locale/prototype/collations/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale
description: >
Checks the "collations" property of the Locale prototype object.
info: |
Intl.Locale.prototype.collations
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 script Specification, 10th edition, clause 17, or successor.
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
includes: [propertyHelper.js]
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "collations");
assert.sameValue(propdesc.set, undefined);
assert.sameValue(typeof propdesc.get, "function");

verifyProperty(Intl.Locale.prototype, "collations", {
enumerable: false,
configurable: true,
});
31 changes: 31 additions & 0 deletions test/intl402/Locale/prototype/hourCycles/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.hourCycles
description: >
Verifies the branding check for the "hourCycles" property of the Locale prototype object.
info: |
Intl.Locale.prototype.hourCycles
2. If Type(loc) is not Object or loc does not have an [[InitializedLocale]] internal slot, then
a. Throw a TypeError exception.
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "hourCycles");
assert.sameValue(typeof propdesc.get, "function");
const invalidValues = [
undefined,
null,
true,
"",
Symbol(),
1,
{},
Intl.Locale.prototype,
];

for (const invalidValue of invalidValues) {
assert.throws(TypeError, () => propdesc.get.call(invalidValue));
}
22 changes: 22 additions & 0 deletions test/intl402/Locale/prototype/hourCycles/name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale.prototype.hourCycles
description: >
Checks the "name" property of Intl.Locale.prototype.hourCycles.
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function 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. Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
Unless otherwise specified, the name property of a built-in function object, if it exists, 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, "hourCycles").get;
verifyProperty(getter, "name", {
value: "get hourCycles",
writable: false,
enumerable: false,
configurable: true,
});
25 changes: 25 additions & 0 deletions test/intl402/Locale/prototype/hourCycles/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale
description: >
Checks the "hourCycles" property of the Locale prototype object.
info: |
Intl.Locale.prototype.hourCycles
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 script Specification, 10th edition, clause 17, or successor.
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
includes: [propertyHelper.js]
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "hourCycles");
assert.sameValue(propdesc.set, undefined);
assert.sameValue(typeof propdesc.get, "function");

verifyProperty(Intl.Locale.prototype, "hourCycles", {
enumerable: false,
configurable: true,
});
31 changes: 31 additions & 0 deletions test/intl402/Locale/prototype/numberingSystems/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.numberingSystems
description: >
Verifies the branding check for the "numberingSystems" property of the Locale prototype object.
info: |
Intl.Locale.prototype.numberingSystems
2. If Type(loc) is not Object or loc does not have an [[InitializedLocale]] internal slot, then
a. Throw a TypeError exception.
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "numberingSystems");
assert.sameValue(typeof propdesc.get, "function");
const invalidValues = [
undefined,
null,
true,
"",
Symbol(),
1,
{},
Intl.Locale.prototype,
];

for (const invalidValue of invalidValues) {
assert.throws(TypeError, () => propdesc.get.call(invalidValue));
}
22 changes: 22 additions & 0 deletions test/intl402/Locale/prototype/numberingSystems/name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale.prototype.numberingSystems
description: >
Checks the "name" property of Intl.Locale.prototype.numberingSystems.
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function 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. Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
Unless otherwise specified, the name property of a built-in function object, if it exists, 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, "numberingSystems").get;
verifyProperty(getter, "name", {
value: "get numberingSystems",
writable: false,
enumerable: false,
configurable: true,
});
25 changes: 25 additions & 0 deletions test/intl402/Locale/prototype/numberingSystems/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale
description: >
Checks the "numberingSystems" property of the Locale prototype object.
info: |
Intl.Locale.prototype.numberingSystems
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 script Specification, 10th edition, clause 17, or successor.
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
includes: [propertyHelper.js]
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "numberingSystems");
assert.sameValue(propdesc.set, undefined);
assert.sameValue(typeof propdesc.get, "function");

verifyProperty(Intl.Locale.prototype, "numberingSystems", {
enumerable: false,
configurable: true,
});
31 changes: 31 additions & 0 deletions test/intl402/Locale/prototype/textInfo/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.textInfo
description: >
Verifies the branding check for the "textInfo" property of the Locale prototype object.
info: |
Intl.Locale.prototype.textInfo
2. If Type(loc) is not Object or loc does not have an [[InitializedLocale]] internal slot, then
a. Throw a TypeError exception.
features: [Intl.Locale,Intl.Locale-info]
---*/

const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "textInfo");
assert.sameValue(typeof propdesc.get, "function");
const invalidValues = [
undefined,
null,
true,
"",
Symbol(),
1,
{},
Intl.Locale.prototype,
];

for (const invalidValue of invalidValues) {
assert.throws(TypeError, () => propdesc.get.call(invalidValue));
}
22 changes: 22 additions & 0 deletions test/intl402/Locale/prototype/textInfo/name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale.prototype.textInfo
description: >
Checks the "name" property of Intl.Locale.prototype.textInfo.
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function 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. Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
Unless otherwise specified, the name property of a built-in function object, if it exists, 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, "textInfo").get;
verifyProperty(getter, "name", {
value: "get textInfo",
writable: false,
enumerable: false,
configurable: true,
});

0 comments on commit 5e0fc43

Please sign in to comment.