From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../non262/Intl/Array/toLocaleString-number.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 js/src/tests/non262/Intl/Array/toLocaleString-number.js (limited to 'js/src/tests/non262/Intl/Array/toLocaleString-number.js') diff --git a/js/src/tests/non262/Intl/Array/toLocaleString-number.js b/js/src/tests/non262/Intl/Array/toLocaleString-number.js new file mode 100644 index 0000000000..6ca8a17837 --- /dev/null +++ b/js/src/tests/non262/Intl/Array/toLocaleString-number.js @@ -0,0 +1,34 @@ +if (typeof Intl === "object") { + const localeSep = [,,].toLocaleString(); + + assertEq([NaN].toLocaleString("ar"), "ليس رقم"); + assertEq([NaN].toLocaleString(["zh-hant", "ar"]), "非數值"); + assertEq([Infinity].toLocaleString("dz"), "གྲངས་མེད"); + assertEq([-Infinity].toLocaleString(["fr", "en"]), "-∞"); + + const sampleValues = [ + -0, +0, -1, +1, -2, +2, -0.5, +0.5, + ]; + const sampleLocales = [ + void 0, + "en", + "th-th-u-nu-thai", + ["tlh", "de"], + ]; + const sampleOptions = [ + void 0, + {}, + {style: "percent"}, + {style: "currency", currency: "USD", minimumIntegerDigits: 4}, + ]; + for (let locale of sampleLocales) { + for (let options of sampleOptions) { + let nf = new Intl.NumberFormat(locale, options); + let expected = sampleValues.map(nf.format).join(localeSep); + assertEq(sampleValues.toLocaleString(locale, options), expected); + } + } +} + +if (typeof reportCompare === "function") + reportCompare(true, true); -- cgit v1.2.3