From e1d80f75c74da17a1a11fc60eb53b6ab83fe8dba Mon Sep 17 00:00:00 2001
From: Ms2ger <Ms2ger@igalia.com>
Date: Mon, 15 Oct 2018 15:33:57 +0200
Subject: [PATCH] Intl.ListFormat: Add some basic tests for
 CanonicalizeLocaleList.

---
 .../constructor/constructor/locales-valid.js  | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 test/intl402/ListFormat/constructor/constructor/locales-valid.js

diff --git a/test/intl402/ListFormat/constructor/constructor/locales-valid.js b/test/intl402/ListFormat/constructor/constructor/locales-valid.js
new file mode 100644
index 0000000000..07cd4b7644
--- /dev/null
+++ b/test/intl402/ListFormat/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.ListFormat
+description: Checks various cases for the locales argument to the ListFormat constructor.
+info: |
+    InitializeListFormat (listFormat, locales, options)
+    1. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
+includes: [testIntl.js]
+features: [Intl.ListFormat]
+---*/
+
+const defaultLocale = new Intl.ListFormat().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.ListFormat(locales);
+  assert.sameValue(rtf.resolvedOptions().locale, expected, name);
+}
-- 
GitLab