[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/+/1807742
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63850}
This commit is contained in:
Frank Tang 2019-09-16 13:48:05 -07:00 committed by Commit Bot
parent 4dfbe61ab9
commit 9849000141
2 changed files with 28 additions and 13 deletions

View File

@ -731,19 +731,6 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
.FromJust());
int32_t minimum = 0, maximum = 0;
if (FractionDigitsFromSkeleton(skeleton, &minimum, &maximum)) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->minimumFractionDigits_string(),
factory->NewNumberFromInt(minimum), Just(kDontThrow))
.FromJust());
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->maximumFractionDigits_string(),
factory->NewNumberFromInt(maximum), Just(kDontThrow))
.FromJust());
}
minimum = 0;
maximum = 0;
if (SignificantDigitsFromSkeleton(skeleton, &minimum, &maximum)) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->minimumSignificantDigits_string(),
@ -753,6 +740,16 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
isolate, options, factory->maximumSignificantDigits_string(),
factory->NewNumberFromInt(maximum), Just(kDontThrow))
.FromJust());
} else {
FractionDigitsFromSkeleton(skeleton, &minimum, &maximum);
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->minimumFractionDigits_string(),
factory->NewNumberFromInt(minimum), Just(kDontThrow))
.FromJust());
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->maximumFractionDigits_string(),
factory->NewNumberFromInt(maximum), Just(kDontThrow))
.FromJust());
}
CHECK(JSReceiver::CreateDataProperty(

View File

@ -0,0 +1,18 @@
// 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);