2018-05-04 19:49:37 +02:00
|
|
|
// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
|
|
|
esid: sec-intl.locale
|
|
|
|
description: >
|
2018-10-03 16:24:38 +02:00
|
|
|
Verify valid language option values (various)
|
2018-05-04 19:49:37 +02:00
|
|
|
info: |
|
|
|
|
Intl.Locale( tag [, options] )
|
|
|
|
10. If options is undefined, then
|
|
|
|
11. Else
|
|
|
|
a. Let options be ? ToObject(options).
|
|
|
|
12. Set tag to ? ApplyOptionsToTag(tag, options).
|
|
|
|
|
|
|
|
ApplyOptionsToTag( tag, options )
|
|
|
|
...
|
2018-05-15 14:37:31 +02:00
|
|
|
9. If tag matches neither the privateuse nor the grandfathered production, then
|
|
|
|
b. If language is not undefined, then
|
2018-05-04 19:49:37 +02:00
|
|
|
i. Set tag to tag with the substring corresponding to the language production replaced by the string language.
|
|
|
|
|
|
|
|
features: [Intl.Locale]
|
|
|
|
---*/
|
|
|
|
|
|
|
|
const validLanguageOptions = [
|
2018-05-17 23:30:48 +02:00
|
|
|
[null, 'null'],
|
|
|
|
['zh-cmn', 'cmn'],
|
|
|
|
['ZH-CMN', 'cmn'],
|
|
|
|
['abcd', 'abcd'],
|
|
|
|
[{ toString() { return 'de' } }, 'de'],
|
2018-05-04 19:49:37 +02:00
|
|
|
];
|
|
|
|
for (const [language, expected] of validLanguageOptions) {
|
2018-05-17 23:30:48 +02:00
|
|
|
let expect = expected || 'en';
|
|
|
|
|
2018-05-04 19:49:37 +02:00
|
|
|
assert.sameValue(
|
2018-10-03 16:24:38 +02:00
|
|
|
new Intl.Locale('en', {language}).toString(),
|
2018-05-17 23:30:48 +02:00
|
|
|
expect,
|
2018-10-03 16:24:38 +02:00
|
|
|
`new Intl.Locale('en', {language: "${language}"}).toString() returns "${expect}"`
|
2018-05-04 19:49:37 +02:00
|
|
|
);
|
2018-05-15 14:37:31 +02:00
|
|
|
|
2018-05-17 23:30:48 +02:00
|
|
|
expect = (expected || 'en') + '-US';
|
2018-05-15 14:37:31 +02:00
|
|
|
assert.sameValue(
|
2018-10-03 16:24:38 +02:00
|
|
|
new Intl.Locale('en-US', {language}).toString(),
|
2018-06-30 00:52:53 +02:00
|
|
|
expect,
|
2018-10-03 16:24:38 +02:00
|
|
|
`new Intl.Locale('en-US', {language: "${language}"}).toString() returns "${expect}"`
|
2018-05-15 14:37:31 +02:00
|
|
|
);
|
|
|
|
|
2018-05-17 23:30:48 +02:00
|
|
|
expect = expected || 'en-els';
|
2018-05-15 14:37:31 +02:00
|
|
|
assert.sameValue(
|
2018-10-03 16:24:38 +02:00
|
|
|
new Intl.Locale('en-els', {language}).toString(),
|
2018-05-17 23:30:48 +02:00
|
|
|
expect,
|
2018-10-03 16:24:38 +02:00
|
|
|
`new Intl.Locale('en-els', {language: "${language}"}).toString() returns "${expect}"`
|
2018-05-15 14:37:31 +02:00
|
|
|
);
|
2018-05-04 19:49:37 +02:00
|
|
|
}
|