From b74fb5c5c9768ffff207a5135e5964f3c820320e Mon Sep 17 00:00:00 2001 From: GregoryTravis Date: Wed, 27 Mar 2024 15:20:31 -0400 Subject: [PATCH] `Set.to_text` should not assume contents are `Text` (#9548) `Set.to_text` fails if the contents are anything other than `Text`. --- distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso | 2 +- test/Base_Tests/src/Data/Set_Spec.enso | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso index a6fa4256a41e..fce7e6e811a1 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso @@ -133,7 +133,7 @@ type Set ## PRIVATE to_text : Text - to_text self = self.to_vector.join ", " "Set{" "}" + to_text self = self.to_vector.map .pretty . join ", " "Set{" "}" ## PRIVATE type Set_Comparator diff --git a/test/Base_Tests/src/Data/Set_Spec.enso b/test/Base_Tests/src/Data/Set_Spec.enso index 1b8e1fc51335..28de9a0d8d5d 100644 --- a/test/Base_Tests/src/Data/Set_Spec.enso +++ b/test/Base_Tests/src/Data/Set_Spec.enso @@ -62,6 +62,12 @@ add_specs suite_builder = (s1 == s1) . should_be_true (s1 == s3) . should_be_false + group_builder.specify "should be able to convert to text" <| + s1 = Set.from_vector ["1", "2", "3"] + s2 = Set.from_vector [1, 2, 3] + s1.to_text.should_equal "Set{'1', '2', '3'}" + s2.to_text.should_equal "Set{1, 2, 3}" + main filter=Nothing = suite = Test.build suite_builder-> add_specs suite_builder