Skip to content

Commit

Permalink
Sync Intl Locale API tests w/ PR67
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Mar 21, 2023
1 parent 9704d7f commit e364283
Show file tree
Hide file tree
Showing 54 changed files with 533 additions and 579 deletions.
31 changes: 0 additions & 31 deletions test/intl402/Locale/prototype/calendars/branding.js

This file was deleted.

25 changes: 0 additions & 25 deletions test/intl402/Locale/prototype/calendars/prop-desc.js

This file was deleted.

31 changes: 0 additions & 31 deletions test/intl402/Locale/prototype/collations/branding.js

This file was deleted.

22 changes: 0 additions & 22 deletions test/intl402/Locale/prototype/collations/name.js

This file was deleted.

25 changes: 0 additions & 25 deletions test/intl402/Locale/prototype/collations/prop-desc.js

This file was deleted.

27 changes: 27 additions & 0 deletions test/intl402/Locale/prototype/getCalendars/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getCalendars
description: Verifies the branding check for the "getCalendars" function of the Locale prototype object.
info: |
Intl.Locale.prototype.getCalendars ()
2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
features: [Intl.Locale,Intl.Locale-info]
---*/

const getCalendars = Intl.Locale.prototype.getCalendars;

assert.sameValue(typeof getCalendars, "function");

