From 53e4da8dce966ad4e576be26bf3bc323181a8ca8 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 18 Dec 2024 15:23:46 -0500 Subject: [PATCH 01/11] vector comparable --- .../AWS/0.0.0-dev/src/S3/S3_File.enso | 8 ++++++++ .../Base/0.0.0-dev/src/Data/Vector.enso | 19 +++++++++++++++++++ test/AWS_Tests/src/S3_Spec.enso | 5 +++++ test/Base_Tests/src/Data/Vector_Spec.enso | 5 +++++ 4 files changed, 37 insertions(+) diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso index 7687176f6f1d..64042c6cc7fa 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso @@ -616,3 +616,11 @@ translate_file_errors related_file result = s3_path = S3_Path.Value error.bucket error.key s3_file = S3_File.Value s3_path related_file.credentials Error.throw (File_Error.Not_Found s3_file) + +## PRIVATE + Sort S3 files by bucket and path. +sort_s3_files s3_files = + s3_file_sort_key s3_file = + s3_path = s3_file.path + [s3_path.bucket, s3.path.key] + s3_files.sort on=s3_file_sort_key diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso index a05719073ba5..2606ce603139 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso @@ -20,6 +20,7 @@ import project.Errors.Problem_Behavior.Problem_Behavior import project.Errors.Wrapped_Error.Wrapped_Error import project.Function.Function import project.Internal.Array_Like_Helpers +import project.Internal.Ordering_Helpers.Default_Comparator import project.Math import project.Meta import project.Nothing.Nothing @@ -1563,3 +1564,21 @@ type No_Wrap ## PRIVATE Wrapped_Error.from (that : Map_Error) = Wrapped_Error.Value that that.inner_error + +type Vector_Comparator + compare x y = + min_length = x.length.min y.length + choose_shorter = + Ordering.compare y.length x.length + go i = + if i >= min_length then choose_shorter else + x_elem = x.at i + y_elem = y.at i + Ordering.compare x_elem y_elem . and_then <| + @Tail_Call go (i + 1) + k = go 0 + k + + hash x = Default_Comparator.hash_builtin x + +Comparable.from (that : Vector) = Comparable.new that Vector_Comparator diff --git a/test/AWS_Tests/src/S3_Spec.enso b/test/AWS_Tests/src/S3_Spec.enso index 24f88c90e3bd..382fee9b4b1b 100644 --- a/test/AWS_Tests/src/S3_Spec.enso +++ b/test/AWS_Tests/src/S3_Spec.enso @@ -261,6 +261,11 @@ add_specs suite_builder = r3.should_be_a Vector r3.map .name . should_contain object_name + group_builder.specify "list should sort its output" <| + r = root.list + r.should_be_a Vector + r . should_equal r.sort + group_builder.specify "will fail if no credentials are provided and no Default credentials are available" pending=(if AWS_Credential.is_default_credential_available then "Default AWS credentials are defined in the environment and this test has no way of overriding them, so it is impossible to test this scenario in such environment.") <| root_without_credentials = S3_File.new "s3://"+bucket_name+"/" r = root_without_credentials.list diff --git a/test/Base_Tests/src/Data/Vector_Spec.enso b/test/Base_Tests/src/Data/Vector_Spec.enso index 707ca96dea2d..496771b5e148 100644 --- a/test/Base_Tests/src/Data/Vector_Spec.enso +++ b/test/Base_Tests/src/Data/Vector_Spec.enso @@ -887,6 +887,11 @@ type_spec suite_builder name alter = suite_builder.group name group_builder-> expected = "abet".utf_8 input.sort . should_equal expected + group_builder.specify "should be comparable for sorting" <| + v = [[1, 2], [3, -4], [1, 1], [3, -5], [3, -2], [1, -1], [1, 0]] + expected = [[1, -1], [1, 0], [1, 1], [1, 2], [3, -5], [3, -4], [3, -2]] + v.sort . should_equal expected + group_builder.specify "should report only a limited number of warnings for incomparable values" <| gen x = case (x % 10) of 0 -> Nothing From 21f017daa3427116c5124bdb0386b539411cd9df Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 18 Dec 2024 15:29:13 -0500 Subject: [PATCH 02/11] sort s3 and ef --- .../lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso | 9 +++++++++ .../lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso | 3 ++- .../Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso | 3 ++- .../0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso | 9 +++++++++ .../src/Network/Enso_Cloud/Enso_File_Spec.enso | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso index a904c3721801..0cd8a3d46865 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso @@ -1,5 +1,6 @@ from Standard.Base import all import Standard.Base.Errors.Illegal_Argument.Illegal_Argument +import Standard.Base.Internal.Ordering_Helpers.Default_Comparator import Standard.Base.Internal.Path_Helpers import project.Errors.S3_Error @@ -156,3 +157,11 @@ type Decomposed_S3_Path if self.parts.is_empty then Nothing else new_parts = self.parts.drop (..Last 1) Decomposed_S3_Path.Value new_parts self.go_to_root + +S3_Path_Comparator = + compare x y = + Ordering.compare [x.bucket, x.key] [y.bucket, y.key] + + hash x = Default_Comparator.hash_builtin x + +Comparable.from that:S3_Path = Comparable.new that S3_Path_Comparator diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso index 64042c6cc7fa..769428367ba9 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso @@ -179,7 +179,7 @@ type S3_File check_recursion action = if recursive then Unimplemented.throw "S3 listing with recursion is not currently implemented." else action check_directory action = if self.is_directory.not then Error.throw (Illegal_Argument.Error "Cannot `list` a non-directory." self.uri) else action - check_directory <| check_recursion <| check_name_filter <| + results = check_directory <| check_recursion <| check_name_filter <| if self.s3_path.bucket == "" then translate_file_errors self <| S3.list_buckets self.credentials . map bucket-> S3_File.Value (S3_Path.Value bucket "") self.credentials else pair = translate_file_errors self <| S3.read_bucket self.s3_path.bucket self.s3_path.key self.credentials delimiter=S3_Path.delimiter bucket = self.s3_path.bucket @@ -188,6 +188,7 @@ type S3_File files = pair.second . map key-> S3_File.Value (S3_Path.Value bucket key) self.credentials sub_folders + files + results.sort on=.path ## ALIAS load bytes, open bytes ICON data_input diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso index 9fb90e46bb04..3dadc08d925e 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso @@ -444,10 +444,11 @@ type Enso_File if self.is_directory.not then Error.throw (Illegal_Argument.Error "Cannot `list` a non-directory.") else # Remove secrets from the list - they are handled separately in `Enso_Secret.list`. assets = list_assets self . filter f-> f.asset_type != Enso_Asset_Type.Secret - assets.map asset-> + results = assets.map asset-> file = Enso_File.Value (self.enso_path.resolve asset.name) Asset_Cache.update file asset file + results.sort on=.enso_path ## GROUP Output ICON folder_add diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso index cf521841068a..5846586affc6 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso @@ -7,6 +7,7 @@ import project.Enso_Cloud.Enso_User.Enso_User import project.Error.Error import project.Errors.Illegal_Argument.Illegal_Argument import project.Errors.Unimplemented.Unimplemented +import project.Internal.Ordering_Helpers.Default_Comparator import project.Internal.Path_Helpers import project.Nothing.Nothing from project.Data.Boolean import Boolean, False, True @@ -72,3 +73,11 @@ normalize segments = ## We need to call normalize again, because technically a path `enso://a/../~/../../~` is a valid path that points to the user home and it should be correctly normalized, but requires numerous passes to do so. @Tail_Call normalize new_segments + +S3_Path_Comparator = + compare x y = + Ordering.compare x.path_segments y.path_segments + + hash x = Default_Comparator.hash_builtin x + +Comparable.from that:S3_Path = Comparable.new that S3_Path_Comparator diff --git a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso index 9b35a37945d4..dfaa24271a09 100644 --- a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso +++ b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso @@ -41,6 +41,11 @@ add_specs suite_builder setup:Cloud_Tests_Setup = suite_builder.group "Enso Clou Data.list test_root.get . map .name . should_contain "test_file.json" Data.list test_root.get.path . map .name . should_contain "test_file.json" + group_builder.specify "list should sort its output" <| + r = Enso_File.home.list + r.should_be_a Vector + r . should_equal r.sort + group_builder.specify "should allow to create and delete a directory" <| my_name = "my_test_dir-" + (Random.uuid.take 5) my_dir = (test_root.get / my_name).create_directory From ee11a77d8fae58235325d7d25079d919d4ab3923 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 18 Dec 2024 15:47:08 -0500 Subject: [PATCH 03/11] more vector comparable tests --- .../lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso | 6 +++--- .../0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso | 6 ++++-- test/Base_Tests/src/Data/Vector_Spec.enso | 12 ++++++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso index 2606ce603139..dc39102795b8 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso @@ -1568,10 +1568,10 @@ Wrapped_Error.from (that : Map_Error) = Wrapped_Error.Value that that.inner_erro type Vector_Comparator compare x y = min_length = x.length.min y.length - choose_shorter = - Ordering.compare y.length x.length + choose_by_length = + Ordering.compare x.length y.length go i = - if i >= min_length then choose_shorter else + if i >= min_length then choose_by_length else x_elem = x.at i y_elem = y.at i Ordering.compare x_elem y_elem . and_then <| diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso index 5846586affc6..21928d398aed 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso @@ -1,5 +1,7 @@ private +import project.Data.Ordering.Comparable +import project.Data.Ordering.Ordering import project.Data.Text.Text import project.Data.Vector.Vector import project.Enso_Cloud.Enso_File.Enso_File @@ -74,10 +76,10 @@ normalize segments = that points to the user home and it should be correctly normalized, but requires numerous passes to do so. @Tail_Call normalize new_segments -S3_Path_Comparator = +type Enso_File_Comparator compare x y = Ordering.compare x.path_segments y.path_segments hash x = Default_Comparator.hash_builtin x -Comparable.from that:S3_Path = Comparable.new that S3_Path_Comparator +Comparable.from that:Enso_File = Comparable.new that Enso_File_Comparator diff --git a/test/Base_Tests/src/Data/Vector_Spec.enso b/test/Base_Tests/src/Data/Vector_Spec.enso index 496771b5e148..fb30a7c6c5d0 100644 --- a/test/Base_Tests/src/Data/Vector_Spec.enso +++ b/test/Base_Tests/src/Data/Vector_Spec.enso @@ -888,10 +888,18 @@ type_spec suite_builder name alter = suite_builder.group name group_builder-> input.sort . should_equal expected group_builder.specify "should be comparable for sorting" <| - v = [[1, 2], [3, -4], [1, 1], [3, -5], [3, -2], [1, -1], [1, 0]] - expected = [[1, -1], [1, 0], [1, 1], [1, 2], [3, -5], [3, -4], [3, -2]] + v = [[1, 2], [3, -4], [1, 1], [3, -5], [3, -2, 4], [3, -2], [1, -1], [1], [], [1, 0]] + expected = [[], [1], [1, -1], [1, 0], [1, 1], [1, 2], [3, -5], [3, -4], [3, -2], [3, -2, 4]] v.sort . should_equal expected + v2 = [['b', 'c'], ['a', 'c'], ['a', 'b'], ['b', 'a'], ['b', 'b'], ['b', 'd'], ['d', 'b']] + expected2 = [['a', 'b'], ['a', 'c'], ['b', 'a'], ['b', 'b'], ['b', 'c'], ['b', 'd'], ['d', 'b']] + v2.sort . should_equal expected2 + + v3 = [[[1, 2], [4, 4]], [[1, 2], [3, 5]], [[1, 2], [3, 4]], [[], [3, 4]], [[1], [3, 4]], [[1, 3], [3, 4]], [[], [2, 4]], [[2, 3], [3, 4]], [[2], [3, 4]]] + expected3 = [[[], [2, 4]], [[], [3, 4]], [[1], [3, 4]], [[1, 2], [3, 4]], [[1, 2], [3, 5]], [[1, 2], [4, 4]], [[1, 3], [3, 4]], [[2], [3, 4]], [[2, 3], [3, 4]]] + v3.sort . should_equal expected3 + group_builder.specify "should report only a limited number of warnings for incomparable values" <| gen x = case (x % 10) of 0 -> Nothing From 17805527646560633d210f6ed78d91c744897f93 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 18 Dec 2024 15:53:35 -0500 Subject: [PATCH 04/11] comparable_via --- .../lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso | 4 +++- .../lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso | 9 +++++++++ .../0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso index 0cd8a3d46865..ba888344a7bb 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso @@ -2,6 +2,7 @@ from Standard.Base import all import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import Standard.Base.Internal.Ordering_Helpers.Default_Comparator import Standard.Base.Internal.Path_Helpers +from Standard.Base.Data.Ordering import comparable_via import project.Errors.S3_Error import project.S3.S3 @@ -164,4 +165,5 @@ S3_Path_Comparator = hash x = Default_Comparator.hash_builtin x -Comparable.from that:S3_Path = Comparable.new that S3_Path_Comparator +#Comparable.from that:S3_Path = Comparable.new that S3_Path_Comparator +Comparable.from that:S3_Path = comparable_via (p-> [p.bucket, p.key]) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso index b6ed46fa0726..7c854281c504 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso @@ -193,5 +193,14 @@ type Ordering from_sign sign = if sign == 0 then Ordering.Equal else if sign > 0 then Ordering.Greater else Ordering.Less +type Via_Comparator + Value f + + compare self x y = Ordering.compare (self.f x) (self.f y) + + hash x = Default_Comparator.hash_builtin x + +comparable_via that f = Comparable.new that (Via_Comparator.Value f) + ## PRIVATE Comparable.from (that:Ordering) = Comparable.new that Ordering_Comparator diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso index 21928d398aed..d02f1fa4dd03 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso @@ -13,6 +13,7 @@ import project.Internal.Ordering_Helpers.Default_Comparator import project.Internal.Path_Helpers import project.Nothing.Nothing from project.Data.Boolean import Boolean, False, True +from project.Data.Ordering import comparable_via from project.Data.Text.Extensions import all ## PRIVATE @@ -82,4 +83,5 @@ type Enso_File_Comparator hash x = Default_Comparator.hash_builtin x -Comparable.from that:Enso_File = Comparable.new that Enso_File_Comparator +#Comparable.from that:Enso_File = Comparable.new that Enso_File_Comparator +Comparable.from that:Enso_File = comparable_via that .path_segments From 4ebf3f3e072c73c335c5c43e525e6dacad51f3e9 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 19 Dec 2024 15:43:36 -0500 Subject: [PATCH 05/11] cleanup --- .../AWS/0.0.0-dev/src/Internal/S3_Path.enso | 7 ++----- .../lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso | 13 ++----------- .../Standard/Base/0.0.0-dev/src/Data/Ordering.enso | 9 --------- .../src/Enso_Cloud/Internal/Enso_Path.enso | 9 +++------ test/AWS_Tests/src/S3_Spec.enso | 3 ++- .../src/Network/Enso_Cloud/Enso_File_Spec.enso | 3 ++- 6 files changed, 11 insertions(+), 33 deletions(-) diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso index ba888344a7bb..e61a75bdda93 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso @@ -2,7 +2,6 @@ from Standard.Base import all import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import Standard.Base.Internal.Ordering_Helpers.Default_Comparator import Standard.Base.Internal.Path_Helpers -from Standard.Base.Data.Ordering import comparable_via import project.Errors.S3_Error import project.S3.S3 @@ -160,10 +159,8 @@ type Decomposed_S3_Path Decomposed_S3_Path.Value new_parts self.go_to_root S3_Path_Comparator = - compare x y = - Ordering.compare [x.bucket, x.key] [y.bucket, y.key] + compare x y = Ordering.compare [x.bucket, x.key] [y.bucket, y.key] hash x = Default_Comparator.hash_builtin x -#Comparable.from that:S3_Path = Comparable.new that S3_Path_Comparator -Comparable.from that:S3_Path = comparable_via (p-> [p.bucket, p.key]) +Comparable.from that:S3_Path = Comparable.new that S3_Path_Comparator diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso index 769428367ba9..ff9882d95583 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso @@ -179,7 +179,7 @@ type S3_File check_recursion action = if recursive then Unimplemented.throw "S3 listing with recursion is not currently implemented." else action check_directory action = if self.is_directory.not then Error.throw (Illegal_Argument.Error "Cannot `list` a non-directory." self.uri) else action - results = check_directory <| check_recursion <| check_name_filter <| + check_directory <| check_recursion <| check_name_filter <| if self.s3_path.bucket == "" then translate_file_errors self <| S3.list_buckets self.credentials . map bucket-> S3_File.Value (S3_Path.Value bucket "") self.credentials else pair = translate_file_errors self <| S3.read_bucket self.s3_path.bucket self.s3_path.key self.credentials delimiter=S3_Path.delimiter bucket = self.s3_path.bucket @@ -187,8 +187,7 @@ type S3_File S3_File.Value (S3_Path.Value bucket key) self.credentials files = pair.second . map key-> S3_File.Value (S3_Path.Value bucket key) self.credentials - sub_folders + files - results.sort on=.path + sub_folders + files . sort on=.s3_path ## ALIAS load bytes, open bytes ICON data_input @@ -617,11 +616,3 @@ translate_file_errors related_file result = s3_path = S3_Path.Value error.bucket error.key s3_file = S3_File.Value s3_path related_file.credentials Error.throw (File_Error.Not_Found s3_file) - -## PRIVATE - Sort S3 files by bucket and path. -sort_s3_files s3_files = - s3_file_sort_key s3_file = - s3_path = s3_file.path - [s3_path.bucket, s3.path.key] - s3_files.sort on=s3_file_sort_key diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso index 7c854281c504..b6ed46fa0726 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso @@ -193,14 +193,5 @@ type Ordering from_sign sign = if sign == 0 then Ordering.Equal else if sign > 0 then Ordering.Greater else Ordering.Less -type Via_Comparator - Value f - - compare self x y = Ordering.compare (self.f x) (self.f y) - - hash x = Default_Comparator.hash_builtin x - -comparable_via that f = Comparable.new that (Via_Comparator.Value f) - ## PRIVATE Comparable.from (that:Ordering) = Comparable.new that Ordering_Comparator diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso index d02f1fa4dd03..49e59ae865ac 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso @@ -13,7 +13,6 @@ import project.Internal.Ordering_Helpers.Default_Comparator import project.Internal.Path_Helpers import project.Nothing.Nothing from project.Data.Boolean import Boolean, False, True -from project.Data.Ordering import comparable_via from project.Data.Text.Extensions import all ## PRIVATE @@ -77,11 +76,9 @@ normalize segments = that points to the user home and it should be correctly normalized, but requires numerous passes to do so. @Tail_Call normalize new_segments -type Enso_File_Comparator - compare x y = - Ordering.compare x.path_segments y.path_segments +type Enso_Path_Comparator + compare x y = Ordering.compare x.path_segments y.path_segments hash x = Default_Comparator.hash_builtin x -#Comparable.from that:Enso_File = Comparable.new that Enso_File_Comparator -Comparable.from that:Enso_File = comparable_via that .path_segments +Comparable.from that:Enso_Path = Comparable.new that Enso_Path_Comparator diff --git a/test/AWS_Tests/src/S3_Spec.enso b/test/AWS_Tests/src/S3_Spec.enso index 382fee9b4b1b..45f3e684c76d 100644 --- a/test/AWS_Tests/src/S3_Spec.enso +++ b/test/AWS_Tests/src/S3_Spec.enso @@ -264,7 +264,8 @@ add_specs suite_builder = group_builder.specify "list should sort its output" <| r = root.list r.should_be_a Vector - r . should_equal r.sort + r . should_equal (r.sort on=.s3_path) + r . should_equal (r.sort on=(x-> x.s3_path.to_text)) group_builder.specify "will fail if no credentials are provided and no Default credentials are available" pending=(if AWS_Credential.is_default_credential_available then "Default AWS credentials are defined in the environment and this test has no way of overriding them, so it is impossible to test this scenario in such environment.") <| root_without_credentials = S3_File.new "s3://"+bucket_name+"/" diff --git a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso index dfaa24271a09..68265a0281eb 100644 --- a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso +++ b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso @@ -44,7 +44,8 @@ add_specs suite_builder setup:Cloud_Tests_Setup = suite_builder.group "Enso Clou group_builder.specify "list should sort its output" <| r = Enso_File.home.list r.should_be_a Vector - r . should_equal r.sort + r . should_equal (r.sort on=.path) + r . should_equal (r.sort on=.enso_path) group_builder.specify "should allow to create and delete a directory" <| my_name = "my_test_dir-" + (Random.uuid.take 5) From 413e901def93ae72c614055e3b83c32f7872984c Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 19 Dec 2024 16:06:11 -0500 Subject: [PATCH 06/11] s3 comparator --- .../lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso | 6 +++--- .../Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso index e61a75bdda93..283b53110376 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso @@ -1,6 +1,5 @@ from Standard.Base import all import Standard.Base.Errors.Illegal_Argument.Illegal_Argument -import Standard.Base.Internal.Ordering_Helpers.Default_Comparator import Standard.Base.Internal.Path_Helpers import project.Errors.S3_Error @@ -158,9 +157,10 @@ type Decomposed_S3_Path new_parts = self.parts.drop (..Last 1) Decomposed_S3_Path.Value new_parts self.go_to_root -S3_Path_Comparator = +type S3_Path_Comparator compare x y = Ordering.compare [x.bucket, x.key] [y.bucket, y.key] - hash x = Default_Comparator.hash_builtin x + hash x = S3_Path_Comparator.hash_builtin x + hash_builtin x = @Builtin_Method "Default_Comparator.hash_builtin" Comparable.from that:S3_Path = Comparable.new that S3_Path_Comparator diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso index 49e59ae865ac..f658380a8a24 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso @@ -79,6 +79,7 @@ normalize segments = type Enso_Path_Comparator compare x y = Ordering.compare x.path_segments y.path_segments - hash x = Default_Comparator.hash_builtin x + hash x = Enso_Path_Comparator.hash_builtin x + hash_builtin x = @Builtin_Method "Default_Comparator.hash_builtin" Comparable.from that:Enso_Path = Comparable.new that Enso_Path_Comparator From a7714294209f6ef363d6f0e72911cd334a06e0aa Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 19 Dec 2024 16:23:23 -0500 Subject: [PATCH 07/11] fix vector Equal --- .../Base/0.0.0-dev/src/Data/Vector.enso | 10 +++++--- test/Base_Tests/src/Data/Vector_Spec.enso | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso index dc39102795b8..63cb3d0e8efa 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso @@ -4,6 +4,7 @@ import project.Data.Filter_Condition.Filter_Condition import project.Data.Index_Sub_Range.Index_Sub_Range import project.Data.List.List import project.Data.Numbers.Integer +import project.Data.Ordering.Ordering import project.Data.Pair.Pair import project.Data.Range.Range import project.Data.Sort_Direction.Sort_Direction @@ -1568,10 +1569,13 @@ Wrapped_Error.from (that : Map_Error) = Wrapped_Error.Value that that.inner_erro type Vector_Comparator compare x y = min_length = x.length.min y.length - choose_by_length = - Ordering.compare x.length y.length + when_prefixes_equal = + ## At this point, if the vectors are the same length, then they are + identical; otherwise, the shorter one is lesser. + if x.length == y.length then Ordering.Equal else + Ordering.compare x.length y.length go i = - if i >= min_length then choose_by_length else + if i >= min_length then when_prefixes_equal else x_elem = x.at i y_elem = y.at i Ordering.compare x_elem y_elem . and_then <| diff --git a/test/Base_Tests/src/Data/Vector_Spec.enso b/test/Base_Tests/src/Data/Vector_Spec.enso index fb30a7c6c5d0..f5f5aea42939 100644 --- a/test/Base_Tests/src/Data/Vector_Spec.enso +++ b/test/Base_Tests/src/Data/Vector_Spec.enso @@ -888,6 +888,31 @@ type_spec suite_builder name alter = suite_builder.group name group_builder-> input.sort . should_equal expected group_builder.specify "should be comparable for sorting" <| + ([1, 2] < [1, 3]) . should_be_true + ([1, 2] > [1, 3]) . should_be_false + ([1, 2] == [1, 3]) . should_be_false + + ([1, 3] < [1, 2]) . should_be_false + ([1, 3] > [1, 2]) . should_be_true + ([1, 3] == [1, 2]) . should_be_false + + ([1, 2] < [1, 2]) . should_be_false + ([1, 2] > [1, 2]) . should_be_false + ([1, 2] == [1, 2]) . should_be_true + + Ordering.compare [1] [1, 2] . should_equal Ordering.Less + Ordering.compare [] [1, 2] . should_equal Ordering.Less + + Ordering.compare [1, 2] [1] . should_equal Ordering.Greater + Ordering.compare [1, 2] [] . should_equal Ordering.Greater + + Ordering.compare [1, 2] [1, 2] . should_equal Ordering.Equal + + Ordering.compare [] [] . should_equal Ordering.Equal + Ordering.compare [] [1] . should_equal Ordering.Less + Ordering.compare [1] [] . should_equal Ordering.Greater + + group_builder.specify "vectors of vectors can be sorted" <| v = [[1, 2], [3, -4], [1, 1], [3, -5], [3, -2, 4], [3, -2], [1, -1], [1], [], [1, 0]] expected = [[], [1], [1, -1], [1, 0], [1, 1], [1, 2], [3, -5], [3, -4], [3, -2], [3, -2, 4]] v.sort . should_equal expected From cbb9fa73cea052f9e8bccd91dd8d4d1ac15d8494 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Fri, 20 Dec 2024 14:10:52 -0500 Subject: [PATCH 08/11] review --- .../AWS/0.0.0-dev/src/Internal/S3_Path.enso | 2 +- .../AWS/0.0.0-dev/src/S3/S3_File.enso | 2 +- .../Base/0.0.0-dev/src/Data/Vector.enso | 22 ------------------- .../src/Enso_Cloud/Internal/Enso_Path.enso | 3 ++- test/AWS_Tests/src/S3_Spec.enso | 3 +-- .../Network/Enso_Cloud/Enso_File_Spec.enso | 1 - 6 files changed, 5 insertions(+), 28 deletions(-) diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso index 283b53110376..87f01c393d48 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/Internal/S3_Path.enso @@ -158,7 +158,7 @@ type Decomposed_S3_Path Decomposed_S3_Path.Value new_parts self.go_to_root type S3_Path_Comparator - compare x y = Ordering.compare [x.bucket, x.key] [y.bucket, y.key] + compare x y = Ordering.compare x.bucket y.bucket . and_then Ordering.compare x.key y.key hash x = S3_Path_Comparator.hash_builtin x hash_builtin x = @Builtin_Method "Default_Comparator.hash_builtin" diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso index ff4080917bf4..890b1c8cf659 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso @@ -187,7 +187,7 @@ type S3_File S3_File.Value (S3_Path.Value bucket key) self.credentials files = pair.second . map key-> S3_File.Value (S3_Path.Value bucket key) self.credentials - sub_folders + files . sort on=.s3_path + (sub_folders + files) . sort on=(x-> x.s3_path) ## ALIAS load bytes, open bytes ICON data_input diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso index 63cb3d0e8efa..c170b5417c0b 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso @@ -4,7 +4,6 @@ import project.Data.Filter_Condition.Filter_Condition import project.Data.Index_Sub_Range.Index_Sub_Range import project.Data.List.List import project.Data.Numbers.Integer -import project.Data.Ordering.Ordering import project.Data.Pair.Pair import project.Data.Range.Range import project.Data.Sort_Direction.Sort_Direction @@ -1565,24 +1564,3 @@ type No_Wrap ## PRIVATE Wrapped_Error.from (that : Map_Error) = Wrapped_Error.Value that that.inner_error - -type Vector_Comparator - compare x y = - min_length = x.length.min y.length - when_prefixes_equal = - ## At this point, if the vectors are the same length, then they are - identical; otherwise, the shorter one is lesser. - if x.length == y.length then Ordering.Equal else - Ordering.compare x.length y.length - go i = - if i >= min_length then when_prefixes_equal else - x_elem = x.at i - y_elem = y.at i - Ordering.compare x_elem y_elem . and_then <| - @Tail_Call go (i + 1) - k = go 0 - k - - hash x = Default_Comparator.hash_builtin x - -Comparable.from (that : Vector) = Comparable.new that Vector_Comparator diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso index f658380a8a24..1aca5bd991be 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso @@ -2,6 +2,7 @@ private import project.Data.Ordering.Comparable import project.Data.Ordering.Ordering +import project.Data.Ordering.Vector_Lexicographic_Order import project.Data.Text.Text import project.Data.Vector.Vector import project.Enso_Cloud.Enso_File.Enso_File @@ -77,7 +78,7 @@ normalize segments = @Tail_Call normalize new_segments type Enso_Path_Comparator - compare x y = Ordering.compare x.path_segments y.path_segments + compare x y = Vector_Lexicographic_Order.compare x.path_segments y.path_segments hash x = Enso_Path_Comparator.hash_builtin x hash_builtin x = @Builtin_Method "Default_Comparator.hash_builtin" diff --git a/test/AWS_Tests/src/S3_Spec.enso b/test/AWS_Tests/src/S3_Spec.enso index 45f3e684c76d..40235807351d 100644 --- a/test/AWS_Tests/src/S3_Spec.enso +++ b/test/AWS_Tests/src/S3_Spec.enso @@ -264,8 +264,7 @@ add_specs suite_builder = group_builder.specify "list should sort its output" <| r = root.list r.should_be_a Vector - r . should_equal (r.sort on=.s3_path) - r . should_equal (r.sort on=(x-> x.s3_path.to_text)) + r . should_equal (r.sort on=(x-> x.path)) group_builder.specify "will fail if no credentials are provided and no Default credentials are available" pending=(if AWS_Credential.is_default_credential_available then "Default AWS credentials are defined in the environment and this test has no way of overriding them, so it is impossible to test this scenario in such environment.") <| root_without_credentials = S3_File.new "s3://"+bucket_name+"/" diff --git a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso index 68265a0281eb..d2618fed660f 100644 --- a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso +++ b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso @@ -45,7 +45,6 @@ add_specs suite_builder setup:Cloud_Tests_Setup = suite_builder.group "Enso Clou r = Enso_File.home.list r.should_be_a Vector r . should_equal (r.sort on=.path) - r . should_equal (r.sort on=.enso_path) group_builder.specify "should allow to create and delete a directory" <| my_name = "my_test_dir-" + (Random.uuid.take 5) From f584add04c66e9fbc0b28f95f8ccd9c7c322a891 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Fri, 20 Dec 2024 14:14:00 -0500 Subject: [PATCH 09/11] file comparators too --- .../lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso | 10 +++++++++- .../Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso index 890b1c8cf659..e985570a3352 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso @@ -187,7 +187,7 @@ type S3_File S3_File.Value (S3_Path.Value bucket key) self.credentials files = pair.second . map key-> S3_File.Value (S3_Path.Value bucket key) self.credentials - (sub_folders + files) . sort on=(x-> x.s3_path) + (sub_folders + files) . sort ## ALIAS load bytes, open bytes ICON data_input @@ -616,3 +616,11 @@ translate_file_errors related_file result = s3_path = S3_Path.Value error.bucket error.key s3_file = S3_File.Value s3_path related_file.credentials Error.throw (File_Error.Not_Found s3_file) + +type S3_File_Comparator + compare x y = Ordering.compare x.s3_path y.s3_path + + hash x = S3_File_Comparator.hash_builtin x + hash_builtin x = @Builtin_Method "Default_Comparator.hash_builtin" + +Comparable.from that:S3_File = Comparable.new that S3_File_Comparator diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso index 3dadc08d925e..4539d172acea 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso @@ -448,7 +448,7 @@ type Enso_File file = Enso_File.Value (self.enso_path.resolve asset.name) Asset_Cache.update file asset file - results.sort on=.enso_path + results.sort ## GROUP Output ICON folder_add @@ -584,3 +584,11 @@ File_Like.from (that : Enso_File) = File_Like.Value that ## PRIVATE Writable_File.from (that : Enso_File) = if Data_Link.is_data_link that then Data_Link_Helpers.interpret_data_link_as_writable_file that else Writable_File.Value that Enso_File_Write_Strategy.instance + +type Enso_File_Comparator + compare x y = Ordering.compare x.enso_path y.enso_path + + hash x = Enso_File_Comparator.hash_builtin x + hash_builtin x = @Builtin_Method "Default_Comparator.hash_builtin" + +Comparable.from that:Enso_File = Comparable.new that Enso_File_Comparator From d1acf61a540baeeee3b9656a6a28163a5cb3deb5 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Fri, 20 Dec 2024 14:27:10 -0500 Subject: [PATCH 10/11] wip --- .../lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso | 2 ++ test/AWS_Tests/src/S3_Spec.enso | 2 ++ test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso | 2 ++ 3 files changed, 6 insertions(+) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso index 4539d172acea..c4540ee6bb39 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso @@ -1,6 +1,8 @@ import project.Any.Any import project.Data.Color.Color import project.Data.Json.JS_Object +import project.Data.Ordering.Comparable +import project.Data.Ordering.Ordering import project.Data.Numbers.Integer import project.Data.Text.Encoding.Encoding import project.Data.Text.Text diff --git a/test/AWS_Tests/src/S3_Spec.enso b/test/AWS_Tests/src/S3_Spec.enso index 40235807351d..026ea8b130c9 100644 --- a/test/AWS_Tests/src/S3_Spec.enso +++ b/test/AWS_Tests/src/S3_Spec.enso @@ -265,6 +265,8 @@ add_specs suite_builder = r = root.list r.should_be_a Vector r . should_equal (r.sort on=(x-> x.path)) + # Check sorting directly. + r . reverse . sort . should_equal r group_builder.specify "will fail if no credentials are provided and no Default credentials are available" pending=(if AWS_Credential.is_default_credential_available then "Default AWS credentials are defined in the environment and this test has no way of overriding them, so it is impossible to test this scenario in such environment.") <| root_without_credentials = S3_File.new "s3://"+bucket_name+"/" diff --git a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso index d2618fed660f..1fc92edb98f4 100644 --- a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso +++ b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso @@ -45,6 +45,8 @@ add_specs suite_builder setup:Cloud_Tests_Setup = suite_builder.group "Enso Clou r = Enso_File.home.list r.should_be_a Vector r . should_equal (r.sort on=.path) + # Check sorting directly. + r . reverse . sort . should_equal r group_builder.specify "should allow to create and delete a directory" <| my_name = "my_test_dir-" + (Random.uuid.take 5) From 86f88790c191c1481b39568d0e5977fea8654f03 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Fri, 20 Dec 2024 14:28:14 -0500 Subject: [PATCH 11/11] revert vec --- .../Base/0.0.0-dev/src/Data/Vector.enso | 1 - test/Base_Tests/src/Data/Vector_Spec.enso | 38 ------------------- 2 files changed, 39 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso index c170b5417c0b..a05719073ba5 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso @@ -20,7 +20,6 @@ import project.Errors.Problem_Behavior.Problem_Behavior import project.Errors.Wrapped_Error.Wrapped_Error import project.Function.Function import project.Internal.Array_Like_Helpers -import project.Internal.Ordering_Helpers.Default_Comparator import project.Math import project.Meta import project.Nothing.Nothing diff --git a/test/Base_Tests/src/Data/Vector_Spec.enso b/test/Base_Tests/src/Data/Vector_Spec.enso index f5f5aea42939..707ca96dea2d 100644 --- a/test/Base_Tests/src/Data/Vector_Spec.enso +++ b/test/Base_Tests/src/Data/Vector_Spec.enso @@ -887,44 +887,6 @@ type_spec suite_builder name alter = suite_builder.group name group_builder-> expected = "abet".utf_8 input.sort . should_equal expected - group_builder.specify "should be comparable for sorting" <| - ([1, 2] < [1, 3]) . should_be_true - ([1, 2] > [1, 3]) . should_be_false - ([1, 2] == [1, 3]) . should_be_false - - ([1, 3] < [1, 2]) . should_be_false - ([1, 3] > [1, 2]) . should_be_true - ([1, 3] == [1, 2]) . should_be_false - - ([1, 2] < [1, 2]) . should_be_false - ([1, 2] > [1, 2]) . should_be_false - ([1, 2] == [1, 2]) . should_be_true - - Ordering.compare [1] [1, 2] . should_equal Ordering.Less - Ordering.compare [] [1, 2] . should_equal Ordering.Less - - Ordering.compare [1, 2] [1] . should_equal Ordering.Greater - Ordering.compare [1, 2] [] . should_equal Ordering.Greater - - Ordering.compare [1, 2] [1, 2] . should_equal Ordering.Equal - - Ordering.compare [] [] . should_equal Ordering.Equal - Ordering.compare [] [1] . should_equal Ordering.Less - Ordering.compare [1] [] . should_equal Ordering.Greater - - group_builder.specify "vectors of vectors can be sorted" <| - v = [[1, 2], [3, -4], [1, 1], [3, -5], [3, -2, 4], [3, -2], [1, -1], [1], [], [1, 0]] - expected = [[], [1], [1, -1], [1, 0], [1, 1], [1, 2], [3, -5], [3, -4], [3, -2], [3, -2, 4]] - v.sort . should_equal expected - - v2 = [['b', 'c'], ['a', 'c'], ['a', 'b'], ['b', 'a'], ['b', 'b'], ['b', 'd'], ['d', 'b']] - expected2 = [['a', 'b'], ['a', 'c'], ['b', 'a'], ['b', 'b'], ['b', 'c'], ['b', 'd'], ['d', 'b']] - v2.sort . should_equal expected2 - - v3 = [[[1, 2], [4, 4]], [[1, 2], [3, 5]], [[1, 2], [3, 4]], [[], [3, 4]], [[1], [3, 4]], [[1, 3], [3, 4]], [[], [2, 4]], [[2, 3], [3, 4]], [[2], [3, 4]]] - expected3 = [[[], [2, 4]], [[], [3, 4]], [[1], [3, 4]], [[1, 2], [3, 4]], [[1, 2], [3, 5]], [[1, 2], [4, 4]], [[1, 3], [3, 4]], [[2], [3, 4]], [[2, 3], [3, 4]]] - v3.sort . should_equal expected3 - group_builder.specify "should report only a limited number of warnings for incomparable values" <| gen x = case (x % 10) of 0 -> Nothing