mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
intl402: add output tests for locale-info (#3007)
* intl402: locale-info tests for array output * fixup! intl402: locale-info tests for array output * fixup! intl402: locale-info tests for array output
This commit is contained in:
parent
9b4ca4371b
commit
26cf753e74
15
test/intl402/Locale/prototype/calendars/output-array.js
vendored
Normal file
15
test/intl402/Locale/prototype/calendars/output-array.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// 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 that the return value of Intl.Locale.prototype.calendars 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));
|
24
test/intl402/Locale/prototype/collations/output-array-values.js
vendored
Normal file
24
test/intl402/Locale/prototype/collations/output-array-values.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// 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 that the return value of Intl.Locale.prototype.collations is an Array
|
||||
that does not contain invalid values.
|
||||
info: |
|
||||
CollationsOfLocale ( loc )
|
||||
...
|
||||
4. Let list be a List of 1 or more unique collation identifiers, which must
|
||||
be lower case String values conforming to the type sequence from UTS 35
|
||||
Unicode Locale Identifier, section 3.2, sorted in descending preference of
|
||||
those in common use for string comparison in locale. The values "standard"
|
||||
and "search" must be excluded from list.
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
---*/
|
||||
|
||||
const output = new Intl.Locale('en').collations;
|
||||
output.forEach(c => {
|
||||
if(['standard', 'search'].includes(c))
|
||||
throw new Test262Error();
|
||||
});
|
15
test/intl402/Locale/prototype/collations/output-array.js
vendored
Normal file
15
test/intl402/Locale/prototype/collations/output-array.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// 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 that the return value of Intl.Locale.prototype.collations 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));
|
23
test/intl402/Locale/prototype/hourCycles/output-array-values.js
vendored
Normal file
23
test/intl402/Locale/prototype/hourCycles/output-array-values.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// 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 that the return value of Intl.Locale.prototype.hourCycles is an Array
|
||||
that only contains valid values.
|
||||
info: |
|
||||
HourCyclesOfLocale ( loc )
|
||||
...
|
||||
4. Let list be a List of 1 or more unique hour cycle identifiers, which must
|
||||
be lower case String values indicating either the 12-hour format ("h11",
|
||||
"h12") or the 24-hour format ("h23", "h24"), sorted in descending preference
|
||||
of those in common use for date and time formatting in locale.
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
---*/
|
||||
|
||||
const output = new Intl.Locale('en').hourCycles;
|
||||
output.forEach(hc => {
|
||||
if(!['h11', 'h12', 'h23', 'h24'].includes(hc))
|
||||
throw new Test262Error();
|
||||
});
|
15
test/intl402/Locale/prototype/hourCycles/output-array.js
vendored
Normal file
15
test/intl402/Locale/prototype/hourCycles/output-array.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// 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 that the return value of Intl.Locale.prototype.hourCycles is an Array.
|
||||
info: |
|
||||
HourCyclesOfLocale ( loc )
|
||||
...
|
||||
5. Return ! CreateArrayFromListAndPreferred( list, preferred ).
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
---*/
|
||||
|
||||
assert(Array.isArray(new Intl.Locale('en').hourCycles));
|
15
test/intl402/Locale/prototype/numberingSystems/output-array.js
vendored
Normal file
15
test/intl402/Locale/prototype/numberingSystems/output-array.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// 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 that the return value of Intl.Locale.prototype.numberingSystems is an Array.
|
||||
info: |
|
||||
NumberingSystemsOfLocale ( loc )
|
||||
...
|
||||
5. Return ! CreateArrayFromListAndPreferred( list, preferred ).
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
---*/
|
||||
|
||||
assert(Array.isArray(new Intl.Locale('en').numberingSystems));
|
25
test/intl402/Locale/prototype/textInfo/output-object-keys.js
vendored
Normal file
25
test/intl402/Locale/prototype/textInfo/output-object-keys.js
vendored
Normal file
@ -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.prototype.textInfo
|
||||
description: >
|
||||
Checks that the return value of Intl.Locale.prototype.textInfo is an Object
|
||||
with the correct keys and properties.
|
||||
info: |
|
||||
get Intl.Locale.prototype.textInfo
|
||||
...
|
||||
7. Perform ! CreateDataPropertyOrThrow(info, "direction", dir).
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
includes: [propertyHelper.js, compareArray.js]
|
||||
---*/
|
||||
|
||||
const result = new Intl.Locale('en').textInfo;
|
||||
|
||||
assert.compareArray(Reflect.ownKeys(result), ['direction']);
|
||||
|
||||
verifyProperty(result, 'direction', {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
15
test/intl402/Locale/prototype/textInfo/output-object.js
vendored
Normal file
15
test/intl402/Locale/prototype/textInfo/output-object.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// 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 that the return value of Intl.Locale.prototype.textInfo is an Object.
|
||||
info: |
|
||||
get Intl.Locale.prototype.textInfo
|
||||
...
|
||||
5. Let info be ! ObjectCreate(%Object.prototype%).
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(new Intl.Locale('en').textInfo), Object.prototype);
|
22
test/intl402/Locale/prototype/timeZones/output-array-sorted.js
vendored
Normal file
22
test/intl402/Locale/prototype/timeZones/output-array-sorted.js
vendored
Normal file
@ -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.timeZones
|
||||
description: >
|
||||
Checks that the return value of Intl.Locale.prototype.timeZones is a sorted
|
||||
Array.
|
||||
info: |
|
||||
TimeZonesOfLocale ( loc )
|
||||
...
|
||||
4. Let list be a List of 1 or more unique time zone identifiers, which must be
|
||||
String values indicating a Zone or Link name of the IANA Time Zone Database,
|
||||
ordered as if an Array of the same values had been sorted using
|
||||
%Array.prototype.sort% using undefined as comparefn, of those in common use
|
||||
in region.
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
const output = new Intl.Locale('en-US').timeZones;
|
||||
assert.compareArray(output, [...output].sort());
|
16
test/intl402/Locale/prototype/timeZones/output-array.js
vendored
Normal file
16
test/intl402/Locale/prototype/timeZones/output-array.js
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// 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.timeZones
|
||||
description: >
|
||||
Checks that the return value of Intl.Locale.prototype.timeZones is an Array
|
||||
when a region subtag is used.
|
||||
info: |
|
||||
TimeZonesOfLocale ( loc )
|
||||
...
|
||||
5. Return ! CreateArrayFromListAndPreferred( list, preferred ).
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
---*/
|
||||
|
||||
assert(Array.isArray(new Intl.Locale('en-US').timeZones));
|
19
test/intl402/Locale/prototype/timeZones/output-undefined.js
vendored
Normal file
19
test/intl402/Locale/prototype/timeZones/output-undefined.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
// 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.timeZones
|
||||
description: >
|
||||
Checks that the return value of Intl.Locale.prototype.timeZones is undefined
|
||||
when no region subtag is used.
|
||||
info: |
|
||||
get Intl.Locale.prototype.timeZones
|
||||
...
|
||||
4. If the unicode_language_id production of locale does not contain the
|
||||
["-" unicode_region_subtag] sequence, return undefined.
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "timeZones");
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(new Intl.Locale('en').timeZones, undefined);
|
52
test/intl402/Locale/prototype/weekInfo/output-object-keys.js
vendored
Normal file
52
test/intl402/Locale/prototype/weekInfo/output-object-keys.js
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
// 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.weekInfo
|
||||
description: >
|
||||
Checks that the return value of Intl.Locale.prototype.weekInfo is an Object
|
||||
with the correct keys and properties.
|
||||
info: |
|
||||
get Intl.Locale.prototype.weekInfo
|
||||
...
|
||||
7. Perform ! CreateDataPropertyOrThrow(info, "firstDay", wi.[[FirstDay]]).
|
||||
8. Perform ! CreateDataPropertyOrThrow(info, "weekendStart", wi.[[WeekendStart]]).
|
||||
9. Perform ! CreateDataPropertyOrThrow(info, "weekendEnd", wi.[[WeekendEnd]]).
|
||||
10. Perform ! CreateDataPropertyOrThrow(info, "minimalDays", wi.[[MinimalDays]]).
|
||||
...
|
||||
|
||||
CreateDataProperty ( O, P, V )
|
||||
...
|
||||
3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true,
|
||||
[[Enumerable]]: true, [[Configurable]]: true }.
|
||||
features: [Reflect,Intl.Locale,Intl.Locale-info]
|
||||
includes: [propertyHelper.js, compareArray.js]
|
||||
---*/
|
||||
|
||||
const result = new Intl.Locale('en').weekInfo;
|
||||
|
||||
assert.compareArray(Reflect.ownKeys(result), ['firstDay', 'weekendStart', 'weekendEnd', 'minimalDays']);
|
||||
|
||||
verifyProperty(result, 'firstDay', {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
verifyProperty(result, 'weekendStart', {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
verifyProperty(result, 'weekendEnd', {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
verifyProperty(result, 'minimalDays', {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
15
test/intl402/Locale/prototype/weekInfo/output-object.js
vendored
Normal file
15
test/intl402/Locale/prototype/weekInfo/output-object.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.weekInfo
|
||||
description: >
|
||||
Checks that the return value of Intl.Locale.prototype.weekInfo is an Object.
|
||||
info: |
|
||||
get Intl.Locale.prototype.weekInfo
|
||||
...
|
||||
5. Let info be ! ObjectCreate(%Object.prototype%).
|
||||
features: [Intl.Locale,Intl.Locale-info]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(new Intl.Locale('en').weekInfo), Object.prototype);
|
Loading…
x
Reference in New Issue
Block a user