Commit 81f864bf authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

Use TypeError instead of RangeError

Reflect recent change to the proposal

http://tc39.es/proposal-intl-DateTimeFormat-formatRange/#sec-intl.datetimeformat.prototype.formatRange

Bug: v8:10681
Change-Id: Ie2e0e85816aeaeb2615d482ccd3ea345a5056c93
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2286813
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68748}
parent c2373c46
......@@ -176,13 +176,13 @@ V8_WARN_UNUSED_RESULT Object DateTimeFormatRange(
Handle<JSDateTimeFormat> dtf =
Handle<JSDateTimeFormat>::cast(date_format_holder);
// 4. If startDate is undefined or endDate is undefined, throw a RangeError
// 4. 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);
if (start_date->IsUndefined(isolate) || end_date->IsUndefined(isolate)) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError(MessageTemplate::kInvalidTimeValue));
isolate, NewTypeError(MessageTemplate::kInvalidTimeValue));
}
// 5. Let x be ? ToNumber(startDate).
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, start_date,
......
......@@ -13,10 +13,10 @@ const date2 = new Date("2019-1-5");
const date3 = new Date("2019-3-4");
const date4 = new Date("2020-3-4");
let dtf = new Intl.DateTimeFormat();
assertThrows(() => dtf.formatRangeToParts(), RangeError);
assertThrows(() => dtf.formatRangeToParts(date1), RangeError);
assertThrows(() => dtf.formatRangeToParts(undefined, date2), RangeError);
assertThrows(() => dtf.formatRangeToParts(date1, undefined), RangeError);
assertThrows(() => dtf.formatRangeToParts(), TypeError);
assertThrows(() => dtf.formatRangeToParts(date1), TypeError);
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);
......
......@@ -13,10 +13,10 @@ const date2 = new Date("2019-1-5");
const date3 = new Date("2019-3-4");
const date4 = new Date("2020-3-4");
var dtf = new Intl.DateTimeFormat(["en"]);
assertThrows(() => dtf.formatRange(), RangeError);
assertThrows(() => dtf.formatRange(date1), RangeError);
assertThrows(() => dtf.formatRange(undefined, date2), RangeError);
assertThrows(() => dtf.formatRange(date1, undefined), RangeError);
assertThrows(() => dtf.formatRange(), TypeError);
assertThrows(() => dtf.formatRange(date1), TypeError);
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);
......
......@@ -668,10 +668,6 @@
# https://crbug.com/v8/10686
'intl402/DateTimeFormat/constructor-options-fractionalSecondDigits-valid': [FAIL],
# https://crbug.com/v8/10681
'intl402/DateTimeFormat/prototype/formatRange/date-undefined-throws': [FAIL],
'intl402/DateTimeFormat/prototype/formatRangeToParts/date-undefined-throws': [FAIL],
######################## NEEDS INVESTIGATION ###########################
# https://bugs.chromium.org/p/v8/issues/detail?id=7833
......
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