Title: [295550] trunk
Revision
295550
Author
ross.kirsl...@sony.com
Date
2022-06-14 19:27:07 -0700 (Tue, 14 Jun 2022)

Log Message

Temporal.PlainTime#since should handle ceil/floor properly
https://bugs.webkit.org/show_bug.cgi?id=241623

Reviewed by Yusuke Suzuki.

This patch adds a spec step that our implementation was missing:

    DifferenceTemporalPlainTime ( operation, temporalTime, other, options )
        ...
        9. If operation is ~since~, then
            a. Set roundingMode to ! NegateTemporalRoundingMode(roundingMode).

* JSTests/test262/expectations.yaml:
Mark four test cases as passing.

* Source/_javascript_Core/runtime/TemporalPlainTime.cpp:
(JSC::TemporalPlainTime::since const):

Canonical link: https://commits.webkit.org/251555@main

Modified Paths

Diff

Modified: trunk/JSTests/test262/expectations.yaml (295549 => 295550)


--- trunk/JSTests/test262/expectations.yaml	2022-06-15 02:21:30 UTC (rev 295549)
+++ trunk/JSTests/test262/expectations.yaml	2022-06-15 02:27:07 UTC (rev 295550)
@@ -1080,12 +1080,6 @@
 test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js:
   default: "TypeError: undefined is not a constructor (evaluating 'new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone)')"
   strict mode: "TypeError: undefined is not a constructor (evaluating 'new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone)')"
-test/built-ins/Temporal/PlainTime/prototype/since/roundingmode-ceil.js:
-  default: 'Test262Error: hours hours result Expected SameValue(«4», «5») to be true'
-  strict mode: 'Test262Error: hours hours result Expected SameValue(«4», «5») to be true'
-test/built-ins/Temporal/PlainTime/prototype/since/roundingmode-floor.js:
-  default: 'Test262Error: hours hours result Expected SameValue(«5», «4») to be true'
-  strict mode: 'Test262Error: hours hours result Expected SameValue(«5», «4») to be true'
 test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js:
   default: "TypeError: undefined is not a constructor (evaluating 'new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone)')"
   strict mode: "TypeError: undefined is not a constructor (evaluating 'new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone)')"

Modified: trunk/Source/_javascript_Core/runtime/TemporalPlainTime.cpp (295549 => 295550)


--- trunk/Source/_javascript_Core/runtime/TemporalPlainTime.cpp	2022-06-15 02:21:30 UTC (rev 295549)
+++ trunk/Source/_javascript_Core/runtime/TemporalPlainTime.cpp	2022-06-15 02:27:07 UTC (rev 295550)
@@ -647,6 +647,12 @@
     auto [smallestUnit, largestUnit, roundingMode, increment] = extractDifferenceOptions(globalObject, optionsValue);
     RETURN_IF_EXCEPTION(scope, { });
 
+    // https://tc39.es/proposal-temporal/#sec-temporal-negatetemporalroundingmode
+    if (roundingMode == RoundingMode::Ceil)
+        roundingMode = RoundingMode::Floor;
+    else if (roundingMode == RoundingMode::Floor)
+        roundingMode = RoundingMode::Ceil;
+
     auto result = differenceTime(other->plainTime(), plainTime());
     result = -result;
     result.setYears(0);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to