From 3113b90d55c572ec94e7d0a7e7ae219c8af026a3 Mon Sep 17 00:00:00 2001 From: Ms2ger <Ms2ger@igalia.com> Date: Mon, 15 Oct 2018 15:34:17 +0200 Subject: [PATCH] Intl.RelativeTimeFormat: Add some basic tests for CanonicalizeLocaleList. --- .../constructor/constructor/locales-valid.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js b/test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js new file mode 100644 index 0000000000..326202e87e --- /dev/null +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js @@ -0,0 +1,31 @@ +// 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); +} -- GitLab