From 19caba81c426a2c2b4c58ab8be799aee24c6efe1 Mon Sep 17 00:00:00 2001
From: Doug Ilijev <doilij@microsoft.com>
Date: Mon, 17 Apr 2017 12:11:46 -0700
Subject: [PATCH] Add version of intl402/6.2.3.js which tests via
 Intl.getCanonicalLocales

---
 test/intl402/{6.2.3.js => 6.2.3_a.js} |  2 +-
 test/intl402/6.2.3_b.js               | 42 +++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
 rename test/intl402/{6.2.3.js => 6.2.3_a.js} (97%)
 create mode 100644 test/intl402/6.2.3_b.js

diff --git a/test/intl402/6.2.3.js b/test/intl402/6.2.3_a.js
similarity index 97%
rename from test/intl402/6.2.3.js
rename to test/intl402/6.2.3_a.js
index 4776f86645..91a316aec0 100644
--- a/test/intl402/6.2.3.js
+++ b/test/intl402/6.2.3_a.js
@@ -47,7 +47,7 @@ testWithIntlConstructors(function (Constructor) {
 
         // Variant 1: construct an object and see whether its locale is canonicalized.
         // In this variant, shortened forms or the default locale may be returned
-        var object = new Constructor([tag], {localeMatcher: "lookup"});
+        var object = new Constructor([tag], { localeMatcher: "lookup" });
         var locale = object.resolvedOptions().locale;
         assert(canonicalizedTags[tag].indexOf(locale) !== -1 || locale === defaultLocale, "For " + tag + " got " + locale + "; expected one of " + canonicalizedTags[tag].join(", ") + ".");
         
diff --git a/test/intl402/6.2.3_b.js b/test/intl402/6.2.3_b.js
new file mode 100644
index 0000000000..5868dae5d8
--- /dev/null
+++ b/test/intl402/6.2.3_b.js
@@ -0,0 +1,42 @@
+// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012  Mozilla Corporation. All rights reserved.
+// Copyright 2017 Microsoft Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 6.2.3
+description: Tests that language tags are canonicalized in return values.
+author: Norbert Lindenberg
+includes: [testIntl.js]
+---*/
+
+var canonicalizedTags = {
+    "de": ["de"],
+    "de-DE": ["de-DE", "de"],
+    "DE-de": ["de-DE", "de"],
+    "cmn": ["cmn"],
+    "CMN-hANS": ["cmn-Hans", "cmn"],
+    "cmn-hans-cn": ["cmn-Hans-CN", "cmn-Hans", "cmn"],
+    "es-419": ["es-419", "es"],
+    "es-419-u-nu-latn": ["es-419-u-nu-latn", "es-419", "es", "es-u-nu-latn"],
+    // -u-ca is incomplete, so it will not show up in resolvedOptions().locale
+    "cmn-hans-cn-u-ca-t-ca-x-t-u": ["cmn-Hans-CN-t-ca-u-ca-x-t-u", "cmn-Hans-CN-t-ca-x-t-u", "cmn-Hans-CN-t-ca-x-t", "cmn-Hans-CN-t-ca", "cmn-Hans-CN", "cmn-Hans", "cmn"],
+    "de-gregory-u-ca-gregory": ["de-gregory-u-ca-gregory", "de-gregory", "de-u-ca-gregory", "de"],
+    "no-nyn": ["nn"],
+    "i-klingon": ["tlh"],
+    "sgn-GR": ["gss"],
+    "ji": ["yi"],
+    "de-DD": ["de-DE", "de"],
+    "zh-hak-CN": ["hak-CN", "hak"],
+    "sgn-ils": ["ils"],
+    "in": ["id"],
+    "x-foo": ["x-foo"]
+};
+
+Object.getOwnPropertyNames(canonicalizedTags).forEach(function (tag) {
+    let locale = Intl.getCanonicalLocales(tag);
+    if (!canonicalizedTags[tag].includes(locale[0])) {
+        $ERROR("For " + tag + " got " + locale + "; expected one of " +
+            canonicalizedTags[tag].join(", ") + ".");
+    }
+});
-- 
GitLab