1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

LibJS: Fix parse ErrorType used in parse_temporal_date_string()

TemporalInvalidDateString, not TemporalInvalidDateTimeString.
This commit is contained in:
Linus Groh 2021-11-24 08:38:50 +00:00
parent b6f49924be
commit 836ce8ee5d
2 changed files with 7 additions and 1 deletions

View file

@ -1269,7 +1269,7 @@ ThrowCompletionOr<TemporalDate> parse_temporal_date_string(GlobalObject& global_
auto parse_result = parse_iso8601(Production::TemporalDateString, iso_string); auto parse_result = parse_iso8601(Production::TemporalDateString, iso_string);
if (!parse_result.has_value()) { if (!parse_result.has_value()) {
// a. Throw a RangeError exception. // a. Throw a RangeError exception.
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDateTimeString, iso_string); return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDateString, iso_string);
} }
// 3. Let result be ? ParseISODateTime(isoString). // 3. Let result be ? ParseISODateTime(isoString).

View file

@ -43,4 +43,10 @@ describe("errors", () => {
Temporal.PlainDate.from(zonedDateTime); Temporal.PlainDate.from(zonedDateTime);
}).toThrowWithMessage(TypeError, "null is not a function"); }).toThrowWithMessage(TypeError, "null is not a function");
}); });
test("invalid date string", () => {
expect(() => {
Temporal.PlainDate.from("foo");
}).toThrowWithMessage(RangeError, "Invalid date string 'foo'");
});
}); });