assert.throws(TypeError, () => getCalendars.call(undefined), "undefined");
assert.throws(TypeError, () => getCalendars.call(null), "null");
assert.throws(TypeError, () => getCalendars.call(true), "true");
assert.throws(TypeError, () => getCalendars.call(""), "empty string");
assert.throws(TypeError, () => getCalendars.call(Symbol()), "symbol");
assert.throws(TypeError, () => getCalendars.call(1), "1");
assert.throws(TypeError, () => getCalendars.call({}), "plain object");
assert.throws(TypeError, () => getCalendars.call(Intl.Locale), "Intl.Locale");
assert.throws(TypeError, () => getCalendars.call(Intl.Locale.prototype), "Intl.Locale.prototype");
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale.prototype.weekInfo
description: >
Checks the "name" property of Intl.Locale.prototype.weekInfo.
esid: sec-Intl.Locale.prototype.getCalendars
description: Checks the "name" property of Intl.Locale.prototype.getCalendars().
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.
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.
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, "weekInfo").get;
verifyProperty(getter, "name", {
value: "get weekInfo",
verifyProperty(Intl.Locale.prototype.getCalendars, "name", {
value: "getCalendars",
writable: false,
enumerable: false,
configurable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale.prototype.calendars
esid: sec-intl.locale.prototype.getCalendars
description: >
Checks that the return value of Intl.Locale.prototype.calendars is an Array.
Checks that the return value of Intl.Locale.prototype.getCalendars is an Array.
info: |
CalendarsOfLocale ( loc )
...
5. Return ! CreateArrayFromListAndPreferred( list, preferred ).
features: [Intl.Locale,Intl.Locale-info]
---*/

assert(Array.isArray(new Intl.Locale('en').calendars));
assert(new Intl.Locale('en').calendars.length > 0, 'array has at least one element');
assert(Array.isArray(new Intl.Locale('en').getCalendars()));
assert(new Intl.Locale('en').getCalendars().length > 0, 'array has at least one element');
25 changes: 25 additions & 0 deletions test/intl402/Locale/prototype/getCalendars/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getCalendars
description: Checks the "getCalendars" property of the Locale prototype object.
info: |
Intl.Locale.prototype.getCalendars ()
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 other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [Intl.Locale,Intl.Locale-info]
---*/

assert.sameValue(
typeof Intl.Locale.prototype.getCalendars,
"function",
"typeof Intl.Locale.prototype.getCalendars is function"
);

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

/*---
esid: sec-Intl.Locale.prototype.getCollations
description: Verifies the branding check for the "getCollations" function of the Locale prototype object.
info: |
Intl.Locale.prototype.getCollations ()
2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
features: [Intl.Locale,Intl.Locale-info]
---*/

const getCollations = Intl.Locale.prototype.getCollations;

assert.sameValue(typeof getCollations, "function");

assert.throws(TypeError, () => getCollations.call(undefined), "undefined");
assert.throws(TypeError, () => getCollations.call(null), "null");
assert.throws(TypeError, () => getCollations.call(true), "true");
assert.throws(TypeError, () => getCollations.call(""), "empty string");
assert.throws(TypeError, () => getCollations.call(Symbol()), "symbol");
assert.throws(TypeError, () => getCollations.call(1), "1");
assert.throws(TypeError, () => getCollations.call({}), "plain object");
assert.throws(TypeError, () => getCollations.call(Intl.Locale), "Intl.Locale");
assert.throws(TypeError, () => getCollations.call(Intl.Locale.prototype), "Intl.Locale.prototype");
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// Copyright 2021 Igalia, S.L. All rights reserved.
// Copyright 2023 Google Inc. 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.
esid: sec-Intl.Locale.prototype.getCollations
description: Checks the "name" property of Intl.Locale.prototype.getCollations().
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.
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.
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",
verifyProperty(Intl.Locale.prototype.getCollations, "name", {
value: "getCollations",
writable: false,
enumerable: false,
configurable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ info: |
features: [Intl.Locale,Intl.Locale-info]
---*/

const output = new Intl.Locale('en').collations;
const output = new Intl.Locale('en').getCollations();
assert(output.length > 0, 'array has at least one element');
output.forEach(c => {
if(['standard', 'search'].includes(c))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale.prototype.collations
esid: sec-intl.locale.prototype.getCollations
description: >
Checks that the return value of Intl.Locale.prototype.collations is an Array.
Checks that the return value of Intl.Locale.prototype.getCollations is an Array.
info: |
CollationsOfLocale ( loc )
...
5. Return ! CreateArrayFromListAndPreferred( list, preferred ).
features: [Intl.Locale,Intl.Locale-info]
---*/

assert(Array.isArray(new Intl.Locale('en').collations));
assert(Array.isArray(new Intl.Locale('en').getCollations()));
25 changes: 25 additions & 0 deletions test/intl402/Locale/prototype/getCollations/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale.prototype.getCollations
description: Checks the "getCollations" property of the Locale prototype object.
info: |
Intl.Locale.prototype.getCollations ()
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 other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [Intl.Locale,Intl.Locale-info]
---*/

assert.sameValue(
typeof Intl.Locale.prototype.getCollations,
"function",
"typeof Intl.Locale.prototype.getCollations is function"
);

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

/*---
esid: sec-Intl.Locale.prototype.getHourCycles
description: Verifies the branding check for the "getHourCycles" function of the Locale prototype object.
info: |
Intl.Locale.prototype.getHourCycles ()
2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
features: [Intl.Locale,Intl.Locale-info]
---*/

const getHourCycles = Intl.Locale.prototype.getHourCycles;

assert.sameValue(typeof getHourCycles, "function");

assert.throws(TypeError, () => getHourCycles.call(undefined), "undefined");
assert.throws(TypeError, () => getHourCycles.call(null), "null");
assert.throws(TypeError, () => getHourCycles.call(true), "true");
assert.throws(TypeError, () => getHourCycles.call(""), "empty string");
assert.throws(TypeError, () => getHourCycles.call(Symbol()), "symbol");
assert.throws(TypeError, () => getHourCycles.call(1), "1");
assert.throws(TypeError, () => getHourCycles.call({}), "plain object");
assert.throws(TypeError, () => getHourCycles.call(Intl.Locale), "Intl.Locale");
assert.throws(TypeError, () => getHourCycles.call(Intl.Locale.prototype), "Intl.Locale.prototype");
Loading

0 comments on commit e364283

Please sign in to comment.