Commit 25c11657 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Clean up by removing the following flags

  harmony_intl_bigint shipped in m76
  harmony_intl_date_format_range shipped in m76
  harmony_intl_datetime_style shipped in m76
  harmony_intl_numberformat_unified shipped in m77

Bug: v8:9272, v8:9273, v8:9274
Change-Id: Icc640e011021e691373bc61725013578b7185e50
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1799263
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63736}
parent 8a1a2867
......@@ -127,19 +127,16 @@ BUILTIN(BigIntPrototypeToLocaleString) {
HandleScope scope(isolate);
const char* method = "BigInt.prototype.toLocaleString";
#ifdef V8_INTL_SUPPORT
if (FLAG_harmony_intl_bigint) {
// 1. Let x be ? thisBigIntValue(this value).
Handle<BigInt> x;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, x, ThisBigIntValue(isolate, args.receiver(), method));
// 1. Let x be ? thisBigIntValue(this value).
Handle<BigInt> x;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, x, ThisBigIntValue(isolate, args.receiver(), method));
RETURN_RESULT_OR_FAILURE(
isolate,
Intl::NumberToLocaleString(isolate, x, args.atOrUndefined(isolate, 1),
args.atOrUndefined(isolate, 2), method));
}
// Fallbacks to old toString implemention if flag is off or no
// V8_INTL_SUPPORT
RETURN_RESULT_OR_FAILURE(
isolate,
Intl::NumberToLocaleString(isolate, x, args.atOrUndefined(isolate, 1),
args.atOrUndefined(isolate, 2), method));
// Fallbacks to old toString implemention if no V8_INTL_SUPPORT
#endif // V8_INTL_SUPPORT
Handle<Object> radix = isolate->factory()->undefined_value();
return BigIntToStringImpl(args.receiver(), radix, isolate, method);
......
......@@ -83,13 +83,8 @@ BUILTIN(NumberFormatPrototypeFormatToParts) {
Handle<Object> x;
if (args.length() >= 2) {
if (FLAG_harmony_intl_bigint) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, x, Object::ToNumeric(isolate, args.at(1)));
} else {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x,
Object::ToNumber(isolate, args.at(1)));
}
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x,
Object::ToNumeric(isolate, args.at(1)));
} else {
x = isolate->factory()->nan_value();
}
......@@ -468,13 +463,8 @@ BUILTIN(NumberFormatInternalFormatNumber) {
// 4. Let x be ? ToNumeric(value).
Handle<Object> numeric_obj;
if (FLAG_harmony_intl_bigint) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, numeric_obj,
Object::ToNumeric(isolate, value));
} else {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, numeric_obj,
Object::ToNumber(isolate, value));
}
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, numeric_obj,
Object::ToNumeric(isolate, value));
icu::number::LocalizedNumberFormatter* icu_localized_number_formatter =
number_format->icu_number_formatter().raw();
......
......@@ -246,12 +246,7 @@ DEFINE_IMPLICATION(harmony_import_meta, harmony_dynamic_import)
V(harmony_promise_all_settled, "harmony Promise.allSettled")
#ifdef V8_INTL_SUPPORT
#define HARMONY_SHIPPING(V) \
HARMONY_SHIPPING_BASE(V) \
V(harmony_intl_bigint, "BigInt.prototype.toLocaleString") \
V(harmony_intl_date_format_range, "DateTimeFormat formatRange") \
V(harmony_intl_datetime_style, "dateStyle timeStyle for DateTimeFormat") \
V(harmony_intl_numberformat_unified, "Unified Intl.NumberFormat Features")
#define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V)
#else
#define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V)
#endif
......
......@@ -2917,6 +2917,13 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallGetter(isolate_, prototype, factory->format_string(),
Builtins::kDateTimeFormatPrototypeFormat, false);
SimpleInstallFunction(isolate_, prototype, "formatRange",
Builtins::kDateTimeFormatPrototypeFormatRange, 2,
false);
SimpleInstallFunction(
isolate_, prototype, "formatRangeToParts",
Builtins::kDateTimeFormatPrototypeFormatRangeToParts, 2, false);
}
{ // -- N u m b e r F o r m a t
......@@ -4271,13 +4278,10 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_nullish)
#ifdef V8_INTL_SUPPORT
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_add_calendar_numbering_system)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_bigint)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_dateformat_day_period)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(
harmony_intl_dateformat_fractional_second_digits)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_dateformat_quarter)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_datetime_style)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_numberformat_unified)
#endif // V8_INTL_SUPPORT
#undef EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE
......@@ -4436,32 +4440,6 @@ void Genesis::InitializeGlobal_harmony_regexp_match_indices() {
#ifdef V8_INTL_SUPPORT
void Genesis::InitializeGlobal_harmony_intl_date_format_range() {
if (!FLAG_harmony_intl_date_format_range) return;
Handle<JSObject> intl = Handle<JSObject>::cast(
JSReceiver::GetProperty(
isolate(),
Handle<JSReceiver>(native_context()->global_object(), isolate()),
factory()->InternalizeUtf8String("Intl"))
.ToHandleChecked());
Handle<JSFunction> date_time_format_constructor = Handle<JSFunction>::cast(
JSReceiver::GetProperty(
isolate(), intl, factory()->InternalizeUtf8String("DateTimeFormat"))
.ToHandleChecked());
Handle<JSObject> prototype(
JSObject::cast(date_time_format_constructor->prototype()), isolate_);
SimpleInstallFunction(isolate_, prototype, "formatRange",
Builtins::kDateTimeFormatPrototypeFormatRange, 2,
false);
SimpleInstallFunction(isolate_, prototype, "formatRangeToParts",
Builtins::kDateTimeFormatPrototypeFormatRangeToParts, 2,
false);
}
void Genesis::InitializeGlobal_harmony_intl_segmenter() {
if (!FLAG_harmony_intl_segmenter) return;
Handle<JSObject> intl = Handle<JSObject>::cast(
......
......@@ -1086,13 +1086,8 @@ MaybeHandle<String> Intl::NumberToLocaleString(Isolate* isolate,
Handle<Object> options,
const char* method) {
Handle<Object> numeric_obj;
if (FLAG_harmony_intl_bigint) {
ASSIGN_RETURN_ON_EXCEPTION(isolate, numeric_obj,
Object::ToNumeric(isolate, num), String);
} else {
ASSIGN_RETURN_ON_EXCEPTION(isolate, numeric_obj,
Object::ToNumber(isolate, num), String);
}
ASSIGN_RETURN_ON_EXCEPTION(isolate, numeric_obj,
Object::ToNumeric(isolate, num), String);
// We only cache the instance when both locales and options are undefined,
// as that is the only case when the specified side-effects of examining
......@@ -1204,40 +1199,18 @@ Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions(
int mxfd = 0;
Handle<Object> mnfd_obj;
Handle<Object> mxfd_obj;
if (FLAG_harmony_intl_numberformat_unified) {
// 6. Let mnfd be ? Get(options, "minimumFractionDigits").
Handle<String> mnfd_str = factory->minimumFractionDigits_string();
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, mnfd_obj, JSReceiver::GetProperty(isolate, options, mnfd_str),
Nothing<NumberFormatDigitOptions>());
// 8. Let mnfd be ? Get(options, "maximumFractionDigits").
Handle<String> mxfd_str = factory->maximumFractionDigits_string();
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, mxfd_obj, JSReceiver::GetProperty(isolate, options, mxfd_str),
Nothing<NumberFormatDigitOptions>());
} else {
// 6. Let mnfd be ? GetNumberOption(options, "minimumFractionDigits", 0, 20,
// mnfdDefault).
if (!Intl::GetNumberOption(isolate, options,
factory->minimumFractionDigits_string(), 0, 20,
mnfd_default)
.To(&mnfd)) {
return Nothing<NumberFormatDigitOptions>();
}
// 7. Let mxfdActualDefault be max( mnfd, mxfdDefault ).
int mxfd_actual_default = std::max(mnfd, mxfd_default);
// 6. Let mnfd be ? Get(options, "minimumFractionDigits").
Handle<String> mnfd_str = factory->minimumFractionDigits_string();
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, mnfd_obj, JSReceiver::GetProperty(isolate, options, mnfd_str),
Nothing<NumberFormatDigitOptions>());
// 8. Let mxfd be ? GetNumberOption(options,
// "maximumFractionDigits", mnfd, 20, mxfdActualDefault).
if (!Intl::GetNumberOption(isolate, options,
factory->maximumFractionDigits_string(), mnfd,
20, mxfd_actual_default)
.To(&mxfd)) {
return Nothing<NumberFormatDigitOptions>();
}
}
// 8. Let mxfd be ? Get(options, "maximumFractionDigits").
Handle<String> mxfd_str = factory->maximumFractionDigits_string();
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, mxfd_obj, JSReceiver::GetProperty(isolate, options, mxfd_str),
Nothing<NumberFormatDigitOptions>());
// 9. Let mnsd be ? Get(options, "minimumSignificantDigits").
Handle<Object> mnsd_obj;
......@@ -1286,47 +1259,44 @@ Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions(
digit_options.minimum_significant_digits = 0;
digit_options.maximum_significant_digits = 0;
if (FLAG_harmony_intl_numberformat_unified) {
// 15. Else If mnfd is not undefined or mxfd is not undefined, then
if (!mnfd_obj->IsUndefined(isolate) || !mxfd_obj->IsUndefined(isolate)) {
// 15. b. Let mnfd be ? DefaultNumberOption(mnfd, 0, 20, mnfdDefault).
Handle<String> mnfd_str = factory->minimumFractionDigits_string();
if (!DefaultNumberOption(isolate, mnfd_obj, 0, 20, mnfd_default,
mnfd_str)
.To(&mnfd)) {
return Nothing<NumberFormatDigitOptions>();
}
// 15. Else If mnfd is not undefined or mxfd is not undefined, then
if (!mnfd_obj->IsUndefined(isolate) || !mxfd_obj->IsUndefined(isolate)) {
// 15. b. Let mnfd be ? DefaultNumberOption(mnfd, 0, 20, mnfdDefault).
Handle<String> mnfd_str = factory->minimumFractionDigits_string();
if (!DefaultNumberOption(isolate, mnfd_obj, 0, 20, mnfd_default, mnfd_str)
.To(&mnfd)) {
return Nothing<NumberFormatDigitOptions>();
}
// 15. c. Let mxfdActualDefault be max( mnfd, mxfdDefault ).
int mxfd_actual_default = std::max(mnfd, mxfd_default);
// 15. c. Let mxfdActualDefault be max( mnfd, mxfdDefault ).
int mxfd_actual_default = std::max(mnfd, mxfd_default);
// 15. d. Let mxfd be ? DefaultNumberOption(mxfd, mnfd, 20,
// mxfdActualDefault).
Handle<String> mxfd_str = factory->maximumFractionDigits_string();
if (!DefaultNumberOption(isolate, mxfd_obj, mnfd, 20,
mxfd_actual_default, mxfd_str)
.To(&mxfd)) {
return Nothing<NumberFormatDigitOptions>();
}
// 15. e. Set intlObj.[[MinimumFractionDigits]] to mnfd.
digit_options.minimum_fraction_digits = mnfd;
// 15. f. Set intlObj.[[MaximumFractionDigits]] to mxfd.
digit_options.maximum_fraction_digits = mxfd;
// Else If intlObj.[[Notation]] is "compact", then
} else if (notation_is_compact) {
// a. Set intlObj.[[RoundingType]] to "compact-rounding".
// Set minimum_significant_digits to -1 to represent roundingtype is
// "compact-rounding".
digit_options.minimum_significant_digits = -1;
// 17. Else,
} else {
// 17. b. Set intlObj.[[MinimumFractionDigits]] to mnfdDefault.
digit_options.minimum_fraction_digits = mnfd_default;
// 17. c. Set intlObj.[[MaximumFractionDigits]] to mxfdDefault.
digit_options.maximum_fraction_digits = mxfd_default;
// 15. d. Let mxfd be ? DefaultNumberOption(mxfd, mnfd, 20,
// mxfdActualDefault).
Handle<String> mxfd_str = factory->maximumFractionDigits_string();
if (!DefaultNumberOption(isolate, mxfd_obj, mnfd, 20, mxfd_actual_default,
mxfd_str)
.To(&mxfd)) {
return Nothing<NumberFormatDigitOptions>();
}
// 15. e. Set intlObj.[[MinimumFractionDigits]] to mnfd.
digit_options.minimum_fraction_digits = mnfd;
// 15. f. Set intlObj.[[MaximumFractionDigits]] to mxfd.
digit_options.maximum_fraction_digits = mxfd;
// Else If intlObj.[[Notation]] is "compact", then
} else if (notation_is_compact) {
// a. Set intlObj.[[RoundingType]] to "compact-rounding".
// Set minimum_significant_digits to -1 to represent roundingtype is
// "compact-rounding".
digit_options.minimum_significant_digits = -1;
// 17. Else,
} else {
// 17. b. Set intlObj.[[MinimumFractionDigits]] to mnfdDefault.
digit_options.minimum_fraction_digits = mnfd_default;
// 17. c. Set intlObj.[[MaximumFractionDigits]] to mxfdDefault.
digit_options.maximum_fraction_digits = mxfd_default;
}
}
return Just(digit_options);
......
......@@ -1243,9 +1243,8 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
const std::vector<const char*> empty_values = {};
// 6. Let calendar be ? GetOption(options, "calendar",
// "string", undefined, undefined).
Maybe<bool> maybe_calendar =
Intl::GetStringOption(isolate, options, "calendar", empty_values,
"Intl.NumberFormat", &calendar_str);
Maybe<bool> maybe_calendar = Intl::GetStringOption(
isolate, options, "calendar", empty_values, service, &calendar_str);
MAYBE_RETURN(maybe_calendar, MaybeHandle<JSDateTimeFormat>());
if (maybe_calendar.FromJust() && calendar_str != nullptr) {
icu::Locale default_locale;
......@@ -1262,7 +1261,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
// 8. Let numberingSystem be ? GetOption(options, "numberingSystem",
// "string", undefined, undefined).
Maybe<bool> maybe_numberingSystem = Intl::GetNumberingSystem(
isolate, options, "Intl.NumberFormat", &numbering_system_str);
isolate, options, service, &numbering_system_str);
MAYBE_RETURN(maybe_numberingSystem, MaybeHandle<JSDateTimeFormat>());
}
......@@ -1409,43 +1408,40 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
DateTimeStyle time_style = DateTimeStyle::kUndefined;
std::unique_ptr<icu::SimpleDateFormat> icu_date_format;
if (FLAG_harmony_intl_datetime_style) {
// 28. Let dateStyle be ? GetOption(options, "dateStyle", "string", «
// "full", "long", "medium", "short" », undefined).
Maybe<DateTimeStyle> maybe_date_style =
Intl::GetStringOption<DateTimeStyle>(
isolate, options, "dateStyle", service,
{"full", "long", "medium", "short"},
{DateTimeStyle::kFull, DateTimeStyle::kLong, DateTimeStyle::kMedium,
DateTimeStyle::kShort},
DateTimeStyle::kUndefined);
MAYBE_RETURN(maybe_date_style, MaybeHandle<JSDateTimeFormat>());
// 29. If dateStyle is not undefined, set dateTimeFormat.[[DateStyle]] to
// dateStyle.
date_style = maybe_date_style.FromJust();
// 30. Let timeStyle be ? GetOption(options, "timeStyle", "string", «
// "full", "long", "medium", "short" »).
Maybe<DateTimeStyle> maybe_time_style =
Intl::GetStringOption<DateTimeStyle>(
isolate, options, "timeStyle", service,
{"full", "long", "medium", "short"},
{DateTimeStyle::kFull, DateTimeStyle::kLong, DateTimeStyle::kMedium,
DateTimeStyle::kShort},
DateTimeStyle::kUndefined);
MAYBE_RETURN(maybe_time_style, MaybeHandle<JSDateTimeFormat>());
// 31. If timeStyle is not undefined, set dateTimeFormat.[[TimeStyle]] to
// timeStyle.
time_style = maybe_time_style.FromJust();
// 32. If dateStyle or timeStyle are not undefined, then
if (date_style != DateTimeStyle::kUndefined ||
time_style != DateTimeStyle::kUndefined) {
icu_date_format = DateTimeStylePattern(date_style, time_style, icu_locale,
hc, generator.get());
}
// 28. Let dateStyle be ? GetOption(options, "dateStyle", "string", «
// "full", "long", "medium", "short" », undefined).
Maybe<DateTimeStyle> maybe_date_style = Intl::GetStringOption<DateTimeStyle>(
isolate, options, "dateStyle", service,
{"full", "long", "medium", "short"},
{DateTimeStyle::kFull, DateTimeStyle::kLong, DateTimeStyle::kMedium,
DateTimeStyle::kShort},
DateTimeStyle::kUndefined);
MAYBE_RETURN(maybe_date_style, MaybeHandle<JSDateTimeFormat>());
// 29. If dateStyle is not undefined, set dateTimeFormat.[[DateStyle]] to
// dateStyle.
date_style = maybe_date_style.FromJust();
// 30. Let timeStyle be ? GetOption(options, "timeStyle", "string", «
// "full", "long", "medium", "short" »).
Maybe<DateTimeStyle> maybe_time_style = Intl::GetStringOption<DateTimeStyle>(
isolate, options, "timeStyle", service,
{"full", "long", "medium", "short"},
{DateTimeStyle::kFull, DateTimeStyle::kLong, DateTimeStyle::kMedium,
DateTimeStyle::kShort},
DateTimeStyle::kUndefined);
MAYBE_RETURN(maybe_time_style, MaybeHandle<JSDateTimeFormat>());
// 31. If timeStyle is not undefined, set dateTimeFormat.[[TimeStyle]] to
// timeStyle.
time_style = maybe_time_style.FromJust();
// 32. If dateStyle or timeStyle are not undefined, then
if (date_style != DateTimeStyle::kUndefined ||
time_style != DateTimeStyle::kUndefined) {
icu_date_format = DateTimeStylePattern(date_style, time_style, icu_locale,
hc, generator.get());
}
// 33. Else,
if (icu_date_format.get() == nullptr) {
bool has_hour_option = false;
......
......@@ -26,46 +26,8 @@ ACCESSORS(JSNumberFormat, icu_number_formatter,
kIcuNumberFormatterOffset)
ACCESSORS(JSNumberFormat, bound_format, Object, kBoundFormatOffset)
// Currenct ECMA 402 spec mandate to record (Min|Max)imumFractionDigits
// uncondictionally while the unified number proposal eventually will only
// record either (Min|Max)imumFractionDigits or (Min|Max)imumSignaficantDigits
// Since LocalizedNumberFormatter can only remember one set, and during
// 2019-1-17 ECMA402 meeting that the committee decide not to take a PR to
// address that prior to the unified number proposal, we have to add these two
// 5 bits int into flags to remember the (Min|Max)imumFractionDigits while
// (Min|Max)imumSignaficantDigits is present.
// TODO(ftang) remove the following once we ship int-number-format-unified
// * SMI_ACCESSORS of flags
// * Four inline functions: (set_)?(min|max)imum_fraction_digits
SMI_ACCESSORS(JSNumberFormat, flags, kFlagsOffset)
inline int JSNumberFormat::minimum_fraction_digits() const {
return MinimumFractionDigitsBits::decode(flags());
}
inline void JSNumberFormat::set_minimum_fraction_digits(int digits) {
DCHECK_GE(MinimumFractionDigitsBits::kMax, digits);
DCHECK_LE(0, digits);
DCHECK_GE(20, digits);
int hints = flags();
hints = MinimumFractionDigitsBits::update(hints, digits);
set_flags(hints);
}
inline int JSNumberFormat::maximum_fraction_digits() const {
return MaximumFractionDigitsBits::decode(flags());
}
inline void JSNumberFormat::set_maximum_fraction_digits(int digits) {
DCHECK_GE(MaximumFractionDigitsBits::kMax, digits);
DCHECK_LE(0, digits);
DCHECK_GE(20, digits);
int hints = flags();
hints = MaximumFractionDigitsBits::update(hints, digits);
set_flags(hints);
}
inline void JSNumberFormat::set_style(Style style) {
DCHECK_GE(StyleBits::kMax, style);
int hints = flags();
......
......@@ -33,7 +33,6 @@ namespace {
// [[CurrencyDisplay]] is one of the values "code", "symbol", "name",
// or "narrowSymbol" identifying the display of the currency number format.
// Note: "narrowSymbol" is added in proposal-unified-intl-numberformat
enum class CurrencyDisplay {
CODE,
SYMBOL,
......@@ -621,12 +620,11 @@ JSNumberFormat::SetDigitOptionsToFormatter(
result = result.integerWidth(icu::number::IntegerWidth::zeroFillTo(
digit_options.minimum_integer_digits));
}
if (FLAG_harmony_intl_numberformat_unified) {
// Value -1 of minimum_significant_digits represent the roundingtype is
// "compact-rounding".
if (digit_options.minimum_significant_digits < 0) {
return result;
}
// Value -1 of minimum_significant_digits represent the roundingtype is
// "compact-rounding".
if (digit_options.minimum_significant_digits < 0) {
return result;
}
icu::number::Precision precision =
(digit_options.minimum_significant_digits > 0)
......@@ -704,15 +702,12 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
isolate, options, factory->currencyDisplay_string(),
CurrencyDisplayString(isolate, skeleton), Just(kDontThrow))
.FromJust());
if (FLAG_harmony_intl_numberformat_unified) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->currencySign_string(),
CurrencySignString(isolate, skeleton), Just(kDontThrow))
.FromJust());
}
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->currencySign_string(),
CurrencySignString(isolate, skeleton), Just(kDontThrow))
.FromJust());
}
if (FLAG_harmony_intl_numberformat_unified) {
if (style == JSNumberFormat::Style::UNIT) {
std::string unit = UnitFromSkeleton(skeleton);
if (!unit.empty()) {
......@@ -727,7 +722,6 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
UnitDisplayString(isolate, skeleton), Just(kDontThrow))
.FromJust());
}
}
CHECK(
JSReceiver::CreateDataProperty(
......@@ -735,27 +729,9 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
factory->NewNumberFromInt(MinimumIntegerDigitsFromSkeleton(skeleton)),
Just(kDontThrow))
.FromJust());
int32_t minimum = 0, maximum = 0;
bool output_fraction =
FractionDigitsFromSkeleton(skeleton, &minimum, &maximum);
if (!FLAG_harmony_intl_numberformat_unified && !output_fraction) {
// Currenct ECMA 402 spec mandate to record (Min|Max)imumFractionDigits
// uncondictionally while the unified number proposal eventually will only
// record either (Min|Max)imumFractionDigits or
// (Min|Max)imumSignaficantDigits Since LocalizedNumberFormatter can only
// remember one set, and during 2019-1-17 ECMA402 meeting that the committee
// decide not to take a PR to address that prior to the unified number
// proposal, we have to add these two 5 bits int into flags to remember the
// (Min|Max)imumFractionDigits while (Min|Max)imumSignaficantDigits is
// present.
// TODO(ftang) remove the following two lines once we ship
// int-number-format-unified
output_fraction = true;
minimum = number_format->minimum_fraction_digits();
maximum = number_format->maximum_fraction_digits();
}
if (output_fraction) {
if (FractionDigitsFromSkeleton(skeleton, &minimum, &maximum)) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->minimumFractionDigits_string(),
factory->NewNumberFromInt(minimum), Just(kDontThrow))
......@@ -765,6 +741,7 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
factory->NewNumberFromInt(maximum), Just(kDontThrow))
.FromJust());
}
minimum = 0;
maximum = 0;
if (SignificantDigitsFromSkeleton(skeleton, &minimum, &maximum)) {
......@@ -783,24 +760,22 @@ Handle<JSObject> JSNumberFormat::ResolvedOptions(
factory->ToBoolean(UseGroupingFromSkeleton(skeleton)),
Just(kDontThrow))
.FromJust());
if (FLAG_harmony_intl_numberformat_unified) {
Notation notation = NotationFromSkeleton(skeleton);
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->notation_string(),
NotationAsString(isolate, notation), Just(kDontThrow))
.FromJust());
// Only output compactDisplay when notation is compact.
if (notation == Notation::COMPACT) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->compactDisplay_string(),
CompactDisplayString(isolate, skeleton), Just(kDontThrow))
.FromJust());
}
Notation notation = NotationFromSkeleton(skeleton);
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->notation_string(),
NotationAsString(isolate, notation), Just(kDontThrow))
.FromJust());
// Only output compactDisplay when notation is compact.
if (notation == Notation::COMPACT) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->signDisplay_string(),
SignDisplayString(isolate, skeleton), Just(kDontThrow))
isolate, options, factory->compactDisplay_string(),
CompactDisplayString(isolate, skeleton), Just(kDontThrow))
.FromJust());
}
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->signDisplay_string(),
SignDisplayString(isolate, skeleton), Just(kDontThrow))
.FromJust());
return options;
}
......@@ -877,7 +852,7 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
// 7. Let _numberingSystem_ be ? GetOption(_options_, `"numberingSystem"`,
// `"string"`, *undefined*, *undefined*).
Maybe<bool> maybe_numberingSystem = Intl::GetNumberingSystem(
isolate, options, "Intl.RelativeTimeFormat", &numbering_system_str);
isolate, options, service, &numbering_system_str);
// 8. If _numberingSystem_ is not *undefined*, then
// a. If _numberingSystem_ does not match the
// `(3*8alphanum) *("-" (3*8alphanum))` sequence, throw a *RangeError*
......@@ -913,20 +888,15 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
.roundingMode(UNUM_ROUND_HALFUP);
// 12. Let style be ? GetOption(options, "style", "string", « "decimal",
// "percent", "currency" », "decimal").
// "percent", "currency", "unit" », "decimal").
std::vector<const char*> style_str_values({"decimal", "percent", "currency"});
std::vector<JSNumberFormat::Style> style_enum_values(
{JSNumberFormat::Style::DECIMAL, JSNumberFormat::Style::PERCENT,
JSNumberFormat::Style::CURRENCY});
if (FLAG_harmony_intl_numberformat_unified) {
style_str_values.push_back("unit");
style_enum_values.push_back(JSNumberFormat::Style::UNIT);
}
Maybe<JSNumberFormat::Style> maybe_style =
Intl::GetStringOption<JSNumberFormat::Style>(
isolate, options, "style", service, style_str_values,
style_enum_values, JSNumberFormat::Style::DECIMAL);
isolate, options, "style", service,
{"decimal", "percent", "currency", "unit"},
{JSNumberFormat::Style::DECIMAL, JSNumberFormat::Style::PERCENT,
JSNumberFormat::Style::CURRENCY, JSNumberFormat::Style::UNIT},
JSNumberFormat::Style::DECIMAL);
MAYBE_RETURN(maybe_style, MaybeHandle<JSNumberFormat>());
JSNumberFormat::Style style = maybe_style.FromJust();
......@@ -976,98 +946,87 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
}
// 18. Let currencyDisplay be ? GetOption(options, "currencyDisplay",
// "string", « "code", "symbol", "name" », "symbol").
std::vector<const char*> currency_display_str_values(
{"code", "symbol", "name"});
std::vector<CurrencyDisplay> currency_display_enum_values(
{CurrencyDisplay::CODE, CurrencyDisplay::SYMBOL, CurrencyDisplay::NAME});
if (FLAG_harmony_intl_numberformat_unified) {
currency_display_str_values.push_back("narrowSymbol");
currency_display_enum_values.push_back(CurrencyDisplay::NARROW_SYMBOL);
}
// "string", « "code", "symbol", "name", "narrowSymbol" », "symbol").
Maybe<CurrencyDisplay> maybe_currency_display =
Intl::GetStringOption<CurrencyDisplay>(
isolate, options, "currencyDisplay", service,
currency_display_str_values, currency_display_enum_values,
{"code", "symbol", "name", "narrowSymbol"},
{CurrencyDisplay::CODE, CurrencyDisplay::SYMBOL,
CurrencyDisplay::NAME, CurrencyDisplay::NARROW_SYMBOL},
CurrencyDisplay::SYMBOL);
MAYBE_RETURN(maybe_currency_display, MaybeHandle<JSNumberFormat>());
CurrencyDisplay currency_display = maybe_currency_display.FromJust();
CurrencySign currency_sign = CurrencySign::STANDARD;
if (FLAG_harmony_intl_numberformat_unified) {
// Let currencySign be ? GetOption(options, "currencySign", "string", «
// "standard", "accounting" », "standard").
Maybe<CurrencySign> maybe_currency_sign =
Intl::GetStringOption<CurrencySign>(
isolate, options, "currencySign", service,
{"standard", "accounting"},
{CurrencySign::STANDARD, CurrencySign::ACCOUNTING},
CurrencySign::STANDARD);
MAYBE_RETURN(maybe_currency_sign, MaybeHandle<JSNumberFormat>());
currency_sign = maybe_currency_sign.FromJust();
// Let unit be ? GetOption(options, "unit", "string", undefined, undefined).
std::unique_ptr<char[]> unit_cstr;
Maybe<bool> found_unit = Intl::GetStringOption(
isolate, options, "unit", empty_values, service, &unit_cstr);
MAYBE_RETURN(found_unit, MaybeHandle<JSNumberFormat>());
std::string unit;
if (found_unit.FromJust()) {
DCHECK_NOT_NULL(unit_cstr.get());
unit = unit_cstr.get();
// Let currencySign be ? GetOption(options, "currencySign", "string", «
// "standard", "accounting" », "standard").
Maybe<CurrencySign> maybe_currency_sign = Intl::GetStringOption<CurrencySign>(
isolate, options, "currencySign", service, {"standard", "accounting"},
{CurrencySign::STANDARD, CurrencySign::ACCOUNTING},
CurrencySign::STANDARD);
MAYBE_RETURN(maybe_currency_sign, MaybeHandle<JSNumberFormat>());
currency_sign = maybe_currency_sign.FromJust();
// Let unit be ? GetOption(options, "unit", "string", undefined, undefined).
std::unique_ptr<char[]> unit_cstr;
Maybe<bool> found_unit = Intl::GetStringOption(
isolate, options, "unit", empty_values, service, &unit_cstr);
MAYBE_RETURN(found_unit, MaybeHandle<JSNumberFormat>());
std::string unit;
if (found_unit.FromJust()) {
DCHECK_NOT_NULL(unit_cstr.get());
unit = unit_cstr.get();
}
// Let unitDisplay be ? GetOption(options, "unitDisplay", "string", «
// "short", "narrow", "long" », "short").
Maybe<UnitDisplay> maybe_unit_display = Intl::GetStringOption<UnitDisplay>(
isolate, options, "unitDisplay", service, {"short", "narrow", "long"},
{UnitDisplay::SHORT, UnitDisplay::NARROW, UnitDisplay::LONG},
UnitDisplay::SHORT);
MAYBE_RETURN(maybe_unit_display, MaybeHandle<JSNumberFormat>());
UnitDisplay unit_display = maybe_unit_display.FromJust();
// If style is "unit", then
if (style == JSNumberFormat::Style::UNIT) {
// If unit is undefined, throw a TypeError exception.
if (unit == "") {
THROW_NEW_ERROR(isolate,
NewTypeError(MessageTemplate::kInvalidUnit,
factory->NewStringFromAsciiChecked(service),
factory->empty_string()),
JSNumberFormat);
}
// Let unitDisplay be ? GetOption(options, "unitDisplay", "string", «
// "short", "narrow", "long" », "short").
Maybe<UnitDisplay> maybe_unit_display = Intl::GetStringOption<UnitDisplay>(
isolate, options, "unitDisplay", service, {"short", "narrow", "long"},
{UnitDisplay::SHORT, UnitDisplay::NARROW, UnitDisplay::LONG},
UnitDisplay::SHORT);
MAYBE_RETURN(maybe_unit_display, MaybeHandle<JSNumberFormat>());
UnitDisplay unit_display = maybe_unit_display.FromJust();
// If style is "unit", then
if (style == JSNumberFormat::Style::UNIT) {
// If unit is undefined, throw a TypeError exception.
if (unit == "") {
THROW_NEW_ERROR(
isolate,
NewTypeError(MessageTemplate::kInvalidUnit,
factory->NewStringFromAsciiChecked(service),
factory->empty_string()),
JSNumberFormat);
}
// If the result of IsWellFormedUnitIdentifier(unit) is false, throw a
// RangeError exception.
Maybe<std::pair<icu::MeasureUnit, icu::MeasureUnit>> maybe_wellformed =
IsWellFormedUnitIdentifier(isolate, unit);
if (maybe_wellformed.IsNothing()) {
THROW_NEW_ERROR(
isolate,
NewRangeError(MessageTemplate::kInvalidUnit,
factory->NewStringFromAsciiChecked(service),
factory->NewStringFromAsciiChecked(unit.c_str())),
JSNumberFormat);
}
std::pair<icu::MeasureUnit, icu::MeasureUnit> unit_pair =
maybe_wellformed.FromJust();
// If the result of IsWellFormedUnitIdentifier(unit) is false, throw a
// RangeError exception.
Maybe<std::pair<icu::MeasureUnit, icu::MeasureUnit>> maybe_wellformed =
IsWellFormedUnitIdentifier(isolate, unit);
if (maybe_wellformed.IsNothing()) {
THROW_NEW_ERROR(
isolate,
NewRangeError(MessageTemplate::kInvalidUnit,
factory->NewStringFromAsciiChecked(service),
factory->NewStringFromAsciiChecked(unit.c_str())),
JSNumberFormat);
}
std::pair<icu::MeasureUnit, icu::MeasureUnit> unit_pair =
maybe_wellformed.FromJust();
// Set intlObj.[[Unit]] to unit.
if (unit_pair.first != icu::NoUnit::base()) {
icu_number_formatter = icu_number_formatter.unit(unit_pair.first);
}
if (unit_pair.second != icu::NoUnit::base()) {
icu_number_formatter = icu_number_formatter.perUnit(unit_pair.second);
}
// Set intlObj.[[Unit]] to unit.
if (unit_pair.first != icu::NoUnit::base()) {
icu_number_formatter = icu_number_formatter.unit(unit_pair.first);
}
if (unit_pair.second != icu::NoUnit::base()) {
icu_number_formatter = icu_number_formatter.perUnit(unit_pair.second);
}
// The default unitWidth is SHORT in ICU and that mapped from
// Symbol so we can skip the setting for optimization.
if (unit_display != UnitDisplay::SHORT) {
icu_number_formatter =
icu_number_formatter.unitWidth(ToUNumberUnitWidth(unit_display));
}
// The default unitWidth is SHORT in ICU and that mapped from
// Symbol so we can skip the setting for optimization.
if (unit_display != UnitDisplay::SHORT) {
icu_number_formatter =
icu_number_formatter.unitWidth(ToUNumberUnitWidth(unit_display));
}
}
......@@ -1123,18 +1082,16 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
}
Notation notation = Notation::STANDARD;
if (FLAG_harmony_intl_numberformat_unified) {
// 25. Let notation be ? GetOption(options, "notation", "string", «
// "standard", "scientific", "engineering", "compact" », "standard").
Maybe<Notation> maybe_notation = Intl::GetStringOption<Notation>(
isolate, options, "notation", service,
{"standard", "scientific", "engineering", "compact"},
{Notation::STANDARD, Notation::SCIENTIFIC, Notation::ENGINEERING,
Notation::COMPACT},
Notation::STANDARD);
MAYBE_RETURN(maybe_notation, MaybeHandle<JSNumberFormat>());
notation = maybe_notation.FromJust();
}
// 25. Let notation be ? GetOption(options, "notation", "string", «
// "standard", "scientific", "engineering", "compact" », "standard").
Maybe<Notation> maybe_notation = Intl::GetStringOption<Notation>(
isolate, options, "notation", service,
{"standard", "scientific", "engineering", "compact"},
{Notation::STANDARD, Notation::SCIENTIFIC, Notation::ENGINEERING,
Notation::COMPACT},
Notation::STANDARD);
MAYBE_RETURN(maybe_notation, MaybeHandle<JSNumberFormat>());
notation = maybe_notation.FromJust();
// 27. Perform ? SetNumberFormatDigitOptions(numberFormat, options,
// mnfdDefault, mxfdDefault).
......@@ -1147,24 +1104,21 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
icu_number_formatter = JSNumberFormat::SetDigitOptionsToFormatter(
icu_number_formatter, digit_options);
if (FLAG_harmony_intl_numberformat_unified) {
// 28. Let compactDisplay be ? GetOption(options, "compactDisplay",
// "string", « "short", "long" », "short").
Maybe<CompactDisplay> maybe_compact_display =
Intl::GetStringOption<CompactDisplay>(
isolate, options, "compactDisplay", service, {"short", "long"},
{CompactDisplay::SHORT, CompactDisplay::LONG},
CompactDisplay::SHORT);
MAYBE_RETURN(maybe_compact_display, MaybeHandle<JSNumberFormat>());
CompactDisplay compact_display = maybe_compact_display.FromJust();
// 26. Set numberFormat.[[Notation]] to notation.
// The default notation in ICU is Simple, which mapped from STANDARD
// so we can skip setting it.
if (notation != Notation::STANDARD) {
icu_number_formatter = icu_number_formatter.notation(
ToICUNotation(notation, compact_display));
}
// 28. Let compactDisplay be ? GetOption(options, "compactDisplay",
// "string", « "short", "long" », "short").
Maybe<CompactDisplay> maybe_compact_display =
Intl::GetStringOption<CompactDisplay>(
isolate, options, "compactDisplay", service, {"short", "long"},
{CompactDisplay::SHORT, CompactDisplay::LONG}, CompactDisplay::SHORT);
MAYBE_RETURN(maybe_compact_display, MaybeHandle<JSNumberFormat>());
CompactDisplay compact_display = maybe_compact_display.FromJust();
// 26. Set numberFormat.[[Notation]] to notation.
// The default notation in ICU is Simple, which mapped from STANDARD
// so we can skip setting it.
if (notation != Notation::STANDARD) {
icu_number_formatter =
icu_number_formatter.notation(ToICUNotation(notation, compact_display));
}
// 30. Let useGrouping be ? GetOption(options, "useGrouping", "boolean",
// undefined, true).
......@@ -1178,27 +1132,25 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
UNumberGroupingStrategy::UNUM_GROUPING_OFF);
}
if (FLAG_harmony_intl_numberformat_unified) {
// 32. Let signDisplay be ? GetOption(options, "signDisplay", "string", «
// "auto", "never", "always", "exceptZero" », "auto").
Maybe<SignDisplay> maybe_sign_display = Intl::GetStringOption<SignDisplay>(
isolate, options, "signDisplay", service,
{"auto", "never", "always", "exceptZero"},
{SignDisplay::AUTO, SignDisplay::NEVER, SignDisplay::ALWAYS,
SignDisplay::EXCEPT_ZERO},
SignDisplay::AUTO);
MAYBE_RETURN(maybe_sign_display, MaybeHandle<JSNumberFormat>());
SignDisplay sign_display = maybe_sign_display.FromJust();
// 33. Set numberFormat.[[SignDisplay]] to signDisplay.
// The default sign in ICU is UNUM_SIGN_AUTO which is mapped from
// SignDisplay::AUTO and CurrencySign::STANDARD so we can skip setting
// under that values for optimization.
if (sign_display != SignDisplay::AUTO ||
currency_sign != CurrencySign::STANDARD) {
icu_number_formatter = icu_number_formatter.sign(
ToUNumberSignDisplay(sign_display, currency_sign));
}
// 32. Let signDisplay be ? GetOption(options, "signDisplay", "string", «
// "auto", "never", "always", "exceptZero" », "auto").
Maybe<SignDisplay> maybe_sign_display = Intl::GetStringOption<SignDisplay>(
isolate, options, "signDisplay", service,
{"auto", "never", "always", "exceptZero"},
{SignDisplay::AUTO, SignDisplay::NEVER, SignDisplay::ALWAYS,
SignDisplay::EXCEPT_ZERO},
SignDisplay::AUTO);
MAYBE_RETURN(maybe_sign_display, MaybeHandle<JSNumberFormat>());
SignDisplay sign_display = maybe_sign_display.FromJust();
// 33. Set numberFormat.[[SignDisplay]] to signDisplay.
// The default sign in ICU is UNUM_SIGN_AUTO which is mapped from
// SignDisplay::AUTO and CurrencySign::STANDARD so we can skip setting
// under that values for optimization.
if (sign_display != SignDisplay::AUTO ||
currency_sign != CurrencySign::STANDARD) {
icu_number_formatter = icu_number_formatter.sign(
ToUNumberSignDisplay(sign_display, currency_sign));
}
// 25. Let dataLocaleData be localeData.[[<dataLocale>]].
......@@ -1229,24 +1181,6 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
number_format->set_style(style);
number_format->set_locale(*locale_str);
if (digit_options.minimum_significant_digits > 0) {
// The current ECMA 402 spec mandates recording (Min|Max)imumFractionDigits
// unconditionally, while the unified number proposal eventually will only
// record either (Min|Max)imumFractionDigits or
// (Min|Max)imumSignificantDigits. Since LocalizedNumberFormatter can only
// remember one set, and during 2019-1-17 ECMA402 meeting the committee
// decided not to take a PR to address that prior to the unified number
// proposal, we have to add these two 5-bit ints into flags to remember the
// (Min|Max)imumFractionDigits while (Min|Max)imumSignificantDigits is
// present.
// TODO(ftang) remove the following two lines once we ship
// int-number-format-unified
number_format->set_minimum_fraction_digits(
digit_options.minimum_fraction_digits);
number_format->set_maximum_fraction_digits(
digit_options.maximum_fraction_digits);
}
number_format->set_icu_number_formatter(*managed_number_formatter);
number_format->set_bound_format(*factory->undefined_value());
......
......@@ -72,26 +72,6 @@ class JSNumberFormat : public JSObject {
DECL_PRINTER(JSNumberFormat)
DECL_VERIFIER(JSNumberFormat)
// Current ECMA 402 spec mandates to record (Min|Max)imumFractionDigits
// unconditionally while the unified number proposal eventually will only
// record either (Min|Max)imumFractionDigits or (Min|Max)imumSignaficantDigits
// Since LocalizedNumberFormatter can only remember one set, and during
// 2019-1-17 ECMA402 meeting that the committee decide not to take a PR to
// address that prior to the unified number proposal, we have to add these two
// 5 bits int into flags to remember the (Min|Max)imumFractionDigits while
// (Min|Max)imumSignaficantDigits is present.
// TODO(ftang) remove the following once we ship int-number-format-unified
// * Four inline functions: (set_)?(min|max)imum_fraction_digits
// * kFlagsOffset
// * #define FLAGS_BIT_FIELDS
// * DECL_INT_ACCESSORS(flags)
inline int minimum_fraction_digits() const;
inline void set_minimum_fraction_digits(int digits);
inline int maximum_fraction_digits() const;
inline void set_maximum_fraction_digits(int digits);
// [[Style]] is one of the values "decimal", "percent", "currency",
// or "unit" identifying the style of the number format.
// Note: "unit" is added in proposal-unified-intl-numberformat
......@@ -106,15 +86,11 @@ class JSNumberFormat : public JSObject {
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) \
V(MinimumFractionDigitsBits, int, 5, _) \
V(MaximumFractionDigitsBits, int, 5, _) \
V(StyleBits, Style, 2, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
STATIC_ASSERT(20 <= MinimumFractionDigitsBits::kMax);
STATIC_ASSERT(20 <= MaximumFractionDigitsBits::kMax);
STATIC_ASSERT(Style::DECIMAL <= StyleBits::kMax);
STATIC_ASSERT(Style::PERCENT <= StyleBits::kMax);
STATIC_ASSERT(Style::CURRENCY <= StyleBits::kMax);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-bigint
var locales = [
"en", // "1,234,567,890,123,456"
"de", // "1.234.567.890.123.456"
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-datetime-style
// Throws only once during construction.
// Check for all getters to prevent regression.
// Preserve the order of getter initialization.
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-datetime-style
// Throws only once during construction.
// Check for all getters to prevent regression.
// Preserve the order of getter initialization.
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-datetime-style
var validStyle = ["full", "long", "medium", "short", undefined];
var invalidStyle = ["narrow", "numeric"];
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-datetime-style
// Throws only once during construction.
// Check for all getters to prevent regression.
// Preserve the order of getter initialization.
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-datetime-style
// Throws only once during construction.
// Check for all getters to prevent regression.
// Preserve the order of getter initialization.
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-date-format-range
const date1 = new Date("2019-01-03T03:20");
const date2 = new Date("2019-01-05T19:33");
const date3 = new Date("2019-01-05T22:57");
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-date-format-range
let descriptor = Object.getOwnPropertyDescriptor(
Intl.DateTimeFormat.prototype, "formatRangeToParts");
assertTrue(descriptor.writable);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-date-format-range
let descriptor = Object.getOwnPropertyDescriptor(
Intl.DateTimeFormat.prototype, "formatRange");
assertTrue(descriptor.writable);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-datetime-style
// Checks for security holes introduced by Object.property overrides.
// For example:
// Object.defineProperty(Array.prototype, 'locale', {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-datetime-style
// Checks for security holes introduced by Object.property overrides.
// For example:
// Object.defineProperty(Array.prototype, 'locale', {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-datetime-style
// Checks for security holes introduced by Object.property overrides.
// For example:
// Object.defineProperty(Array.prototype, 'locale', {
......
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Checks for security holes introduced by Object.property overrides.
// For example:
// Object.defineProperty(Array.prototype, 'locale', {
// set: function(value) {
// throw new Error('blah');
// },
// configurable: true,
// enumerable: false
// });
//
// would throw in case of (JS) x.locale = 'us' or (C++) x->Set('locale', 'us').
//
// Update both number-format.js and number-format.cc so they have the same
// list of properties.
// Flags: --noharmony-intl-numberformat-unified
// First get supported properties.
var properties = [];
// Some properties are optional and won't show up in resolvedOptions if
// they were not requested - currency, currencyDisplay,
// minimumSignificantDigits and maximumSignificantDigits - so we request them.
var options = Intl.NumberFormat(
undefined, {style: 'currency', currency: 'USD', currencyDisplay: 'name',
minimumSignificantDigits: 1, maximumSignificantDigits: 5}).
resolvedOptions();
for (var prop in options) {
if (options.hasOwnProperty(prop)) {
properties.push(prop);
}
}
var expectedProperties = [
'style', 'locale', 'numberingSystem',
'currency', 'currencyDisplay', 'useGrouping',
'minimumIntegerDigits', 'minimumFractionDigits',
'maximumFractionDigits', 'minimumSignificantDigits',
'maximumSignificantDigits'
];
assertEquals(expectedProperties.length, properties.length);
properties.forEach(function(prop) {
assertFalse(expectedProperties.indexOf(prop) === -1);
});
taintProperties(properties);
var locale = Intl.NumberFormat(undefined,
{currency: 'USD', currencyDisplay: 'name',
minimumIntegerDigits: 2,
numberingSystem: 'latn'}).
resolvedOptions().locale;
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
const testData = [
["short"],
["long"],
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Similar to constructor-order.js but also consider the new options
// in https://tc39-transfer.github.io/proposal-unified-intl-numberformat/
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test defaults
let nf = new Intl.NumberFormat();
assertEquals(undefined, nf.resolvedOptions().currencyDisplay);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test default.
let nf = new Intl.NumberFormat();
assertEquals(undefined, nf.resolvedOptions().currencySign);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Except when the notation is "compact", the resolvedOptions().compactDisplay
// should be undefined.
//
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test notation: "engineering" with formatToParts.
const nf = Intl.NumberFormat("en", {notation: "engineering"});
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test notation: "scientific" with formatToParts.
const nf = Intl.NumberFormat("en", {notation: "scientific"});
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test defaults.
let nf = new Intl.NumberFormat();
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
//
// Test the handling of "percent" w/ "unit"
let nf1 = new Intl.NumberFormat("en-US", {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test default.
let nf = new Intl.NumberFormat();
assertEquals("auto", nf.resolvedOptions().signDisplay);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test default.
let nf = new Intl.NumberFormat();
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test default.
let nf = new Intl.NumberFormat();
assertEquals(undefined, nf.resolvedOptions().unitDisplay);
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test precision of compact-rounding
let compact = {notation: "compact"};
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test format of all valid units won't throw exception.
let validList = [
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-numberformat-unified
// Test Infinity, -Infinity, NaN won't crash with any notation in formatToParts.
let validNotations = [
......
......@@ -44,16 +44,12 @@ from testrunner.outproc import test262
# TODO(littledan): move the flag mapping into the status file
FEATURE_FLAGS = {
'Intl.DateTimeFormat-datetimestyle': '--harmony-intl-datetime-style',
'Intl.DateTimeFormat-formatRange': '--harmony-intl-date-format-range',
'Intl.NumberFormat-unified': '--harmony-intl-numberformat-unified',
'Intl.Segmenter': '--harmony-intl-segmenter',
'Intl.DateTimeFormat-dayPeriod': '--harmony-intl-dateformat-day-period',
'Intl.DateTimeFormat-quarter': '--harmony-intl-dateformat-quarter',
'Intl.DateTimeFormat-fractionalSecondDigits': '--harmony-intl-dateformat-fractional-second-digits',
'Symbol.prototype.description': '--harmony-symbol-description',
'export-star-as-namespace-from-module': '--harmony-namespace-exports',
'BigInt': '--harmony-intl-bigint',
'Promise.allSettled': '--harmony-promise-all-settled',
'FinalizationGroup': '--harmony-weak-refs',
'WeakRef': '--harmony-weak-refs',
......
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