From bf9cb84fe5399bb50ba1bc5fc6e1ad0382f0755d Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Mon, 29 Jul 2024 13:52:31 -0400 Subject: [PATCH] failing test --- .../src/Data/Ordering/Comparator_Spec.enso | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/Base_Tests/src/Data/Ordering/Comparator_Spec.enso b/test/Base_Tests/src/Data/Ordering/Comparator_Spec.enso index ab0010b22a..53a0273baf 100644 --- a/test/Base_Tests/src/Data/Ordering/Comparator_Spec.enso +++ b/test/Base_Tests/src/Data/Ordering/Comparator_Spec.enso @@ -1,5 +1,6 @@ from Standard.Base import all import Standard.Base.Errors.Common.Incomparable_Values +import Standard.Base.Errors.Illegal_Argument.Illegal_Argument polyglot java import org.enso.base.ObjectComparator @@ -36,6 +37,18 @@ type No_Ord_Comparator Comparable.from (that:No_Ord) = Comparable.new that No_Ord_Comparator +type Attach_Warning + Value (n : Integer) + +type Attach_Warning_Comparator + compare (x : Attach_Warning) (y : Attach_Warning) = + r = Ordering.compare x.n y.n + Warning.attach (Illegal_Argument.Error "warning") r + + hash x:Attach_Warning = Ordering.hash x.n + +Comparable.from (that : Attach_Warning) = Comparable.new that Attach_Warning_Comparator + # Tests add_specs suite_builder = suite_builder.group "Object Comparator" group_builder-> @@ -81,6 +94,12 @@ add_specs suite_builder = suite_builder.group "Object Comparator" group_builder- (default_comparator 1 True) . should_fail_with Incomparable_Values (default_comparator (No_Ord.Value 1) (No_Ord.Value 2)).should_fail_with Incomparable_Values + group_builder.specify "warnings attached in a comparator should propagate to the operator result" <| + Problems.expect_only_warning Illegal_Argument <| ((Attach_Warning.Value 1) < (Attach_Warning.Value 2)) + Problems.expect_only_warning Illegal_Argument <| ((Attach_Warning.Value 1) >= (Attach_Warning.Value 2)) + # TODO: https://github.com/enso-org/enso/issues/10679 + # Problems.expect_only_warning Illegal_Argument <| ((Attach_Warning.Value 1) == (Attach_Warning.Value 2)) + main filter=Nothing = suite = Test.build suite_builder-> add_specs suite_builder