Bug 1543658: Add missing rounding-mode to Intl.PluralRules. r=jwalden

Differential Revision: https://phabricator.services.mozilla.com/D37705

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2019-07-16 13:28:15 +00:00
parent 5f1db12cf1
commit fdac3e6f91
2 changed files with 21 additions and 0 deletions

View File

@ -261,6 +261,10 @@ static UNumberFormatter* NewUNumberFormatterForPluralRules(
}
}
if (!skeleton.roundingModeHalfUp()) {
return nullptr;
}
return skeleton.toFormatter(cx, locale.get());
}

View File

@ -0,0 +1,17 @@
// |reftest| skip-if(!this.hasOwnProperty("Intl"))
// The rounding mode defaults to half-up for both NumberFormat and PluralRules.
var locale = "en";
var options = {maximumFractionDigits: 0};
assertEq(new Intl.NumberFormat(locale, options).format(0), "0");
assertEq(new Intl.NumberFormat(locale, options).format(0.5), "1");
assertEq(new Intl.NumberFormat(locale, options).format(1), "1");
assertEq(new Intl.PluralRules(locale, options).select(0), "other");
assertEq(new Intl.PluralRules(locale, options).select(0.5), "one");
assertEq(new Intl.PluralRules(locale, options).select(1), "one");
if (typeof reportCompare === "function")
reportCompare(0, 0, 'ok');