summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Intl/extensions
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/tests/non262/Intl/extensions
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Intl/extensions')
-rw-r--r--js/src/tests/non262/Intl/extensions/browser.js0
-rw-r--r--js/src/tests/non262/Intl/extensions/options-value-emulates-undefined.js29
-rw-r--r--js/src/tests/non262/Intl/extensions/shell.js0
-rw-r--r--js/src/tests/non262/Intl/extensions/unicode-extension-sequences.js74
4 files changed, 103 insertions, 0 deletions
diff --git a/js/src/tests/non262/Intl/extensions/browser.js b/js/src/tests/non262/Intl/extensions/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/non262/Intl/extensions/browser.js
diff --git a/js/src/tests/non262/Intl/extensions/options-value-emulates-undefined.js b/js/src/tests/non262/Intl/extensions/options-value-emulates-undefined.js
new file mode 100644
index 0000000000..5b2ee124aa
--- /dev/null
+++ b/js/src/tests/non262/Intl/extensions/options-value-emulates-undefined.js
@@ -0,0 +1,29 @@
+// |reftest| skip-if(!xulRuntime.shell||!this.hasOwnProperty('Intl'))
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 843004;
+var summary =
+ "Use of an object that emulates |undefined| as the sole option must " +
+ "preclude imputing default values";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var opt = createIsHTMLDDA();
+opt.toString = function() { return "long"; };
+
+var str = new Date(2013, 12 - 1, 14).toLocaleString("en-US", { weekday: opt });
+
+// Because "weekday" was present and not undefined (stringifying to "long"),
+// this must be a string like "Saturday" (in this implementation, that is).
+assertEq(str, "Saturday");
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/non262/Intl/extensions/shell.js b/js/src/tests/non262/Intl/extensions/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/non262/Intl/extensions/shell.js
diff --git a/js/src/tests/non262/Intl/extensions/unicode-extension-sequences.js b/js/src/tests/non262/Intl/extensions/unicode-extension-sequences.js
new file mode 100644
index 0000000000..ead69a4632
--- /dev/null
+++ b/js/src/tests/non262/Intl/extensions/unicode-extension-sequences.js
@@ -0,0 +1,74 @@
+// |reftest| skip-if(!this.getSelfHostedValue)
+
+const startOfUnicodeExtensions = getSelfHostedValue("startOfUnicodeExtensions");
+const endOfUnicodeExtensions = getSelfHostedValue("endOfUnicodeExtensions");
+
+const testcases = [
+ // Language tag without Unicode extension.
+ { locale: "en", start: -1, end: 0 },
+ { locale: "en-Latn", start: -1, end: 0 },
+ { locale: "en-x-y", start: -1, end: 0 },
+ { locale: "en-x-yz", start: -1, end: 0 },
+ { locale: "en-x-u-kf", start: -1, end: 0 },
+
+ // Unicode extension sequence starts with key subtag.
+ // - no suceeding key or type subtags.
+ { locale: "en-u-ab", start: 2, end: 7 },
+ { locale: "en-u-ab-x-y", start: 2, end: 7 },
+ { locale: "en-u-ab-x-yz", start: 2, end: 7 },
+ { locale: "en-u-ab-x-u-kn", start: 2, end: 7 },
+ // - followed by key subtag.
+ { locale: "en-u-ab-cd", start: 2, end: 10 },
+ { locale: "en-u-ab-cd-x-y", start: 2, end: 10 },
+ { locale: "en-u-ab-cd-x-yz", start: 2, end: 10 },
+ { locale: "en-u-ab-cd-x-u-kn", start: 2, end: 10 },
+ // - followed by type subtag.
+ { locale: "en-u-ab-cdef", start: 2, end: 12 },
+ { locale: "en-u-ab-cdef-x-y", start: 2, end: 12 },
+ { locale: "en-u-ab-cdef-x-yz", start: 2, end: 12 },
+ { locale: "en-u-ab-cdef-x-y-u-kn", start: 2, end: 12 },
+
+ // Unicode extension sequence starts with attribute subtag.
+ // - no suceeding attribute or key subtags.
+ { locale: "en-u-abc", start: 2, end: 8 },
+ { locale: "en-u-abc-x-y", start: 2, end: 8 },
+ { locale: "en-u-abc-x-yz", start: 2, end: 8 },
+ { locale: "en-u-abc-x-y-u-kn", start: 2, end: 8 },
+ // - followed by attribute subtag.
+ { locale: "en-u-abc-def", start: 2, end: 12 },
+ { locale: "en-u-abc-def-x-y", start: 2, end: 12 },
+ { locale: "en-u-abc-def-x-yz", start: 2, end: 12 },
+ { locale: "en-u-abc-def-x-y-u-kn", start: 2, end: 12 },
+ // - followed by key subtag.
+ { locale: "en-u-abc-de", start: 2, end: 11 },
+ { locale: "en-u-abc-de-x-y", start: 2, end: 11 },
+ { locale: "en-u-abc-de-x-yz", start: 2, end: 11 },
+ { locale: "en-u-abc-de-x-y-u-kn", start: 2, end: 11 },
+ // - followed by two key subtags.
+ { locale: "en-u-abc-de-fg", start: 2, end: 14 },
+ { locale: "en-u-abc-de-fg-x-y", start: 2, end: 14 },
+ { locale: "en-u-abc-de-fg-x-yz", start: 2, end: 14 },
+ { locale: "en-u-abc-de-fg-x-y-u-kn", start: 2, end: 14 },
+ // - followed by key and type subtag.
+ { locale: "en-u-abc-de-fgh", start: 2, end: 15 },
+ { locale: "en-u-abc-de-fgh-x-y", start: 2, end: 15 },
+ { locale: "en-u-abc-de-fgh-x-yz", start: 2, end: 15 },
+ { locale: "en-u-abc-de-fgh-x-y-u-kn", start: 2, end: 15 },
+
+ // Also test when the Unicode extension doesn't start at index 2.
+ { locale: "en-Latn-u-kf", start: 7, end: 12 },
+ { locale: "und-u-kf", start: 3, end: 8 },
+];
+
+for (const {locale, start, end} of testcases) {
+ // Ensure the input is a valid language tag.
+ assertEqArray(Intl.getCanonicalLocales(locale), [locale]);
+
+ assertEq(startOfUnicodeExtensions(locale), start);
+
+ if (start >= 0)
+ assertEq(endOfUnicodeExtensions(locale, start), end);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);