Skip to content

Commit

Permalink
Fix few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Akirathan committed Oct 26, 2022
1 parent bd781d1 commit edf289e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ years y = new years=y
ensure_period : Any -> Suspend (Any -> Any) -> Text -> Any ! (Time_Error | Illegal_Argument_Error)
ensure_period object ~action error_msg="Cannot use Duration as a parameter" =
case object of
period : Period -> action
_ : Period -> action
_ : Duration.Duration ->
Error.throw Time_Error_Data error_msg
x ->
Expand Down Expand Up @@ -157,19 +157,19 @@ type Period
compare_to : Period -> Ordering ! (Time_Error | Illegal_Argument_Error)
compare_to self that =
case self of
Period_With_Date _ start_date_self ->
Period.Period_With_Date _ start_date_self ->
case that of
Period_With_Date _ start_date_that ->
Period.Period_With_Date _ start_date_that ->
end_date_self = start_date_self + self
duration_self = Duration.between start_date_self.to_date_time end_date_self.to_date_time
end_date_that = start_date_that + that
duration_that = Duration.between start_date_that.to_date_time end_date_that.to_date_time
duration_self.compare_to duration_that
Period_Without_Date _ ->
Period.Period_Without_Date _ ->
(start_date_self + self).compare_to (start_date_self + that)
Period_Without_Date _ ->
Period.Period_Without_Date _ ->
case that of
Period_With_Date _ start_date_that ->
Period.Period_With_Date _ start_date_that ->
(start_date_that + self).compare_to (start_date_that + that)
Period_Without_Date _ ->
Period.Period_Without_Date _ ->
Error.throw (Time_Error_Data "Cannot compare two Period_Without_Date, as there is no start date")
2 changes: 1 addition & 1 deletion test/Tests/src/Data/Time/Period_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec =
((Period.between (Date.new 2022 1 10) (Date.new 2022 1 1)) < (Period.between (Date.new 2022 5 1) (Date.new 2022 5 10))) . should_be_true
((Period.between (Date.new 2022 1 10) (Date.new 2022 1 1)) != (Period.between (Date.new 2022 5 1) (Date.new 2022 5 10))) . should_be_true
# 2020 is a leap year, so February in 2020 has more days than February in 2021
((Period.between (Date.new 2020 1 2) (Date.new 2020 1 3)) > (Period.between (Date.new 2021 1 2) (Date.new 2021 1 3))) . should_be_true
((Period.between (Date.new 2020 2 1) (Date.new 2020 3 1)) > (Period.between (Date.new 2021 2 1) (Date.new 2021 3 1))) . should_be_true

Test.specify "should compare between Period_With_Date and Period_Without_Date" <|
(Period.between (Date.new 2022 1 1) (Date.new 2022 1 2)) == (Period.days 1)
Expand Down

0 comments on commit edf289e

Please sign in to comment.