Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
AdRiley committed Feb 9, 2024
1 parent 8baa6b9 commit 3769c95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import project.Data.Filter_Condition.Filter_Condition
import project.Data.Json.JS_Object
import project.Data.Numbers.Integer
import project.Data.Pair.Pair
import project.Data.Range.Range
import project.Data.Text.Text
import project.Data.Time.Date.Date
import project.Data.Time.Date_Period.Date_Period
Expand Down Expand Up @@ -488,7 +487,7 @@ type Date_Range
into a new date.
- if_empty: Value returned if the range is empty.
reduce : (Date -> Date -> Date) -> Any -> Any
reduce self function ~if_empty=(Error.throw (Empty_Error.Error Range)) =
reduce self function ~if_empty=(Error.throw (Empty_Error.Error Date_Range)) =
case self.length of
0 -> if_empty
1 -> self.start
Expand Down
7 changes: 5 additions & 2 deletions test/Base_Tests/src/Data/Time/Date_Range_Spec.enso
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from Standard.Base import all
import Standard.Base.Errors.Common.Type_Error
import Standard.Base.Errors.Empty_Error.Empty_Error
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument

from Standard.Test import all
Expand Down Expand Up @@ -181,8 +182,10 @@ add_specs suite_builder =
Test.expect_panic_with (r.last_index_of invalid_arg) Type_Error

reducer x y = if x > y then x else y
# Catch+to_text to fix Empty_Error equality.
r.reduce reducer . catch . to_text . should_equal (r.to_vector.reduce reducer . catch . to_text)

case r.length of
0 -> r.reduce reducer . should_fail_with (Empty_Error.Error Range)
_ -> r.reduce reducer . should_equal (r.to_vector.reduce reducer)

group_builder.specify "should define friendly text representations" <|
r1 = (Date.new 2020 02 28).up_to (Date.new 2020 03 02)
Expand Down

0 comments on commit 3769c95

Please sign in to comment.