Commit 98490001 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Fix m(ax|in)imumFractionDigits for currency

Fix m(ax|in)imumFractionDigits of Intl.NumberFormat
resolvedOptions are set to 0. For example, currency
instance for CPY or KRW.

Bug: chromium:1003748
Change-Id: Ia1963d8d070b066bd5afa61f8c4716a21450af05
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1807742Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63850}
parent 4dfbe61a
......@@ -731,26 +731,23 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
.FromJust());
int32_t minimum = 0, maximum = 0;
if (FractionDigitsFromSkeleton(skeleton, &minimum, &maximum)) {
if (SignificantDigitsFromSkeleton(skeleton, &minimum, &maximum)) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->minimumFractionDigits_string(),
isolate, options, factory->minimumSignificantDigits_string(),
factory->NewNumberFromInt(minimum), Just(kDontThrow))
.FromJust());
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->maximumFractionDigits_string(),
isolate, options, factory->maximumSignificantDigits_string(),
factory->NewNumberFromInt(maximum), Just(kDontThrow))
.FromJust());
}
minimum = 0;
maximum = 0;
if (SignificantDigitsFromSkeleton(skeleton, &minimum, &maximum)) {
} else {
FractionDigitsFromSkeleton(skeleton, &minimum, &maximum);
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->minimumSignificantDigits_string(),
isolate, options, factory->minimumFractionDigits_string(),
factory->NewNumberFromInt(minimum), Just(kDontThrow))
.FromJust());
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->maximumSignificantDigits_string(),
isolate, options, factory->maximumFractionDigits_string(),
factory->NewNumberFromInt(maximum), Just(kDontThrow))
.FromJust());
}
......
// Copyright 2019 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.
let usd = new Intl.NumberFormat('en',
{ style: 'currency', currency: 'USD' }).resolvedOptions();
assertEquals(2, usd.maximumFractionDigits);
assertEquals(2, usd.minimumFractionDigits);
let jpy = new Intl.NumberFormat('en',
{ style: 'currency', currency: 'JPY' }).resolvedOptions();
assertEquals(0, jpy.maximumFractionDigits);
assertEquals(0, jpy.minimumFractionDigits);
let krw = new Intl.NumberFormat('en',
{ style: 'currency', currency: 'KRW' }).resolvedOptions();
assertEquals(0, krw.maximumFractionDigits);
assertEquals(0, krw.minimumFractionDigits);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment