mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibJS: Convert errant MUST to TRY in Temporal.PlainDateTime.with
This commit is contained in:
committed by
Andreas Kling
parent
c3fc8996bf
commit
d5b26183f3
@@ -289,7 +289,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with)
|
|||||||
auto result = TRY(interpret_temporal_date_time_fields(vm, calendar, fields, overflow));
|
auto result = TRY(interpret_temporal_date_time_fields(vm, calendar, fields, overflow));
|
||||||
|
|
||||||
// 17. Return ? CreateTemporalDateTime(result, calendar).
|
// 17. Return ? CreateTemporalDateTime(result, calendar).
|
||||||
return MUST(create_temporal_date_time(vm, result, calendar));
|
return TRY(create_temporal_date_time(vm, result, calendar));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5.3.26 Temporal.PlainDateTime.prototype.withPlainTime ( [ plainTimeLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.withplaintime
|
// 5.3.26 Temporal.PlainDateTime.prototype.withPlainTime ( [ plainTimeLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.withplaintime
|
||||||
|
|||||||
@@ -80,4 +80,12 @@ describe("errors", () => {
|
|||||||
new Temporal.PlainDateTime(1970, 1, 1).with({ timeZone: {} });
|
new Temporal.PlainDateTime(1970, 1, 1).with({ timeZone: {} });
|
||||||
}).toThrowWithMessage(TypeError, "Object must be a partial Temporal object");
|
}).toThrowWithMessage(TypeError, "Object must be a partial Temporal object");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("invalid ISO date range", () => {
|
||||||
|
const plainDateTime = new Temporal.PlainDateTime(-271821, 4, 19, 0, 0, 0, 0, 0, 1);
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
plainDateTime.with({ nanosecond: 0 });
|
||||||
|
}).toThrowWithMessage(RangeError, "Invalid plain date time");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user