diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso index aa0e0add33b0..78d7b02dbb40 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso @@ -710,7 +710,7 @@ type Array [0, 1, 2].to_array . reduce (+) reduce : (Any -> Any -> Any) -> Any -> Any - reduce self function ~if_empty=(Error.throw (Empty_Error.Error Vector)) = Vector.reduce self function if_empty + reduce self function ~if_empty=(Error.throw (Empty_Error.Error Array)) = Vector.reduce self function if_empty ## GROUP Logical ICON preparation diff --git a/test/Base_Tests/src/Data/Array_Spec.enso b/test/Base_Tests/src/Data/Array_Spec.enso index efff85a4c43e..fb4945687b49 100644 --- a/test/Base_Tests/src/Data/Array_Spec.enso +++ b/test/Base_Tests/src/Data/Array_Spec.enso @@ -1,4 +1,5 @@ from Standard.Base import all +import Standard.Base.Errors.Empty_Error.Empty_Error import Standard.Base.Errors.Common.Index_Out_Of_Bounds import Standard.Base.Errors.Illegal_State.Illegal_State @@ -42,6 +43,12 @@ add_specs suite_builder = arr . should_equal [3, 1, 2] new_arr . should_equal [1, 2, 3] + group_builder.specify "should be able to be reduced" <| + make_enso_array [1, 2, 3, 4, 5] . reduce (+) . should_equal 15 + make_enso_array [1, 3, 5] . reduce (+) . should_equal 9 + make_enso_array [] . reduce (+) . should_fail_with (Empty_Error.Error Array) + make_enso_array [] . reduce (+) 0 . should_equal 0 + suite_builder.group "Compare functionality with Vector" group_builder-> group_builder.specify "compare methods" <| vector_methods = Meta.meta Vector . methods . sort diff --git a/test/Base_Tests/src/Data/Vector_Spec.enso b/test/Base_Tests/src/Data/Vector_Spec.enso index 5bfe6e5bac07..c3e980df2eee 100644 --- a/test/Base_Tests/src/Data/Vector_Spec.enso +++ b/test/Base_Tests/src/Data/Vector_Spec.enso @@ -155,8 +155,9 @@ type_spec suite_builder name alter = suite_builder.group name group_builder-> group_builder.specify "should allow to reduce elements if it is non-empty" <| alter [1,2,3] . reduce (+) . should_equal 6 - alter [] . reduce (+) . should_fail_with (Empty_Error.Error Vector) - alter [] . reduce (+) 0 . should_equal 0 + empty_vec = alter [] + empty_vec . reduce (+) . should_fail_with (Empty_Error.Error (Meta.type_of empty_vec)) + empty_vec . reduce (+) 0 . should_equal 0 group_builder.specify "should check any" <| vec = alter [1, 2, 3, 4, 5]