-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RD-9616: Fix the computation of Interval.ToMillis (#213)
Rounding is done last so that we don't round days. It was a mistake. Added a test that would fail without the patch (both computations would mistakenly return 30 days).
- Loading branch information
Showing
3 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/RD9616Test.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2023 RAW Labs S.A. | ||
* | ||
* Use of this software is governed by the Business Source License | ||
* included in the file licenses/BSL.txt. | ||
* | ||
* As of the Change Date specified in that file, in accordance with | ||
* the Business Source License, use of this software will be governed | ||
* by the Apache License, Version 2.0, included in the file | ||
* licenses/APL.txt. | ||
*/ | ||
|
||
package raw.compiler.rql2.tests.regressions | ||
|
||
import raw.compiler.rql2.tests.CompilerTestContext | ||
|
||
trait RD9616Test extends CompilerTestContext { | ||
|
||
test( | ||
"""let | ||
| date1=Date.Build(2002,1,1), | ||
| date2=Date.Build(2002,2,1), | ||
| date3=Date.Build(2002,1,31) | ||
|in | ||
| {Date.Subtract(date2,date1), Date.Subtract(date3,date1)}""".stripMargin | ||
)(it => it should evaluateTo("{Interval.Build(days=30, hours=10, minutes=30), Interval.Build(days=30)}")) | ||
|
||
test( | ||
"""let | ||
| date1=Date.Build(2002,1,1), | ||
| date2=Date.Build(2002,2,1), | ||
| date3=Date.Build(2002,1,31) | ||
|in | ||
| {Interval.ToMillis(Date.Subtract(date2,date1)), Interval.ToMillis(Date.Subtract(date3,date1))}""".stripMargin | ||
)(it => it should evaluateTo("{2629800000L, 2592000000L}")) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters