summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/supportedLocalesOf-locales-arg-coered-to-object.js
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/supportedLocalesOf-locales-arg-coered-to-object.js
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/supportedLocalesOf-locales-arg-coered-to-object.js')
-rw-r--r--js/src/tests/test262/intl402/supportedLocalesOf-locales-arg-coered-to-object.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/supportedLocalesOf-locales-arg-coered-to-object.js b/js/src/tests/test262/intl402/supportedLocalesOf-locales-arg-coered-to-object.js
new file mode 100644
index 0000000000..9abbeeae27
--- /dev/null
+++ b/js/src/tests/test262/intl402/supportedLocalesOf-locales-arg-coered-to-object.js
@@ -0,0 +1,33 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 9.2.1_4
+description: >
+ Tests that non-objects are converted to objects before
+ canonicalization.
+author: Norbert Lindenberg
+includes: [testIntl.js]
+---*/
+
+testWithIntlConstructors(function (Constructor) {
+ // undefined is handled separately
+
+ // null should result in a TypeError
+ assert.throws(TypeError, function() {
+ var supportedForNull = Constructor.supportedLocalesOf(null);
+ }, "Null as locale list was not rejected.");
+
+ // let's use an empty list for comparison
+ var supportedForEmptyList = Constructor.supportedLocalesOf([]);
+ // we don't compare the elements because length should be 0 - let's just verify that
+ assert.sameValue(supportedForEmptyList.length, 0, "Internal test error: Assumption about length being 0 is invalid.");
+
+ // most non-objects will be interpreted as empty lists because a missing length property is interpreted as 0
+ var supportedForNumber = Constructor.supportedLocalesOf(5);
+ assert.sameValue(supportedForNumber.length, supportedForEmptyList.length, "Supported locales differ between numeric and empty list input.");
+ var supportedForBoolean = Constructor.supportedLocalesOf(true);
+ assert.sameValue(supportedForBoolean.length, supportedForEmptyList.length, "Supported locales differ between boolean and empty list input.");
+});
+
+reportCompare(0, 0);