[Intl] Fix order of NumberFormat resolvedOptions
Change the order of creating property for the return object of Intl.NumberFormat.property.resolvedOptions() according to the table in the spec. This is due to spec change in from "any order" to "table " in https://github.com/tc39/ecma402/pull/279 Failure w/o fixing it will happen once we land test262/intl402/NumberFormat/prototype/resolvedOptions/order Bug: v8:8378 Change-Id: Ic68fcfeba78af87d9bbd13c935ad9a91e76f4965 Reviewed-on: https://chromium-review.googlesource.com/c/1303195 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#57195}
This commit is contained in:
parent
18ac14688d
commit
511b7cb5b6
@ -60,14 +60,13 @@ bool IsWellFormedCurrencyCode(const std::string& currency) {
|
||||
} // anonymous namespace
|
||||
|
||||
// static
|
||||
// ecma402 #sec-intl.numberformat.prototype.resolvedoptions
|
||||
Handle<JSObject> JSNumberFormat::ResolvedOptions(
|
||||
Isolate* isolate, Handle<JSNumberFormat> number_format_holder) {
|
||||
Factory* factory = isolate->factory();
|
||||
|
||||
// 4. Let options be ! ObjectCreate(%ObjectPrototype%).
|
||||
Handle<JSObject> options = factory->NewJSObject(isolate->object_function());
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
isolate, options, factory->style_string(),
|
||||
number_format_holder->StyleAsString(), kDontThrow)
|
||||
.FromJust());
|
||||
|
||||
icu::NumberFormat* number_format =
|
||||
number_format_holder->icu_number_format()->raw();
|
||||
@ -78,14 +77,30 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
|
||||
|
||||
Handle<String> locale =
|
||||
Handle<String>(number_format_holder->locale(), isolate);
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
isolate, options, factory->locale_string(), locale, kDontThrow)
|
||||
.FromJust());
|
||||
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
icu::Locale icu_locale = number_format->getLocale(ULOC_VALID_LOCALE, error);
|
||||
DCHECK(U_SUCCESS(error));
|
||||
|
||||
std::string numbering_system = Intl::GetNumberingSystem(icu_locale);
|
||||
|
||||
// 5. For each row of Table 4, except the header row, in table order, do
|
||||
// Table 4: Resolved Options of NumberFormat Instances
|
||||
// Internal Slot Property
|
||||
// [[Locale]] "locale"
|
||||
// [[NumberingSystem]] "numberingSystem"
|
||||
// [[Style]] "style"
|
||||
// [[Currency]] "currency"
|
||||
// [[CurrencyDisplay]] "currencyDisplay"
|
||||
// [[MinimumIntegerDigits]] "minimumIntegerDigits"
|
||||
// [[MinimumFractionDigits]] "minimumFractionDigits"
|
||||
// [[MaximumFractionDigits]] "maximumFractionDigits"
|
||||
// [[MinimumSignificantDigits]] "minimumSignificantDigits"
|
||||
// [[MaximumSignificantDigits]] "maximumSignificantDigits"
|
||||
// [[UseGrouping]] "useGrouping"
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
isolate, options, factory->locale_string(), locale, kDontThrow)
|
||||
.FromJust());
|
||||
if (!numbering_system.empty()) {
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
isolate, options, factory->numberingSystem_string(),
|
||||
@ -93,12 +108,11 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
|
||||
kDontThrow)
|
||||
.FromJust());
|
||||
}
|
||||
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
isolate, options, factory->style_string(),
|
||||
number_format_holder->StyleAsString(), kDontThrow)
|
||||
.FromJust());
|
||||
if (number_format_holder->style() == Style::CURRENCY) {
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
isolate, options, factory->currencyDisplay_string(),
|
||||
number_format_holder->CurrencyDisplayAsString(), kDontThrow)
|
||||
.FromJust());
|
||||
icu::UnicodeString currency(number_format->getCurrency());
|
||||
DCHECK(!currency.isEmpty());
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
@ -110,8 +124,12 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
|
||||
.ToHandleChecked(),
|
||||
kDontThrow)
|
||||
.FromJust());
|
||||
}
|
||||
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
isolate, options, factory->currencyDisplay_string(),
|
||||
number_format_holder->CurrencyDisplayAsString(), kDontThrow)
|
||||
.FromJust());
|
||||
}
|
||||
CHECK(JSReceiver::CreateDataProperty(
|
||||
isolate, options, factory->minimumIntegerDigits_string(),
|
||||
factory->NewNumberFromInt(number_format->getMinimumIntegerDigits()),
|
||||
@ -148,7 +166,6 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
|
||||
factory->ToBoolean((number_format->isGroupingUsed() == TRUE)),
|
||||
kDontThrow)
|
||||
.FromJust());
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,6 @@
|
||||
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=8378
|
||||
'intl402/DateTimeFormat/prototype/resolvedOptions/order': [FAIL],
|
||||
'intl402/NumberFormat/prototype/resolvedOptions/order': [FAIL],
|
||||
|
||||
# https://code.google.com/p/v8/issues/detail?id=4251
|
||||
'language/expressions/postfix-increment/S11.3.1_A5_T1': [FAIL],
|
||||
|
Loading…
Reference in New Issue
Block a user