diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/intl402/NumberFormat/test-option-useGrouping.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/NumberFormat/test-option-useGrouping.js')
-rw-r--r-- | js/src/tests/test262/intl402/NumberFormat/test-option-useGrouping.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/NumberFormat/test-option-useGrouping.js b/js/src/tests/test262/intl402/NumberFormat/test-option-useGrouping.js new file mode 100644 index 0000000000..31bf4385bd --- /dev/null +++ b/js/src/tests/test262/intl402/NumberFormat/test-option-useGrouping.js @@ -0,0 +1,43 @@ +// |reftest| skip-if(release_or_beta) -- Intl.NumberFormat-v3 is not released yet +// Copyright 2012 Mozilla Corporation. All rights reserved. +// Copyright 2022 Apple Inc. All rights reserved. +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.1_34 +description: Tests that the option useGrouping is processed correctly. +info: | + The "Intl.NumberFormat v3" proposal contradicts the behavior required by the + latest revision of ECMA402. +author: Norbert Lindenberg +features: [Intl.NumberFormat-v3] +---*/ + +function resolveUseGrouping(option) { + return new Intl.NumberFormat(undefined, { useGrouping: option }).resolvedOptions().useGrouping; +} + +for (let string of ["min2", "auto", "always"]) { + assert.sameValue(resolveUseGrouping(string), string); +} + +assert.sameValue(resolveUseGrouping(true), "always"); +assert.sameValue(resolveUseGrouping(false), false); +assert.sameValue(resolveUseGrouping(undefined), "auto"); +assert.sameValue(resolveUseGrouping("true"), "auto"); +assert.sameValue(resolveUseGrouping("false"), "auto"); + +for (let falsy of [0, null, ""]) { + assert.sameValue(resolveUseGrouping(falsy), false); +} + +for (let invalidOptions of [42, "MIN2", {} , "True", "TRUE" , "FALSE" , "False" , "Undefined" , "undefined"]) { + assert.throws(RangeError, function () { + return new Intl.NumberFormat(undefined, { useGrouping: invalidOptions }); + }, "Throws RangeError when useGrouping value is not supported"); +} + + + +reportCompare(0, 0); |