[Intl] Remove DateTimeFormat order check not throw RangeError
TC39 2022-07-22 decided to take PR701 to skip order check on DateTimeFormat formatRange and formatRangeToParts See https://github.com/tc39/ecma402/pull/701 https://docs.google.com/presentation/d/1UUvbf3FFu9PGtrPAKPdMad9DZuVFLIvkAsAxyJZyvxM for details. Bug: v8:13094 Change-Id: I9ade938726f2a79e0ab2b5deb7fe36c001f2722f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3779042 Reviewed-by: Shu-yu Guo <syg@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/main@{#81985}
This commit is contained in:
parent
830fb81730
commit
d2f11a7403
@ -160,23 +160,10 @@ template <class T, MaybeHandle<T> (*F)(Isolate*, Handle<JSDateTimeFormat>,
|
||||
V8_WARN_UNUSED_RESULT Object DateTimeFormatRange(
|
||||
BuiltinArguments args, Isolate* isolate, const char* const method_name) {
|
||||
// 1. Let dtf be this value.
|
||||
// 2. If Type(dtf) is not Object, throw a TypeError exception.
|
||||
CHECK_RECEIVER(JSObject, date_format_holder, method_name);
|
||||
// 2. Perform ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]).
|
||||
CHECK_RECEIVER(JSDateTimeFormat, dtf, method_name);
|
||||
|
||||
Factory* factory = isolate->factory();
|
||||
|
||||
// 3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot,
|
||||
// throw a TypeError exception.
|
||||
if (!date_format_holder->IsJSDateTimeFormat()) {
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
|
||||
factory->NewStringFromAsciiChecked(method_name),
|
||||
date_format_holder));
|
||||
}
|
||||
Handle<JSDateTimeFormat> dtf =
|
||||
Handle<JSDateTimeFormat>::cast(date_format_holder);
|
||||
|
||||
// 4. If startDate is undefined or endDate is undefined, throw a TypeError
|
||||
// 3. If startDate is undefined or endDate is undefined, throw a TypeError
|
||||
// exception.
|
||||
Handle<Object> start_date = args.atOrUndefined(isolate, 1);
|
||||
Handle<Object> end_date = args.atOrUndefined(isolate, 2);
|
||||
@ -184,24 +171,19 @@ V8_WARN_UNUSED_RESULT Object DateTimeFormatRange(
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError(MessageTemplate::kInvalidTimeValue));
|
||||
}
|
||||
// 5. Let x be ? ToNumber(startDate).
|
||||
// 4. Let x be ? ToNumber(startDate).
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, start_date,
|
||||
Object::ToNumber(isolate, start_date));
|
||||
double x = start_date->Number();
|
||||
|
||||
// 6. Let y be ? ToNumber(endDate).
|
||||
// 5. Let y be ? ToNumber(endDate).
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, end_date,
|
||||
Object::ToNumber(isolate, end_date));
|
||||
double y = end_date->Number();
|
||||
// 7. If x is greater than y, throw a RangeError exception.
|
||||
if (x > y) {
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewRangeError(MessageTemplate::kInvalidTimeValue));
|
||||
}
|
||||
|
||||
// 8. Return ? FormatDateTimeRange(dtf, x, y)
|
||||
// 6. Return ? FormatDateTimeRange(dtf, x, y)
|
||||
// OR
|
||||
// 8. Return ? FormatDateTimeRangeToParts(dtf, x, y).
|
||||
// 6. Return ? FormatDateTimeRangeToParts(dtf, x, y).
|
||||
RETURN_RESULT_OR_FAILURE(isolate, F(isolate, dtf, x, y));
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ assertThrows(() => dtf.formatRangeToParts(undefined, date2), TypeError);
|
||||
assertThrows(() => dtf.formatRangeToParts(date1, undefined), TypeError);
|
||||
assertThrows(() => dtf.formatRangeToParts("2019-1-3", date2), RangeError);
|
||||
assertThrows(() => dtf.formatRangeToParts(date1, "2019-5-4"), RangeError);
|
||||
assertThrows(() => dtf.formatRangeToParts(date2, date1), RangeError);
|
||||
|
||||
assertDoesNotThrow(() =>dtf.formatRangeToParts(date2, date1));
|
||||
assertDoesNotThrow(() =>dtf.formatRangeToParts(date1, date2));
|
||||
|
||||
function partsToString(parts) {
|
||||
|
@ -19,8 +19,8 @@ assertThrows(() => dtf.formatRange(undefined, date2), TypeError);
|
||||
assertThrows(() => dtf.formatRange(date1, undefined), TypeError);
|
||||
assertThrows(() => dtf.formatRange("2019-1-3", date2), RangeError);
|
||||
assertThrows(() => dtf.formatRange(date1, "2019-5-4"), RangeError);
|
||||
assertThrows(() => dtf.formatRange(date2, date1), RangeError);
|
||||
|
||||
assertDoesNotThrow(() =>dtf.formatRange(date2, date1));
|
||||
assertDoesNotThrow(() =>dtf.formatRange(date1, date2));
|
||||
|
||||
assertEquals("1/3/2019 – 1/5/2019", dtf.formatRange(date1, date2));
|
||||
|
@ -969,6 +969,10 @@
|
||||
'built-ins/Temporal/PlainTime/prototype/equals/argument-string-no-implicit-midnight': [FAIL],
|
||||
'harness/temporalHelpers-one-shift-time-zone': [SKIP],
|
||||
|
||||
# https://github.com/tc39/test262/pull/3609
|
||||
'intl402/DateTimeFormat/prototype/formatRange/date-x-greater-than-y-throws': [FAIL],
|
||||
'intl402/DateTimeFormat/prototype/formatRangeToParts/date-x-greater-than-y-throws': [FAIL],
|
||||
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=11660
|
||||
'intl402/DurationFormat/prototype/prototype_attributes': [FAIL],
|
||||
'intl402/DurationFormat/prototype/constructor/prop-desc': [FAIL],
|
||||
|
Loading…
Reference in New Issue
Block a user