mirror of https://github.com/tc39/test262.git
Intl.Locale: ensure that the expect value is correctly printed in the assertion message
This commit is contained in:
parent
a33ccf6bf1
commit
50de5f98ab
|
@ -36,32 +36,38 @@ features: [Intl.Locale]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const validHourCycleOptions = [
|
const validHourCycleOptions = [
|
||||||
"h11",
|
'h11',
|
||||||
"h12",
|
'h12',
|
||||||
"h23",
|
'h23',
|
||||||
"h24",
|
'h24',
|
||||||
{ toString() { return "h24"; } },
|
{ toString() { return 'h24'; } },
|
||||||
];
|
];
|
||||||
for (const hourCycle of validHourCycleOptions) {
|
for (const hourCycle of validHourCycleOptions) {
|
||||||
const options = { hourCycle };
|
const options = { hourCycle };
|
||||||
const expected = String(hourCycle);
|
const expected = String(hourCycle);
|
||||||
|
let expect = 'en-u-hc-' + expected;
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en', options).toString(),
|
new Intl.Locale('en', options).toString(),
|
||||||
"en-u-hc-" + expected,
|
expect,
|
||||||
|
`new Intl.Locale('en', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-u-hc-h00', options).toString(),
|
new Intl.Locale('en-u-hc-h00', options).toString(),
|
||||||
"en-u-hc-" + expected,
|
expect,
|
||||||
|
`new Intl.Locale('en-u-hc-h00', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-u-hc-h12', options).toString(),
|
new Intl.Locale('en-u-hc-h12', options).toString(),
|
||||||
"en-u-hc-" + expected,
|
expect,
|
||||||
|
`new Intl.Locale('en-u-hc-h12', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-u-hc-h00', options).hourCycle,
|
new Intl.Locale('en-u-hc-h00', options).hourCycle,
|
||||||
expected,
|
expected,
|
||||||
|
`new Intl.Locale('en-u-hc-h00', options).hourCycle equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,33 +24,37 @@ features: [Intl.Locale]
|
||||||
|
|
||||||
const validLanguageOptions = [
|
const validLanguageOptions = [
|
||||||
[undefined, undefined],
|
[undefined, undefined],
|
||||||
[null, "null"],
|
[null, 'null'],
|
||||||
["zh-cmn", "cmn"],
|
['zh-cmn', 'cmn'],
|
||||||
["ZH-CMN", "cmn"],
|
['ZH-CMN', 'cmn'],
|
||||||
["abcd", "abcd"],
|
['abcd', 'abcd'],
|
||||||
["abcde", "abcde"],
|
['abcde', 'abcde'],
|
||||||
["abcdef", "abcdef"],
|
['abcdef', 'abcdef'],
|
||||||
["abcdefg", "abcdefg"],
|
['abcdefg', 'abcdefg'],
|
||||||
["abcdefgh", "abcdefgh"],
|
['abcdefgh', 'abcdefgh'],
|
||||||
[{ toString() { return "de" } }, "de"],
|
[{ toString() { return 'de' } }, 'de'],
|
||||||
];
|
];
|
||||||
for (const [language, expected] of validLanguageOptions) {
|
for (const [language, expected] of validLanguageOptions) {
|
||||||
let options = { language };
|
let options = { language };
|
||||||
|
let expect = expected || 'en';
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en', options).toString(),
|
new Intl.Locale('en', options).toString(),
|
||||||
expected || 'en',
|
expect,
|
||||||
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect = (expected || 'en') + '-US';
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-US', options).toString(),
|
new Intl.Locale('en-US', options).toString(),
|
||||||
(expected || "en") + "-US",
|
expected,
|
||||||
`new Intl.Locale('en-US', options).toString() equals the value of ${expected}-US`
|
`new Intl.Locale('en-US', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect = expected || 'en-els';
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-els', options).toString(),
|
new Intl.Locale('en-els', options).toString(),
|
||||||
expected || "en-els",
|
expect,
|
||||||
`new Intl.Locale('en-els', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en-els', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,33 +30,38 @@ features: [Intl.Locale]
|
||||||
|
|
||||||
const validRegionOptions = [
|
const validRegionOptions = [
|
||||||
[undefined, undefined],
|
[undefined, undefined],
|
||||||
["FR", "en-FR"],
|
['FR', 'en-FR'],
|
||||||
["554", "en-554"],
|
['554', 'en-554'],
|
||||||
[554, "en-554"],
|
[554, 'en-554'],
|
||||||
];
|
];
|
||||||
for (const [region, expected] of validRegionOptions) {
|
for (const [region, expected] of validRegionOptions) {
|
||||||
let options = { region };
|
let options = { region };
|
||||||
|
let expect = expected || 'en';
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en', options).toString(),
|
new Intl.Locale('en', options).toString(),
|
||||||
expected || "en",
|
expect,
|
||||||
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect = expected || 'en-US';
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-US', options).toString(),
|
new Intl.Locale('en-US', options).toString(),
|
||||||
expected || "en-US",
|
expect,
|
||||||
`new Intl.Locale('en-US', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en-US', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect = (expected || 'en') + '-u-ca-gregory';
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-u-ca-gregory', options).toString(),
|
new Intl.Locale('en-u-ca-gregory', options).toString(),
|
||||||
(expected || "en") + "-u-ca-gregory",
|
expect,
|
||||||
`new Intl.Locale('en-u-ca-gregory', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en-u-ca-gregory', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect = (expected || 'en-US') + '-u-ca-gregory';
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-US-u-ca-gregory', options).toString(),
|
new Intl.Locale('en-US-u-ca-gregory', options).toString(),
|
||||||
(expected || "en-US") + "-u-ca-gregory",
|
expect,
|
||||||
`new Intl.Locale('en-US-u-ca-gregory', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en-US-u-ca-gregory', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,29 +31,33 @@ features: [Intl.Locale]
|
||||||
|
|
||||||
const validScriptOptions = [
|
const validScriptOptions = [
|
||||||
[undefined, undefined],
|
[undefined, undefined],
|
||||||
[null, "Null"],
|
[null, 'Null'],
|
||||||
["bali", "Bali"],
|
['bali', 'Bali'],
|
||||||
["Bali", "Bali"],
|
['Bali', 'Bali'],
|
||||||
["bALI", "BALI"], // TODO REVIEW: is this the correct case regularization?
|
['bALI', 'BALI'], // TODO REVIEW: is this the correct case regularization?
|
||||||
[{ toString() { return "Brai" } }, "Brai"],
|
[{ toString() { return 'Brai' } }, 'Brai'],
|
||||||
];
|
];
|
||||||
for (const [script, expected] of validScriptOptions) {
|
for (const [script, expected] of validScriptOptions) {
|
||||||
let options = { script };
|
let options = { script };
|
||||||
assert.sameValue(
|
let expect = expected ? 'en-' + expected : 'en';
|
||||||
new Intl.Locale("en", options).toString(),
|
|
||||||
expected ? ("en-" + expected) : "en",
|
|
||||||
`new Intl.Locale("en", options).toString() equals the value of ${expected}`
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale("en-DK", options).toString(),
|
new Intl.Locale('en', options).toString(),
|
||||||
(expected ? ("en-" + expected) : "en") + "-DK",
|
expect,
|
||||||
`new Intl.Locale("en", options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect = (expected ? ('en-' + expected) : 'en') + '-DK';
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale("en-Cyrl", options).toString(),
|
new Intl.Locale('en-DK', options).toString(),
|
||||||
expected ? ("en-" + expected) : "en-Cyrl",
|
expect,
|
||||||
`new Intl.Locale("en-Cyrl", options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en', options).toString() equals the value of ${expect}`
|
||||||
|
);
|
||||||
|
|
||||||
|
expect = expected ? ('en-' + expected) : 'en-Cyrl';
|
||||||
|
assert.sameValue(
|
||||||
|
new Intl.Locale('en-Cyrl', options).toString(),
|
||||||
|
expect,
|
||||||
|
`new Intl.Locale('en-Cyrl', options).toString() equals the value of ${expect}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue