From 3769c9596f1cc64419bfbd0216ae92f3d1be8b03 Mon Sep 17 00:00:00 2001 From: Adam Riley Date: Fri, 9 Feb 2024 12:19:38 +0000 Subject: [PATCH] Fix test --- .../Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso | 3 +-- test/Base_Tests/src/Data/Time/Date_Range_Spec.enso | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso index f32ed45e7def..ef8737b06b53 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso @@ -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 @@ -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 diff --git a/test/Base_Tests/src/Data/Time/Date_Range_Spec.enso b/test/Base_Tests/src/Data/Time/Date_Range_Spec.enso index 61b35db12da1..5fae7b7eec74 100644 --- a/test/Base_Tests/src/Data/Time/Date_Range_Spec.enso +++ b/test/Base_Tests/src/Data/Time/Date_Range_Spec.enso @@ -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 @@ -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)