node/deps/v8/test/intl/number-format/rounding-mode-v3.js
Michaël Zasso fd4f80ce54
deps: update V8 to 10.1.124.6
PR-URL: https://github.com/nodejs/node/pull/42657
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2022-04-12 22:08:39 +02:00

61 lines
1.5 KiB
JavaScript

// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-number-format-v3
let validRoundingMode = [
"ceil",
"floor",
"expand",
"halfCeil",
"halfExpand",
"halfFloor",
"halfTrunc",
"halfEven",
"trunc",
];
let invalidRoundingMode = [
"ceiling",
"down",
"Down",
"flooring",
"halfDown",
"halfUp",
"halfup",
"halfeven",
"halfdown",
"half-up",
"half-even",
"half-down",
"up",
"Up",
];
validRoundingMode.forEach(function(roundingMode) {
let nf = new Intl.NumberFormat(undefined, {roundingMode});
assertEquals(roundingMode, nf.resolvedOptions().roundingMode);
});
invalidRoundingMode.forEach(function(roundingMode) {
assertThrows(() => {
let nf = new Intl.NumberFormat(undefined, {roundingMode}); });
});
// Check default is "halfExpand"
assertEquals("halfExpand", (new Intl.NumberFormat().resolvedOptions().roundingMode));
assertEquals("halfExpand", (new Intl.NumberFormat(
undefined, {roundingMode: undefined}).resolvedOptions().roundingMode));
// Check roundingMode is read once after reading signDisplay
let read = [];
let options = {
get signDisplay() { read.push('signDisplay'); return undefined; },
get roundingMode() { read.push('roundingMode'); return undefined; },
};
assertDoesNotThrow(() => new Intl.NumberFormat(undefined, options));
assertEquals("signDisplay,roundingMode", read.join(","));