From 85e384960c27406aac93d88bcffcbe80a1020e9a Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Tue, 4 Oct 2022 02:37:08 -0700 Subject: [PATCH] [Temporal] Sync Rounding Mode Sync to PR https://github.com/tc39/proposal-temporal/pull/2262 add "expand", "halfCeil", "halfFloor", "halfTrunc", and "halfEven"* rounding mode. Bug: v8:11544 Change-Id: I8f7787a2d0743acc6a3b1ad43f370089ce405b8b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3933576 Reviewed-by: Adam Klein Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/main@{#83523} --- src/objects/js-temporal-objects.cc | 21 ++++-- test/test262/test262.status | 101 ----------------------------- 2 files changed, 17 insertions(+), 105 deletions(-) diff --git a/src/objects/js-temporal-objects.cc b/src/objects/js-temporal-objects.cc index e1a53e00d1..9c7c9e0c2b 100644 --- a/src/objects/js-temporal-objects.cc +++ b/src/objects/js-temporal-objects.cc @@ -392,11 +392,18 @@ Maybe ToTemporalRoundingMode(Isolate* isolate, Handle options, RoundingMode fallback, const char* method_name) { + // 1. Return ? GetOption(normalizedOptions, "roundingMode", "string", « + // "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", + // "halfTrunc", "halfEven" », fallback). + return GetStringOption( isolate, options, "roundingMode", method_name, - {"ceil", "floor", "trunc", "halfExpand"}, - {RoundingMode::kCeil, RoundingMode::kFloor, RoundingMode::kTrunc, - RoundingMode::kHalfExpand}, + {"ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", + "halfExpand", "halfTrunc", "halfEven"}, + {RoundingMode::kCeil, RoundingMode::kFloor, RoundingMode::kExpand, + RoundingMode::kTrunc, RoundingMode::kHalfCeil, RoundingMode::kHalfFloor, + RoundingMode::kHalfExpand, RoundingMode::kHalfTrunc, + RoundingMode::kHalfEven}, fallback); } @@ -18414,7 +18421,13 @@ RoundingMode NegateTemporalRoundingMode(RoundingMode rounding_mode) { // 2. If roundingMode is "floor", return "ceil". case RoundingMode::kFloor: return RoundingMode::kCeil; - // 3. Return roundingMode. + // 3. If roundingMode is "halfCeil", return "halfFloor". + case RoundingMode::kHalfCeil: + return RoundingMode::kHalfFloor; + // 4. If roundingMode is "halfFloor", return "halfCeil". + case RoundingMode::kHalfFloor: + return RoundingMode::kHalfCeil; + // 5. Return roundingMode. default: return rounding_mode; } diff --git a/test/test262/test262.status b/test/test262/test262.status index d537f53947..3246e9055b 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -553,127 +553,26 @@ 'built-ins/Temporal/Duration/prototype/round/precision-exact-in-balance-duration-relative-years-with-calendar': [FAIL], 'built-ins/Temporal/Duration/prototype/round/precision-exact-in-round-duration': [FAIL], 'built-ins/Temporal/Duration/prototype/round/roundingmode-ceil': [FAIL], - 'built-ins/Temporal/Duration/prototype/round/roundingmode-expand': [FAIL], 'built-ins/Temporal/Duration/prototype/round/roundingmode-floor': [FAIL], - 'built-ins/Temporal/Duration/prototype/round/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/Duration/prototype/round/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/Duration/prototype/round/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/Duration/prototype/round/roundingmode-halfTrunc': [FAIL], 'built-ins/Temporal/Duration/prototype/round/roundingmode-trunc': [FAIL], - 'built-ins/Temporal/Instant/prototype/round/roundingmode-expand': [FAIL], - 'built-ins/Temporal/Instant/prototype/round/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/Instant/prototype/round/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/Instant/prototype/round/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/Instant/prototype/round/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/Instant/prototype/since/roundingmode-expand': [FAIL], - 'built-ins/Temporal/Instant/prototype/since/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/Instant/prototype/since/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/Instant/prototype/since/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/Instant/prototype/since/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/Instant/prototype/toString/roundingmode-expand': [FAIL], - 'built-ins/Temporal/Instant/prototype/toString/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/Instant/prototype/toString/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/Instant/prototype/toString/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/Instant/prototype/toString/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/Instant/prototype/until/roundingmode-expand': [FAIL], - 'built-ins/Temporal/Instant/prototype/until/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/Instant/prototype/until/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/Instant/prototype/until/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/Instant/prototype/until/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/since/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/since/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/since/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/since/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/since/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/until/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/until/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/until/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/until/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/until/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/round/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/round/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/round/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/round/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/round/roundingmode-halfTrunc': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/since/roundingmode-ceil': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/since/roundingmode-expand': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/since/roundingmode-floor': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/since/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/since/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/since/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/since/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfTrunc': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/roundingmode-ceil': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/roundingmode-expand': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/roundingmode-floor': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/until/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/until/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/until/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/until/roundingmode-halfTrunc': [FAIL], 'built-ins/Temporal/PlainTime/prototype/add/precision-exact-mathematical-values-1': [FAIL], 'built-ins/Temporal/PlainTime/prototype/add/precision-exact-mathematical-values-2': [FAIL], 'built-ins/Temporal/PlainTime/prototype/add/precision-exact-mathematical-values-3': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/round/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/round/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/round/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/round/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/round/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/since/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/since/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/since/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/since/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/since/roundingmode-halfTrunc': [FAIL], 'built-ins/Temporal/PlainTime/prototype/subtract/precision-exact-mathematical-values-1': [FAIL], 'built-ins/Temporal/PlainTime/prototype/subtract/precision-exact-mathematical-values-2': [FAIL], 'built-ins/Temporal/PlainTime/prototype/subtract/precision-exact-mathematical-values-3': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/toString/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/toString/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/toString/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/toString/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/toString/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/until/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/until/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/until/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/until/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/until/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/since/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/since/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/since/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/since/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/since/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/until/roundingmode-expand': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/until/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/until/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/until/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/until/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-expand': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-halfTrunc': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/since/roundingmode-ceil': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/since/roundingmode-expand': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/since/roundingmode-floor': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/since/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/since/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/since/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/since/roundingmode-halfTrunc': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/toString/roundingmode-expand': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/toString/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/toString/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/toString/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/toString/roundingmode-halfTrunc': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-ceil': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-expand': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-floor': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-halfCeil': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-halfEven': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-halfFloor': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-halfTrunc': [FAIL], 'intl402/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive': [FAIL], # https://bugs.chromium.org/p/v8/issues/detail?id=13342