Skip to content
Snippets Groups Projects
Commit 3113b90d authored by Ms2ger's avatar Ms2ger Committed by Rick Waldron
Browse files

Intl.RelativeTimeFormat: Add some basic tests for CanonicalizeLocaleList.

parent e1d80f75
No related branches found
No related tags found
No related merge requests found
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.RelativeTimeFormat
description: Checks various cases for the locales argument to the RelativeTimeFormat constructor.
info: |
InitializeRelativeTimeFormat (relativeTimeFormat, locales, options)
3. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
includes: [testIntl.js]
features: [Intl.RelativeTimeFormat]
---*/
const defaultLocale = new Intl.RelativeTimeFormat().resolvedOptions().locale;
const tests = [
[undefined, defaultLocale, "undefined"],
["EN", "en", "Single value"],
[[], defaultLocale, "Empty array"],
[["en-GB-oed"], "en-GB", "Grandfathered"],
[["x-private"], defaultLocale, "Private"],
[["en", "EN"], "en", "Duplicate value (canonical first)"],
[["EN", "en"], "en", "Duplicate value (canonical last)"],
[{ 0: "DE", length: 0 }, defaultLocale, "Object with zero length"],
[{ 0: "DE", length: 1 }, "de", "Object with length"],
];
for (const [locales, expected, name] of tests) {
const rtf = new Intl.RelativeTimeFormat(locales);
assert.sameValue(rtf.resolvedOptions().locale, expected, name);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment