[Temporal] Sync PR 2297 change ToSecondsStringPrecision

Validate fractionalSecondDigits after truncation

https://github.com/tc39/proposal-temporal/pull/2297

Spec text:
https://tc39.es/proposal-temporal/#sec-temporal-tosecondsstringprecision

Bug: v8:11544
Change-Id: I648f087f4fa2cfd6245c7946cfa625a7c5e3b3b9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3855702
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82801}
This commit is contained in:
Frank Tang 2022-08-29 20:24:15 -07:00 committed by V8 LUCI CQ
parent a7c7c4dc12
commit 0f901f00e8
2 changed files with 5 additions and 10 deletions

View File

@ -15698,18 +15698,18 @@ Maybe<StringPrecision> ToSecondsStringPrecision(
factory->fractionalSecondDigits_string()),
Nothing<StringPrecision>());
}
// 12. If (fractionalDigitsVal) < 0 or (fractionalDigitsVal) > 9, throw a
// 12. Let fractionalDigitCount be RoundTowardsZero((fractionalDigitsVal)).
int64_t fractional_digit_count =
RoundTowardsZero(fractional_digits_val->Number());
// 13. If fractionalDigitCount < 0 or fractionalDigitCount > 9, throw a
// RangeError exception.
if (fractional_digits_val->Number() < 0 ||
fractional_digits_val->Number() > 9) {
if (fractional_digit_count < 0 || fractional_digit_count > 9) {
THROW_NEW_ERROR_RETURN_VALUE(
isolate,
NewRangeError(MessageTemplate::kPropertyValueOutOfRange,
factory->fractionalSecondDigits_string()),
Nothing<StringPrecision>());
}
// 13. Let fractionalDigitCount be floor((fractionalDigitsVal)).
int32_t fractional_digit_count = std::floor(fractional_digits_val->Number());
// 14. If fractionalDigitCount is 0, then
switch (fractional_digit_count) {
case 0:

View File

@ -685,14 +685,9 @@
'intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition': [FAIL],
'intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'built-ins/Temporal/Instant/prototype/add/minimum-maximum-instant': [FAIL],
'built-ins/Temporal/Instant/prototype/subtract/minimum-maximum-instant': [FAIL],
'built-ins/Temporal/Instant/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'built-ins/Temporal/PlainMonthDay/refisoyear-out-of-range': [FAIL],
'built-ins/Temporal/PlainTime/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'intl402/Temporal/TimeZone/from/etc-timezone': [FAIL],
'intl402/Temporal/TimeZone/from/iana-legacy-names': [FAIL],
'intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries': [FAIL],