diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/non262/Intl/extensions | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
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); |