summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Array
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/Array
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/Array')
-rw-r--r--js/src/tests/test262/intl402/Array/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Array/prototype/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Array/prototype/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Array/prototype/toLocaleString/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Array/prototype/toLocaleString/calls-toLocaleString-number-elements.js19
-rw-r--r--js/src/tests/test262/intl402/Array/prototype/toLocaleString/invoke-element-tolocalestring.js63
-rw-r--r--js/src/tests/test262/intl402/Array/prototype/toLocaleString/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Array/shell.js0
8 files changed, 82 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Array/browser.js b/js/src/tests/test262/intl402/Array/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Array/browser.js
diff --git a/js/src/tests/test262/intl402/Array/prototype/browser.js b/js/src/tests/test262/intl402/Array/prototype/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Array/prototype/browser.js
diff --git a/js/src/tests/test262/intl402/Array/prototype/shell.js b/js/src/tests/test262/intl402/Array/prototype/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Array/prototype/shell.js
diff --git a/js/src/tests/test262/intl402/Array/prototype/toLocaleString/browser.js b/js/src/tests/test262/intl402/Array/prototype/toLocaleString/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Array/prototype/toLocaleString/browser.js
diff --git a/js/src/tests/test262/intl402/Array/prototype/toLocaleString/calls-toLocaleString-number-elements.js b/js/src/tests/test262/intl402/Array/prototype/toLocaleString/calls-toLocaleString-number-elements.js
new file mode 100644
index 0000000000..bd1a389a64
--- /dev/null
+++ b/js/src/tests/test262/intl402/Array/prototype/toLocaleString/calls-toLocaleString-number-elements.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2018 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sup-array.prototype.tolocalestring
+description: >
+ Ensure "toLocaleString" is called with locale and options on number elements.
+---*/
+
+var n = 0;
+
+var locale = "th-u-nu-thai";
+var options = {
+ minimumFractionDigits: 3
+};
+
+assert.sameValue([n].toLocaleString(locale, options), n.toLocaleString(locale, options));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Array/prototype/toLocaleString/invoke-element-tolocalestring.js b/js/src/tests/test262/intl402/Array/prototype/toLocaleString/invoke-element-tolocalestring.js
new file mode 100644
index 0000000000..5016ebec27
--- /dev/null
+++ b/js/src/tests/test262/intl402/Array/prototype/toLocaleString/invoke-element-tolocalestring.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2022 Richard Gibson. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sup-array.prototype.tolocalestring
+description: >
+ The toLocaleString method of each non-undefined non-null element
+ must be called with two arguments.
+info: |
+ Array.prototype.toLocaleString ( [ _locales_ [ , _options_ ] ] )
+
+ 4. Let _R_ be the empty String.
+ 5. Let _k_ be 0.
+ 6. Repeat, while _k_ &lt; _len_,
+ a. If _k_ &gt; 0, then
+ i. Set _R_ to the string-concatenation of _R_ and _separator_.
+ b. Let _nextElement_ be ? Get(_array_, ! ToString(_k_)).
+ c. If _nextElement_ is not *undefined* or *null*, then
+ i. Let _S_ be ? ToString(? Invoke(_nextElement_, *"toLocaleString"*, &laquo; _locales_, _options_ &raquo;)).
+ ii. Set _R_ to the string-concatenation of _R_ and _S_.
+ d. Increase _k_ by 1.
+ 7. Return _R_.
+includes: [compareArray.js]
+---*/
+
+const unique = {
+ toString() {
+ return "<sentinel object>";
+ }
+};
+
+const testCases = [
+ { label: "no arguments", args: [], expectedArgs: [undefined, undefined] },
+ { label: "undefined locale", args: [undefined], expectedArgs: [undefined, undefined] },
+ { label: "string locale", args: ["ar"], expectedArgs: ["ar", undefined] },
+ { label: "object locale", args: [unique], expectedArgs: [unique, undefined] },
+ { label: "undefined locale and options", args: [undefined, unique], expectedArgs: [undefined, unique] },
+ { label: "string locale and options", args: ["zh", unique], expectedArgs: ["zh", unique] },
+ { label: "object locale and options", args: [unique, unique], expectedArgs: [unique, unique] },
+ { label: "extra arguments", args: [unique, unique, unique], expectedArgs: [unique, unique] },
+];
+
+for (const { label, args, expectedArgs } of testCases) {
+ assert.sameValue([undefined].toLocaleString(...args), "",
+ `must skip undefined elements when provided ${label}`);
+}
+for (const { label, args, expectedArgs } of testCases) {
+ assert.sameValue([null].toLocaleString(...args), "",
+ `must skip null elements when provided ${label}`);
+}
+
+for (const { label, args, expectedArgs } of testCases) {
+ const spy = {
+ toLocaleString(...receivedArgs) {
+ assert.compareArray(receivedArgs, expectedArgs,
+ `must invoke element toLocaleString with expected arguments when provided ${label}`);
+ return "ok";
+ }
+ };
+ assert.sameValue([spy].toLocaleString(...args), "ok");
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Array/prototype/toLocaleString/shell.js b/js/src/tests/test262/intl402/Array/prototype/toLocaleString/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Array/prototype/toLocaleString/shell.js
diff --git a/js/src/tests/test262/intl402/Array/shell.js b/js/src/tests/test262/intl402/Array/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Array/shell.js