summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Locale/constructor-options-numeric-valid.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/intl402/Locale/constructor-options-numeric-valid.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/Locale/constructor-options-numeric-valid.js')
-rw-r--r--js/src/tests/test262/intl402/Locale/constructor-options-numeric-valid.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Locale/constructor-options-numeric-valid.js b/js/src/tests/test262/intl402/Locale/constructor-options-numeric-valid.js
new file mode 100644
index 0000000000..eaa1351961
--- /dev/null
+++ b/js/src/tests/test262/intl402/Locale/constructor-options-numeric-valid.js
@@ -0,0 +1,70 @@
+// Copyright 2018 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.locale
+description: >
+ Checks valid cases for the options argument to the Locale constructor.
+info: |
+ Intl.Locale( tag [, options] )
+
+ ...
+ 24. Let kn be ? GetOption(options, "numeric", "boolean", undefined, undefined).
+ 25. If kn is not undefined, set kn to ! ToString(kn).
+ ...
+ 30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
+ ...
+
+ ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys )
+
+ ...
+ 8. Let locale be the String value that is tag with all Unicode locale extension sequences removed.
+ 9. Let newExtension be ! CanonicalizeUnicodeExtension(attributes, keywords).
+ 10. If newExtension is not the empty String, then
+ a. Let locale be ! InsertUnicodeExtension(locale, newExtension).
+ ...
+
+ CanonicalizeUnicodeExtension( attributes, keywords )
+ ...
+ 4. Repeat for each element entry of keywords in List order,
+ a. Let keyword be entry.[[Key]].
+ b. If entry.[[Value]] is not the empty String, then
+ i. Let keyword be the string-concatenation of keyword, "-", and entry.[[Value]].
+ c. Append keyword to fullKeywords.
+ ...
+features: [Intl.Locale]
+---*/
+
+const validNumericOptions = [
+ [false, false],
+ [true, true],
+ [null, false],
+ [0, false],
+ [0.5, true],
+ ["true", true],
+ ["false", true],
+ [{ valueOf() { return false; } }, true],
+];
+for (const [numeric, expected] of validNumericOptions) {
+ let expect = expected ? "en-u-kn" : "en-u-kn-false";
+
+ assert.sameValue(
+ new Intl.Locale('en', {numeric}).toString(),
+ expect,
+ `new Intl.Locale("en", {numeric: ${numeric}}).toString() returns "${expected}"`
+ );
+
+ assert.sameValue(
+ new Intl.Locale('en-u-kn-true', {numeric}).toString(),
+ expect,
+ `new Intl.Locale("en-u-kn-true", {numeric: ${numeric}}).toString() returns "${expected}"`
+ );
+
+ assert.sameValue(
+ new Intl.Locale('en-u-kf-lower', {numeric}).numeric,
+ expected,
+ `new Intl.Locale("en-u-kf-lower", {numeric: ${numeric}}).numeric equals "${expected}"`
+ );
+}
+
+reportCompare(0, 0);