From 12632d67cb049021b9e4754beb7a312b052b72b7 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 14:03:55 -0500 Subject: [PATCH 01/58] wip --- .../Test/0.0.0-dev/src/Extensions.enso | 53 +++++++++++++------ test/Test_Tests/src/Extensions_Spec.enso | 5 ++ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index a440a3a3a48d..04ba9463ec53 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -73,24 +73,43 @@ Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True = example_should_equal = Examples.add_1_to 1 . should_equal 2 Any.should_equal : Any -> Integer -> Spec_Result Any.should_equal self that frames_to_skip=0 = - rhs_error_check that - loc = Test.get_source_location 1+frames_to_skip - case self == that of - True -> Spec_Result.Success - False -> - additional_comment = case self of - _ : Vector -> case that of - _ : Vector -> - case self.length == that.length of - True -> - diff = self.zip that . index_of p-> - p.first != p.second - "; first difference at index " + diff.to_text + " " - False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") " + omitting omitter-> + rhs_error_check that + #loc = Test.get_source_location 1+frames_to_skip + case self == that of + True -> Spec_Result.Success + False -> + additional_comment = case self of + _ : Vector -> case that of + _ : Vector -> + case self.length == that.length of + True -> + diff = self.zip that . index_of p-> + p.first != p.second + "; first difference at index " + diff.to_text + " " + False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") " + _ -> "" _ -> "" - _ -> "" - msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + loc + ")." - Test.fail msg + msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omitter.loc + ")." + Test.fail msg + +type Omitter + Value ~err + + loc self = + stack_trace = Runtime.get_stack_trace + omitting_index = stack_trace.index_of (frame-> frame.name == "Extensions.omitting") + #real_stack_trace = stack_trace.drop (..While (frame-> frame.name != 'Extensions.omitting')) + IO.println "==== o " + stack_trace.drop omitting_index . take 5 . map IO.println + real_stack_trace = stack_trace.drop (omitting_index + 2) + IO.println "==== r " + real_stack_trace . take 5 . map IO.println + top = real_stack_trace . at 0 + top.to_display_text + +omitting ~action = + action (Omitter.Value (Error.throw "here")) ## Asserts that `self` value is equal to the expected type value. diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index afee91d94597..1f622dae57fb 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -11,6 +11,11 @@ main filter=Nothing = suite.run_with_filter filter add_specs suite_builder = + suite_builder.group "should be able to get a stack trace without test helper farmes" group_builder-> + group_builder.specify "abcd" <| + "ab".should_equal "ab" + "ab".should_equal "ac" + suite_builder.group "should_equal extension method" group_builder-> group_builder.specify "should report correct location for Text" <| r1 = expect_test_failure <| From 007f068579706693940685e5a4ae9c462b09cb92 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 14:34:58 -0500 Subject: [PATCH 02/58] nesting --- .../Test/0.0.0-dev/src/Extensions.enso | 52 +++++++++++++++---- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 04ba9463ec53..aea618c4cad1 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -2,6 +2,7 @@ from Standard.Base import all import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.No_Such_Method import Standard.Base.Errors.Illegal_Argument.Illegal_Argument +import Standard.Base.Runtime.Ref.Ref import project.Spec_Result.Spec_Result import project.Test.Test @@ -72,9 +73,12 @@ Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True = example_should_equal = Examples.add_1_to 1 . should_equal 2 Any.should_equal : Any -> Integer -> Spec_Result -Any.should_equal self that frames_to_skip=0 = - omitting omitter-> +Any.should_equal self that frames_to_skip=0 default_omitter:(Omitter|Nothing)=Nothing = + #omitter = make_omitter + omitting default_omitter omitter-> rhs_error_check that + IO.println "ERR should_equal "+omitter.loc + self.another_checker default_omitter=omitter #loc = Test.get_source_location 1+frames_to_skip case self == that of True -> Spec_Result.Success @@ -93,23 +97,51 @@ Any.should_equal self that frames_to_skip=0 = msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omitter.loc + ")." Test.fail msg +Any.another_checker self default_omitter:Omitter=Nothing = + omitting default_omitter omitter-> + IO.println "ERR another_checker "+omitter.loc + +pst s st = + IO.println "==== "+s + st . take 12 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) + +hoho x=(Ref.new 12) = + v = x.get + x.put (v + 1) + IO.println "hoho "+v.to_text + +heyho = + IO.println "inheyho" + Runtime.get_stack_trace + +blah x=heyho = + pst "heyho" x + type Omitter Value ~err loc self = + #blah + #blah + stack_trace = Runtime.get_stack_trace - omitting_index = stack_trace.index_of (frame-> frame.name == "Extensions.omitting") - #real_stack_trace = stack_trace.drop (..While (frame-> frame.name != 'Extensions.omitting')) - IO.println "==== o " - stack_trace.drop omitting_index . take 5 . map IO.println + pst "full" stack_trace + + omitting_index = stack_trace.last_index_of (frame-> frame.name == "Extensions.omitting") real_stack_trace = stack_trace.drop (omitting_index + 2) - IO.println "==== r " - real_stack_trace . take 5 . map IO.println + + IO.println "OI "+omitting_index.to_text + #real_stack_trace = stack_trace.drop (..While (frame-> frame.name != 'Extensions.omitting')) + pst "real" real_stack_trace + top = real_stack_trace . at 0 top.to_display_text -omitting ~action = - action (Omitter.Value (Error.throw "here")) +omitting default_omitter ~action = + omitter = default_omitter.if_nothing (Omitter.Value (Error.throw "here")) + action omitter + +make_omitter -> Omitter = Omitter.Value (Error.throw "here") ## Asserts that `self` value is equal to the expected type value. From c4438e72eb4c6c020d4e2cedc0b4b7612476be82 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 14:41:30 -0500 Subject: [PATCH 03/58] wip --- .../Test/0.0.0-dev/src/Extensions.enso | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index aea618c4cad1..a4be6ff1cb74 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -73,29 +73,27 @@ Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True = example_should_equal = Examples.add_1_to 1 . should_equal 2 Any.should_equal : Any -> Integer -> Spec_Result -Any.should_equal self that frames_to_skip=0 default_omitter:(Omitter|Nothing)=Nothing = - #omitter = make_omitter - omitting default_omitter omitter-> - rhs_error_check that - IO.println "ERR should_equal "+omitter.loc - self.another_checker default_omitter=omitter - #loc = Test.get_source_location 1+frames_to_skip - case self == that of - True -> Spec_Result.Success - False -> - additional_comment = case self of - _ : Vector -> case that of - _ : Vector -> - case self.length == that.length of - True -> - diff = self.zip that . index_of p-> - p.first != p.second - "; first difference at index " + diff.to_text + " " - False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") " - _ -> "" +Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> + rhs_error_check that + IO.println "ERR should_equal "+omitter.loc + self.another_checker default_omitter=omitter + #loc = Test.get_source_location 1+frames_to_skip + case self == that of + True -> Spec_Result.Success + False -> + additional_comment = case self of + _ : Vector -> case that of + _ : Vector -> + case self.length == that.length of + True -> + diff = self.zip that . index_of p-> + p.first != p.second + "; first difference at index " + diff.to_text + " " + False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") " _ -> "" - msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omitter.loc + ")." - Test.fail msg + _ -> "" + msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omitter.loc + ")." + Test.fail msg Any.another_checker self default_omitter:Omitter=Nothing = omitting default_omitter omitter-> @@ -125,14 +123,14 @@ type Omitter #blah stack_trace = Runtime.get_stack_trace - pst "full" stack_trace + #pst "full" stack_trace omitting_index = stack_trace.last_index_of (frame-> frame.name == "Extensions.omitting") real_stack_trace = stack_trace.drop (omitting_index + 2) - IO.println "OI "+omitting_index.to_text + #IO.println "OI "+omitting_index.to_text #real_stack_trace = stack_trace.drop (..While (frame-> frame.name != 'Extensions.omitting')) - pst "real" real_stack_trace + #pst "real" real_stack_trace top = real_stack_trace . at 0 top.to_display_text From f926e8b312214baa7ead17d0a49223f437af32ad Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 14:53:32 -0500 Subject: [PATCH 04/58] wip --- .../lib/Standard/Test/0.0.0-dev/src/Extensions.enso | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index a4be6ff1cb74..580192fa7235 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -75,7 +75,7 @@ Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True = Any.should_equal : Any -> Integer -> Spec_Result Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that - IO.println "ERR should_equal "+omitter.loc + #IO.println "ERR should_equal "+omitter.loc self.another_checker default_omitter=omitter #loc = Test.get_source_location 1+frames_to_skip case self == that of @@ -97,7 +97,8 @@ Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter o Any.another_checker self default_omitter:Omitter=Nothing = omitting default_omitter omitter-> - IO.println "ERR another_checker "+omitter.loc + #IO.println "ERR another_checker "+omitter.loc + _ = 1 pst s st = IO.println "==== "+s @@ -137,6 +138,7 @@ type Omitter omitting default_omitter ~action = omitter = default_omitter.if_nothing (Omitter.Value (Error.throw "here")) + IO.println "AAAAA "+omitter.loc.to_display_text action omitter make_omitter -> Omitter = Omitter.Value (Error.throw "here") From 461f7b256a83a248f9c04bdf564bcfe3e696baa4 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 15:24:47 -0500 Subject: [PATCH 05/58] all in extensions and test --- .../Test/0.0.0-dev/src/Extensions.enso | 159 ++++++++---------- .../Standard/Test/0.0.0-dev/src/Omitter.enso | 0 .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 22 ++- 3 files changed, 82 insertions(+), 99 deletions(-) create mode 100644 distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 580192fa7235..cc2293813e86 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -26,11 +26,10 @@ from project.Extensions_Helpers import rhs_error_check example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error Any.should_fail_with : Any -> Integer -> Boolean -> Spec_Result -Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True = +Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter=Nothing = omitting omitter omitter-> _ = unwrap_errors - loc = Test.get_source_location 1+frames_to_skip matcher_text = matcher . to_text - Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + loc + ").") + Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + omitter.loc + ").") ## Expect a function to fail with the provided dataflow error. @@ -50,13 +49,12 @@ Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True = example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error Error.should_fail_with : Any -> Integer -> Boolean -> Spec_Result -Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True = +Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter=Nothing = omitting omitter omitter-> unwrap_maybe error = if unwrap_errors then Error.unwrap error else error caught = unwrap_maybe self.catch if caught == matcher || caught.is_a matcher then Nothing else - loc = Test.get_source_location 2+frames_to_skip matcher_text = matcher . to_text - Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + loc + ").") details='The error had the following stack trace:\n'+self.get_stack_trace_text + Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + omitter.loc + ").") details='The error had the following stack trace:\n'+self.get_stack_trace_text ## Asserts that `self` value is equal to the expected value. @@ -76,7 +74,7 @@ Any.should_equal : Any -> Integer -> Spec_Result Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that #IO.println "ERR should_equal "+omitter.loc - self.another_checker default_omitter=omitter + #self.another_checker default_omitter=omitter #loc = Test.get_source_location 1+frames_to_skip case self == that of True -> Spec_Result.Success @@ -133,7 +131,7 @@ type Omitter #real_stack_trace = stack_trace.drop (..While (frame-> frame.name != 'Extensions.omitting')) #pst "real" real_stack_trace - top = real_stack_trace . at 0 + top = real_stack_trace . at 0 . source_location top.to_display_text omitting default_omitter ~action = @@ -158,17 +156,16 @@ make_omitter -> Omitter = Omitter.Value (Error.throw "here") example_should_equal = Examples.some_type . should_equal_type Vector Any.should_equal_type : Any -> Integer -> Spec_Result -Any.should_equal_type self that frames_to_skip=0 = case (self.is_same_object_as that) of +Any.should_equal_type self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> case (self.is_same_object_as that) of True -> Spec_Result.Success False -> - loc = Test.get_source_location 2+frames_to_skip - msg = self.to_text + " did not equal type " + that.to_text + " (at " + loc + ")." + msg = self.to_text + " did not equal type " + that.to_text + " (at " + omitter.loc + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_equal_type self that frames_to_skip=0 = +Error.should_equal_type self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [that] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` value is not equal to the expected value. @@ -185,18 +182,17 @@ Error.should_equal_type self that frames_to_skip=0 = example_should_not_equal = Examples.add_1_to 1 . should_not_equal 2 Any.should_not_equal : Any -> Integer -> Spec_Result -Any.should_not_equal self that frames_to_skip=0 = if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else - loc = Test.get_source_location 2+frames_to_skip +Any.should_not_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else case self != that of True -> Spec_Result.Success False -> - msg = self.to_text + " did equal " + that.to_text + " (at " + loc + ")." + msg = self.to_text + " did equal " + that.to_text + " (at " + omitter.loc + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal self that frames_to_skip=0 = +Error.should_not_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [that] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` value is not equal to the expected type value. @@ -213,17 +209,16 @@ Error.should_not_equal self that frames_to_skip=0 = example_should_not_equal = Examples.some_type . should_not_equal_type Vector Any.should_not_equal_type : Any -> Integer -> Spec_Result -Any.should_not_equal_type self that frames_to_skip=0 = case (self.is_same_object_as that . not) of +Any.should_not_equal_type self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> case (self.is_same_object_as that . not) of True -> Spec_Result.Success False -> - loc = Test.get_source_location 2+frames_to_skip - msg = self.to_text + " did equal type " + that.to_text + " (at " + loc + ")." + msg = self.to_text + " did equal type " + that.to_text + " (at " + omitter.loc + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal_type self that frames_to_skip=0 = +Error.should_not_equal_type self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [that] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` value is a Text value and starts with `that`. @@ -239,15 +234,14 @@ Error.should_not_equal_type self that frames_to_skip=0 = example_should_start_with = "Hello World!" . should_start_with "Hello" Any.should_start_with : Text -> Integer -> Spec_Result -Any.should_start_with self that frames_to_skip=0 = +Any.should_start_with self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that - loc = Test.get_source_location 1+frames_to_skip case self of _ : Text -> if self.starts_with that then Spec_Result.Success else - msg = self.to_text + " does not start with " + that.to_text + " (at " + loc + ")." + msg = self.to_text + " does not start with " + that.to_text + " (at " + omitter.loc + ")." Test.fail msg _ -> - msg = self.to_text + " is not a `Text` value (at " + loc + ")." + msg = self.to_text + " is not a `Text` value (at " + omitter.loc + ")." Test.fail msg ## Asserts that `self` value is a Text value and ends with `that`. @@ -264,15 +258,14 @@ Any.should_start_with self that frames_to_skip=0 = example_should_end_with = "Hello World!" . should_end_with "ld!" Any.should_end_with : Text -> Integer -> Spec_Result -Any.should_end_with self that frames_to_skip=0 = +Any.should_end_with self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that - loc = Test.get_source_location 1+frames_to_skip case self of _ : Text -> if self.ends_with that then Spec_Result.Success else - msg = self.to_text + " does not end with " + that.to_text + " (at " + loc + ")." + msg = self.to_text + " does not end with " + that.to_text + " (at " + omitter.loc + ")." Test.fail msg _ -> - msg = self.to_text + " is not a `Text` value (at " + loc + ")." + msg = self.to_text + " is not a `Text` value (at " + omitter.loc + ")." Test.fail msg ## Asserts that `self` value is a Text value and starts with `that`. @@ -289,9 +282,9 @@ Any.should_end_with self that frames_to_skip=0 = example_should_start_with = "Hello World!" . should_start_with "Hello" Error.should_start_with : Any -> Integer -> Spec_Result -Error.should_start_with self that frames_to_skip=0 = +Error.should_start_with self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [that] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` value is a Text value and ends with `that`. @@ -307,9 +300,9 @@ Error.should_start_with self that frames_to_skip=0 = example_should_end_with = "Hello World!" . should_end_with "ld!" Error.should_end_with : Any -> Integer -> Spec_Result -Error.should_end_with self that frames_to_skip=0 = +Error.should_end_with self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [that] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` value is equal to the expected value. @@ -324,9 +317,9 @@ Error.should_end_with self that frames_to_skip=0 = example_should_equal = Examples.add_1_to 1 . should_equal 2 Error.should_equal : Any -> Integer -> Spec_Result -Error.should_equal self that frames_to_skip=0 = +Error.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` is within `epsilon` from `that`. @@ -351,9 +344,8 @@ Error.should_equal self that frames_to_skip=0 = example_should_equal = 1.00000001 . should_equal 1.00000002 epsilon=0.0001 Number.should_equal : Float -> Float -> Integer -> Spec_Result -Number.should_equal self that epsilon=0 frames_to_skip=0 = +Number.should_equal self that epsilon=0 frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that - loc = Test.get_source_location 1+frames_to_skip matches = case that of n : Number -> self.equals n epsilon . catch Incomparable_Values _-> ## Incomparable_Values is thrown if one of the values is NaN. @@ -364,7 +356,7 @@ Number.should_equal self that epsilon=0 frames_to_skip=0 = case matches of True -> Spec_Result.Success False -> - msg = self.to_text + " did not equal " + that.to_text + " (at " + loc + ")." + msg = self.to_text + " did not equal " + that.to_text + " (at " + omitter.loc + ")." Test.fail msg ## Asserts that `self` is within `epsilon` from `that`. @@ -375,9 +367,9 @@ Number.should_equal self that epsilon=0 frames_to_skip=0 = - frames_to_skip (optional, advanced): used to alter the location which is displayed as the source of this error. Decimal.should_equal : Number -> Float-> Float -> Integer -> Spec_Result -Decimal.should_equal self that epsilon=0 frames_to_skip=0 = +Decimal.should_equal self that epsilon=0 frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that - self.to_float . should_equal that.to_float epsilon frames_to_skip+1 + self.to_float . should_equal that.to_float epsilon omitter=omitter ## Asserts that `self` value is not an error. @@ -409,14 +401,14 @@ Any.should_succeed self frames_to_skip=0 = "foobar".write (enso_project.data / "f.txt") . should_succeed Error.should_succeed : Integer -> Any -Error.should_succeed self frames_to_skip=0 = - Test.fail_match_on_unexpected_error self 1+frames_to_skip +Error.should_succeed self frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> + Test.fail_match_on_unexpected_error self omitter=omitter ## Handles an unexpected dataflow error. Error.should_be_a : Any -> Integer -> Any -Error.should_be_a self typ frames_to_skip=0 = +Error.should_be_a self typ frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = typ - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that the given `Boolean` is `True` @@ -428,11 +420,10 @@ Error.should_be_a self typ frames_to_skip=0 = example_should_be_true = Examples.get_boolean . should_be_true Boolean.should_be_true : Spec_Result -Boolean.should_be_true self = case self of +Boolean.should_be_true self omitter=Nothing = omitting omitter omitter-> case self of True -> Spec_Result.Success False -> - loc = Test.get_source_location 2 - Test.fail "Expected False to be True (at "+loc+")." + Test.fail "Expected False to be True (at "+omitter.loc+")." ## Asserts that the given `Boolean` is `True`. @@ -444,7 +435,7 @@ Boolean.should_be_true self = case self of example_should_be_true = Examples.get_boolean . should_be_true Error.should_be_true : Spec_Result -Error.should_be_true self = Test.fail_match_on_unexpected_error self 1 +Error.should_be_true self omitter=Nothing = omitting omitter omitter-> Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that the given `Boolean` is `False` @@ -456,10 +447,9 @@ Error.should_be_true self = Test.fail_match_on_unexpected_error self 1 example_should_be_false = Examples.get_boolean . should_be_false Boolean.should_be_false : Spec_Result -Boolean.should_be_false self = case self of +Boolean.should_be_false self omitter=Nothing = omitting omitter omitter-> case self of True -> - loc = Test.get_source_location 2 - Test.fail "Expected True to be False (at "+loc+")." + Test.fail "Expected True to be False (at "+omitter.loc+")." False -> Spec_Result.Success ## Asserts that the given `Boolean` is `False` @@ -472,7 +462,7 @@ Boolean.should_be_false self = case self of example_should_be_false = Examples.get_boolean . should_be_false Error.should_be_false : Spec_Result -Error.should_be_false self = Test.fail_match_on_unexpected_error self 1 +Error.should_be_false self omitter=Nothing = omitting omitter omitter-> Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that a value is of a given type. @@ -486,9 +476,8 @@ Error.should_be_false self = Test.fail_match_on_unexpected_error self 1 example_should_be_a = 1.should_be_a Boolean Any.should_be_a : Any -> Spec_Result -Any.should_be_a self typ = +Any.should_be_a self typ omitter=Nothing = omitting omitter omitter-> rhs_error_check typ - loc = Test.get_source_location 1 fail_on_wrong_arg_type = Panic.throw <| Illegal_Argument.Error "typ ("+typ.to_display_text+") must either be a type or a constructor. Use `should_equal` for value equality test instead." @@ -498,36 +487,36 @@ Any.should_be_a self typ = if a.constructor == c then Spec_Result.Success else expected_type = c.declaring_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+loc+")." + message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+omitter.loc+")." Test.fail message _ -> expected_type = c.declaring_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+loc+")." + message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitter.loc+")." Test.fail message meta_type : Meta.Type -> ok = self.is_a typ || self==typ if ok then Spec_Result.Success else expected_type = meta_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+loc+")." + message = "Expected a value of type "+expected_type+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitter.loc+")." Test.fail message # Workaround for 0-argument atom constructors which 'unapplies' them. atom : Meta.Atom -> ctor = atom . constructor if ctor.fields.not_empty then fail_on_wrong_arg_type else - self.should_equal atom.value + self.should_equal atom.value omitter=omitter _ : Meta.Polyglot -> ok = self.is_a typ if ok then Spec_Result.Success else actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of Java class "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+loc+")." + message = "Expected a value of Java class "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitter.loc+")." Test.fail message p : Meta.Primitive -> ok = self == p.value if ok then Spec_Result.Success else actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+loc+")." + message = "Expected a value of "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitter.loc+")." Test.fail message _ -> fail_on_wrong_arg_type @@ -553,24 +542,23 @@ Any.should_be_a self typ = example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] Any.should_equal_ignoring_order : Any -> Integer -> Spec_Result -Any.should_equal_ignoring_order self that frames_to_skip=0 = - loc = Test.get_source_location 1+frames_to_skip +Any.should_equal_ignoring_order self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> if that.is_a Vector . not then - Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+loc+").") + Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+omitter.loc+").") that.each element-> if self.contains element . not then - msg = "The collection (" + self.to_text + ") did not contain " + element.to_text + " (at " + loc + ")." + msg = "The collection (" + self.to_text + ") did not contain " + element.to_text + " (at " + omitter.loc + ")." Test.fail msg self.each element-> if that.contains element . not then - msg = "The collection contained an element (" + element.to_text + ") which was not expected (at " + loc + ")." + msg = "The collection contained an element (" + element.to_text + ") which was not expected (at " + omitter.loc + ")." Test.fail msg Test.with_clue "Duplicate elements in either collection should have the same counts - checked by comparing sorted collections: " <| ## If the vector contains vectors or incomparable values, they may not get sorted correctly. We normalize by converting to a text representation. normalize e = Panic.catch No_Such_Method e.pretty _->e.to_text - (self.sort on=normalize) . should_equal (that.sort on=normalize) frames_to_skip=frames_to_skip+3 + (self.sort on=normalize) . should_equal (that.sort on=normalize) omitter=omitter Spec_Result.Success ## Asserts that `self` value contains the same elements as `that`. @@ -595,9 +583,9 @@ Any.should_equal_ignoring_order self that frames_to_skip=0 = example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] Error.should_equal_ignoring_order : Any -> Integer -> Spec_Result -Error.should_equal_ignoring_order self that frames_to_skip=0 = +Error.should_equal_ignoring_order self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [that] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` value contains only elements in `that`. @@ -622,12 +610,11 @@ Error.should_equal_ignoring_order self that frames_to_skip=0 = example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] Any.should_only_contain_elements_in : Any -> Integer -> Spec_Result -Any.should_only_contain_elements_in self that frames_to_skip=0 = +Any.should_only_contain_elements_in self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that - loc = Test.get_source_location 1+frames_to_skip self.each element-> if that.contains element . not then - msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + loc + ")." + msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + omitter.loc + ")." Test.fail msg Spec_Result.Success @@ -654,9 +641,9 @@ Any.should_only_contain_elements_in self that frames_to_skip=0 = example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] Error.should_only_contain_elements_in : Any -> Integer -> Spec_Result -Error.should_only_contain_elements_in self that frames_to_skip=0 = +Error.should_only_contain_elements_in self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [that] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` value contains an element. @@ -676,15 +663,14 @@ Error.should_only_contain_elements_in self that frames_to_skip=0 = example_should_equal = "foobar".should_contain "foo" Any.should_contain : Any -> Integer -> Spec_Result -Any.should_contain self element frames_to_skip=0 = +Any.should_contain self element frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check element - loc = Test.get_source_location 1+frames_to_skip contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else - msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + loc + ")." + msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omitter.loc + ")." Test.fail msg if contains_result then Spec_Result.Success else - msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + loc + ")." + msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + omitter.loc + ")." Test.fail msg ## Asserts that `self` value contains an element. @@ -705,9 +691,9 @@ Any.should_contain self element frames_to_skip=0 = example_should_equal = "foobar".should_contain "foo" Error.should_contain : Any -> Integer -> Spec_Result -Error.should_contain self element frames_to_skip=0 = +Error.should_contain self element frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [element] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter ## Asserts that `self` value does not contain an element. @@ -720,15 +706,14 @@ Error.should_contain self element frames_to_skip=0 = rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. Any.should_not_contain : Any -> Integer -> Spec_Result -Any.should_not_contain self element frames_to_skip=0 = +Any.should_not_contain self element frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check element - loc = Test.get_source_location 1+frames_to_skip contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else - msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + loc + ")." + msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omitter.loc + ")." Test.fail msg if contains_result.not then Spec_Result.Success else - msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + loc + ")." + msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + omitter.loc + ")." Test.fail msg ## Asserts that `self` value does not contain an element. @@ -742,6 +727,6 @@ Any.should_not_contain self element frames_to_skip=0 = rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. Error.should_not_contain : Any -> Integer -> Spec_Result -Error.should_not_contain self element frames_to_skip=0 = +Error.should_not_contain self element frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> _ = [element] - Test.fail_match_on_unexpected_error self 1+frames_to_skip + Test.fail_match_on_unexpected_error self omitter=omitter diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index e56520913126..c99eeaf23241 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -43,8 +43,7 @@ type Test example_expect_panic_with = Test.expect_panic_with Examples.throw_panic Examples.My_Error expect_panic_with : Any -> Any -> Integer -> Test_Result - expect_panic_with ~action matcher frames_to_skip=0 = - loc = Test.get_source_location 1+frames_to_skip + expect_panic_with ~action matcher frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> handle_panic caught_panic = payload = caught_panic.payload is_internal_test_panic = payload.is_a Spec_Result @@ -55,17 +54,17 @@ type Test is_panic_matching = payload.is_a matcher if is_panic_matching then payload else stack_trace = caught_panic.convert_to_dataflow_error.get_stack_trace_text - Test.fail ("Expected a " + matcher.to_text + ", but " + payload.to_text + " was thrown instead (at " + loc + ").") details=stack_trace + Test.fail ("Expected a " + matcher.to_text + ", but " + payload.to_text + " was thrown instead (at " + omitter.loc + ").") details=stack_trace Panic.catch Any handler=handle_panic <| res = action # If the action did not panic above, we fail the test. case res.is_error of True -> - Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action returned a Dataflow Error " + res.catch.to_display_text + " instead (at " + loc + ").") + Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action returned a Dataflow Error " + res.catch.to_display_text + " instead (at " + omitter.loc + ").") False -> return_suffix = if res.is_nothing then "" else " and returned ["+res.to_text+"]" - Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action succeeded" + return_suffix + " (at " + loc + ").") + Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action succeeded" + return_suffix + " (at " + omitter.loc + ").") ## Expect a function to fail with the provided panic. @@ -90,20 +89,19 @@ type Test IO.println 'this is not reached' expect_panic : Any -> Any -> Test_Result - expect_panic matcher ~action = Test.expect_panic_with action matcher frames_to_skip=1 + expect_panic matcher ~action omitter=Nothing = omitting omitter omitter-> Test.expect_panic_with action matcher omitter=omitter ## Checks that the provided action returns without any errors or warnings. If you just want to check for errors, usage of the `.should_succeed` extension function is preferred. - assert_no_problems value frames_to_skip=0 = + assert_no_problems value frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> value.catch Any _-> Test.fail_match_on_unexpected_error value 2+frames_to_skip warnings = Warning.get_all value . map .value if warnings.not_empty then - loc = Test.get_source_location 2+frames_to_skip - msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + loc + ")." + msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + omitter.loc + ")." Test.fail msg ## Fail a test with the given message. @@ -133,10 +131,9 @@ type Test ## PRIVATE Reports an unexpected dataflow error has occurred. fail_match_on_unexpected_error : Error -> Integer -> Nothing - fail_match_on_unexpected_error error frames_to_skip = + fail_match_on_unexpected_error error frames_to_skip omitter=nothing = omitting omitter omitter-> payload = error.catch - loc = Test.get_source_location 1+frames_to_skip - msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + loc + ")." + msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omitter.loc + ")." Test.fail msg details=error.get_stack_trace_text ## Executes the block of code passed as behavior and adds a clue modifier which @@ -229,4 +226,5 @@ type Test stack = Standard.Base.Runtime.get_stack_trace element = stack . at skip_frames+1 loc = element . source_location + IO.println "NOOOO "+omitter.loc.to_display_text loc . to_display_text From 39bcd9bbd4cecd7672b30aae4a40c10602cf230e Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 15:32:43 -0500 Subject: [PATCH 06/58] wip --- .../Test/0.0.0-dev/src/Extensions.enso | 50 +------------------ .../Standard/Test/0.0.0-dev/src/Omitter.enso | 22 ++++++++ .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 5 +- 3 files changed, 26 insertions(+), 51 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index cc2293813e86..65a9e0bb909b 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -2,11 +2,11 @@ from Standard.Base import all import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.No_Such_Method import Standard.Base.Errors.Illegal_Argument.Illegal_Argument -import Standard.Base.Runtime.Ref.Ref import project.Spec_Result.Spec_Result import project.Test.Test from project.Extensions_Helpers import rhs_error_check +from project.Omitter import all ## Expect a function to fail with the provided dataflow error. @@ -93,54 +93,6 @@ Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter o msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omitter.loc + ")." Test.fail msg -Any.another_checker self default_omitter:Omitter=Nothing = - omitting default_omitter omitter-> - #IO.println "ERR another_checker "+omitter.loc - _ = 1 - -pst s st = - IO.println "==== "+s - st . take 12 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) - -hoho x=(Ref.new 12) = - v = x.get - x.put (v + 1) - IO.println "hoho "+v.to_text - -heyho = - IO.println "inheyho" - Runtime.get_stack_trace - -blah x=heyho = - pst "heyho" x - -type Omitter - Value ~err - - loc self = - #blah - #blah - - stack_trace = Runtime.get_stack_trace - #pst "full" stack_trace - - omitting_index = stack_trace.last_index_of (frame-> frame.name == "Extensions.omitting") - real_stack_trace = stack_trace.drop (omitting_index + 2) - - #IO.println "OI "+omitting_index.to_text - #real_stack_trace = stack_trace.drop (..While (frame-> frame.name != 'Extensions.omitting')) - #pst "real" real_stack_trace - - top = real_stack_trace . at 0 . source_location - top.to_display_text - -omitting default_omitter ~action = - omitter = default_omitter.if_nothing (Omitter.Value (Error.throw "here")) - IO.println "AAAAA "+omitter.loc.to_display_text - action omitter - -make_omitter -> Omitter = Omitter.Value (Error.throw "here") - ## Asserts that `self` value is equal to the expected type value. Arguments: diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index e69de29bb2d1..7d058cd1b9e8 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -0,0 +1,22 @@ +from Standard.Base import all + +type Omitter + Value ~err + + loc self = + stack_trace = Runtime.get_stack_trace + #pst "full" stack_trace + + omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") + real_stack_trace = stack_trace.drop (omitting_index + 2) + + #IO.println "OI "+omitting_index.to_text + #pst "real" real_stack_trace + + top = real_stack_trace . at 0 . source_location + top.to_display_text + +omitting default_omitter ~action = + omitter = default_omitter.if_nothing (Omitter.Value (Error.throw "here")) + IO.println "AAAAA "+omitter.loc.to_display_text + action omitter diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index c99eeaf23241..361f2eb6e125 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -10,6 +10,7 @@ import project.Spec_Result.Spec_Result import project.Suite.Suite import project.Suite.Suite_Builder import project.Test_Result.Test_Result +from project.Omitter import all polyglot java import java.lang.Thread @@ -131,7 +132,7 @@ type Test ## PRIVATE Reports an unexpected dataflow error has occurred. fail_match_on_unexpected_error : Error -> Integer -> Nothing - fail_match_on_unexpected_error error frames_to_skip omitter=nothing = omitting omitter omitter-> + fail_match_on_unexpected_error error frames_to_skip omitter=Nothing = omitting omitter omitter-> payload = error.catch msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omitter.loc + ")." Test.fail msg details=error.get_stack_trace_text @@ -226,5 +227,5 @@ type Test stack = Standard.Base.Runtime.get_stack_trace element = stack . at skip_frames+1 loc = element . source_location - IO.println "NOOOO "+omitter.loc.to_display_text + IO.println "NOOOO "+loc.to_display_text loc . to_display_text From 5c5a9bd04294aba0880471120d6567cb97a131dc Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 16:11:44 -0500 Subject: [PATCH 07/58] convert all --- .../Test/0.0.0-dev/src/Extensions.enso | 3 -- .../Standard/Test/0.0.0-dev/src/Problems.enso | 43 +++++++++---------- .../Test/0.0.0-dev/src/Should_Reach.enso | 5 +-- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 8 ++-- test/Base_Tests/src/System/File_Spec.enso | 6 +-- .../Aggregate_Spec.enso | 16 +++---- .../src/Common_Table_Operations/Util.enso | 16 +++---- test/Table_Tests/src/IO/Fetch_Spec.enso | 5 ++- .../Table_Tests/src/In_Memory/Table_Spec.enso | 5 ++- test/Table_Tests/src/Util.enso | 37 ++++++++-------- 10 files changed, 67 insertions(+), 77 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 65a9e0bb909b..d1b442a0f0d7 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -73,9 +73,6 @@ Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter= Any.should_equal : Any -> Integer -> Spec_Result Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that - #IO.println "ERR should_equal "+omitter.loc - #self.another_checker default_omitter=omitter - #loc = Test.get_source_location 1+frames_to_skip case self == that of True -> Spec_Result.Success False -> diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index 4300e6e2f776..0078b2ace63b 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -2,6 +2,7 @@ from Standard.Base import all from project import Test from project.Extensions import all +from project.Omitter import all ## Returns values of warnings attached to the value. get_attached_warnings v = @@ -27,20 +28,20 @@ get_attached_warnings v = duplicated and that will be accepted. If false (default), the warning count has to match the counts in `expected_problems`. test_problem_handling : (Problem_Behavior -> Any) -> Vector Any -> (Any -> Nothing) -> Boolean -> Boolean -> Nothing -test_problem_handling action expected_problems result_checker (unwrap_errors : Boolean = True) (ignore_warning_cardinality : Boolean = False) = +test_problem_handling action expected_problems result_checker (unwrap_errors : Boolean = True) (ignore_warning_cardinality : Boolean = False) omitter=Nothing = omitting omitter omitter-> unwrap_maybe error = if unwrap_errors then Error.unwrap error else error error_checker error_result = first_problem = expected_problems.first first_problem_type = Meta.type_of first_problem - error_result . should_fail_with first_problem_type unwrap_errors=unwrap_errors frames_to_skip=3 - (unwrap_maybe error_result.catch) . should_equal first_problem frames_to_skip=3 + error_result . should_fail_with first_problem_type unwrap_errors=unwrap_errors omitter=omitter + (unwrap_maybe error_result.catch) . should_equal first_problem omitter=omitter warnings_checker warnings = Test.with_clue "The warnings were "+warnings.to_text+'.\n' <| (if ignore_warning_cardinality then warnings.distinct else warnings) . map unwrap_maybe - . should_equal_ignoring_order expected_problems frames_to_skip=8 - test_advanced_problem_handling action error_checker warnings_checker result_checker frames_to_skip=1 + . should_equal_ignoring_order expected_problems omitter=omitter + test_advanced_problem_handling action error_checker warnings_checker result_checker omitter=omitter ## UNSTABLE Tests how a specific operation behaves depending on the requested @@ -59,11 +60,11 @@ test_problem_handling action expected_problems result_checker (unwrap_errors : B the action is correct. It does not return anything, instead it should use the standard testing approach, like `x.should_equal y`. test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Integer -> Nothing -test_advanced_problem_handling action error_checker warnings_checker result_checker frames_to_skip=0 = +test_advanced_problem_handling action error_checker warnings_checker result_checker frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> # First, we check the action ignoring any warnings. result_ignoring = action Problem_Behavior.Ignore result_checker result_ignoring - get_attached_warnings result_ignoring . should_equal [] frames_to_skip=frames_to_skip+1 + get_attached_warnings result_ignoring . should_equal [] omitter=omitter # Then, we check the fail-on-first-error mode. error_result = action Problem_Behavior.Report_Error @@ -76,13 +77,12 @@ test_advanced_problem_handling action error_checker warnings_checker result_chec ## UNSTABLE Checks if the provided value does not have any attached problems. -assume_no_problems result = - loc = Test.get_source_location 1 +assume_no_problems result omitter=Nothing = omitting omitter omitter-> if result.is_error then - Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+loc+")." details=result.get_stack_trace_text + Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitter.loc+")." details=result.get_stack_trace_text warnings = get_attached_warnings result if warnings.not_empty then - Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+loc+")." + Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+omitter.loc+")." ## UNSTABLE Checks if the provided value has a specific warning attached. @@ -95,16 +95,15 @@ assume_no_problems result = - unwrap_errors: If true, remove any wrapping errors from the result before checking against the expected warning. expect_warning : Any -> Any -> Boolean -> Nothing -expect_warning expected_warning result unwrap_errors=True = +expect_warning expected_warning result unwrap_errors=True omitter=Nothing = omitting omitter omitter-> unwrap_maybe error = if unwrap_errors then Error.unwrap error else error - loc = Test.get_source_location 1 if result.is_error then - Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+loc+")." + Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitter.loc+")." warnings = get_attached_warnings result . map unwrap_maybe found = warnings.find if_missing=Nothing x-> (x == expected_warning) || (x.is_a expected_warning) found.if_nothing <| - Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+loc+').' + Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omitter.loc+').' ## UNSTABLE Checks if the provided value has a specific warning attached and if there are @@ -119,20 +118,19 @@ expect_warning expected_warning result unwrap_errors=True = - unwrap_errors: If true, remove any wrapping errors from the result before checking against the expected warning. expect_only_warning : Any -> Any -> Boolean -> Any -expect_only_warning expected_warning result unwrap_errors=True = +expect_only_warning expected_warning result unwrap_errors=True omitter=Nothing = omitting omitter omitter-> unwrap_maybe error = if unwrap_errors then Error.unwrap error else error - loc = Test.get_source_location 1 if result.is_error then - Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+loc+")." + Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitter.loc+")." warnings = get_attached_warnings result . map unwrap_maybe is_expected x = (x == expected_warning) || (x.is_a expected_warning) found = warnings.find if_missing=Nothing is_expected if found.is_nothing then - Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+loc+').' + Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omitter.loc+').' invalid = warnings.filter x-> is_expected x . not if invalid.not_empty then - Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+loc+').' + Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+omitter.loc+').' found ## UNSTABLE @@ -140,9 +138,8 @@ expect_only_warning expected_warning result unwrap_errors=True = It allows other warnings to be present also. not_expect_warning : Any -> Any -> Nothing -not_expect_warning expected_warning_type result = +not_expect_warning expected_warning_type result omitter=Nothing = omitting omitter omitter-> warnings = get_attached_warnings result found = warnings.find if_missing=Nothing x-> x.is_a expected_warning_type if found.is_nothing.not then - loc = Test.get_source_location 3 - Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+loc+').' + Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+omitter.loc+').' diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index ef5908c76280..2d549a3bdac6 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -22,7 +22,6 @@ type Should_Reach ## Checks if a point was reached in execution. should_have_reached : Integer -> Spec_Result - should_have_reached self (frames_to_skip : Integer = 0) -> Spec_Result = - loc = Test.get_source_location 1+frames_to_skip + should_have_reached self (frames_to_skip : Integer = 0) -> Spec_Result omitter=Nothing = omitting omitter omitter-> if self.reached_ref.get then Spec_Result.Success else - Test.fail ("Did not reach Should_Reach (at "+loc+").") + Test.fail ("Did not reach Should_Reach (at "+omitter.loc+").") diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 361f2eb6e125..05f1a8bda02c 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -99,7 +99,7 @@ type Test extension function is preferred. assert_no_problems value frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> value.catch Any _-> - Test.fail_match_on_unexpected_error value 2+frames_to_skip + Test.fail_match_on_unexpected_error value omitter=omitter warnings = Warning.get_all value . map .value if warnings.not_empty then msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + omitter.loc + ")." @@ -189,9 +189,7 @@ type Test or fails with the last error thrown by the action after exhausting retry attempts. with_retries : Any -> Any - with_retries ~action = - loc = Test.get_source_location 1 - + with_retries ~action omitter=Nothing = omitting omitter omitter-> milliseconds_between_attempts = 100 ## We give the CI a bit more attempts, as failures are more annoying there. For local development, a bit less retries is enough - there it is more @@ -204,7 +202,7 @@ type Test # If the iterations are exhausted, we rethrow the panic. if i > max_retries then Panic.throw caught_panic else if i % 10 == 0 then - IO.println 'Still failing after '+i.to_text+' retries ('+loc.to_display_text+'):\n'+caught_panic.payload.to_display_text + IO.println 'Still failing after '+i.to_text+' retries ('+omitter.loc.to_display_text+'):\n'+caught_panic.payload.to_display_text Thread.sleep milliseconds_between_attempts @Tail_Call go (i+1) go 1 diff --git a/test/Base_Tests/src/System/File_Spec.enso b/test/Base_Tests/src/System/File_Spec.enso index 20232241ced4..ffe795d7df01 100644 --- a/test/Base_Tests/src/System/File_Spec.enso +++ b/test/Base_Tests/src/System/File_Spec.enso @@ -12,18 +12,18 @@ polyglot java import org.enso.base_test_helpers.FileSystemHelper from Standard.Test import all import Standard.Test.Test_Environment +from Standard.Test.Omitter import all import project.Data.Data_Spec import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup ## We rely on a less strict equality for `File` as it is fine if a relative file gets resolved to absolute. -File.should_equal self other frames_to_skip=0 = - loc = Test.get_source_location 1+frames_to_skip +File.should_equal self other frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> are_same = case other of _ : File -> self.absolute.normalize.path == other.absolute.normalize.path _ -> False if are_same then self else - Test.fail "Expected "+self.to_text+" to be equal to "+other.to_text+" (at "+loc+")." + Test.fail "Expected "+self.to_text+" to be equal to "+other.to_text+" (at "+omitter.loc+")." set_writable file writable = diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index 98ec05d04b81..2a7667a021ff 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -11,6 +11,7 @@ import Standard.Database.Feature.Feature from Standard.Database.Errors import Unsupported_Database_Operation, Aggregagtion_Requires_Order from Standard.Test import all +from Standard.Test.Omitter import all from project.Common_Table_Operations.Util import run_default_backend, within_table @@ -58,8 +59,8 @@ add_aggregate_specs suite_builder setup = table_builder = setup.table_builder data = Data.setup table_fn empty_table_fn - expect_column_names names table = - table.columns . map .name . should_equal names frames_to_skip=3 + expect_column_names names table omitter=Nothing = omitting omitter omitter-> + table.columns . map .name . should_equal names omitter=omitter find_row key table (columns=Nothing) = table_columns = if columns.is_nothing then table.columns else columns.map x->(table.columns.at x) @@ -1107,10 +1108,10 @@ add_aggregate_specs suite_builder setup = suite_builder.group prefix+"Table.aggregate Count_Distinct" group_builder-> group_builder.specify "should correctly count missing values" <| - get_value t = + get_value t omitter=Nothing = omitting omitter omitter-> columns = materialize t . columns - columns.length . should_equal 1 frames_to_skip=1 - columns.first.length . should_equal 1 frames_to_skip=1 + columns.length . should_equal 1 omitter=omitter + columns.first.length . should_equal 1 omitter=omitter columns.first . at 0 ## TODO currently our builder does not allow all-null tables, so we @@ -1254,14 +1255,13 @@ add_aggregate_specs suite_builder setup = m1.columns.first.at 0 . should_equal 1.1180339887499 epsilon=0.000001 m1.columns.second.at 0 . should_equal 1.2909944487358 epsilon=0.000001 - expect_null_or_nan value = + expect_null_or_nan value omitter=Nothing = omitting omitter omitter-> matches = case value of Nothing -> True _ : Float -> Double.isNaN value _ -> False if matches.not then - loc = Test.get_source_location 2 - Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+loc+")." + Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+omitter.loc+")." if setup.flagged ..Supports_Infinity then suite_builder.group prefix+"Table.aggregate should correctly handle infinities" group_builder-> pos_inf = 1/0 diff --git a/test/Table_Tests/src/Common_Table_Operations/Util.enso b/test/Table_Tests/src/Common_Table_Operations/Util.enso index 8c63931ae62e..94dc955234f5 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Util.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Util.enso @@ -4,13 +4,14 @@ from Standard.Table import Column, Table, Value_Type import Standard.Database.DB_Table.DB_Table from Standard.Test import all +from Standard.Test.Omitter import all from project.In_Memory.Common_Spec import in_memory_setup -expect_column_names names table ignore_order=False = +expect_column_names names table ignore_order=False omitter=Nothing = omitting omitter omitter-> case ignore_order of - False -> table.columns . map .name . should_equal names frames_to_skip=2 - True -> table.columns . map .name . sort . should_equal names.sort frames_to_skip=2 + False -> table.columns . map .name . should_equal names omitter=omitter + True -> table.columns . map .name . sort . should_equal names.sort omitter=omitter ## These tests are parametrized by various backends and so they should be run in context of a specific backend. However, for the purpose of testing we provide @@ -60,18 +61,17 @@ Any.should_equal_tz_agnostic self other = It ensures that they represent the same instant in time, but ignore the timezone that is attached to them. This is simply done by converting them to UTC. -Vector.should_equal_tz_agnostic self other = - loc = Test.get_source_location 1 +Vector.should_equal_tz_agnostic self other omitter=Nothing = omitting omitter omitter-> case other of _ : Vector -> utc = Time_Zone.utc normalize_date_time dt = case dt of _ : Date_Time -> dt.at_zone utc - _ -> Test.fail "The vector should contain Date_Time objects but it contained "+dt.to_display_text+" (at "+loc+")" + _ -> Test.fail "The vector should contain Date_Time objects but it contained "+dt.to_display_text+" (at "+omitter.loc+")" self_normalized = self.map normalize_date_time other_normalized = other.map normalize_date_time - self_normalized.should_equal other_normalized frames_to_skip=2 - _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+loc+")" + self_normalized.should_equal other_normalized omitter=omitter + _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+omitter.loc+")" ## PRIVATE Error.should_equal_tz_agnostic self other = diff --git a/test/Table_Tests/src/IO/Fetch_Spec.enso b/test/Table_Tests/src/IO/Fetch_Spec.enso index c4b11c1a27c6..282a32da9491 100644 --- a/test/Table_Tests/src/IO/Fetch_Spec.enso +++ b/test/Table_Tests/src/IO/Fetch_Spec.enso @@ -17,6 +17,7 @@ import Standard.Table.Errors.Invalid_JSON_Format from Standard.Test import all import Standard.Test.Test_Environment +from Standard.Test.Omitter import all import enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup from enso_dev.Base_Tests.Network.Http.Http_Test_Setup import base_url_with_slash, pending_has_url @@ -135,9 +136,9 @@ add_specs suite_builder = after_count = get_num_response_cache_entries [before_count, after_count] - expect_counts expected_counts ~action = + expect_counts expected_counts ~action omitter=Nothing = omitting omitter omitter-> counts = with_counts action - counts . should_equal expected_counts frames_to_skip=1 + counts . should_equal expected_counts omitter=omitter get_cache_files : Vector Text get_cache_files -> Vector Text = diff --git a/test/Table_Tests/src/In_Memory/Table_Spec.enso b/test/Table_Tests/src/In_Memory/Table_Spec.enso index 3a6b9230c999..70341aa18884 100644 --- a/test/Table_Tests/src/In_Memory/Table_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Table_Spec.enso @@ -17,6 +17,7 @@ import Standard.Database.Extensions.Upload_In_Memory_Table from Standard.Database import Database, SQLite from Standard.Test import all +from Standard.Test.Omitter import all from project.Util import all @@ -682,8 +683,8 @@ add_specs suite_builder = actual.column_names . should_equal ["col0", "col_between", "col1"] suite_builder.group "Use First Row As Names" group_builder-> - expect_column_names names table = - table.columns . map .name . should_equal names frames_to_skip=2 + expect_column_names names table omitter=Nothing = omitting omitter omitter-> + table.columns . map .name . should_equal names omitter=omitter group_builder.specify "should work happily with mixed types" <| c_0 = ['A', ["H", "B", "C"]] diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 4e88fd13315c..4f2b813c383b 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -6,36 +6,35 @@ import Standard.Database.DB_Column.DB_Column from Standard.Table import Column, Table from Standard.Test import all +from project.Omitter import all polyglot java import org.enso.base_test_helpers.FileSystemHelper Table.should_equal : Any -> Integer -> Any -Table.should_equal self expected frames_to_skip=0 = - loc = Test.get_source_location 1+frames_to_skip +Table.should_equal self expected frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check expected - Panic.catch Test_Failure_Error (table_should_equal_impl self expected loc) error-> + Panic.catch Test_Failure_Error (table_should_equal_impl self expected omitter.loc) error-> Test.fail error.payload.message Column.should_equal : Any -> Integer -> Any -Column.should_equal self expected frames_to_skip=0 = - loc = Test.get_source_location 1+frames_to_skip +Column.should_equal self expected frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check expected - Panic.catch Test_Failure_Error (column_should_equal_impl self expected loc) error-> + Panic.catch Test_Failure_Error (column_should_equal_impl self expected omitter.loc) error-> Test.fail error.payload.message DB_Table.should_equal : DB_Table -> Integer -> Any -DB_Table.should_equal self expected frames_to_skip=0 = +DB_Table.should_equal self expected frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check expected t0 = self.read t1 = expected.read - t0 . should_equal t1 frames_to_skip+1 + t0 . should_equal t1 omitter=omitter DB_Column.should_equal : DB_Column -> Integer -> Any -DB_Column.should_equal self expected frames_to_skip=0 = +DB_Column.should_equal self expected frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check expected t0 = self.read t1 = expected.read - t0 . should_equal t1 frames_to_skip+1 + t0 . should_equal t1 omitter=omitter type Test_Failure_Error ## PRIVATE @@ -110,18 +109,17 @@ set_writable file writable = For example, if `example` is `[[1, 2], [3]]`, then both `[1, 2, 3]` and `[2, 1, 3]` will be accepted, but `[2, 3, 1]` will be rejected. -Any.should_have_relative_ordering self (example : Vector) = - loc = Test.get_source_location 1 +Any.should_have_relative_ordering self (example : Vector) omitter=Nothing = omitting omitter omitter-> case self of _ : Vector -> example.each v-> case v of _ : Vector -> - if v.is_empty then Test.fail "The example vector should not contain empty vectors as they are meaningless (at "+loc+")." - _ -> Test.fail "Expected a vector of vectors but got a vector containing "+v.to_display_text+" (at "+loc+")." + if v.is_empty then Test.fail "The example vector should not contain empty vectors as they are meaningless (at "+omitter.loc+")." + _ -> Test.fail "Expected a vector of vectors but got a vector containing "+v.to_display_text+" (at "+omitter.loc+")." total_length = example.fold 0 acc-> v-> acc+v.length if self.length != total_length then - Test.fail "Expected a vector of length "+total_length.to_text+" but got "+self.length.to_text+" (at "+loc+")." + Test.fail "Expected a vector of length "+total_length.to_text+" but got "+self.length.to_text+" (at "+omitter.loc+")." pieces = Vector.build builder-> example.fold 0 offset-> reference_v-> @@ -138,15 +136,14 @@ Any.should_have_relative_ordering self (example : Vector) = (got_piece.sort on_problems=..Report_Error) == (expected_piece.sort on_problems=..Report_Error) if are_consistent.not then offset = pieces.take ix . fold 0 acc-> p-> acc+p.length - Test.fail "Expected the run of vector elements starting at offset "+offset.to_text+" to be a permutation of "+expected_piece.to_display_text+" but got "+got_piece.to_display_text+" (at "+loc+")." + Test.fail "Expected the run of vector elements starting at offset "+offset.to_text+" to be a permutation of "+expected_piece.to_display_text+" but got "+got_piece.to_display_text+" (at "+omitter.loc+")." - _ -> Test.fail "Expected a vector but got "+self.to_display_text+" (at "+loc+")." + _ -> Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omitter.loc+")." ## PRIVATE See `Any.should_have_relative_ordering`. -Error.should_have_relative_ordering self example = - loc = Test.get_source_location 1 +Error.should_have_relative_ordering self example omitter=Nothing = omitting omitter omitter-> _ = example - Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+loc+")." + Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omitter.loc+")." ## PRIVATE From 1fd59118385fa36dc262de1c409d1631ef7b2c18 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 16:17:01 -0500 Subject: [PATCH 08/58] all fts --- .../Test/0.0.0-dev/src/Extensions.enso | 103 +++++------------- .../Standard/Test/0.0.0-dev/src/Problems.enso | 2 +- .../Test/0.0.0-dev/src/Should_Reach.enso | 2 +- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 6 +- test/Base_Tests/src/System/File_Spec.enso | 2 +- test/Table_Tests/src/Util.enso | 8 +- 6 files changed, 37 insertions(+), 86 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index d1b442a0f0d7..1258acb925d3 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -12,8 +12,6 @@ from project.Omitter import all Arguments: - matcher: The expected type of dataflow error contained in `self`. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. - unwrap_errors: If true, remove any wrapping errors from the result before checking against the expected warning. @@ -26,7 +24,7 @@ from project.Omitter import all example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error Any.should_fail_with : Any -> Integer -> Boolean -> Spec_Result -Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter=Nothing = omitting omitter omitter-> +Any.should_fail_with self matcher unwrap_errors=True omitter=Nothing = omitting omitter omitter-> _ = unwrap_errors matcher_text = matcher . to_text Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + omitter.loc + ").") @@ -35,8 +33,6 @@ Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter=No Arguments: - matcher: The expected type of dataflow error contained in `self`. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. - unwrap_errors: If true, remove any wrapping errors from the result before checking against the expected warning. @@ -49,7 +45,7 @@ Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter=No example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error Error.should_fail_with : Any -> Integer -> Boolean -> Spec_Result -Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter=Nothing = omitting omitter omitter-> +Error.should_fail_with self matcher unwrap_errors=True omitter=Nothing = omitting omitter omitter-> unwrap_maybe error = if unwrap_errors then Error.unwrap error else error caught = unwrap_maybe self.catch if caught == matcher || caught.is_a matcher then Nothing else @@ -60,8 +56,6 @@ Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter= Arguments: - that: The value to check `self` for equality with. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one value should equal another, @@ -71,7 +65,7 @@ Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True omitter= example_should_equal = Examples.add_1_to 1 . should_equal 2 Any.should_equal : Any -> Integer -> Spec_Result -Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Any.should_equal self that omitter=Nothing = omitting omitter omitter-> rhs_error_check that case self == that of True -> Spec_Result.Success @@ -94,8 +88,6 @@ Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter o Arguments: - that: The type to check `self` for equality with. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that some type is equal to another., @@ -105,14 +97,14 @@ Any.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter o example_should_equal = Examples.some_type . should_equal_type Vector Any.should_equal_type : Any -> Integer -> Spec_Result -Any.should_equal_type self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> case (self.is_same_object_as that) of +Any.should_equal_type self that omitter=Nothing = omitting omitter omitter-> case (self.is_same_object_as that) of True -> Spec_Result.Success False -> msg = self.to_text + " did not equal type " + that.to_text + " (at " + omitter.loc + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_equal_type self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_equal_type self that omitter=Nothing = omitting omitter omitter-> _ = [that] Test.fail_match_on_unexpected_error self omitter=omitter @@ -120,8 +112,6 @@ Error.should_equal_type self that frames_to_skip=0 omitter=Nothing = omitting om Arguments: - that: The value to check `self` for equality with. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one value should equal another, @@ -131,7 +121,7 @@ Error.should_equal_type self that frames_to_skip=0 omitter=Nothing = omitting om example_should_not_equal = Examples.add_1_to 1 . should_not_equal 2 Any.should_not_equal : Any -> Integer -> Spec_Result -Any.should_not_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else +Any.should_not_equal self that omitter=Nothing = omitting omitter omitter-> if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else case self != that of True -> Spec_Result.Success False -> @@ -139,7 +129,7 @@ Any.should_not_equal self that frames_to_skip=0 omitter=Nothing = omitting omitt Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_not_equal self that omitter=Nothing = omitting omitter omitter-> _ = [that] Test.fail_match_on_unexpected_error self omitter=omitter @@ -147,8 +137,6 @@ Error.should_not_equal self that frames_to_skip=0 omitter=Nothing = omitting omi Arguments: - that: The type to check `self` for equality with. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that some type is equal to another., @@ -158,14 +146,14 @@ Error.should_not_equal self that frames_to_skip=0 omitter=Nothing = omitting omi example_should_not_equal = Examples.some_type . should_not_equal_type Vector Any.should_not_equal_type : Any -> Integer -> Spec_Result -Any.should_not_equal_type self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> case (self.is_same_object_as that . not) of +Any.should_not_equal_type self that omitter=Nothing = omitting omitter omitter-> case (self.is_same_object_as that . not) of True -> Spec_Result.Success False -> msg = self.to_text + " did equal type " + that.to_text + " (at " + omitter.loc + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal_type self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_not_equal_type self that omitter=Nothing = omitting omitter omitter-> _ = [that] Test.fail_match_on_unexpected_error self omitter=omitter @@ -173,8 +161,6 @@ Error.should_not_equal_type self that frames_to_skip=0 omitter=Nothing = omittin Arguments: - that: The value to check `self` starts with. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one value should start with another. @@ -183,7 +169,7 @@ Error.should_not_equal_type self that frames_to_skip=0 omitter=Nothing = omittin example_should_start_with = "Hello World!" . should_start_with "Hello" Any.should_start_with : Text -> Integer -> Spec_Result -Any.should_start_with self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Any.should_start_with self that omitter=Nothing = omitting omitter omitter-> rhs_error_check that case self of _ : Text -> if self.starts_with that then Spec_Result.Success else @@ -197,8 +183,6 @@ Any.should_start_with self that frames_to_skip=0 omitter=Nothing = omitting omit Arguments: - that: The value to check `self` ends with. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one value should end with another. @@ -207,7 +191,7 @@ Any.should_start_with self that frames_to_skip=0 omitter=Nothing = omitting omit example_should_end_with = "Hello World!" . should_end_with "ld!" Any.should_end_with : Text -> Integer -> Spec_Result -Any.should_end_with self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Any.should_end_with self that omitter=Nothing = omitting omitter omitter-> rhs_error_check that case self of _ : Text -> if self.ends_with that then Spec_Result.Success else @@ -221,8 +205,6 @@ Any.should_end_with self that frames_to_skip=0 omitter=Nothing = omitting omitte Arguments: - that: The value to check `self` starts with. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one value should start with another. @@ -231,7 +213,7 @@ Any.should_end_with self that frames_to_skip=0 omitter=Nothing = omitting omitte example_should_start_with = "Hello World!" . should_start_with "Hello" Error.should_start_with : Any -> Integer -> Spec_Result -Error.should_start_with self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_start_with self that omitter=Nothing = omitting omitter omitter-> _ = [that] Test.fail_match_on_unexpected_error self omitter=omitter @@ -239,8 +221,6 @@ Error.should_start_with self that frames_to_skip=0 omitter=Nothing = omitting om Arguments: - that: The value to check `self` ends with. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one value should end with another. @@ -249,7 +229,7 @@ Error.should_start_with self that frames_to_skip=0 omitter=Nothing = omitting om example_should_end_with = "Hello World!" . should_end_with "ld!" Error.should_end_with : Any -> Integer -> Spec_Result -Error.should_end_with self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_end_with self that omitter=Nothing = omitting omitter omitter-> _ = [that] Test.fail_match_on_unexpected_error self omitter=omitter @@ -266,7 +246,7 @@ Error.should_end_with self that frames_to_skip=0 omitter=Nothing = omitting omit example_should_equal = Examples.add_1_to 1 . should_equal 2 Error.should_equal : Any -> Integer -> Spec_Result -Error.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_equal self that omitter=Nothing = omitting omitter omitter-> rhs_error_check that Test.fail_match_on_unexpected_error self omitter=omitter @@ -275,8 +255,6 @@ Error.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter Arguments: - that: The value to compare `self` for equality with. - epsilon: The epsilon for comparing two float numbers. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Compare two float values. @@ -293,7 +271,7 @@ Error.should_equal self that frames_to_skip=0 omitter=Nothing = omitting omitter example_should_equal = 1.00000001 . should_equal 1.00000002 epsilon=0.0001 Number.should_equal : Float -> Float -> Integer -> Spec_Result -Number.should_equal self that epsilon=0 frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Number.should_equal self that epsilon=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that matches = case that of n : Number -> self.equals n epsilon . catch Incomparable_Values _-> @@ -313,10 +291,8 @@ Number.should_equal self that epsilon=0 frames_to_skip=0 omitter=Nothing = omitt Arguments: - that: The value to compare `self` for equality with. - epsilon: The epsilon for comparing two float numbers. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. Decimal.should_equal : Number -> Float-> Float -> Integer -> Spec_Result -Decimal.should_equal self that epsilon=0 frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Decimal.should_equal self that epsilon=0 omitter=Nothing = omitting omitter omitter-> rhs_error_check that self.to_float . should_equal that.to_float epsilon omitter=omitter @@ -324,38 +300,29 @@ Decimal.should_equal self that epsilon=0 frames_to_skip=0 omitter=Nothing = omit It returns the original value, so that it can be inspected further. - Arguments: - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. - > Example Assert that a given action did not result in errors or warnings. "foobar".write (enso_project.data / "f.txt") . should_succeed Any.should_succeed : Integer -> Any -Any.should_succeed self frames_to_skip=0 = - _ = frames_to_skip +Any.should_succeed self = self ## Asserts that `self` value is not an error. It returns the original value, so that it can be inspected further. - Arguments: - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. - > Example Assert that a given action did not result in errors or warnings. "foobar".write (enso_project.data / "f.txt") . should_succeed Error.should_succeed : Integer -> Any -Error.should_succeed self frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_succeed self omitter=Nothing = omitting omitter omitter-> Test.fail_match_on_unexpected_error self omitter=omitter ## Handles an unexpected dataflow error. Error.should_be_a : Any -> Integer -> Any -Error.should_be_a self typ frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_be_a self typ omitter=Nothing = omitting omitter omitter-> _ = typ Test.fail_match_on_unexpected_error self omitter=omitter @@ -480,8 +447,6 @@ Any.should_be_a self typ omitter=Nothing = omitting omitter omitter-> Arguments: - that: The collection to compare. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one vector should contain the same elements as another. @@ -491,7 +456,7 @@ Any.should_be_a self typ omitter=Nothing = omitting omitter omitter-> example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] Any.should_equal_ignoring_order : Any -> Integer -> Spec_Result -Any.should_equal_ignoring_order self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Any.should_equal_ignoring_order self that omitter=Nothing = omitting omitter omitter-> if that.is_a Vector . not then Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+omitter.loc+").") that.each element-> @@ -521,8 +486,6 @@ Any.should_equal_ignoring_order self that frames_to_skip=0 omitter=Nothing = omi Arguments: - _: The collection to compare. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one vector should contain the same elements as another. @@ -532,7 +495,7 @@ Any.should_equal_ignoring_order self that frames_to_skip=0 omitter=Nothing = omi example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] Error.should_equal_ignoring_order : Any -> Integer -> Spec_Result -Error.should_equal_ignoring_order self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_equal_ignoring_order self that omitter=Nothing = omitting omitter omitter-> _ = [that] Test.fail_match_on_unexpected_error self omitter=omitter @@ -548,8 +511,6 @@ Error.should_equal_ignoring_order self that frames_to_skip=0 omitter=Nothing = o Arguments: - that: The collection to compare. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one vector should contain only elements in another. @@ -559,7 +520,7 @@ Error.should_equal_ignoring_order self that frames_to_skip=0 omitter=Nothing = o example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] Any.should_only_contain_elements_in : Any -> Integer -> Spec_Result -Any.should_only_contain_elements_in self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Any.should_only_contain_elements_in self that omitter=Nothing = omitting omitter omitter-> rhs_error_check that self.each element-> if that.contains element . not then @@ -579,8 +540,6 @@ Any.should_only_contain_elements_in self that frames_to_skip=0 omitter=Nothing = Arguments: - that: The collection to compare. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. > Example Assert that one vector should contain only elements in another. @@ -590,7 +549,7 @@ Any.should_only_contain_elements_in self that frames_to_skip=0 omitter=Nothing = example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] Error.should_only_contain_elements_in : Any -> Integer -> Spec_Result -Error.should_only_contain_elements_in self that frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_only_contain_elements_in self that omitter=Nothing = omitting omitter omitter-> _ = [that] Test.fail_match_on_unexpected_error self omitter=omitter @@ -598,8 +557,6 @@ Error.should_only_contain_elements_in self that frames_to_skip=0 omitter=Nothing Arguments: - element: The element to check. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. This method delegates to the `contains` method of `self` and will use the rules of the particular type - be it a `Vector`, `Text` or any custom type @@ -612,7 +569,7 @@ Error.should_only_contain_elements_in self that frames_to_skip=0 omitter=Nothing example_should_equal = "foobar".should_contain "foo" Any.should_contain : Any -> Integer -> Spec_Result -Any.should_contain self element frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Any.should_contain self element omitter=Nothing = omitting omitter omitter-> rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else @@ -626,8 +583,6 @@ Any.should_contain self element frames_to_skip=0 omitter=Nothing = omitting omit Arguments: - element: The element to check. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. This method delegates to the `contains` method of `self` and will use the rules of the particular type - be it a `Vector`, `Text` or any custom type @@ -640,7 +595,7 @@ Any.should_contain self element frames_to_skip=0 omitter=Nothing = omitting omit example_should_equal = "foobar".should_contain "foo" Error.should_contain : Any -> Integer -> Spec_Result -Error.should_contain self element frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_contain self element omitter=Nothing = omitting omitter omitter-> _ = [element] Test.fail_match_on_unexpected_error self omitter=omitter @@ -648,14 +603,12 @@ Error.should_contain self element frames_to_skip=0 omitter=Nothing = omitting om Arguments: - element: The element to check. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. This method delegates to the `contains` method of `self` and will use the rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. Any.should_not_contain : Any -> Integer -> Spec_Result -Any.should_not_contain self element frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Any.should_not_contain self element omitter=Nothing = omitting omitter omitter-> rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else @@ -669,13 +622,11 @@ Any.should_not_contain self element frames_to_skip=0 omitter=Nothing = omitting Arguments: - element: The element to check. - - frames_to_skip (optional, advanced): used to alter the location which is - displayed as the source of this error. This method delegates to the `contains` method of `self` and will use the rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. Error.should_not_contain : Any -> Integer -> Spec_Result -Error.should_not_contain self element frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Error.should_not_contain self element omitter=Nothing = omitting omitter omitter-> _ = [element] Test.fail_match_on_unexpected_error self omitter=omitter diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index 0078b2ace63b..ee19ef5f0866 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -60,7 +60,7 @@ test_problem_handling action expected_problems result_checker (unwrap_errors : B the action is correct. It does not return anything, instead it should use the standard testing approach, like `x.should_equal y`. test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Integer -> Nothing -test_advanced_problem_handling action error_checker warnings_checker result_checker frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +test_advanced_problem_handling action error_checker warnings_checker result_checker omitter=Nothing = omitting omitter omitter-> # First, we check the action ignoring any warnings. result_ignoring = action Problem_Behavior.Ignore result_checker result_ignoring diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index 2d549a3bdac6..d1c222d9a6fe 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -22,6 +22,6 @@ type Should_Reach ## Checks if a point was reached in execution. should_have_reached : Integer -> Spec_Result - should_have_reached self (frames_to_skip : Integer = 0) -> Spec_Result omitter=Nothing = omitting omitter omitter-> + should_have_reached self -> Spec_Result omitter=Nothing = omitting omitter omitter-> if self.reached_ref.get then Spec_Result.Success else Test.fail ("Did not reach Should_Reach (at "+omitter.loc+").") diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 05f1a8bda02c..90f86e73d714 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -44,7 +44,7 @@ type Test example_expect_panic_with = Test.expect_panic_with Examples.throw_panic Examples.My_Error expect_panic_with : Any -> Any -> Integer -> Test_Result - expect_panic_with ~action matcher frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> + expect_panic_with ~action matcher omitter=Nothing = omitting omitter omitter-> handle_panic caught_panic = payload = caught_panic.payload is_internal_test_panic = payload.is_a Spec_Result @@ -97,7 +97,7 @@ type Test If you just want to check for errors, usage of the `.should_succeed` extension function is preferred. - assert_no_problems value frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> + assert_no_problems value omitter=Nothing = omitting omitter omitter-> value.catch Any _-> Test.fail_match_on_unexpected_error value omitter=omitter warnings = Warning.get_all value . map .value @@ -132,7 +132,7 @@ type Test ## PRIVATE Reports an unexpected dataflow error has occurred. fail_match_on_unexpected_error : Error -> Integer -> Nothing - fail_match_on_unexpected_error error frames_to_skip omitter=Nothing = omitting omitter omitter-> + fail_match_on_unexpected_error error omitter=Nothing = omitting omitter omitter-> payload = error.catch msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omitter.loc + ")." Test.fail msg details=error.get_stack_trace_text diff --git a/test/Base_Tests/src/System/File_Spec.enso b/test/Base_Tests/src/System/File_Spec.enso index ffe795d7df01..90a924381bd6 100644 --- a/test/Base_Tests/src/System/File_Spec.enso +++ b/test/Base_Tests/src/System/File_Spec.enso @@ -18,7 +18,7 @@ import project.Data.Data_Spec import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup ## We rely on a less strict equality for `File` as it is fine if a relative file gets resolved to absolute. -File.should_equal self other frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +File.should_equal self other omitter=Nothing = omitting omitter omitter-> are_same = case other of _ : File -> self.absolute.normalize.path == other.absolute.normalize.path _ -> False diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 4f2b813c383b..24372f7d673c 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -11,26 +11,26 @@ from project.Omitter import all polyglot java import org.enso.base_test_helpers.FileSystemHelper Table.should_equal : Any -> Integer -> Any -Table.should_equal self expected frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Table.should_equal self expected omitter=Nothing = omitting omitter omitter-> rhs_error_check expected Panic.catch Test_Failure_Error (table_should_equal_impl self expected omitter.loc) error-> Test.fail error.payload.message Column.should_equal : Any -> Integer -> Any -Column.should_equal self expected frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +Column.should_equal self expected omitter=Nothing = omitting omitter omitter-> rhs_error_check expected Panic.catch Test_Failure_Error (column_should_equal_impl self expected omitter.loc) error-> Test.fail error.payload.message DB_Table.should_equal : DB_Table -> Integer -> Any -DB_Table.should_equal self expected frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +DB_Table.should_equal self expected omitter=Nothing = omitting omitter omitter-> rhs_error_check expected t0 = self.read t1 = expected.read t0 . should_equal t1 omitter=omitter DB_Column.should_equal : DB_Column -> Integer -> Any -DB_Column.should_equal self expected frames_to_skip=0 omitter=Nothing = omitting omitter omitter-> +DB_Column.should_equal self expected omitter=Nothing = omitting omitter omitter-> rhs_error_check expected t0 = self.read t1 = expected.read From ff9c67ab66ed8bea0247f178d2db12bde80e6d64 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 16:21:12 -0500 Subject: [PATCH 09/58] no gsl --- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 21 ------------------- .../src/Semantic/Meta_Location_Spec.enso | 5 ----- .../src/Common_Table_Operations/Main.enso | 6 +++--- .../src/Common_Table_Operations/Util.enso | 10 ++++----- test/Test_Tests/src/Helpers.enso | 6 +++--- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 90f86e73d714..3360ef140835 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -206,24 +206,3 @@ type Test Thread.sleep milliseconds_between_attempts @Tail_Call go (i+1) go 1 - - - ## PRIVATE - - Returns a Text representing the source location of a stack frame above - the call. - - Arguments: - - skip_frames: how many frames on the stack to skip. - - If the function is called with 0 it will return the location of that call. - Note that not only function calls, but also things like pattern matching add - frames to the stack and there is no guarantee that the amount of frames that - need to be skipped will not change between versions, so this method should be - used carefully. - get_source_location skip_frames:Integer -> Text = - stack = Standard.Base.Runtime.get_stack_trace - element = stack . at skip_frames+1 - loc = element . source_location - IO.println "NOOOO "+loc.to_display_text - loc . to_display_text diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index f8f698858ca3..7b902015054d 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -17,11 +17,6 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil Platform.OS.Windows -> "This test is disabled on Windows until issue 1561 is fixed." _ -> Nothing - group_builder.specify "should allow to get the source location of a frame" pending=location_pending <| - src = Test.get_source_location 0 - loc = "Meta_Location_Spec.enso:21:15-40" - src.take (..Last loc.length) . should_equal loc - group_builder.specify "should allow to get qualified type names of values" <| x = 42 y = My_Type.Value 1 2 3 diff --git a/test/Table_Tests/src/Common_Table_Operations/Main.enso b/test/Table_Tests/src/Common_Table_Operations/Main.enso index 4dc890751917..fbcc0a96b1aa 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Main.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Main.enso @@ -3,6 +3,7 @@ from Standard.Base import all import Standard.Database.Internal.Replace_Params.Replace_Params from Standard.Test import Test +from Standard.Test.Omitter import all import project.Common_Table_Operations.Add_Group_Number_Spec import project.Common_Table_Operations.Add_Row_Number_Spec @@ -84,11 +85,10 @@ type Test_Setup supports_custom_objects self = self.is_database.not ## Checks if the provided column has integer type as defined by the backend. - expect_integer_type self column = - loc = Test.get_source_location 1 + expect_integer_type self column omitter=Nothing = omitting omitter omitter-> value_type = column.value_type if self.is_integer_type value_type then column else - Test.fail ("Expected column ["+column.name+"] to have integer type, but got "+value_type.to_display_text+" (at " + loc + ").") + Test.fail ("Expected column ["+column.name+"] to have integer type, but got "+value_type.to_display_text+" (at " + omitter.loc + ").") type Test_Selection ## The configuration specifying what features are supported by a given diff --git a/test/Table_Tests/src/Common_Table_Operations/Util.enso b/test/Table_Tests/src/Common_Table_Operations/Util.enso index 94dc955234f5..754442869ce5 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Util.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Util.enso @@ -50,10 +50,9 @@ within_table table = Test.with_clue 'Resulting table:\n'+description+'\n\n' ## PRIVATE -Any.should_equal_tz_agnostic self other = - loc = Test.get_source_location 1 +Any.should_equal_tz_agnostic self other omitter=Nothing = omitting omitter omitter-> _ = other - Test.fail "Expected a vector but got "+self.to_display_text+" (at "+loc+")." + Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omitter.loc+")." ## PRIVATE A helper method that compares two vectors of Date_Time values. @@ -74,10 +73,9 @@ Vector.should_equal_tz_agnostic self other omitter=Nothing = omitting omitter om _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+omitter.loc+")" ## PRIVATE -Error.should_equal_tz_agnostic self other = - loc = Test.get_source_location 1 +Error.should_equal_tz_agnostic self other omitter=Nothing = omitting omitter omitter-> _ = other - Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+loc+")." + Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omitter.loc+")." ## PRIVATE Builds a table ensuring that the rows are in the order as given. diff --git a/test/Test_Tests/src/Helpers.enso b/test/Test_Tests/src/Helpers.enso index 5942d2f545f6..dae9559f8c84 100644 --- a/test/Test_Tests/src/Helpers.enso +++ b/test/Test_Tests/src/Helpers.enso @@ -2,10 +2,10 @@ from Standard.Base import all import Standard.Test.Spec_Result.Spec_Result from Standard.Test import Test +from Standard.Test.Omitter import all ## Expects the inner action to report a test failure exception and returns its payload. -expect_test_failure ~action -> Spec_Result = - loc = Test.get_source_location 1 +expect_test_failure ~action -> Spec_Result omitter=Nothing = omitting omitter omitter-> handle_panic caught_panic = result = caught_panic.payload case result of @@ -14,4 +14,4 @@ expect_test_failure ~action -> Spec_Result = Panic.catch Spec_Result handler=handle_panic <| action - Test.fail "Expected the inner action to fail, but there was no failure (at "+loc+")." + Test.fail "Expected the inner action to fail, but there was no failure (at "+omitter.loc+")." From ca2c0ce4ce42e16997254815114dc44399fe5dfa Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 5 Feb 2025 16:27:50 -0500 Subject: [PATCH 10/58] wip --- test/Table_Tests/src/Util.enso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 24372f7d673c..3960ad977cf2 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -6,7 +6,7 @@ import Standard.Database.DB_Column.DB_Column from Standard.Table import Column, Table from Standard.Test import all -from project.Omitter import all +from Standard.Test.Omitter import all polyglot java import org.enso.base_test_helpers.FileSystemHelper From 8f26d0ad602a13a22243212761d63cfcfc26e4d9 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 11:52:53 -0500 Subject: [PATCH 11/58] simplify, no obj --- .../Test/0.0.0-dev/src/Extensions.enso | 144 +++++++++--------- .../Standard/Test/0.0.0-dev/src/Omitter.enso | 30 ++-- .../Standard/Test/0.0.0-dev/src/Problems.enso | 38 ++--- .../Test/0.0.0-dev/src/Should_Reach.enso | 4 +- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 24 +-- test/Base_Tests/src/System/File_Spec.enso | 4 +- .../Aggregate_Spec.enso | 14 +- .../src/Common_Table_Operations/Main.enso | 4 +- .../src/Common_Table_Operations/Util.enso | 22 +-- test/Table_Tests/src/IO/Fetch_Spec.enso | 4 +- .../Table_Tests/src/In_Memory/Table_Spec.enso | 4 +- test/Table_Tests/src/Util.enso | 32 ++-- test/Test_Tests/src/Helpers.enso | 4 +- 13 files changed, 164 insertions(+), 164 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 1258acb925d3..9505f3ce41bb 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -24,10 +24,10 @@ from project.Omitter import all example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error Any.should_fail_with : Any -> Integer -> Boolean -> Spec_Result -Any.should_fail_with self matcher unwrap_errors=True omitter=Nothing = omitting omitter omitter-> +Any.should_fail_with self matcher unwrap_errors=True = omitting <| _ = unwrap_errors matcher_text = matcher . to_text - Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + omitter.loc + ").") + Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + omitting_get_stack_trace + ").") ## Expect a function to fail with the provided dataflow error. @@ -45,12 +45,12 @@ Any.should_fail_with self matcher unwrap_errors=True omitter=Nothing = omitting example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error Error.should_fail_with : Any -> Integer -> Boolean -> Spec_Result -Error.should_fail_with self matcher unwrap_errors=True omitter=Nothing = omitting omitter omitter-> +Error.should_fail_with self matcher unwrap_errors=True = omitting <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error caught = unwrap_maybe self.catch if caught == matcher || caught.is_a matcher then Nothing else matcher_text = matcher . to_text - Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + omitter.loc + ").") details='The error had the following stack trace:\n'+self.get_stack_trace_text + Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + omitting_get_stack_trace + ").") details='The error had the following stack trace:\n'+self.get_stack_trace_text ## Asserts that `self` value is equal to the expected value. @@ -65,7 +65,7 @@ Error.should_fail_with self matcher unwrap_errors=True omitter=Nothing = omittin example_should_equal = Examples.add_1_to 1 . should_equal 2 Any.should_equal : Any -> Integer -> Spec_Result -Any.should_equal self that omitter=Nothing = omitting omitter omitter-> +Any.should_equal self that = omitting <| rhs_error_check that case self == that of True -> Spec_Result.Success @@ -81,7 +81,7 @@ Any.should_equal self that omitter=Nothing = omitting omitter omitter-> False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") " _ -> "" _ -> "" - msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omitter.loc + ")." + msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omitting_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value is equal to the expected type value. @@ -97,16 +97,16 @@ Any.should_equal self that omitter=Nothing = omitting omitter omitter-> example_should_equal = Examples.some_type . should_equal_type Vector Any.should_equal_type : Any -> Integer -> Spec_Result -Any.should_equal_type self that omitter=Nothing = omitting omitter omitter-> case (self.is_same_object_as that) of +Any.should_equal_type self that = omitting <| case (self.is_same_object_as that) of True -> Spec_Result.Success False -> - msg = self.to_text + " did not equal type " + that.to_text + " (at " + omitter.loc + ")." + msg = self.to_text + " did not equal type " + that.to_text + " (at " + omitting_get_stack_trace + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_equal_type self that omitter=Nothing = omitting omitter omitter-> +Error.should_equal_type self that = omitting <| _ = [that] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` value is not equal to the expected value. @@ -121,17 +121,17 @@ Error.should_equal_type self that omitter=Nothing = omitting omitter omitter-> example_should_not_equal = Examples.add_1_to 1 . should_not_equal 2 Any.should_not_equal : Any -> Integer -> Spec_Result -Any.should_not_equal self that omitter=Nothing = omitting omitter omitter-> if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else +Any.should_not_equal self that = omitting <| if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else case self != that of True -> Spec_Result.Success False -> - msg = self.to_text + " did equal " + that.to_text + " (at " + omitter.loc + ")." + msg = self.to_text + " did equal " + that.to_text + " (at " + omitting_get_stack_trace + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal self that omitter=Nothing = omitting omitter omitter-> +Error.should_not_equal self that = omitting <| _ = [that] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` value is not equal to the expected type value. @@ -146,16 +146,16 @@ Error.should_not_equal self that omitter=Nothing = omitting omitter omitter-> example_should_not_equal = Examples.some_type . should_not_equal_type Vector Any.should_not_equal_type : Any -> Integer -> Spec_Result -Any.should_not_equal_type self that omitter=Nothing = omitting omitter omitter-> case (self.is_same_object_as that . not) of +Any.should_not_equal_type self that = omitting <| case (self.is_same_object_as that . not) of True -> Spec_Result.Success False -> - msg = self.to_text + " did equal type " + that.to_text + " (at " + omitter.loc + ")." + msg = self.to_text + " did equal type " + that.to_text + " (at " + omitting_get_stack_trace + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal_type self that omitter=Nothing = omitting omitter omitter-> +Error.should_not_equal_type self that = omitting <| _ = [that] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` value is a Text value and starts with `that`. @@ -169,14 +169,14 @@ Error.should_not_equal_type self that omitter=Nothing = omitting omitter omitter example_should_start_with = "Hello World!" . should_start_with "Hello" Any.should_start_with : Text -> Integer -> Spec_Result -Any.should_start_with self that omitter=Nothing = omitting omitter omitter-> +Any.should_start_with self that = omitting <| rhs_error_check that case self of _ : Text -> if self.starts_with that then Spec_Result.Success else - msg = self.to_text + " does not start with " + that.to_text + " (at " + omitter.loc + ")." + msg = self.to_text + " does not start with " + that.to_text + " (at " + omitting_get_stack_trace + ")." Test.fail msg _ -> - msg = self.to_text + " is not a `Text` value (at " + omitter.loc + ")." + msg = self.to_text + " is not a `Text` value (at " + omitting_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value is a Text value and ends with `that`. @@ -191,14 +191,14 @@ Any.should_start_with self that omitter=Nothing = omitting omitter omitter-> example_should_end_with = "Hello World!" . should_end_with "ld!" Any.should_end_with : Text -> Integer -> Spec_Result -Any.should_end_with self that omitter=Nothing = omitting omitter omitter-> +Any.should_end_with self that = omitting <| rhs_error_check that case self of _ : Text -> if self.ends_with that then Spec_Result.Success else - msg = self.to_text + " does not end with " + that.to_text + " (at " + omitter.loc + ")." + msg = self.to_text + " does not end with " + that.to_text + " (at " + omitting_get_stack_trace + ")." Test.fail msg _ -> - msg = self.to_text + " is not a `Text` value (at " + omitter.loc + ")." + msg = self.to_text + " is not a `Text` value (at " + omitting_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value is a Text value and starts with `that`. @@ -213,9 +213,9 @@ Any.should_end_with self that omitter=Nothing = omitting omitter omitter-> example_should_start_with = "Hello World!" . should_start_with "Hello" Error.should_start_with : Any -> Integer -> Spec_Result -Error.should_start_with self that omitter=Nothing = omitting omitter omitter-> +Error.should_start_with self that = omitting <| _ = [that] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` value is a Text value and ends with `that`. @@ -229,9 +229,9 @@ Error.should_start_with self that omitter=Nothing = omitting omitter omitter-> example_should_end_with = "Hello World!" . should_end_with "ld!" Error.should_end_with : Any -> Integer -> Spec_Result -Error.should_end_with self that omitter=Nothing = omitting omitter omitter-> +Error.should_end_with self that = omitting <| _ = [that] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` value is equal to the expected value. @@ -246,9 +246,9 @@ Error.should_end_with self that omitter=Nothing = omitting omitter omitter-> example_should_equal = Examples.add_1_to 1 . should_equal 2 Error.should_equal : Any -> Integer -> Spec_Result -Error.should_equal self that omitter=Nothing = omitting omitter omitter-> +Error.should_equal self that = omitting <| rhs_error_check that - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` is within `epsilon` from `that`. @@ -271,7 +271,7 @@ Error.should_equal self that omitter=Nothing = omitting omitter omitter-> example_should_equal = 1.00000001 . should_equal 1.00000002 epsilon=0.0001 Number.should_equal : Float -> Float -> Integer -> Spec_Result -Number.should_equal self that epsilon=0 omitter=Nothing = omitting omitter omitter-> +Number.should_equal self that epsilon=0 = omitting <| rhs_error_check that matches = case that of n : Number -> self.equals n epsilon . catch Incomparable_Values _-> @@ -283,7 +283,7 @@ Number.should_equal self that epsilon=0 omitter=Nothing = omitting omitter omitt case matches of True -> Spec_Result.Success False -> - msg = self.to_text + " did not equal " + that.to_text + " (at " + omitter.loc + ")." + msg = self.to_text + " did not equal " + that.to_text + " (at " + omitting_get_stack_trace + ")." Test.fail msg ## Asserts that `self` is within `epsilon` from `that`. @@ -292,9 +292,9 @@ Number.should_equal self that epsilon=0 omitter=Nothing = omitting omitter omitt - that: The value to compare `self` for equality with. - epsilon: The epsilon for comparing two float numbers. Decimal.should_equal : Number -> Float-> Float -> Integer -> Spec_Result -Decimal.should_equal self that epsilon=0 omitter=Nothing = omitting omitter omitter-> +Decimal.should_equal self that epsilon=0 = omitting <| rhs_error_check that - self.to_float . should_equal that.to_float epsilon omitter=omitter + self.to_float . should_equal that.to_float epsilon ## Asserts that `self` value is not an error. @@ -317,14 +317,14 @@ Any.should_succeed self = "foobar".write (enso_project.data / "f.txt") . should_succeed Error.should_succeed : Integer -> Any -Error.should_succeed self omitter=Nothing = omitting omitter omitter-> - Test.fail_match_on_unexpected_error self omitter=omitter +Error.should_succeed self = omitting <| + Test.fail_match_on_unexpected_error self ## Handles an unexpected dataflow error. Error.should_be_a : Any -> Integer -> Any -Error.should_be_a self typ omitter=Nothing = omitting omitter omitter-> +Error.should_be_a self typ = omitting <| _ = typ - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that the given `Boolean` is `True` @@ -336,10 +336,10 @@ Error.should_be_a self typ omitter=Nothing = omitting omitter omitter-> example_should_be_true = Examples.get_boolean . should_be_true Boolean.should_be_true : Spec_Result -Boolean.should_be_true self omitter=Nothing = omitting omitter omitter-> case self of +Boolean.should_be_true self = omitting <| case self of True -> Spec_Result.Success False -> - Test.fail "Expected False to be True (at "+omitter.loc+")." + Test.fail "Expected False to be True (at "+omitting_get_stack_trace+")." ## Asserts that the given `Boolean` is `True`. @@ -351,7 +351,7 @@ Boolean.should_be_true self omitter=Nothing = omitting omitter omitter-> case se example_should_be_true = Examples.get_boolean . should_be_true Error.should_be_true : Spec_Result -Error.should_be_true self omitter=Nothing = omitting omitter omitter-> Test.fail_match_on_unexpected_error self omitter=omitter +Error.should_be_true self = omitting <| Test.fail_match_on_unexpected_error self ## Asserts that the given `Boolean` is `False` @@ -363,9 +363,9 @@ Error.should_be_true self omitter=Nothing = omitting omitter omitter-> Test.fail example_should_be_false = Examples.get_boolean . should_be_false Boolean.should_be_false : Spec_Result -Boolean.should_be_false self omitter=Nothing = omitting omitter omitter-> case self of +Boolean.should_be_false self = omitting <| case self of True -> - Test.fail "Expected True to be False (at "+omitter.loc+")." + Test.fail "Expected True to be False (at "+omitting_get_stack_trace+")." False -> Spec_Result.Success ## Asserts that the given `Boolean` is `False` @@ -378,7 +378,7 @@ Boolean.should_be_false self omitter=Nothing = omitting omitter omitter-> case s example_should_be_false = Examples.get_boolean . should_be_false Error.should_be_false : Spec_Result -Error.should_be_false self omitter=Nothing = omitting omitter omitter-> Test.fail_match_on_unexpected_error self omitter=omitter +Error.should_be_false self = omitting <| Test.fail_match_on_unexpected_error self ## Asserts that a value is of a given type. @@ -392,7 +392,7 @@ Error.should_be_false self omitter=Nothing = omitting omitter omitter-> Test.fai example_should_be_a = 1.should_be_a Boolean Any.should_be_a : Any -> Spec_Result -Any.should_be_a self typ omitter=Nothing = omitting omitter omitter-> +Any.should_be_a self typ = omitting <| rhs_error_check typ fail_on_wrong_arg_type = Panic.throw <| @@ -403,36 +403,36 @@ Any.should_be_a self typ omitter=Nothing = omitting omitter omitter-> if a.constructor == c then Spec_Result.Success else expected_type = c.declaring_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+omitter.loc+")." + message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+omitting_get_stack_trace+")." Test.fail message _ -> expected_type = c.declaring_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitter.loc+")." + message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitting_get_stack_trace+")." Test.fail message meta_type : Meta.Type -> ok = self.is_a typ || self==typ if ok then Spec_Result.Success else expected_type = meta_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitter.loc+")." + message = "Expected a value of type "+expected_type+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitting_get_stack_trace+")." Test.fail message # Workaround for 0-argument atom constructors which 'unapplies' them. atom : Meta.Atom -> ctor = atom . constructor if ctor.fields.not_empty then fail_on_wrong_arg_type else - self.should_equal atom.value omitter=omitter + self.should_equal atom.value _ : Meta.Polyglot -> ok = self.is_a typ if ok then Spec_Result.Success else actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of Java class "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitter.loc+")." + message = "Expected a value of Java class "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitting_get_stack_trace+")." Test.fail message p : Meta.Primitive -> ok = self == p.value if ok then Spec_Result.Success else actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitter.loc+")." + message = "Expected a value of "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitting_get_stack_trace+")." Test.fail message _ -> fail_on_wrong_arg_type @@ -456,23 +456,23 @@ Any.should_be_a self typ omitter=Nothing = omitting omitter omitter-> example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] Any.should_equal_ignoring_order : Any -> Integer -> Spec_Result -Any.should_equal_ignoring_order self that omitter=Nothing = omitting omitter omitter-> +Any.should_equal_ignoring_order self that = omitting <| if that.is_a Vector . not then - Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+omitter.loc+").") + Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+omitting_get_stack_trace+").") that.each element-> if self.contains element . not then - msg = "The collection (" + self.to_text + ") did not contain " + element.to_text + " (at " + omitter.loc + ")." + msg = "The collection (" + self.to_text + ") did not contain " + element.to_text + " (at " + omitting_get_stack_trace + ")." Test.fail msg self.each element-> if that.contains element . not then - msg = "The collection contained an element (" + element.to_text + ") which was not expected (at " + omitter.loc + ")." + msg = "The collection contained an element (" + element.to_text + ") which was not expected (at " + omitting_get_stack_trace + ")." Test.fail msg Test.with_clue "Duplicate elements in either collection should have the same counts - checked by comparing sorted collections: " <| ## If the vector contains vectors or incomparable values, they may not get sorted correctly. We normalize by converting to a text representation. normalize e = Panic.catch No_Such_Method e.pretty _->e.to_text - (self.sort on=normalize) . should_equal (that.sort on=normalize) omitter=omitter + (self.sort on=normalize) . should_equal (that.sort on=normalize) Spec_Result.Success ## Asserts that `self` value contains the same elements as `that`. @@ -495,9 +495,9 @@ Any.should_equal_ignoring_order self that omitter=Nothing = omitting omitter omi example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] Error.should_equal_ignoring_order : Any -> Integer -> Spec_Result -Error.should_equal_ignoring_order self that omitter=Nothing = omitting omitter omitter-> +Error.should_equal_ignoring_order self that = omitting <| _ = [that] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` value contains only elements in `that`. @@ -520,11 +520,11 @@ Error.should_equal_ignoring_order self that omitter=Nothing = omitting omitter o example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] Any.should_only_contain_elements_in : Any -> Integer -> Spec_Result -Any.should_only_contain_elements_in self that omitter=Nothing = omitting omitter omitter-> +Any.should_only_contain_elements_in self that = omitting <| rhs_error_check that self.each element-> if that.contains element . not then - msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + omitter.loc + ")." + msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + omitting_get_stack_trace + ")." Test.fail msg Spec_Result.Success @@ -549,9 +549,9 @@ Any.should_only_contain_elements_in self that omitter=Nothing = omitting omitter example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] Error.should_only_contain_elements_in : Any -> Integer -> Spec_Result -Error.should_only_contain_elements_in self that omitter=Nothing = omitting omitter omitter-> +Error.should_only_contain_elements_in self that = omitting <| _ = [that] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` value contains an element. @@ -569,14 +569,14 @@ Error.should_only_contain_elements_in self that omitter=Nothing = omitting omitt example_should_equal = "foobar".should_contain "foo" Any.should_contain : Any -> Integer -> Spec_Result -Any.should_contain self element omitter=Nothing = omitting omitter omitter-> +Any.should_contain self element = omitting <| rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else - msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omitter.loc + ")." + msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omitting_get_stack_trace + ")." Test.fail msg if contains_result then Spec_Result.Success else - msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + omitter.loc + ")." + msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + omitting_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value contains an element. @@ -595,9 +595,9 @@ Any.should_contain self element omitter=Nothing = omitting omitter omitter-> example_should_equal = "foobar".should_contain "foo" Error.should_contain : Any -> Integer -> Spec_Result -Error.should_contain self element omitter=Nothing = omitting omitter omitter-> +Error.should_contain self element = omitting <| _ = [element] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self ## Asserts that `self` value does not contain an element. @@ -608,14 +608,14 @@ Error.should_contain self element omitter=Nothing = omitting omitter omitter-> rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. Any.should_not_contain : Any -> Integer -> Spec_Result -Any.should_not_contain self element omitter=Nothing = omitting omitter omitter-> +Any.should_not_contain self element = omitting <| rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else - msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omitter.loc + ")." + msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omitting_get_stack_trace + ")." Test.fail msg if contains_result.not then Spec_Result.Success else - msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + omitter.loc + ")." + msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + omitting_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value does not contain an element. @@ -627,6 +627,6 @@ Any.should_not_contain self element omitter=Nothing = omitting omitter omitter-> rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. Error.should_not_contain : Any -> Integer -> Spec_Result -Error.should_not_contain self element omitter=Nothing = omitting omitter omitter-> +Error.should_not_contain self element = omitting <| _ = [element] - Test.fail_match_on_unexpected_error self omitter=omitter + Test.fail_match_on_unexpected_error self diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 7d058cd1b9e8..36ce7a38a44a 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -1,22 +1,22 @@ from Standard.Base import all -type Omitter - Value ~err +pst s st = + IO.println "==== "+s + st . take 12 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) - loc self = - stack_trace = Runtime.get_stack_trace - #pst "full" stack_trace +omitting ~action = + IO.println "AAAAA "+omitting_get_stack_trace.to_display_text + action - omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") - real_stack_trace = stack_trace.drop (omitting_index + 2) +omitting_get_stack_trace = + stack_trace = Runtime.get_stack_trace + pst "full" stack_trace - #IO.println "OI "+omitting_index.to_text - #pst "real" real_stack_trace + omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") + real_stack_trace = stack_trace.drop (omitting_index + 2) - top = real_stack_trace . at 0 . source_location - top.to_display_text + IO.println "OI "+omitting_index.to_text + pst "real" real_stack_trace -omitting default_omitter ~action = - omitter = default_omitter.if_nothing (Omitter.Value (Error.throw "here")) - IO.println "AAAAA "+omitter.loc.to_display_text - action omitter + top = real_stack_trace . at 0 . source_location + top.to_display_text diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index ee19ef5f0866..5bcf812488d3 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -28,20 +28,20 @@ get_attached_warnings v = duplicated and that will be accepted. If false (default), the warning count has to match the counts in `expected_problems`. test_problem_handling : (Problem_Behavior -> Any) -> Vector Any -> (Any -> Nothing) -> Boolean -> Boolean -> Nothing -test_problem_handling action expected_problems result_checker (unwrap_errors : Boolean = True) (ignore_warning_cardinality : Boolean = False) omitter=Nothing = omitting omitter omitter-> +test_problem_handling action expected_problems result_checker (unwrap_errors : Boolean = True) (ignore_warning_cardinality : Boolean = False) = omitting <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error error_checker error_result = first_problem = expected_problems.first first_problem_type = Meta.type_of first_problem - error_result . should_fail_with first_problem_type unwrap_errors=unwrap_errors omitter=omitter - (unwrap_maybe error_result.catch) . should_equal first_problem omitter=omitter + error_result . should_fail_with first_problem_type unwrap_errors=unwrap_errors + (unwrap_maybe error_result.catch) . should_equal first_problem warnings_checker warnings = Test.with_clue "The warnings were "+warnings.to_text+'.\n' <| (if ignore_warning_cardinality then warnings.distinct else warnings) . map unwrap_maybe - . should_equal_ignoring_order expected_problems omitter=omitter - test_advanced_problem_handling action error_checker warnings_checker result_checker omitter=omitter + . should_equal_ignoring_order expected_problems + test_advanced_problem_handling action error_checker warnings_checker result_checker ## UNSTABLE Tests how a specific operation behaves depending on the requested @@ -60,11 +60,11 @@ test_problem_handling action expected_problems result_checker (unwrap_errors : B the action is correct. It does not return anything, instead it should use the standard testing approach, like `x.should_equal y`. test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Integer -> Nothing -test_advanced_problem_handling action error_checker warnings_checker result_checker omitter=Nothing = omitting omitter omitter-> +test_advanced_problem_handling action error_checker warnings_checker result_checker = omitting <| # First, we check the action ignoring any warnings. result_ignoring = action Problem_Behavior.Ignore result_checker result_ignoring - get_attached_warnings result_ignoring . should_equal [] omitter=omitter + get_attached_warnings result_ignoring . should_equal [] # Then, we check the fail-on-first-error mode. error_result = action Problem_Behavior.Report_Error @@ -77,12 +77,12 @@ test_advanced_problem_handling action error_checker warnings_checker result_chec ## UNSTABLE Checks if the provided value does not have any attached problems. -assume_no_problems result omitter=Nothing = omitting omitter omitter-> +assume_no_problems result = omitting <| if result.is_error then - Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitter.loc+")." details=result.get_stack_trace_text + Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitting_get_stack_trace+")." details=result.get_stack_trace_text warnings = get_attached_warnings result if warnings.not_empty then - Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+omitter.loc+")." + Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+omitting_get_stack_trace+")." ## UNSTABLE Checks if the provided value has a specific warning attached. @@ -95,15 +95,15 @@ assume_no_problems result omitter=Nothing = omitting omitter omitter-> - unwrap_errors: If true, remove any wrapping errors from the result before checking against the expected warning. expect_warning : Any -> Any -> Boolean -> Nothing -expect_warning expected_warning result unwrap_errors=True omitter=Nothing = omitting omitter omitter-> +expect_warning expected_warning result unwrap_errors=True = omitting <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error if result.is_error then - Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitter.loc+")." + Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitting_get_stack_trace+")." warnings = get_attached_warnings result . map unwrap_maybe found = warnings.find if_missing=Nothing x-> (x == expected_warning) || (x.is_a expected_warning) found.if_nothing <| - Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omitter.loc+').' + Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omitting_get_stack_trace+').' ## UNSTABLE Checks if the provided value has a specific warning attached and if there are @@ -118,19 +118,19 @@ expect_warning expected_warning result unwrap_errors=True omitter=Nothing = omit - unwrap_errors: If true, remove any wrapping errors from the result before checking against the expected warning. expect_only_warning : Any -> Any -> Boolean -> Any -expect_only_warning expected_warning result unwrap_errors=True omitter=Nothing = omitting omitter omitter-> +expect_only_warning expected_warning result unwrap_errors=True = omitting <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error if result.is_error then - Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitter.loc+")." + Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitting_get_stack_trace+")." warnings = get_attached_warnings result . map unwrap_maybe is_expected x = (x == expected_warning) || (x.is_a expected_warning) found = warnings.find if_missing=Nothing is_expected if found.is_nothing then - Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omitter.loc+').' + Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omitting_get_stack_trace+').' invalid = warnings.filter x-> is_expected x . not if invalid.not_empty then - Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+omitter.loc+').' + Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+omitting_get_stack_trace+').' found ## UNSTABLE @@ -138,8 +138,8 @@ expect_only_warning expected_warning result unwrap_errors=True omitter=Nothing = It allows other warnings to be present also. not_expect_warning : Any -> Any -> Nothing -not_expect_warning expected_warning_type result omitter=Nothing = omitting omitter omitter-> +not_expect_warning expected_warning_type result = omitting <| warnings = get_attached_warnings result found = warnings.find if_missing=Nothing x-> x.is_a expected_warning_type if found.is_nothing.not then - Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+omitter.loc+').' + Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+omitting_get_stack_trace+').' diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index d1c222d9a6fe..eb41abb8dc51 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -22,6 +22,6 @@ type Should_Reach ## Checks if a point was reached in execution. should_have_reached : Integer -> Spec_Result - should_have_reached self -> Spec_Result omitter=Nothing = omitting omitter omitter-> + should_have_reached self -> Spec_Result = omitting <| if self.reached_ref.get then Spec_Result.Success else - Test.fail ("Did not reach Should_Reach (at "+omitter.loc+").") + Test.fail ("Did not reach Should_Reach (at "+omitting_get_stack_trace+").") diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 3360ef140835..6ee99e510371 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -44,7 +44,7 @@ type Test example_expect_panic_with = Test.expect_panic_with Examples.throw_panic Examples.My_Error expect_panic_with : Any -> Any -> Integer -> Test_Result - expect_panic_with ~action matcher omitter=Nothing = omitting omitter omitter-> + expect_panic_with ~action matcher = omitting <| handle_panic caught_panic = payload = caught_panic.payload is_internal_test_panic = payload.is_a Spec_Result @@ -55,17 +55,17 @@ type Test is_panic_matching = payload.is_a matcher if is_panic_matching then payload else stack_trace = caught_panic.convert_to_dataflow_error.get_stack_trace_text - Test.fail ("Expected a " + matcher.to_text + ", but " + payload.to_text + " was thrown instead (at " + omitter.loc + ").") details=stack_trace + Test.fail ("Expected a " + matcher.to_text + ", but " + payload.to_text + " was thrown instead (at " + omitting_get_stack_trace + ").") details=stack_trace Panic.catch Any handler=handle_panic <| res = action # If the action did not panic above, we fail the test. case res.is_error of True -> - Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action returned a Dataflow Error " + res.catch.to_display_text + " instead (at " + omitter.loc + ").") + Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action returned a Dataflow Error " + res.catch.to_display_text + " instead (at " + omitting_get_stack_trace + ").") False -> return_suffix = if res.is_nothing then "" else " and returned ["+res.to_text+"]" - Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action succeeded" + return_suffix + " (at " + omitter.loc + ").") + Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action succeeded" + return_suffix + " (at " + omitting_get_stack_trace + ").") ## Expect a function to fail with the provided panic. @@ -90,19 +90,19 @@ type Test IO.println 'this is not reached' expect_panic : Any -> Any -> Test_Result - expect_panic matcher ~action omitter=Nothing = omitting omitter omitter-> Test.expect_panic_with action matcher omitter=omitter + expect_panic matcher ~action = omitting <| Test.expect_panic_with action matcher ## Checks that the provided action returns without any errors or warnings. If you just want to check for errors, usage of the `.should_succeed` extension function is preferred. - assert_no_problems value omitter=Nothing = omitting omitter omitter-> + assert_no_problems value = omitting <| value.catch Any _-> - Test.fail_match_on_unexpected_error value omitter=omitter + Test.fail_match_on_unexpected_error value warnings = Warning.get_all value . map .value if warnings.not_empty then - msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + omitter.loc + ")." + msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + omitting_get_stack_trace + ")." Test.fail msg ## Fail a test with the given message. @@ -132,9 +132,9 @@ type Test ## PRIVATE Reports an unexpected dataflow error has occurred. fail_match_on_unexpected_error : Error -> Integer -> Nothing - fail_match_on_unexpected_error error omitter=Nothing = omitting omitter omitter-> + fail_match_on_unexpected_error error = omitting <| payload = error.catch - msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omitter.loc + ")." + msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omitting_get_stack_trace + ")." Test.fail msg details=error.get_stack_trace_text ## Executes the block of code passed as behavior and adds a clue modifier which @@ -189,7 +189,7 @@ type Test or fails with the last error thrown by the action after exhausting retry attempts. with_retries : Any -> Any - with_retries ~action omitter=Nothing = omitting omitter omitter-> + with_retries ~action = omitting <| milliseconds_between_attempts = 100 ## We give the CI a bit more attempts, as failures are more annoying there. For local development, a bit less retries is enough - there it is more @@ -202,7 +202,7 @@ type Test # If the iterations are exhausted, we rethrow the panic. if i > max_retries then Panic.throw caught_panic else if i % 10 == 0 then - IO.println 'Still failing after '+i.to_text+' retries ('+omitter.loc.to_display_text+'):\n'+caught_panic.payload.to_display_text + IO.println 'Still failing after '+i.to_text+' retries ('+omitting_get_stack_trace.to_display_text+'):\n'+caught_panic.payload.to_display_text Thread.sleep milliseconds_between_attempts @Tail_Call go (i+1) go 1 diff --git a/test/Base_Tests/src/System/File_Spec.enso b/test/Base_Tests/src/System/File_Spec.enso index 90a924381bd6..009070ae95f1 100644 --- a/test/Base_Tests/src/System/File_Spec.enso +++ b/test/Base_Tests/src/System/File_Spec.enso @@ -18,12 +18,12 @@ import project.Data.Data_Spec import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup ## We rely on a less strict equality for `File` as it is fine if a relative file gets resolved to absolute. -File.should_equal self other omitter=Nothing = omitting omitter omitter-> +File.should_equal self other = omitting <| are_same = case other of _ : File -> self.absolute.normalize.path == other.absolute.normalize.path _ -> False if are_same then self else - Test.fail "Expected "+self.to_text+" to be equal to "+other.to_text+" (at "+omitter.loc+")." + Test.fail "Expected "+self.to_text+" to be equal to "+other.to_text+" (at "+omitting_get_stack_trace+")." set_writable file writable = diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index 2a7667a021ff..2e992e738b72 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -59,8 +59,8 @@ add_aggregate_specs suite_builder setup = table_builder = setup.table_builder data = Data.setup table_fn empty_table_fn - expect_column_names names table omitter=Nothing = omitting omitter omitter-> - table.columns . map .name . should_equal names omitter=omitter + expect_column_names names table = omitting <| + table.columns . map .name . should_equal names find_row key table (columns=Nothing) = table_columns = if columns.is_nothing then table.columns else columns.map x->(table.columns.at x) @@ -1108,10 +1108,10 @@ add_aggregate_specs suite_builder setup = suite_builder.group prefix+"Table.aggregate Count_Distinct" group_builder-> group_builder.specify "should correctly count missing values" <| - get_value t omitter=Nothing = omitting omitter omitter-> + get_value t = omitting <| columns = materialize t . columns - columns.length . should_equal 1 omitter=omitter - columns.first.length . should_equal 1 omitter=omitter + columns.length . should_equal 1 + columns.first.length . should_equal 1 columns.first . at 0 ## TODO currently our builder does not allow all-null tables, so we @@ -1255,13 +1255,13 @@ add_aggregate_specs suite_builder setup = m1.columns.first.at 0 . should_equal 1.1180339887499 epsilon=0.000001 m1.columns.second.at 0 . should_equal 1.2909944487358 epsilon=0.000001 - expect_null_or_nan value omitter=Nothing = omitting omitter omitter-> + expect_null_or_nan value = omitting <| matches = case value of Nothing -> True _ : Float -> Double.isNaN value _ -> False if matches.not then - Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+omitter.loc+")." + Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+omitting_get_stack_trace+")." if setup.flagged ..Supports_Infinity then suite_builder.group prefix+"Table.aggregate should correctly handle infinities" group_builder-> pos_inf = 1/0 diff --git a/test/Table_Tests/src/Common_Table_Operations/Main.enso b/test/Table_Tests/src/Common_Table_Operations/Main.enso index fbcc0a96b1aa..42e71df73c09 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Main.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Main.enso @@ -85,10 +85,10 @@ type Test_Setup supports_custom_objects self = self.is_database.not ## Checks if the provided column has integer type as defined by the backend. - expect_integer_type self column omitter=Nothing = omitting omitter omitter-> + expect_integer_type self column = omitting <| value_type = column.value_type if self.is_integer_type value_type then column else - Test.fail ("Expected column ["+column.name+"] to have integer type, but got "+value_type.to_display_text+" (at " + omitter.loc + ").") + Test.fail ("Expected column ["+column.name+"] to have integer type, but got "+value_type.to_display_text+" (at " + omitting_get_stack_trace + ").") type Test_Selection ## The configuration specifying what features are supported by a given diff --git a/test/Table_Tests/src/Common_Table_Operations/Util.enso b/test/Table_Tests/src/Common_Table_Operations/Util.enso index 754442869ce5..f7468e84b741 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Util.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Util.enso @@ -8,10 +8,10 @@ from Standard.Test.Omitter import all from project.In_Memory.Common_Spec import in_memory_setup -expect_column_names names table ignore_order=False omitter=Nothing = omitting omitter omitter-> +expect_column_names names table ignore_order=False = omitting <| case ignore_order of - False -> table.columns . map .name . should_equal names omitter=omitter - True -> table.columns . map .name . sort . should_equal names.sort omitter=omitter + False -> table.columns . map .name . should_equal names + True -> table.columns . map .name . sort . should_equal names.sort ## These tests are parametrized by various backends and so they should be run in context of a specific backend. However, for the purpose of testing we provide @@ -50,9 +50,9 @@ within_table table = Test.with_clue 'Resulting table:\n'+description+'\n\n' ## PRIVATE -Any.should_equal_tz_agnostic self other omitter=Nothing = omitting omitter omitter-> +Any.should_equal_tz_agnostic self other = omitting <| _ = other - Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omitter.loc+")." + Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omitting_get_stack_trace+")." ## PRIVATE A helper method that compares two vectors of Date_Time values. @@ -60,22 +60,22 @@ Any.should_equal_tz_agnostic self other omitter=Nothing = omitting omitter omitt It ensures that they represent the same instant in time, but ignore the timezone that is attached to them. This is simply done by converting them to UTC. -Vector.should_equal_tz_agnostic self other omitter=Nothing = omitting omitter omitter-> +Vector.should_equal_tz_agnostic self other = omitting <| case other of _ : Vector -> utc = Time_Zone.utc normalize_date_time dt = case dt of _ : Date_Time -> dt.at_zone utc - _ -> Test.fail "The vector should contain Date_Time objects but it contained "+dt.to_display_text+" (at "+omitter.loc+")" + _ -> Test.fail "The vector should contain Date_Time objects but it contained "+dt.to_display_text+" (at "+omitting_get_stack_trace+")" self_normalized = self.map normalize_date_time other_normalized = other.map normalize_date_time - self_normalized.should_equal other_normalized omitter=omitter - _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+omitter.loc+")" + self_normalized.should_equal other_normalized + _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+omitting_get_stack_trace+")" ## PRIVATE -Error.should_equal_tz_agnostic self other omitter=Nothing = omitting omitter omitter-> +Error.should_equal_tz_agnostic self other = omitting <| _ = other - Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omitter.loc+")." + Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omitting_get_stack_trace+")." ## PRIVATE Builds a table ensuring that the rows are in the order as given. diff --git a/test/Table_Tests/src/IO/Fetch_Spec.enso b/test/Table_Tests/src/IO/Fetch_Spec.enso index 282a32da9491..79b410daa66c 100644 --- a/test/Table_Tests/src/IO/Fetch_Spec.enso +++ b/test/Table_Tests/src/IO/Fetch_Spec.enso @@ -136,9 +136,9 @@ add_specs suite_builder = after_count = get_num_response_cache_entries [before_count, after_count] - expect_counts expected_counts ~action omitter=Nothing = omitting omitter omitter-> + expect_counts expected_counts ~action = omitting <| counts = with_counts action - counts . should_equal expected_counts omitter=omitter + counts . should_equal expected_counts get_cache_files : Vector Text get_cache_files -> Vector Text = diff --git a/test/Table_Tests/src/In_Memory/Table_Spec.enso b/test/Table_Tests/src/In_Memory/Table_Spec.enso index 70341aa18884..4fd448aae255 100644 --- a/test/Table_Tests/src/In_Memory/Table_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Table_Spec.enso @@ -683,8 +683,8 @@ add_specs suite_builder = actual.column_names . should_equal ["col0", "col_between", "col1"] suite_builder.group "Use First Row As Names" group_builder-> - expect_column_names names table omitter=Nothing = omitting omitter omitter-> - table.columns . map .name . should_equal names omitter=omitter + expect_column_names names table = omitting <| + table.columns . map .name . should_equal names group_builder.specify "should work happily with mixed types" <| c_0 = ['A', ["H", "B", "C"]] diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 0f10cdcb8b3f..66ed73873eb1 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -11,30 +11,30 @@ from Standard.Test.Omitter import all polyglot java import org.enso.base_test_helpers.FileSystemHelper Table.should_equal : Any -> Integer -> Boolean -> Any -Table.should_equal self expected ignore_order=False omitter=Nothing = omitting omitter omitter-> +Table.should_equal self expected ignore_order=False = omitting <| rhs_error_check expected - Panic.catch Test_Failure_Error (table_should_equal_impl self expected omitter.loc ignore_order) error-> + Panic.catch Test_Failure_Error (table_should_equal_impl self expected omitting_get_stack_trace ignore_order) error-> Test.fail error.payload.message Column.should_equal : Any -> Integer -> Any -Column.should_equal self expected omitter=Nothing = omitting omitter omitter-> +Column.should_equal self expected = omitting <| rhs_error_check expected - Panic.catch Test_Failure_Error (column_should_equal_impl self expected omitter.loc) error-> + Panic.catch Test_Failure_Error (column_should_equal_impl self expected omitting_get_stack_trace) error-> Test.fail error.payload.message DB_Table.should_equal : DB_Table -> Integer -> Boolean -> Any -DB_Table.should_equal self expected ignore_order=False omitter=Nothing = omitting omitter omitter-> +DB_Table.should_equal self expected ignore_order=False = omitting <| rhs_error_check expected t0 = self.read t1 = expected.read - t0 . should_equal t1 ignore_order=ignore_order omitter=omitter + t0 . should_equal t1 ignore_order=ignore_order DB_Column.should_equal : DB_Column -> Integer -> Any -DB_Column.should_equal self expected omitter=Nothing = omitting omitter omitter-> +DB_Column.should_equal self expected = omitting <| rhs_error_check expected t0 = self.read t1 = expected.read - t0 . should_equal t1 omitter=omitter + t0 . should_equal t1 type Test_Failure_Error ## PRIVATE @@ -112,17 +112,17 @@ set_writable file writable = For example, if `example` is `[[1, 2], [3]]`, then both `[1, 2, 3]` and `[2, 1, 3]` will be accepted, but `[2, 3, 1]` will be rejected. -Any.should_have_relative_ordering self (example : Vector) omitter=Nothing = omitting omitter omitter-> +Any.should_have_relative_ordering self (example : Vector) = omitting <| case self of _ : Vector -> example.each v-> case v of _ : Vector -> - if v.is_empty then Test.fail "The example vector should not contain empty vectors as they are meaningless (at "+omitter.loc+")." - _ -> Test.fail "Expected a vector of vectors but got a vector containing "+v.to_display_text+" (at "+omitter.loc+")." + if v.is_empty then Test.fail "The example vector should not contain empty vectors as they are meaningless (at "+omitting_get_stack_trace+")." + _ -> Test.fail "Expected a vector of vectors but got a vector containing "+v.to_display_text+" (at "+omitting_get_stack_trace+")." total_length = example.fold 0 acc-> v-> acc+v.length if self.length != total_length then - Test.fail "Expected a vector of length "+total_length.to_text+" but got "+self.length.to_text+" (at "+omitter.loc+")." + Test.fail "Expected a vector of length "+total_length.to_text+" but got "+self.length.to_text+" (at "+omitting_get_stack_trace+")." pieces = Vector.build builder-> example.fold 0 offset-> reference_v-> @@ -139,14 +139,14 @@ Any.should_have_relative_ordering self (example : Vector) omitter=Nothing = omit (got_piece.sort on_problems=..Report_Error) == (expected_piece.sort on_problems=..Report_Error) if are_consistent.not then offset = pieces.take ix . fold 0 acc-> p-> acc+p.length - Test.fail "Expected the run of vector elements starting at offset "+offset.to_text+" to be a permutation of "+expected_piece.to_display_text+" but got "+got_piece.to_display_text+" (at "+omitter.loc+")." + Test.fail "Expected the run of vector elements starting at offset "+offset.to_text+" to be a permutation of "+expected_piece.to_display_text+" but got "+got_piece.to_display_text+" (at "+omitting_get_stack_trace+")." - _ -> Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omitter.loc+")." + _ -> Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omitting_get_stack_trace+")." ## PRIVATE See `Any.should_have_relative_ordering`. -Error.should_have_relative_ordering self example omitter=Nothing = omitting omitter omitter-> +Error.should_have_relative_ordering self example = omitting <| _ = example - Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omitter.loc+")." + Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omitting_get_stack_trace+")." ## PRIVATE diff --git a/test/Test_Tests/src/Helpers.enso b/test/Test_Tests/src/Helpers.enso index dae9559f8c84..a40e25f7d792 100644 --- a/test/Test_Tests/src/Helpers.enso +++ b/test/Test_Tests/src/Helpers.enso @@ -5,7 +5,7 @@ from Standard.Test import Test from Standard.Test.Omitter import all ## Expects the inner action to report a test failure exception and returns its payload. -expect_test_failure ~action -> Spec_Result omitter=Nothing = omitting omitter omitter-> +expect_test_failure ~action -> Spec_Result = omitting <| handle_panic caught_panic = result = caught_panic.payload case result of @@ -14,4 +14,4 @@ expect_test_failure ~action -> Spec_Result omitter=Nothing = omitting omitter om Panic.catch Spec_Result handler=handle_panic <| action - Test.fail "Expected the inner action to fail, but there was no failure (at "+omitter.loc+")." + Test.fail "Expected the inner action to fail, but there was no failure (at "+omitting_get_stack_trace+")." From 20072e9a64d9e74a0008e40c511e0ca9e4438e78 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 11:59:05 -0500 Subject: [PATCH 12/58] wip --- distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 36ce7a38a44a..d7994f8c2217 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -5,18 +5,18 @@ pst s st = st . take 12 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) omitting ~action = - IO.println "AAAAA "+omitting_get_stack_trace.to_display_text + #IO.println "AAAAA "+omitting_get_stack_trace.to_display_text action omitting_get_stack_trace = stack_trace = Runtime.get_stack_trace - pst "full" stack_trace + #pst "full" stack_trace omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") real_stack_trace = stack_trace.drop (omitting_index + 2) - IO.println "OI "+omitting_index.to_text - pst "real" real_stack_trace + #IO.println "OI "+omitting_index.to_text + #pst "real" real_stack_trace top = real_stack_trace . at 0 . source_location top.to_display_text From b8afddffbb1727edbde6d3a2aeb7090043cd7b0e Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 13:00:12 -0500 Subject: [PATCH 13/58] wip --- distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index eb41abb8dc51..8e2aa3409079 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -4,6 +4,7 @@ import Standard.Base.Runtime.Ref.Ref import project.Spec_Result.Spec_Result from project import Test from project.Extensions import all +from project.Omitter import all ## Test class for checking if a certain point in the code has been reached. type Should_Reach From 75cfe920901b8e2cf44a77d96d0eb3360becc8b1 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 13:38:46 -0500 Subject: [PATCH 14/58] fix signatures --- .../Test/0.0.0-dev/src/Extensions.enso | 48 +++++++++---------- .../Standard/Test/0.0.0-dev/src/Problems.enso | 2 +- .../Test/0.0.0-dev/src/Should_Reach.enso | 2 +- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 4 +- test/Table_Tests/src/Util.enso | 8 ++-- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 9505f3ce41bb..0f80fe7bcefd 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -23,7 +23,7 @@ from project.Omitter import all example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error -Any.should_fail_with : Any -> Integer -> Boolean -> Spec_Result +Any.should_fail_with : Any -> Boolean -> Spec_Result Any.should_fail_with self matcher unwrap_errors=True = omitting <| _ = unwrap_errors matcher_text = matcher . to_text @@ -44,7 +44,7 @@ Any.should_fail_with self matcher unwrap_errors=True = omitting <| example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error -Error.should_fail_with : Any -> Integer -> Boolean -> Spec_Result +Error.should_fail_with : Any -> Boolean -> Spec_Result Error.should_fail_with self matcher unwrap_errors=True = omitting <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error caught = unwrap_maybe self.catch @@ -64,7 +64,7 @@ Error.should_fail_with self matcher unwrap_errors=True = omitting <| from Standard.Test import Test example_should_equal = Examples.add_1_to 1 . should_equal 2 -Any.should_equal : Any -> Integer -> Spec_Result +Any.should_equal : Any -> Spec_Result Any.should_equal self that = omitting <| rhs_error_check that case self == that of @@ -96,7 +96,7 @@ Any.should_equal self that = omitting <| from Standard.Test import Test example_should_equal = Examples.some_type . should_equal_type Vector -Any.should_equal_type : Any -> Integer -> Spec_Result +Any.should_equal_type : Any -> Spec_Result Any.should_equal_type self that = omitting <| case (self.is_same_object_as that) of True -> Spec_Result.Success False -> @@ -120,7 +120,7 @@ Error.should_equal_type self that = omitting <| from Standard.Test import Test example_should_not_equal = Examples.add_1_to 1 . should_not_equal 2 -Any.should_not_equal : Any -> Integer -> Spec_Result +Any.should_not_equal : Any -> Spec_Result Any.should_not_equal self that = omitting <| if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else case self != that of True -> Spec_Result.Success @@ -145,7 +145,7 @@ Error.should_not_equal self that = omitting <| from Standard.Test import Test example_should_not_equal = Examples.some_type . should_not_equal_type Vector -Any.should_not_equal_type : Any -> Integer -> Spec_Result +Any.should_not_equal_type : Any -> Spec_Result Any.should_not_equal_type self that = omitting <| case (self.is_same_object_as that . not) of True -> Spec_Result.Success False -> @@ -168,7 +168,7 @@ Error.should_not_equal_type self that = omitting <| from Standard.Test import Test example_should_start_with = "Hello World!" . should_start_with "Hello" -Any.should_start_with : Text -> Integer -> Spec_Result +Any.should_start_with : Text -> Spec_Result Any.should_start_with self that = omitting <| rhs_error_check that case self of @@ -190,7 +190,7 @@ Any.should_start_with self that = omitting <| from Standard.Test import Test example_should_end_with = "Hello World!" . should_end_with "ld!" -Any.should_end_with : Text -> Integer -> Spec_Result +Any.should_end_with : Text -> Spec_Result Any.should_end_with self that = omitting <| rhs_error_check that case self of @@ -212,7 +212,7 @@ Any.should_end_with self that = omitting <| from Standard.Test import Test example_should_start_with = "Hello World!" . should_start_with "Hello" -Error.should_start_with : Any -> Integer -> Spec_Result +Error.should_start_with : Any -> Spec_Result Error.should_start_with self that = omitting <| _ = [that] Test.fail_match_on_unexpected_error self @@ -228,7 +228,7 @@ Error.should_start_with self that = omitting <| from Standard.Test import Test example_should_end_with = "Hello World!" . should_end_with "ld!" -Error.should_end_with : Any -> Integer -> Spec_Result +Error.should_end_with : Any -> Spec_Result Error.should_end_with self that = omitting <| _ = [that] Test.fail_match_on_unexpected_error self @@ -245,7 +245,7 @@ Error.should_end_with self that = omitting <| from Standard.Test import Test example_should_equal = Examples.add_1_to 1 . should_equal 2 -Error.should_equal : Any -> Integer -> Spec_Result +Error.should_equal : Any -> Spec_Result Error.should_equal self that = omitting <| rhs_error_check that Test.fail_match_on_unexpected_error self @@ -270,7 +270,7 @@ Error.should_equal self that = omitting <| example_should_equal = 1.00000001 . should_equal 1.00000002 epsilon=0.0001 -Number.should_equal : Float -> Float -> Integer -> Spec_Result +Number.should_equal : Float -> Float -> Spec_Result Number.should_equal self that epsilon=0 = omitting <| rhs_error_check that matches = case that of @@ -291,7 +291,7 @@ Number.should_equal self that epsilon=0 = omitting <| Arguments: - that: The value to compare `self` for equality with. - epsilon: The epsilon for comparing two float numbers. -Decimal.should_equal : Number -> Float-> Float -> Integer -> Spec_Result +Decimal.should_equal : Number -> Float-> Float -> Spec_Result Decimal.should_equal self that epsilon=0 = omitting <| rhs_error_check that self.to_float . should_equal that.to_float epsilon @@ -304,7 +304,7 @@ Decimal.should_equal self that epsilon=0 = omitting <| Assert that a given action did not result in errors or warnings. "foobar".write (enso_project.data / "f.txt") . should_succeed -Any.should_succeed : Integer -> Any +Any.should_succeed : Any Any.should_succeed self = self @@ -316,12 +316,12 @@ Any.should_succeed self = Assert that a given action did not result in errors or warnings. "foobar".write (enso_project.data / "f.txt") . should_succeed -Error.should_succeed : Integer -> Any +Error.should_succeed : Any Error.should_succeed self = omitting <| Test.fail_match_on_unexpected_error self ## Handles an unexpected dataflow error. -Error.should_be_a : Any -> Integer -> Any +Error.should_be_a : Any -> Any Error.should_be_a self typ = omitting <| _ = typ Test.fail_match_on_unexpected_error self @@ -455,7 +455,7 @@ Any.should_be_a self typ = omitting <| from Standard.Test import Test example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] -Any.should_equal_ignoring_order : Any -> Integer -> Spec_Result +Any.should_equal_ignoring_order : Any -> Spec_Result Any.should_equal_ignoring_order self that = omitting <| if that.is_a Vector . not then Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+omitting_get_stack_trace+").") @@ -494,7 +494,7 @@ Any.should_equal_ignoring_order self that = omitting <| from Standard.Test import Test example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] -Error.should_equal_ignoring_order : Any -> Integer -> Spec_Result +Error.should_equal_ignoring_order : Any -> Spec_Result Error.should_equal_ignoring_order self that = omitting <| _ = [that] Test.fail_match_on_unexpected_error self @@ -519,7 +519,7 @@ Error.should_equal_ignoring_order self that = omitting <| from Standard.Test import Test example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] -Any.should_only_contain_elements_in : Any -> Integer -> Spec_Result +Any.should_only_contain_elements_in : Any -> Spec_Result Any.should_only_contain_elements_in self that = omitting <| rhs_error_check that self.each element-> @@ -548,7 +548,7 @@ Any.should_only_contain_elements_in self that = omitting <| from Standard.Test import Test example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] -Error.should_only_contain_elements_in : Any -> Integer -> Spec_Result +Error.should_only_contain_elements_in : Any -> Spec_Result Error.should_only_contain_elements_in self that = omitting <| _ = [that] Test.fail_match_on_unexpected_error self @@ -568,7 +568,7 @@ Error.should_only_contain_elements_in self that = omitting <| from Standard.Test import Test example_should_equal = "foobar".should_contain "foo" -Any.should_contain : Any -> Integer -> Spec_Result +Any.should_contain : Any -> Spec_Result Any.should_contain self element = omitting <| rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> @@ -594,7 +594,7 @@ Any.should_contain self element = omitting <| from Standard.Test import Test example_should_equal = "foobar".should_contain "foo" -Error.should_contain : Any -> Integer -> Spec_Result +Error.should_contain : Any -> Spec_Result Error.should_contain self element = omitting <| _ = [element] Test.fail_match_on_unexpected_error self @@ -607,7 +607,7 @@ Error.should_contain self element = omitting <| This method delegates to the `contains` method of `self` and will use the rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. -Any.should_not_contain : Any -> Integer -> Spec_Result +Any.should_not_contain : Any -> Spec_Result Any.should_not_contain self element = omitting <| rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> @@ -626,7 +626,7 @@ Any.should_not_contain self element = omitting <| This method delegates to the `contains` method of `self` and will use the rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. -Error.should_not_contain : Any -> Integer -> Spec_Result +Error.should_not_contain : Any -> Spec_Result Error.should_not_contain self element = omitting <| _ = [element] Test.fail_match_on_unexpected_error self diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index 5bcf812488d3..19cfd61663e5 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -59,7 +59,7 @@ test_problem_handling action expected_problems result_checker (unwrap_errors : B - result_checker: A function which should verify that the result generated by the action is correct. It does not return anything, instead it should use the standard testing approach, like `x.should_equal y`. -test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Integer -> Nothing +test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Nothing test_advanced_problem_handling action error_checker warnings_checker result_checker = omitting <| # First, we check the action ignoring any warnings. result_ignoring = action Problem_Behavior.Ignore diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index 8e2aa3409079..f72fd5d1ef50 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -22,7 +22,7 @@ type Should_Reach Nothing ## Checks if a point was reached in execution. - should_have_reached : Integer -> Spec_Result + should_have_reached : Spec_Result should_have_reached self -> Spec_Result = omitting <| if self.reached_ref.get then Spec_Result.Success else Test.fail ("Did not reach Should_Reach (at "+omitting_get_stack_trace+").") diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 6ee99e510371..2afbee13b295 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -43,7 +43,7 @@ type Test example_expect_panic_with = Test.expect_panic_with Examples.throw_panic Examples.My_Error - expect_panic_with : Any -> Any -> Integer -> Test_Result + expect_panic_with : Any -> Any -> Test_Result expect_panic_with ~action matcher = omitting <| handle_panic caught_panic = payload = caught_panic.payload @@ -131,7 +131,7 @@ type Test ## PRIVATE Reports an unexpected dataflow error has occurred. - fail_match_on_unexpected_error : Error -> Integer -> Nothing + fail_match_on_unexpected_error : Error -> Nothing fail_match_on_unexpected_error error = omitting <| payload = error.catch msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omitting_get_stack_trace + ")." diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 66ed73873eb1..3c97bc4636ff 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -10,26 +10,26 @@ from Standard.Test.Omitter import all polyglot java import org.enso.base_test_helpers.FileSystemHelper -Table.should_equal : Any -> Integer -> Boolean -> Any +Table.should_equal : Any -> Boolean -> Any Table.should_equal self expected ignore_order=False = omitting <| rhs_error_check expected Panic.catch Test_Failure_Error (table_should_equal_impl self expected omitting_get_stack_trace ignore_order) error-> Test.fail error.payload.message -Column.should_equal : Any -> Integer -> Any +Column.should_equal : Any -> Any Column.should_equal self expected = omitting <| rhs_error_check expected Panic.catch Test_Failure_Error (column_should_equal_impl self expected omitting_get_stack_trace) error-> Test.fail error.payload.message -DB_Table.should_equal : DB_Table -> Integer -> Boolean -> Any +DB_Table.should_equal : DB_Table -> Boolean -> Any DB_Table.should_equal self expected ignore_order=False = omitting <| rhs_error_check expected t0 = self.read t1 = expected.read t0 . should_equal t1 ignore_order=ignore_order -DB_Column.should_equal : DB_Column -> Integer -> Any +DB_Column.should_equal : DB_Column -> Any DB_Column.should_equal self expected = omitting <| rhs_error_check expected t0 = self.read From 10814dbd2ac46cb4f75c173f09a03d3fe984120d Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 13:51:27 -0500 Subject: [PATCH 15/58] wip --- distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso | 2 +- test/Table_Tests/src/Util.enso | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 2afbee13b295..2159fa06938a 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -202,7 +202,7 @@ type Test # If the iterations are exhausted, we rethrow the panic. if i > max_retries then Panic.throw caught_panic else if i % 10 == 0 then - IO.println 'Still failing after '+i.to_text+' retries ('+omitting_get_stack_trace.to_display_text+'):\n'+caught_panic.payload.to_display_text + IO.println 'Still failing after '+i.to_text+' retries ('+omitting_get_stack_trace+'):\n'+caught_panic.payload.to_display_text Thread.sleep milliseconds_between_attempts @Tail_Call go (i+1) go 1 diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 3c97bc4636ff..6295518aab2b 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -22,12 +22,12 @@ Column.should_equal self expected = omitting <| Panic.catch Test_Failure_Error (column_should_equal_impl self expected omitting_get_stack_trace) error-> Test.fail error.payload.message -DB_Table.should_equal : DB_Table -> Boolean -> Any +DB_Table.should_equal : DB_Table|Table -> Boolean -> Any DB_Table.should_equal self expected ignore_order=False = omitting <| rhs_error_check expected t0 = self.read t1 = expected.read - t0 . should_equal t1 ignore_order=ignore_order + t0 . should_equal t1 ignore_order DB_Column.should_equal : DB_Column -> Any DB_Column.should_equal self expected = omitting <| From c3635b04e1f3240d43d39a022cca1b0e6f71d01a Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 14:22:54 -0500 Subject: [PATCH 16/58] into Main --- distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso | 3 +++ distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso | 1 - distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso | 1 - test/Base_Tests/src/System/File_Spec.enso | 1 - .../src/Common_Table_Operations/Aggregate_Spec.enso | 1 - test/Table_Tests/src/Common_Table_Operations/Main.enso | 1 - test/Table_Tests/src/Common_Table_Operations/Util.enso | 1 - test/Table_Tests/src/IO/Fetch_Spec.enso | 1 - test/Table_Tests/src/In_Memory/Table_Spec.enso | 1 - test/Table_Tests/src/Util.enso | 1 - test/Test_Tests/src/Helpers.enso | 1 - 11 files changed, 3 insertions(+), 10 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso index 0b2e84fed6f6..5163215f3d71 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso @@ -27,6 +27,9 @@ export project.Extensions.should_succeed export project.Faker.Faker +export project.Omitter.omitting +export project.Omitter.omitting_get_stack_trace + export project.Problems export project.Suite.Suite diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index f72fd5d1ef50..eea99456e3dc 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -4,7 +4,6 @@ import Standard.Base.Runtime.Ref.Ref import project.Spec_Result.Spec_Result from project import Test from project.Extensions import all -from project.Omitter import all ## Test class for checking if a certain point in the code has been reached. type Should_Reach diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 2159fa06938a..3a1c94455181 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -12,7 +12,6 @@ import project.Suite.Suite_Builder import project.Test_Result.Test_Result from project.Omitter import all - polyglot java import java.lang.Thread diff --git a/test/Base_Tests/src/System/File_Spec.enso b/test/Base_Tests/src/System/File_Spec.enso index 009070ae95f1..36563f02ccfa 100644 --- a/test/Base_Tests/src/System/File_Spec.enso +++ b/test/Base_Tests/src/System/File_Spec.enso @@ -12,7 +12,6 @@ polyglot java import org.enso.base_test_helpers.FileSystemHelper from Standard.Test import all import Standard.Test.Test_Environment -from Standard.Test.Omitter import all import project.Data.Data_Spec import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index 2e992e738b72..f6a55080af4e 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -11,7 +11,6 @@ import Standard.Database.Feature.Feature from Standard.Database.Errors import Unsupported_Database_Operation, Aggregagtion_Requires_Order from Standard.Test import all -from Standard.Test.Omitter import all from project.Common_Table_Operations.Util import run_default_backend, within_table diff --git a/test/Table_Tests/src/Common_Table_Operations/Main.enso b/test/Table_Tests/src/Common_Table_Operations/Main.enso index 42e71df73c09..f628b7de33ac 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Main.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Main.enso @@ -3,7 +3,6 @@ from Standard.Base import all import Standard.Database.Internal.Replace_Params.Replace_Params from Standard.Test import Test -from Standard.Test.Omitter import all import project.Common_Table_Operations.Add_Group_Number_Spec import project.Common_Table_Operations.Add_Row_Number_Spec diff --git a/test/Table_Tests/src/Common_Table_Operations/Util.enso b/test/Table_Tests/src/Common_Table_Operations/Util.enso index f7468e84b741..2b530ffd2ec4 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Util.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Util.enso @@ -4,7 +4,6 @@ from Standard.Table import Column, Table, Value_Type import Standard.Database.DB_Table.DB_Table from Standard.Test import all -from Standard.Test.Omitter import all from project.In_Memory.Common_Spec import in_memory_setup diff --git a/test/Table_Tests/src/IO/Fetch_Spec.enso b/test/Table_Tests/src/IO/Fetch_Spec.enso index 79b410daa66c..a81330df6962 100644 --- a/test/Table_Tests/src/IO/Fetch_Spec.enso +++ b/test/Table_Tests/src/IO/Fetch_Spec.enso @@ -17,7 +17,6 @@ import Standard.Table.Errors.Invalid_JSON_Format from Standard.Test import all import Standard.Test.Test_Environment -from Standard.Test.Omitter import all import enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup from enso_dev.Base_Tests.Network.Http.Http_Test_Setup import base_url_with_slash, pending_has_url diff --git a/test/Table_Tests/src/In_Memory/Table_Spec.enso b/test/Table_Tests/src/In_Memory/Table_Spec.enso index 4fd448aae255..29e3e56a7a2a 100644 --- a/test/Table_Tests/src/In_Memory/Table_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Table_Spec.enso @@ -17,7 +17,6 @@ import Standard.Database.Extensions.Upload_In_Memory_Table from Standard.Database import Database, SQLite from Standard.Test import all -from Standard.Test.Omitter import all from project.Util import all diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 6295518aab2b..1f789a1ee6e2 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -6,7 +6,6 @@ import Standard.Database.DB_Column.DB_Column from Standard.Table import Column, Table from Standard.Test import all -from Standard.Test.Omitter import all polyglot java import org.enso.base_test_helpers.FileSystemHelper diff --git a/test/Test_Tests/src/Helpers.enso b/test/Test_Tests/src/Helpers.enso index a40e25f7d792..5d5bc726cba3 100644 --- a/test/Test_Tests/src/Helpers.enso +++ b/test/Test_Tests/src/Helpers.enso @@ -2,7 +2,6 @@ from Standard.Base import all import Standard.Test.Spec_Result.Spec_Result from Standard.Test import Test -from Standard.Test.Omitter import all ## Expects the inner action to report a test failure exception and returns its payload. expect_test_failure ~action -> Spec_Result = omitting <| From c4cdca911f1f859435409f28a924bc9cb61d461e Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 14:40:00 -0500 Subject: [PATCH 17/58] wip --- distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index eea99456e3dc..f72fd5d1ef50 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -4,6 +4,7 @@ import Standard.Base.Runtime.Ref.Ref import project.Spec_Result.Spec_Result from project import Test from project.Extensions import all +from project.Omitter import all ## Test class for checking if a certain point in the code has been reached. type Should_Reach From 7fff45fad3fc2d57ad826998853f45bd3f71a2e7 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 15:08:15 -0500 Subject: [PATCH 18/58] put gsl back for with_retries --- .../Standard/Test/0.0.0-dev/src/Omitter.enso | 2 +- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 27 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index d7994f8c2217..28835ad81bd0 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -5,7 +5,7 @@ pst s st = st . take 12 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) omitting ~action = - #IO.println "AAAAA "+omitting_get_stack_trace.to_display_text + IO.println "AAAAA "+omitting_get_stack_trace action omitting_get_stack_trace = diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 3a1c94455181..97e244827782 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -188,7 +188,9 @@ type Test or fails with the last error thrown by the action after exhausting retry attempts. with_retries : Any -> Any - with_retries ~action = omitting <| + with_retries ~action = + loc = Test.get_source_location 1 + milliseconds_between_attempts = 100 ## We give the CI a bit more attempts, as failures are more annoying there. For local development, a bit less retries is enough - there it is more @@ -201,7 +203,28 @@ type Test # If the iterations are exhausted, we rethrow the panic. if i > max_retries then Panic.throw caught_panic else if i % 10 == 0 then - IO.println 'Still failing after '+i.to_text+' retries ('+omitting_get_stack_trace+'):\n'+caught_panic.payload.to_display_text + IO.println 'Still failing after '+i.to_text+' retries ('+loc.to_display_text+'):\n'+caught_panic.payload.to_display_text Thread.sleep milliseconds_between_attempts @Tail_Call go (i+1) go 1 + + + ## PRIVATE + + Returns a Text representing the source location of a stack frame above + the call. + + Arguments: + - skip_frames: how many frames on the stack to skip. + + If the function is called with 0 it will return the location of that call. + Note that not only function calls, but also things like pattern matching add + frames to the stack and there is no guarantee that the amount of frames that + need to be skipped will not change between versions, so this method should be + used carefully. + get_source_location skip_frames:Integer -> Text = + stack = Standard.Base.Runtime.get_stack_trace + element = stack . at skip_frames+1 + loc = element . source_location + IO.println "AAAAA "+loc.to_display_text + loc . to_display_text From 11ba0f8f705b83df668efad0fa420c5a6ad2c264 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 15:41:16 -0500 Subject: [PATCH 19/58] gsl test back --- test/Base_Tests/src/Semantic/Meta_Location_Spec.enso | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index 7b902015054d..f8f698858ca3 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -17,6 +17,11 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil Platform.OS.Windows -> "This test is disabled on Windows until issue 1561 is fixed." _ -> Nothing + group_builder.specify "should allow to get the source location of a frame" pending=location_pending <| + src = Test.get_source_location 0 + loc = "Meta_Location_Spec.enso:21:15-40" + src.take (..Last loc.length) . should_equal loc + group_builder.specify "should allow to get qualified type names of values" <| x = 42 y = My_Type.Value 1 2 3 From 429fd69443d05a18d13138c8d8685182eb710b62 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 15:53:34 -0500 Subject: [PATCH 20/58] wip --- test/Test_Tests/src/Extensions_Spec.enso | 12 +++++++----- test/Test_Tests/src/Helpers.enso | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index 1f622dae57fb..e3ae3f7def80 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -11,11 +11,6 @@ main filter=Nothing = suite.run_with_filter filter add_specs suite_builder = - suite_builder.group "should be able to get a stack trace without test helper farmes" group_builder-> - group_builder.specify "abcd" <| - "ab".should_equal "ab" - "ab".should_equal "ac" - suite_builder.group "should_equal extension method" group_builder-> group_builder.specify "should report correct location for Text" <| r1 = expect_test_failure <| @@ -89,3 +84,10 @@ add_specs suite_builder = r1 = expect_test_failure <| "abc".should_end_with "d" r1.message.should_contain "Extensions_Spec.enso:85" + + suite_builder.group "should be able to get a stack trace without test helper farmes" group_builder-> + group_builder.specify "abcd" <| + "ab".should_equal "ab" + r1 = expect_test_failure <| + "ab".should_equal "ac" + r1.message.should_contain "Extensions_Spec.enso:92" diff --git a/test/Test_Tests/src/Helpers.enso b/test/Test_Tests/src/Helpers.enso index 5d5bc726cba3..a40e25f7d792 100644 --- a/test/Test_Tests/src/Helpers.enso +++ b/test/Test_Tests/src/Helpers.enso @@ -2,6 +2,7 @@ from Standard.Base import all import Standard.Test.Spec_Result.Spec_Result from Standard.Test import Test +from Standard.Test.Omitter import all ## Expects the inner action to report a test failure exception and returns its payload. expect_test_failure ~action -> Spec_Result = omitting <| From 2cdfdf904003fd7eb602e905165b454df8281332 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 16:03:38 -0500 Subject: [PATCH 21/58] wip --- .../lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 28835ad81bd0..151d90267085 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -1,22 +1,28 @@ from Standard.Base import all +verbose = True + pst s st = IO.println "==== "+s st . take 12 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) omitting ~action = - IO.println "AAAAA "+omitting_get_stack_trace + #IO.println "AAAAA "+omitting_get_stack_trace + action + +omitting ~action = + #IO.println "AAAAA "+omitting_get_stack_trace action omitting_get_stack_trace = stack_trace = Runtime.get_stack_trace - #pst "full" stack_trace + if verbose then pst "full" stack_trace omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") real_stack_trace = stack_trace.drop (omitting_index + 2) - #IO.println "OI "+omitting_index.to_text - #pst "real" real_stack_trace + if verbose then IO.println "OI "+omitting_index.to_text + if verbose then pst "real" real_stack_trace top = real_stack_trace . at 0 . source_location top.to_display_text From e9d78e378ffd9f1c9ad5bde723d0f050aa227537 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 16:05:07 -0500 Subject: [PATCH 22/58] disambiguate --- .../Test/0.0.0-dev/src/Extensions.enso | 52 +++++++++---------- .../lib/Standard/Test/0.0.0-dev/src/Main.enso | 2 +- .../Standard/Test/0.0.0-dev/src/Omitter.enso | 8 +-- .../Standard/Test/0.0.0-dev/src/Problems.enso | 16 +++--- .../Test/0.0.0-dev/src/Should_Reach.enso | 2 +- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 10 ++-- test/Base_Tests/src/System/File_Spec.enso | 2 +- .../Aggregate_Spec.enso | 2 +- .../src/Common_Table_Operations/Main.enso | 2 +- .../src/Common_Table_Operations/Util.enso | 8 +-- test/Table_Tests/src/Util.enso | 16 +++--- test/Test_Tests/src/Helpers.enso | 2 +- 12 files changed, 59 insertions(+), 63 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 0f80fe7bcefd..92ccb78623f0 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -27,7 +27,7 @@ Any.should_fail_with : Any -> Boolean -> Spec_Result Any.should_fail_with self matcher unwrap_errors=True = omitting <| _ = unwrap_errors matcher_text = matcher . to_text - Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + omitting_get_stack_trace + ").") + Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + omit_get_stack_trace + ").") ## Expect a function to fail with the provided dataflow error. @@ -50,7 +50,7 @@ Error.should_fail_with self matcher unwrap_errors=True = omitting <| caught = unwrap_maybe self.catch if caught == matcher || caught.is_a matcher then Nothing else matcher_text = matcher . to_text - Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + omitting_get_stack_trace + ").") details='The error had the following stack trace:\n'+self.get_stack_trace_text + Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + omit_get_stack_trace + ").") details='The error had the following stack trace:\n'+self.get_stack_trace_text ## Asserts that `self` value is equal to the expected value. @@ -81,7 +81,7 @@ Any.should_equal self that = omitting <| False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") " _ -> "" _ -> "" - msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omitting_get_stack_trace + ")." + msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omit_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value is equal to the expected type value. @@ -100,7 +100,7 @@ Any.should_equal_type : Any -> Spec_Result Any.should_equal_type self that = omitting <| case (self.is_same_object_as that) of True -> Spec_Result.Success False -> - msg = self.to_text + " did not equal type " + that.to_text + " (at " + omitting_get_stack_trace + ")." + msg = self.to_text + " did not equal type " + that.to_text + " (at " + omit_get_stack_trace + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. @@ -125,7 +125,7 @@ Any.should_not_equal self that = omitting <| if that.is_error then (Panic.throw case self != that of True -> Spec_Result.Success False -> - msg = self.to_text + " did equal " + that.to_text + " (at " + omitting_get_stack_trace + ")." + msg = self.to_text + " did equal " + that.to_text + " (at " + omit_get_stack_trace + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. @@ -149,7 +149,7 @@ Any.should_not_equal_type : Any -> Spec_Result Any.should_not_equal_type self that = omitting <| case (self.is_same_object_as that . not) of True -> Spec_Result.Success False -> - msg = self.to_text + " did equal type " + that.to_text + " (at " + omitting_get_stack_trace + ")." + msg = self.to_text + " did equal type " + that.to_text + " (at " + omit_get_stack_trace + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. @@ -173,10 +173,10 @@ Any.should_start_with self that = omitting <| rhs_error_check that case self of _ : Text -> if self.starts_with that then Spec_Result.Success else - msg = self.to_text + " does not start with " + that.to_text + " (at " + omitting_get_stack_trace + ")." + msg = self.to_text + " does not start with " + that.to_text + " (at " + omit_get_stack_trace + ")." Test.fail msg _ -> - msg = self.to_text + " is not a `Text` value (at " + omitting_get_stack_trace + ")." + msg = self.to_text + " is not a `Text` value (at " + omit_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value is a Text value and ends with `that`. @@ -195,10 +195,10 @@ Any.should_end_with self that = omitting <| rhs_error_check that case self of _ : Text -> if self.ends_with that then Spec_Result.Success else - msg = self.to_text + " does not end with " + that.to_text + " (at " + omitting_get_stack_trace + ")." + msg = self.to_text + " does not end with " + that.to_text + " (at " + omit_get_stack_trace + ")." Test.fail msg _ -> - msg = self.to_text + " is not a `Text` value (at " + omitting_get_stack_trace + ")." + msg = self.to_text + " is not a `Text` value (at " + omit_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value is a Text value and starts with `that`. @@ -283,7 +283,7 @@ Number.should_equal self that epsilon=0 = omitting <| case matches of True -> Spec_Result.Success False -> - msg = self.to_text + " did not equal " + that.to_text + " (at " + omitting_get_stack_trace + ")." + msg = self.to_text + " did not equal " + that.to_text + " (at " + omit_get_stack_trace + ")." Test.fail msg ## Asserts that `self` is within `epsilon` from `that`. @@ -339,7 +339,7 @@ Boolean.should_be_true : Spec_Result Boolean.should_be_true self = omitting <| case self of True -> Spec_Result.Success False -> - Test.fail "Expected False to be True (at "+omitting_get_stack_trace+")." + Test.fail "Expected False to be True (at "+omit_get_stack_trace+")." ## Asserts that the given `Boolean` is `True`. @@ -365,7 +365,7 @@ Error.should_be_true self = omitting <| Test.fail_match_on_unexpected_error self Boolean.should_be_false : Spec_Result Boolean.should_be_false self = omitting <| case self of True -> - Test.fail "Expected True to be False (at "+omitting_get_stack_trace+")." + Test.fail "Expected True to be False (at "+omit_get_stack_trace+")." False -> Spec_Result.Success ## Asserts that the given `Boolean` is `False` @@ -403,19 +403,19 @@ Any.should_be_a self typ = omitting <| if a.constructor == c then Spec_Result.Success else expected_type = c.declaring_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+omitting_get_stack_trace+")." + message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+omit_get_stack_trace+")." Test.fail message _ -> expected_type = c.declaring_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitting_get_stack_trace+")." + message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omit_get_stack_trace+")." Test.fail message meta_type : Meta.Type -> ok = self.is_a typ || self==typ if ok then Spec_Result.Success else expected_type = meta_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitting_get_stack_trace+")." + message = "Expected a value of type "+expected_type+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omit_get_stack_trace+")." Test.fail message # Workaround for 0-argument atom constructors which 'unapplies' them. atom : Meta.Atom -> @@ -426,13 +426,13 @@ Any.should_be_a self typ = omitting <| ok = self.is_a typ if ok then Spec_Result.Success else actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of Java class "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitting_get_stack_trace+")." + message = "Expected a value of Java class "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omit_get_stack_trace+")." Test.fail message p : Meta.Primitive -> ok = self == p.value if ok then Spec_Result.Success else actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omitting_get_stack_trace+")." + message = "Expected a value of "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omit_get_stack_trace+")." Test.fail message _ -> fail_on_wrong_arg_type @@ -458,14 +458,14 @@ Any.should_be_a self typ = omitting <| Any.should_equal_ignoring_order : Any -> Spec_Result Any.should_equal_ignoring_order self that = omitting <| if that.is_a Vector . not then - Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+omitting_get_stack_trace+").") + Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+omit_get_stack_trace+").") that.each element-> if self.contains element . not then - msg = "The collection (" + self.to_text + ") did not contain " + element.to_text + " (at " + omitting_get_stack_trace + ")." + msg = "The collection (" + self.to_text + ") did not contain " + element.to_text + " (at " + omit_get_stack_trace + ")." Test.fail msg self.each element-> if that.contains element . not then - msg = "The collection contained an element (" + element.to_text + ") which was not expected (at " + omitting_get_stack_trace + ")." + msg = "The collection contained an element (" + element.to_text + ") which was not expected (at " + omit_get_stack_trace + ")." Test.fail msg Test.with_clue "Duplicate elements in either collection should have the same counts - checked by comparing sorted collections: " <| ## If the vector contains vectors or incomparable values, they may not get sorted correctly. @@ -524,7 +524,7 @@ Any.should_only_contain_elements_in self that = omitting <| rhs_error_check that self.each element-> if that.contains element . not then - msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + omitting_get_stack_trace + ")." + msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + omit_get_stack_trace + ")." Test.fail msg Spec_Result.Success @@ -573,10 +573,10 @@ Any.should_contain self element = omitting <| rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else - msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omitting_get_stack_trace + ")." + msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omit_get_stack_trace + ")." Test.fail msg if contains_result then Spec_Result.Success else - msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + omitting_get_stack_trace + ")." + msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + omit_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value contains an element. @@ -612,10 +612,10 @@ Any.should_not_contain self element = omitting <| rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else - msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omitting_get_stack_trace + ")." + msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omit_get_stack_trace + ")." Test.fail msg if contains_result.not then Spec_Result.Success else - msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + omitting_get_stack_trace + ")." + msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + omit_get_stack_trace + ")." Test.fail msg ## Asserts that `self` value does not contain an element. diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso index 5163215f3d71..757aa5534b31 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso @@ -28,7 +28,7 @@ export project.Extensions.should_succeed export project.Faker.Faker export project.Omitter.omitting -export project.Omitter.omitting_get_stack_trace +export project.Omitter.omit_get_stack_trace export project.Problems diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 151d90267085..45e71f648bac 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -7,14 +7,10 @@ pst s st = st . take 12 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) omitting ~action = - #IO.println "AAAAA "+omitting_get_stack_trace + #IO.println "AAAAA "+omit_get_stack_trace action -omitting ~action = - #IO.println "AAAAA "+omitting_get_stack_trace - action - -omitting_get_stack_trace = +omit_get_stack_trace = stack_trace = Runtime.get_stack_trace if verbose then pst "full" stack_trace diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index 19cfd61663e5..5e0d5d919909 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -79,10 +79,10 @@ test_advanced_problem_handling action error_checker warnings_checker result_chec Checks if the provided value does not have any attached problems. assume_no_problems result = omitting <| if result.is_error then - Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitting_get_stack_trace+")." details=result.get_stack_trace_text + Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omit_get_stack_trace+")." details=result.get_stack_trace_text warnings = get_attached_warnings result if warnings.not_empty then - Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+omit_get_stack_trace+")." ## UNSTABLE Checks if the provided value has a specific warning attached. @@ -98,12 +98,12 @@ expect_warning : Any -> Any -> Boolean -> Nothing expect_warning expected_warning result unwrap_errors=True = omitting <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error if result.is_error then - Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omit_get_stack_trace+")." warnings = get_attached_warnings result . map unwrap_maybe found = warnings.find if_missing=Nothing x-> (x == expected_warning) || (x.is_a expected_warning) found.if_nothing <| - Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omitting_get_stack_trace+').' + Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omit_get_stack_trace+').' ## UNSTABLE Checks if the provided value has a specific warning attached and if there are @@ -121,16 +121,16 @@ expect_only_warning : Any -> Any -> Boolean -> Any expect_only_warning expected_warning result unwrap_errors=True = omitting <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error if result.is_error then - Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omit_get_stack_trace+")." warnings = get_attached_warnings result . map unwrap_maybe is_expected x = (x == expected_warning) || (x.is_a expected_warning) found = warnings.find if_missing=Nothing is_expected if found.is_nothing then - Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omitting_get_stack_trace+').' + Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omit_get_stack_trace+').' invalid = warnings.filter x-> is_expected x . not if invalid.not_empty then - Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+omitting_get_stack_trace+').' + Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+omit_get_stack_trace+').' found ## UNSTABLE @@ -142,4 +142,4 @@ not_expect_warning expected_warning_type result = omitting <| warnings = get_attached_warnings result found = warnings.find if_missing=Nothing x-> x.is_a expected_warning_type if found.is_nothing.not then - Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+omitting_get_stack_trace+').' + Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+omit_get_stack_trace+').' diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index f72fd5d1ef50..1268e8f57f55 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -25,4 +25,4 @@ type Should_Reach should_have_reached : Spec_Result should_have_reached self -> Spec_Result = omitting <| if self.reached_ref.get then Spec_Result.Success else - Test.fail ("Did not reach Should_Reach (at "+omitting_get_stack_trace+").") + Test.fail ("Did not reach Should_Reach (at "+omit_get_stack_trace+").") diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 97e244827782..8af09e22affb 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -54,17 +54,17 @@ type Test is_panic_matching = payload.is_a matcher if is_panic_matching then payload else stack_trace = caught_panic.convert_to_dataflow_error.get_stack_trace_text - Test.fail ("Expected a " + matcher.to_text + ", but " + payload.to_text + " was thrown instead (at " + omitting_get_stack_trace + ").") details=stack_trace + Test.fail ("Expected a " + matcher.to_text + ", but " + payload.to_text + " was thrown instead (at " + omit_get_stack_trace + ").") details=stack_trace Panic.catch Any handler=handle_panic <| res = action # If the action did not panic above, we fail the test. case res.is_error of True -> - Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action returned a Dataflow Error " + res.catch.to_display_text + " instead (at " + omitting_get_stack_trace + ").") + Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action returned a Dataflow Error " + res.catch.to_display_text + " instead (at " + omit_get_stack_trace + ").") False -> return_suffix = if res.is_nothing then "" else " and returned ["+res.to_text+"]" - Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action succeeded" + return_suffix + " (at " + omitting_get_stack_trace + ").") + Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action succeeded" + return_suffix + " (at " + omit_get_stack_trace + ").") ## Expect a function to fail with the provided panic. @@ -101,7 +101,7 @@ type Test Test.fail_match_on_unexpected_error value warnings = Warning.get_all value . map .value if warnings.not_empty then - msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + omitting_get_stack_trace + ")." + msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + omit_get_stack_trace + ")." Test.fail msg ## Fail a test with the given message. @@ -133,7 +133,7 @@ type Test fail_match_on_unexpected_error : Error -> Nothing fail_match_on_unexpected_error error = omitting <| payload = error.catch - msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omitting_get_stack_trace + ")." + msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omit_get_stack_trace + ")." Test.fail msg details=error.get_stack_trace_text ## Executes the block of code passed as behavior and adds a clue modifier which diff --git a/test/Base_Tests/src/System/File_Spec.enso b/test/Base_Tests/src/System/File_Spec.enso index 36563f02ccfa..018e115da761 100644 --- a/test/Base_Tests/src/System/File_Spec.enso +++ b/test/Base_Tests/src/System/File_Spec.enso @@ -22,7 +22,7 @@ File.should_equal self other = omitting <| _ : File -> self.absolute.normalize.path == other.absolute.normalize.path _ -> False if are_same then self else - Test.fail "Expected "+self.to_text+" to be equal to "+other.to_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected "+self.to_text+" to be equal to "+other.to_text+" (at "+omit_get_stack_trace+")." set_writable file writable = diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index f6a55080af4e..fa57fcf86932 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -1260,7 +1260,7 @@ add_aggregate_specs suite_builder setup = _ : Float -> Double.isNaN value _ -> False if matches.not then - Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+omit_get_stack_trace+")." if setup.flagged ..Supports_Infinity then suite_builder.group prefix+"Table.aggregate should correctly handle infinities" group_builder-> pos_inf = 1/0 diff --git a/test/Table_Tests/src/Common_Table_Operations/Main.enso b/test/Table_Tests/src/Common_Table_Operations/Main.enso index f628b7de33ac..8b5751746aff 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Main.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Main.enso @@ -87,7 +87,7 @@ type Test_Setup expect_integer_type self column = omitting <| value_type = column.value_type if self.is_integer_type value_type then column else - Test.fail ("Expected column ["+column.name+"] to have integer type, but got "+value_type.to_display_text+" (at " + omitting_get_stack_trace + ").") + Test.fail ("Expected column ["+column.name+"] to have integer type, but got "+value_type.to_display_text+" (at " + omit_get_stack_trace + ").") type Test_Selection ## The configuration specifying what features are supported by a given diff --git a/test/Table_Tests/src/Common_Table_Operations/Util.enso b/test/Table_Tests/src/Common_Table_Operations/Util.enso index 2b530ffd2ec4..937aec187388 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Util.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Util.enso @@ -51,7 +51,7 @@ within_table table = ## PRIVATE Any.should_equal_tz_agnostic self other = omitting <| _ = other - Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omit_get_stack_trace+")." ## PRIVATE A helper method that compares two vectors of Date_Time values. @@ -65,16 +65,16 @@ Vector.should_equal_tz_agnostic self other = omitting <| utc = Time_Zone.utc normalize_date_time dt = case dt of _ : Date_Time -> dt.at_zone utc - _ -> Test.fail "The vector should contain Date_Time objects but it contained "+dt.to_display_text+" (at "+omitting_get_stack_trace+")" + _ -> Test.fail "The vector should contain Date_Time objects but it contained "+dt.to_display_text+" (at "+omit_get_stack_trace+")" self_normalized = self.map normalize_date_time other_normalized = other.map normalize_date_time self_normalized.should_equal other_normalized - _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+omitting_get_stack_trace+")" + _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+omit_get_stack_trace+")" ## PRIVATE Error.should_equal_tz_agnostic self other = omitting <| _ = other - Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omit_get_stack_trace+")." ## PRIVATE Builds a table ensuring that the rows are in the order as given. diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 1f789a1ee6e2..b4e25f1be68b 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -12,13 +12,13 @@ polyglot java import org.enso.base_test_helpers.FileSystemHelper Table.should_equal : Any -> Boolean -> Any Table.should_equal self expected ignore_order=False = omitting <| rhs_error_check expected - Panic.catch Test_Failure_Error (table_should_equal_impl self expected omitting_get_stack_trace ignore_order) error-> + Panic.catch Test_Failure_Error (table_should_equal_impl self expected omit_get_stack_trace ignore_order) error-> Test.fail error.payload.message Column.should_equal : Any -> Any Column.should_equal self expected = omitting <| rhs_error_check expected - Panic.catch Test_Failure_Error (column_should_equal_impl self expected omitting_get_stack_trace) error-> + Panic.catch Test_Failure_Error (column_should_equal_impl self expected omit_get_stack_trace) error-> Test.fail error.payload.message DB_Table.should_equal : DB_Table|Table -> Boolean -> Any @@ -116,12 +116,12 @@ Any.should_have_relative_ordering self (example : Vector) = omitting <| _ : Vector -> example.each v-> case v of _ : Vector -> - if v.is_empty then Test.fail "The example vector should not contain empty vectors as they are meaningless (at "+omitting_get_stack_trace+")." - _ -> Test.fail "Expected a vector of vectors but got a vector containing "+v.to_display_text+" (at "+omitting_get_stack_trace+")." + if v.is_empty then Test.fail "The example vector should not contain empty vectors as they are meaningless (at "+omit_get_stack_trace+")." + _ -> Test.fail "Expected a vector of vectors but got a vector containing "+v.to_display_text+" (at "+omit_get_stack_trace+")." total_length = example.fold 0 acc-> v-> acc+v.length if self.length != total_length then - Test.fail "Expected a vector of length "+total_length.to_text+" but got "+self.length.to_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected a vector of length "+total_length.to_text+" but got "+self.length.to_text+" (at "+omit_get_stack_trace+")." pieces = Vector.build builder-> example.fold 0 offset-> reference_v-> @@ -138,14 +138,14 @@ Any.should_have_relative_ordering self (example : Vector) = omitting <| (got_piece.sort on_problems=..Report_Error) == (expected_piece.sort on_problems=..Report_Error) if are_consistent.not then offset = pieces.take ix . fold 0 acc-> p-> acc+p.length - Test.fail "Expected the run of vector elements starting at offset "+offset.to_text+" to be a permutation of "+expected_piece.to_display_text+" but got "+got_piece.to_display_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected the run of vector elements starting at offset "+offset.to_text+" to be a permutation of "+expected_piece.to_display_text+" but got "+got_piece.to_display_text+" (at "+omit_get_stack_trace+")." - _ -> Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omitting_get_stack_trace+")." + _ -> Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omit_get_stack_trace+")." ## PRIVATE See `Any.should_have_relative_ordering`. Error.should_have_relative_ordering self example = omitting <| _ = example - Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omitting_get_stack_trace+")." + Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omit_get_stack_trace+")." ## PRIVATE diff --git a/test/Test_Tests/src/Helpers.enso b/test/Test_Tests/src/Helpers.enso index a40e25f7d792..8b215f103d23 100644 --- a/test/Test_Tests/src/Helpers.enso +++ b/test/Test_Tests/src/Helpers.enso @@ -14,4 +14,4 @@ expect_test_failure ~action -> Spec_Result = omitting <| Panic.catch Spec_Result handler=handle_panic <| action - Test.fail "Expected the inner action to fail, but there was no failure (at "+omitting_get_stack_trace+")." + Test.fail "Expected the inner action to fail, but there was no failure (at "+omit_get_stack_trace+")." From c8af61b6a8dff263ff86f1e79ee8b2b033374430 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 16:16:17 -0500 Subject: [PATCH 23/58] unomitting --- .../lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 15 +++++++++++---- test/Test_Tests/src/Helpers.enso | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 45e71f648bac..59a537cb75e6 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -1,6 +1,6 @@ from Standard.Base import all -verbose = True +verbose = False pst s st = IO.println "==== "+s @@ -10,14 +10,21 @@ omitting ~action = #IO.println "AAAAA "+omit_get_stack_trace action +unomitting ~action = + #IO.println "AAAAA "+omit_get_stack_trace + action + omit_get_stack_trace = stack_trace = Runtime.get_stack_trace if verbose then pst "full" stack_trace - omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") - real_stack_trace = stack_trace.drop (omitting_index + 2) + first_omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") + last_unomitting_index = stack_trace.index_of (frame-> frame.name == "Omitter.unomitting") + to_drop = if first_omitting_index.is_nothing then 0 else + if last_unomitting_index.is_nothing.not && last_unomitting_index < first_omitting_index then last_unomitting_index - 1 else first_omitting_index + 2 + real_stack_trace = stack_trace.drop to_drop - if verbose then IO.println "OI "+omitting_index.to_text + if verbose then IO.println "OI "+first_omitting_index.to_text+" "+last_unomitting_index.to_text if verbose then pst "real" real_stack_trace top = real_stack_trace . at 0 . source_location diff --git a/test/Test_Tests/src/Helpers.enso b/test/Test_Tests/src/Helpers.enso index 8b215f103d23..aafe3d2fbc9a 100644 --- a/test/Test_Tests/src/Helpers.enso +++ b/test/Test_Tests/src/Helpers.enso @@ -13,5 +13,5 @@ expect_test_failure ~action -> Spec_Result = omitting <| _ -> Test.fail "Expected test failure, but "+result.to_text+" was raised as error." Panic.catch Spec_Result handler=handle_panic <| - action + unomitting action Test.fail "Expected the inner action to fail, but there was no failure (at "+omit_get_stack_trace+")." From 98283028acd27730684755b7eef47a77bda36231 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 6 Feb 2025 16:40:59 -0500 Subject: [PATCH 24/58] more tests --- .../lib/Standard/Test/0.0.0-dev/src/Main.enso | 1 + .../Standard/Test/0.0.0-dev/src/Omitter.enso | 4 +-- test/Test_Tests/src/Extensions_Spec.enso | 30 ++++++++++++++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso index 757aa5534b31..a41821a75d59 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso @@ -28,6 +28,7 @@ export project.Extensions.should_succeed export project.Faker.Faker export project.Omitter.omitting +export project.Omitter.unomitting export project.Omitter.omit_get_stack_trace export project.Problems diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 59a537cb75e6..01d6b313dd71 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -1,6 +1,6 @@ from Standard.Base import all -verbose = False +verbose = True pst s st = IO.println "==== "+s @@ -21,7 +21,7 @@ omit_get_stack_trace = first_omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") last_unomitting_index = stack_trace.index_of (frame-> frame.name == "Omitter.unomitting") to_drop = if first_omitting_index.is_nothing then 0 else - if last_unomitting_index.is_nothing.not && last_unomitting_index < first_omitting_index then last_unomitting_index - 1 else first_omitting_index + 2 + if last_unomitting_index.is_nothing.not && last_unomitting_index < first_omitting_index then last_unomitting_index - 2 else first_omitting_index + 2 real_stack_trace = stack_trace.drop to_drop if verbose then IO.println "OI "+first_omitting_index.to_text+" "+last_unomitting_index.to_text diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index e3ae3f7def80..45d90ec72f2b 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -85,9 +85,31 @@ add_specs suite_builder = "abc".should_end_with "d" r1.message.should_contain "Extensions_Spec.enso:85" - suite_builder.group "should be able to get a stack trace without test helper farmes" group_builder-> - group_builder.specify "abcd" <| - "ab".should_equal "ab" + suite_builder.group "stack trace location" group_builder-> + group_builder.specify "should be able to get a stack trace without test helper frames" <| r1 = expect_test_failure <| "ab".should_equal "ac" - r1.message.should_contain "Extensions_Spec.enso:92" + r1.message.should_contain "Extensions_Spec.enso:91" + + group_builder.specify "should be able to get a stack trace without test helper frames (with nesting)" <| + should_equal_2 x y = omitting <| + x.should_equal y + should_equal_3 x y = omitting <| + should_equal_2 x y + + r1 = expect_test_failure <| + should_equal_3 "ab" "ac" + r1.message.should_contain "Extensions_Spec.enso:101" + + group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a callback)" <| + should_equal_2 checker x y = omitting <| + unomitting (checker x y) + should_equal_3 checker x y = omitting <| + should_equal_2 checker x y + + my_checker x y = + x.should_equal y + + r1 = expect_test_failure <| + should_equal_3 my_checker "ab" "ac" + r1.message.should_contain "Extensions_Spec.enso:111" From e524998d1c0a87eacd8d0d55f3784068b00b7598 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Fri, 7 Feb 2025 15:17:47 -0500 Subject: [PATCH 25/58] goofy but works --- .../Standard/Test/0.0.0-dev/src/Omitter.enso | 36 ++++++++++++------- test/Test_Tests/src/Extensions_Spec.enso | 2 +- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 01d6b313dd71..f32e7e6b4247 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -1,10 +1,11 @@ from Standard.Base import all +import Standard.Base.Runtime.Ref.Ref verbose = True pst s st = IO.println "==== "+s - st . take 12 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) + st . take 20 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) omitting ~action = #IO.println "AAAAA "+omit_get_stack_trace @@ -16,16 +17,27 @@ unomitting ~action = omit_get_stack_trace = stack_trace = Runtime.get_stack_trace - if verbose then pst "full" stack_trace - first_omitting_index = stack_trace.last_index_of (frame-> frame.name == "Omitter.omitting") - last_unomitting_index = stack_trace.index_of (frame-> frame.name == "Omitter.unomitting") - to_drop = if first_omitting_index.is_nothing then 0 else - if last_unomitting_index.is_nothing.not && last_unomitting_index < first_omitting_index then last_unomitting_index - 2 else first_omitting_index + 2 - real_stack_trace = stack_trace.drop to_drop - - if verbose then IO.println "OI "+first_omitting_index.to_text+" "+last_unomitting_index.to_text - if verbose then pst "real" real_stack_trace - - top = real_stack_trace . at 0 . source_location + ## + cs = Ref.new 0 + last_zero = Ref.new 0 + cses = (stack_trace.length - 1).down_to 0 include_end=True . map i-> + name = stack_trace.at i . name + if name == "Omitter.omitting" then cs.modify (_+1) else + if name == "Omitter.unomitting" then cs.modify (_-1) else Nothing + if cs.get == 0 then last_zero.put i + cs.get + index = if cs.get == 0 then 0 else last_zero.get + 1 + + real_stack_trace = stack_trace.drop index + + if verbose then + pst "full" stack_trace + pst "real" real_stack_trace + IO.println "OI "+index.to_text + IO.println "OI "+cses.to_text + IO.println "OI "+(stack_trace.at index).to_text + IO.println "OI "+(real_stack_trace.at 0).to_text + + top = stack_trace . at index . source_location top.to_display_text diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index 45d90ec72f2b..7f479d75082a 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -105,7 +105,7 @@ add_specs suite_builder = should_equal_2 checker x y = omitting <| unomitting (checker x y) should_equal_3 checker x y = omitting <| - should_equal_2 checker x y + should_equal_2 (unomitting (checker x y)) my_checker x y = x.should_equal y From 0eb6018361a54634be9f462b13b61be5697f838a Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Fri, 7 Feb 2025 15:37:27 -0500 Subject: [PATCH 26/58] fold --- .../Standard/Test/0.0.0-dev/src/Omitter.enso | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index f32e7e6b4247..fe4e7915fc75 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -1,11 +1,11 @@ from Standard.Base import all import Standard.Base.Runtime.Ref.Ref -verbose = True +verbose = False pst s st = IO.println "==== "+s - st . take 20 . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) + st . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) omitting ~action = #IO.println "AAAAA "+omit_get_stack_trace @@ -17,27 +17,22 @@ unomitting ~action = omit_get_stack_trace = stack_trace = Runtime.get_stack_trace + reversed_stack_trace = stack_trace.reverse - ## - cs = Ref.new 0 - last_zero = Ref.new 0 - cses = (stack_trace.length - 1).down_to 0 include_end=True . map i-> - name = stack_trace.at i . name - if name == "Omitter.omitting" then cs.modify (_+1) else - if name == "Omitter.unomitting" then cs.modify (_-1) else Nothing - if cs.get == 0 then last_zero.put i - cs.get - index = if cs.get == 0 then 0 else last_zero.get + 1 - - real_stack_trace = stack_trace.drop index + delta_for_frame frame = + name = frame.name + if name == "Omitter.omitting" then 1 else + if name == "Omitter.unomitting" then -1 else 0 + nesting_levels = reversed_stack_trace.map delta_for_frame . running_fold 0 (_ + _) + index = + i = nesting_levels.last_index_of 0 + if i.is_nothing then 0 else i-1 if verbose then pst "full" stack_trace - pst "real" real_stack_trace IO.println "OI "+index.to_text - IO.println "OI "+cses.to_text - IO.println "OI "+(stack_trace.at index).to_text - IO.println "OI "+(real_stack_trace.at 0).to_text + IO.println "OI "+nesting_levels.to_text + IO.println "OI "+(reversed_stack_trace.at index).to_text - top = stack_trace . at index . source_location + top = reversed_stack_trace . at index . source_location top.to_display_text From 02dd30776a79fafea62b60e3f551801452764bd7 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Fri, 7 Feb 2025 15:50:57 -0500 Subject: [PATCH 27/58] log --- distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index fe4e7915fc75..b1d8b798e7d2 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -8,7 +8,7 @@ pst s st = st . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) omitting ~action = - #IO.println "AAAAA "+omit_get_stack_trace + IO.println "AAAAA "+omit_get_stack_trace action unomitting ~action = From 26ed0f675373aa789533a77eba817238e0f99c3a Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Fri, 7 Feb 2025 16:59:56 -0500 Subject: [PATCH 28/58] problems --- .../lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 4 ++-- .../lib/Standard/Test/0.0.0-dev/src/Problems.enso | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index b1d8b798e7d2..dbbc297f0737 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -1,7 +1,7 @@ from Standard.Base import all import Standard.Base.Runtime.Ref.Ref -verbose = False +verbose = True pst s st = IO.println "==== "+s @@ -30,7 +30,7 @@ omit_get_stack_trace = if verbose then pst "full" stack_trace - IO.println "OI "+index.to_text + IO.println "OI "+index.to_text+" "+(stack_trace.length + 1 - index).to_text IO.println "OI "+nesting_levels.to_text IO.println "OI "+(reversed_stack_trace.at index).to_text diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index 5e0d5d919909..93706e514827 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -31,17 +31,17 @@ test_problem_handling : (Problem_Behavior -> Any) -> Vector Any -> (Any -> Nothi test_problem_handling action expected_problems result_checker (unwrap_errors : Boolean = True) (ignore_warning_cardinality : Boolean = False) = omitting <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error - error_checker error_result = + error_checker error_result = omitting <| first_problem = expected_problems.first first_problem_type = Meta.type_of first_problem error_result . should_fail_with first_problem_type unwrap_errors=unwrap_errors (unwrap_maybe error_result.catch) . should_equal first_problem - warnings_checker warnings = + warnings_checker warnings = omitting <| Test.with_clue "The warnings were "+warnings.to_text+'.\n' <| (if ignore_warning_cardinality then warnings.distinct else warnings) . map unwrap_maybe . should_equal_ignoring_order expected_problems - test_advanced_problem_handling action error_checker warnings_checker result_checker + test_advanced_problem_handling (unomitting action) (x-> unomitting (error_checker x)) (x-> unomitting (warnings_checker x)) (x-> unomitting (result_checker x)) ## UNSTABLE Tests how a specific operation behaves depending on the requested @@ -68,12 +68,12 @@ test_advanced_problem_handling action error_checker warnings_checker result_chec # Then, we check the fail-on-first-error mode. error_result = action Problem_Behavior.Report_Error - error_checker error_result + unomitting (error_checker error_result) # Lastly, we check the report warnings mode and ensure that both the result is correct and the warnings are as expected. result_warning = action Problem_Behavior.Report_Warning result_checker result_warning - warnings_checker (get_attached_warnings result_warning) + unomitting (warnings_checker (get_attached_warnings result_warning)) ## UNSTABLE Checks if the provided value does not have any attached problems. From 9c96e13500c6ee86805615535d64d228ac5152d2 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Mon, 10 Feb 2025 16:19:04 -0500 Subject: [PATCH 29/58] more us --- .../lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 2 +- .../lib/Standard/Test/0.0.0-dev/src/Problems.enso | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index dbbc297f0737..414459f17b5a 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -1,7 +1,7 @@ from Standard.Base import all import Standard.Base.Runtime.Ref.Ref -verbose = True +verbose = False pst s st = IO.println "==== "+s diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index 93706e514827..eed8a26486c9 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -62,17 +62,17 @@ test_problem_handling action expected_problems result_checker (unwrap_errors : B test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Nothing test_advanced_problem_handling action error_checker warnings_checker result_checker = omitting <| # First, we check the action ignoring any warnings. - result_ignoring = action Problem_Behavior.Ignore - result_checker result_ignoring + result_ignoring = unomitting (action Problem_Behavior.Ignore) + unomitting (result_checker result_ignoring) get_attached_warnings result_ignoring . should_equal [] # Then, we check the fail-on-first-error mode. - error_result = action Problem_Behavior.Report_Error + error_result = unomitting (action Problem_Behavior.Report_Error) unomitting (error_checker error_result) # Lastly, we check the report warnings mode and ensure that both the result is correct and the warnings are as expected. - result_warning = action Problem_Behavior.Report_Warning - result_checker result_warning + result_warning = unomitting (action Problem_Behavior.Report_Warning) + unomitting (result_checker result_warning) unomitting (warnings_checker (get_attached_warnings result_warning)) ## UNSTABLE From 023bb2b72de10a534ea6d7c629c15d8b376d5775 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 11:29:49 -0500 Subject: [PATCH 30/58] mls --- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 29 ++----------------- .../src/Semantic/Meta_Location_Spec.enso | 5 ++-- .../src/Common_Table_Operations/Main.enso | 1 + 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 8af09e22affb..bd3c3f1ff384 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -188,9 +188,7 @@ type Test or fails with the last error thrown by the action after exhausting retry attempts. with_retries : Any -> Any - with_retries ~action = - loc = Test.get_source_location 1 - + with_retries ~action = omitting <| milliseconds_between_attempts = 100 ## We give the CI a bit more attempts, as failures are more annoying there. For local development, a bit less retries is enough - there it is more @@ -199,32 +197,11 @@ type Test max_retries = if Environment.get "CI" . is_nothing . not then 100 else 20 go i = - Panic.catch Any action caught_panic-> + Panic.catch Any (unomitting action) caught_panic-> # If the iterations are exhausted, we rethrow the panic. if i > max_retries then Panic.throw caught_panic else if i % 10 == 0 then - IO.println 'Still failing after '+i.to_text+' retries ('+loc.to_display_text+'):\n'+caught_panic.payload.to_display_text + IO.println 'Still failing after '+i.to_text+' retries ('+omit_get_stack_trace.to_display_text+'):\n'+caught_panic.payload.to_display_text Thread.sleep milliseconds_between_attempts @Tail_Call go (i+1) go 1 - - - ## PRIVATE - - Returns a Text representing the source location of a stack frame above - the call. - - Arguments: - - skip_frames: how many frames on the stack to skip. - - If the function is called with 0 it will return the location of that call. - Note that not only function calls, but also things like pattern matching add - frames to the stack and there is no guarantee that the amount of frames that - need to be skipped will not change between versions, so this method should be - used carefully. - get_source_location skip_frames:Integer -> Text = - stack = Standard.Base.Runtime.get_stack_trace - element = stack . at skip_frames+1 - loc = element . source_location - IO.println "AAAAA "+loc.to_display_text - loc . to_display_text diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index f8f698858ca3..f5ae02206941 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -2,6 +2,7 @@ from Standard.Base import all import Standard.Base from Standard.Test import all +from Standard.Test.Omitter import all polyglot java import org.enso.base_test_helpers.CallbackHelper @@ -18,8 +19,8 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil _ -> Nothing group_builder.specify "should allow to get the source location of a frame" pending=location_pending <| - src = Test.get_source_location 0 - loc = "Meta_Location_Spec.enso:21:15-40" + src = omit_get_stack_trace + loc = "Meta_Location_Spec.enso:22:15-34" src.take (..Last loc.length) . should_equal loc group_builder.specify "should allow to get qualified type names of values" <| diff --git a/test/Table_Tests/src/Common_Table_Operations/Main.enso b/test/Table_Tests/src/Common_Table_Operations/Main.enso index 8b5751746aff..c06aa1cda122 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Main.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Main.enso @@ -3,6 +3,7 @@ from Standard.Base import all import Standard.Database.Internal.Replace_Params.Replace_Params from Standard.Test import Test +from Standard.Test.Omitter import all import project.Common_Table_Operations.Add_Group_Number_Spec import project.Common_Table_Operations.Add_Row_Number_Spec From 0661925a7612b35296572714e981cc9b5d9c8fc4 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 15:18:41 -0500 Subject: [PATCH 31/58] no-arg test, fix 2-arg test --- .../lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 2 +- test/Test_Tests/src/Extensions_Spec.enso | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 414459f17b5a..7f2beec21e7c 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -8,7 +8,7 @@ pst s st = st . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) omitting ~action = - IO.println "AAAAA "+omit_get_stack_trace + #IO.println "AAAAA "+omit_get_stack_trace action unomitting ~action = diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index 7f479d75082a..1a03968ad6a2 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -105,7 +105,7 @@ add_specs suite_builder = should_equal_2 checker x y = omitting <| unomitting (checker x y) should_equal_3 checker x y = omitting <| - should_equal_2 (unomitting (checker x y)) + should_equal_2 (x-> y-> unomitting (checker x y)) x y my_checker x y = x.should_equal y @@ -113,3 +113,16 @@ add_specs suite_builder = r1 = expect_test_failure <| should_equal_3 my_checker "ab" "ac" r1.message.should_contain "Extensions_Spec.enso:111" + + group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a no-arg callback)" <| + should_equal_2 checker _ _ = omitting <| + unomitting checker + should_equal_3 checker x y = omitting <| + should_equal_2 (unomitting checker) x y + + my_checker = + False . should_be_true + + r1 = expect_test_failure <| + should_equal_3 my_checker "ab" "ac" + r1.message.should_contain "Extensions_Spec.enso:124" From 5fe1222f38d195cb766b2fba7bda88101a33a088 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 15:25:48 -0500 Subject: [PATCH 32/58] 0, 1, 2 --- test/Test_Tests/src/Extensions_Spec.enso | 50 +++++++++++++++--------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index 1a03968ad6a2..28d964222bfc 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -101,28 +101,42 @@ add_specs suite_builder = should_equal_3 "ab" "ac" r1.message.should_contain "Extensions_Spec.enso:101" - group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a callback)" <| - should_equal_2 checker x y = omitting <| - unomitting (checker x y) - should_equal_3 checker x y = omitting <| - should_equal_2 (x-> y-> unomitting (checker x y)) x y - - my_checker x y = - x.should_equal y - - r1 = expect_test_failure <| - should_equal_3 my_checker "ab" "ac" - r1.message.should_contain "Extensions_Spec.enso:111" - group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a no-arg callback)" <| - should_equal_2 checker _ _ = omitting <| + ## This test is here because of differences in stack traces with no-arg calls. + should_equal_a checker _ _ = omitting <| unomitting checker - should_equal_3 checker x y = omitting <| - should_equal_2 (unomitting checker) x y + should_equal_b checker x y = omitting <| + should_equal_a (unomitting checker) x y my_checker = False . should_be_true r1 = expect_test_failure <| - should_equal_3 my_checker "ab" "ac" - r1.message.should_contain "Extensions_Spec.enso:124" + should_equal_b my_checker "ab" "ac" + r1.message.should_contain "Extensions_Spec.enso:112" + + group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a one-arg callback)" <| + should_equal_a checker x = omitting <| + unomitting (checker x) + should_equal_b checker x = omitting <| + should_equal_a (x-> unomitting (checker x)) x + + my_checker x = + x . should_equal "ac" + + r1 = expect_test_failure <| + should_equal_b my_checker "ab" + r1.message.should_contain "Extensions_Spec.enso:125" + + group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a two-arg callback)" <| + should_equal_a checker x y = omitting <| + unomitting (checker x y) + should_equal_b checker x y = omitting <| + should_equal_a (x-> y-> unomitting (checker x y)) x y + + my_checker x y = + x.should_equal y + + r1 = expect_test_failure <| + should_equal_b my_checker "ab" "ac" + r1.message.should_contain "Extensions_Spec.enso:138" From 635e050969ac0ff8c960dd1c97345c53fbd107a2 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 15:29:14 -0500 Subject: [PATCH 33/58] wrappers --- distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso | 2 ++ distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 6 ++++++ test/Test_Tests/src/Extensions_Spec.enso | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso index a41821a75d59..96980bfc1cef 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso @@ -29,6 +29,8 @@ export project.Faker.Faker export project.Omitter.omitting export project.Omitter.unomitting +export project.Omitter.wrap_unomitting +export project.Omitter.wrap_unomitting_2 export project.Omitter.omit_get_stack_trace export project.Problems diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 7f2beec21e7c..8974a6bae737 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -15,6 +15,12 @@ unomitting ~action = #IO.println "AAAAA "+omit_get_stack_trace action +wrap_unomitting f x = + unomitting (f x) + +wrap_unomitting_2 f x y = + unomitting (f x y) + omit_get_stack_trace = stack_trace = Runtime.get_stack_trace reversed_stack_trace = stack_trace.reverse diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index 28d964222bfc..8ed64213fe18 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -119,7 +119,7 @@ add_specs suite_builder = should_equal_a checker x = omitting <| unomitting (checker x) should_equal_b checker x = omitting <| - should_equal_a (x-> unomitting (checker x)) x + should_equal_a (wrap_unomitting checker x) my_checker x = x . should_equal "ac" @@ -132,7 +132,7 @@ add_specs suite_builder = should_equal_a checker x y = omitting <| unomitting (checker x y) should_equal_b checker x y = omitting <| - should_equal_a (x-> y-> unomitting (checker x y)) x y + should_equal_a (wrap_unomitting_2 checker x y) my_checker x y = x.should_equal y From 903a36435976a21fa3516c548c08366340d53ad4 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 15:38:32 -0500 Subject: [PATCH 34/58] wip --- .../lib/Standard/Test/0.0.0-dev/src/Main.enso | 4 ++-- .../lib/Standard/Test/0.0.0-dev/src/Omitter.enso | 12 ++++++------ test/Test_Tests/src/Extensions_Spec.enso | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso index 96980bfc1cef..e6ca12c6cc24 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso @@ -29,8 +29,8 @@ export project.Faker.Faker export project.Omitter.omitting export project.Omitter.unomitting -export project.Omitter.wrap_unomitting -export project.Omitter.wrap_unomitting_2 +export project.Omitter.unomitting_1 +export project.Omitter.unomitting_2 export project.Omitter.omit_get_stack_trace export project.Problems diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso index 8974a6bae737..79f4050ba0de 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso @@ -15,11 +15,11 @@ unomitting ~action = #IO.println "AAAAA "+omit_get_stack_trace action -wrap_unomitting f x = - unomitting (f x) +unomitting_1 f x = + f x -wrap_unomitting_2 f x y = - unomitting (f x y) +unomitting_2 f x y = + f x y omit_get_stack_trace = stack_trace = Runtime.get_stack_trace @@ -27,8 +27,8 @@ omit_get_stack_trace = delta_for_frame frame = name = frame.name - if name == "Omitter.omitting" then 1 else - if name == "Omitter.unomitting" then -1 else 0 + if name.starts_with "Omitter.omitting" then 1 else + if name.starts_with "Omitter.unomitting" then -1 else 0 nesting_levels = reversed_stack_trace.map delta_for_frame . running_fold 0 (_ + _) index = i = nesting_levels.last_index_of 0 diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index 8ed64213fe18..c215442e34e2 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -119,7 +119,7 @@ add_specs suite_builder = should_equal_a checker x = omitting <| unomitting (checker x) should_equal_b checker x = omitting <| - should_equal_a (wrap_unomitting checker x) + should_equal_a (unomitting_1 checker x) my_checker x = x . should_equal "ac" @@ -132,7 +132,7 @@ add_specs suite_builder = should_equal_a checker x y = omitting <| unomitting (checker x y) should_equal_b checker x y = omitting <| - should_equal_a (wrap_unomitting_2 checker x y) + should_equal_a (unomitting_2 checker x y) my_checker x y = x.should_equal y From de153c110a97bfdf506571c6fc63439c97929eb1 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 15:49:22 -0500 Subject: [PATCH 35/58] rename --- .../Test/0.0.0-dev/src/Extensions.enso | 116 +++++++++--------- .../src/{Omitter.enso => Frame_Hider.enso} | 18 +-- .../lib/Standard/Test/0.0.0-dev/src/Main.enso | 6 +- .../Standard/Test/0.0.0-dev/src/Problems.enso | 50 ++++---- .../Test/0.0.0-dev/src/Should_Reach.enso | 5 +- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 26 ++-- .../src/Semantic/Meta_Location_Spec.enso | 3 +- test/Base_Tests/src/System/File_Spec.enso | 4 +- .../Aggregate_Spec.enso | 8 +- .../src/Common_Table_Operations/Main.enso | 5 +- .../src/Common_Table_Operations/Util.enso | 16 +-- test/Table_Tests/src/IO/Fetch_Spec.enso | 2 +- .../Table_Tests/src/In_Memory/Table_Spec.enso | 2 +- test/Table_Tests/src/Util.enso | 28 ++--- test/Test_Tests/src/Extensions_Spec.enso | 28 ++--- test/Test_Tests/src/Helpers.enso | 8 +- 16 files changed, 159 insertions(+), 166 deletions(-) rename distribution/lib/Standard/Test/0.0.0-dev/src/{Omitter.enso => Frame_Hider.enso} (70%) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 92ccb78623f0..90d9eff80ad8 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -3,10 +3,10 @@ import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.No_Such_Method import Standard.Base.Errors.Illegal_Argument.Illegal_Argument +import project.Frame_Hider import project.Spec_Result.Spec_Result import project.Test.Test from project.Extensions_Helpers import rhs_error_check -from project.Omitter import all ## Expect a function to fail with the provided dataflow error. @@ -24,10 +24,10 @@ from project.Omitter import all example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error Any.should_fail_with : Any -> Boolean -> Spec_Result -Any.should_fail_with self matcher unwrap_errors=True = omitting <| +Any.should_fail_with self matcher unwrap_errors=True = Frame_Hider.hide <| _ = unwrap_errors matcher_text = matcher . to_text - Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + omit_get_stack_trace + ").") + Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + Frame_Hider.get_top_stack_frame + ").") ## Expect a function to fail with the provided dataflow error. @@ -45,12 +45,12 @@ Any.should_fail_with self matcher unwrap_errors=True = omitting <| example_should_fail_with = Examples.throw_error . should_fail_with Examples.My_Error Error.should_fail_with : Any -> Boolean -> Spec_Result -Error.should_fail_with self matcher unwrap_errors=True = omitting <| +Error.should_fail_with self matcher unwrap_errors=True = Frame_Hider.hide <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error caught = unwrap_maybe self.catch if caught == matcher || caught.is_a matcher then Nothing else matcher_text = matcher . to_text - Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + omit_get_stack_trace + ").") details='The error had the following stack trace:\n'+self.get_stack_trace_text + Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + Frame_Hider.get_top_stack_frame + ").") details='The error had the following stack trace:\n'+self.get_stack_trace_text ## Asserts that `self` value is equal to the expected value. @@ -65,7 +65,7 @@ Error.should_fail_with self matcher unwrap_errors=True = omitting <| example_should_equal = Examples.add_1_to 1 . should_equal 2 Any.should_equal : Any -> Spec_Result -Any.should_equal self that = omitting <| +Any.should_equal self that = Frame_Hider.hide <| rhs_error_check that case self == that of True -> Spec_Result.Success @@ -81,7 +81,7 @@ Any.should_equal self that = omitting <| False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") " _ -> "" _ -> "" - msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + omit_get_stack_trace + ")." + msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Asserts that `self` value is equal to the expected type value. @@ -97,14 +97,14 @@ Any.should_equal self that = omitting <| example_should_equal = Examples.some_type . should_equal_type Vector Any.should_equal_type : Any -> Spec_Result -Any.should_equal_type self that = omitting <| case (self.is_same_object_as that) of +Any.should_equal_type self that = Frame_Hider.hide <| case (self.is_same_object_as that) of True -> Spec_Result.Success False -> - msg = self.to_text + " did not equal type " + that.to_text + " (at " + omit_get_stack_trace + ")." + msg = self.to_text + " did not equal type " + that.to_text + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_equal_type self that = omitting <| +Error.should_equal_type self that = Frame_Hider.hide <| _ = [that] Test.fail_match_on_unexpected_error self @@ -121,15 +121,15 @@ Error.should_equal_type self that = omitting <| example_should_not_equal = Examples.add_1_to 1 . should_not_equal 2 Any.should_not_equal : Any -> Spec_Result -Any.should_not_equal self that = omitting <| if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else +Any.should_not_equal self that = Frame_Hider.hide <| if that.is_error then (Panic.throw (Illegal_Argument.Error "Expected value provided as `that` for `should_not_equal` cannot be an error, but got: "+that.to_display_text)) else case self != that of True -> Spec_Result.Success False -> - msg = self.to_text + " did equal " + that.to_text + " (at " + omit_get_stack_trace + ")." + msg = self.to_text + " did equal " + that.to_text + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal self that = omitting <| +Error.should_not_equal self that = Frame_Hider.hide <| _ = [that] Test.fail_match_on_unexpected_error self @@ -146,14 +146,14 @@ Error.should_not_equal self that = omitting <| example_should_not_equal = Examples.some_type . should_not_equal_type Vector Any.should_not_equal_type : Any -> Spec_Result -Any.should_not_equal_type self that = omitting <| case (self.is_same_object_as that . not) of +Any.should_not_equal_type self that = Frame_Hider.hide <| case (self.is_same_object_as that . not) of True -> Spec_Result.Success False -> - msg = self.to_text + " did equal type " + that.to_text + " (at " + omit_get_stack_trace + ")." + msg = self.to_text + " did equal type " + that.to_text + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal_type self that = omitting <| +Error.should_not_equal_type self that = Frame_Hider.hide <| _ = [that] Test.fail_match_on_unexpected_error self @@ -169,14 +169,14 @@ Error.should_not_equal_type self that = omitting <| example_should_start_with = "Hello World!" . should_start_with "Hello" Any.should_start_with : Text -> Spec_Result -Any.should_start_with self that = omitting <| +Any.should_start_with self that = Frame_Hider.hide <| rhs_error_check that case self of _ : Text -> if self.starts_with that then Spec_Result.Success else - msg = self.to_text + " does not start with " + that.to_text + " (at " + omit_get_stack_trace + ")." + msg = self.to_text + " does not start with " + that.to_text + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg _ -> - msg = self.to_text + " is not a `Text` value (at " + omit_get_stack_trace + ")." + msg = self.to_text + " is not a `Text` value (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Asserts that `self` value is a Text value and ends with `that`. @@ -191,14 +191,14 @@ Any.should_start_with self that = omitting <| example_should_end_with = "Hello World!" . should_end_with "ld!" Any.should_end_with : Text -> Spec_Result -Any.should_end_with self that = omitting <| +Any.should_end_with self that = Frame_Hider.hide <| rhs_error_check that case self of _ : Text -> if self.ends_with that then Spec_Result.Success else - msg = self.to_text + " does not end with " + that.to_text + " (at " + omit_get_stack_trace + ")." + msg = self.to_text + " does not end with " + that.to_text + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg _ -> - msg = self.to_text + " is not a `Text` value (at " + omit_get_stack_trace + ")." + msg = self.to_text + " is not a `Text` value (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Asserts that `self` value is a Text value and starts with `that`. @@ -213,7 +213,7 @@ Any.should_end_with self that = omitting <| example_should_start_with = "Hello World!" . should_start_with "Hello" Error.should_start_with : Any -> Spec_Result -Error.should_start_with self that = omitting <| +Error.should_start_with self that = Frame_Hider.hide <| _ = [that] Test.fail_match_on_unexpected_error self @@ -229,7 +229,7 @@ Error.should_start_with self that = omitting <| example_should_end_with = "Hello World!" . should_end_with "ld!" Error.should_end_with : Any -> Spec_Result -Error.should_end_with self that = omitting <| +Error.should_end_with self that = Frame_Hider.hide <| _ = [that] Test.fail_match_on_unexpected_error self @@ -246,7 +246,7 @@ Error.should_end_with self that = omitting <| example_should_equal = Examples.add_1_to 1 . should_equal 2 Error.should_equal : Any -> Spec_Result -Error.should_equal self that = omitting <| +Error.should_equal self that = Frame_Hider.hide <| rhs_error_check that Test.fail_match_on_unexpected_error self @@ -271,7 +271,7 @@ Error.should_equal self that = omitting <| example_should_equal = 1.00000001 . should_equal 1.00000002 epsilon=0.0001 Number.should_equal : Float -> Float -> Spec_Result -Number.should_equal self that epsilon=0 = omitting <| +Number.should_equal self that epsilon=0 = Frame_Hider.hide <| rhs_error_check that matches = case that of n : Number -> self.equals n epsilon . catch Incomparable_Values _-> @@ -283,7 +283,7 @@ Number.should_equal self that epsilon=0 = omitting <| case matches of True -> Spec_Result.Success False -> - msg = self.to_text + " did not equal " + that.to_text + " (at " + omit_get_stack_trace + ")." + msg = self.to_text + " did not equal " + that.to_text + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Asserts that `self` is within `epsilon` from `that`. @@ -292,7 +292,7 @@ Number.should_equal self that epsilon=0 = omitting <| - that: The value to compare `self` for equality with. - epsilon: The epsilon for comparing two float numbers. Decimal.should_equal : Number -> Float-> Float -> Spec_Result -Decimal.should_equal self that epsilon=0 = omitting <| +Decimal.should_equal self that epsilon=0 = Frame_Hider.hide <| rhs_error_check that self.to_float . should_equal that.to_float epsilon @@ -317,12 +317,12 @@ Any.should_succeed self = "foobar".write (enso_project.data / "f.txt") . should_succeed Error.should_succeed : Any -Error.should_succeed self = omitting <| +Error.should_succeed self = Frame_Hider.hide <| Test.fail_match_on_unexpected_error self ## Handles an unexpected dataflow error. Error.should_be_a : Any -> Any -Error.should_be_a self typ = omitting <| +Error.should_be_a self typ = Frame_Hider.hide <| _ = typ Test.fail_match_on_unexpected_error self @@ -336,10 +336,10 @@ Error.should_be_a self typ = omitting <| example_should_be_true = Examples.get_boolean . should_be_true Boolean.should_be_true : Spec_Result -Boolean.should_be_true self = omitting <| case self of +Boolean.should_be_true self = Frame_Hider.hide <| case self of True -> Spec_Result.Success False -> - Test.fail "Expected False to be True (at "+omit_get_stack_trace+")." + Test.fail "Expected False to be True (at "+Frame_Hider.get_top_stack_frame+")." ## Asserts that the given `Boolean` is `True`. @@ -351,7 +351,7 @@ Boolean.should_be_true self = omitting <| case self of example_should_be_true = Examples.get_boolean . should_be_true Error.should_be_true : Spec_Result -Error.should_be_true self = omitting <| Test.fail_match_on_unexpected_error self +Error.should_be_true self = Frame_Hider.hide <| Test.fail_match_on_unexpected_error self ## Asserts that the given `Boolean` is `False` @@ -363,9 +363,9 @@ Error.should_be_true self = omitting <| Test.fail_match_on_unexpected_error self example_should_be_false = Examples.get_boolean . should_be_false Boolean.should_be_false : Spec_Result -Boolean.should_be_false self = omitting <| case self of +Boolean.should_be_false self = Frame_Hider.hide <| case self of True -> - Test.fail "Expected True to be False (at "+omit_get_stack_trace+")." + Test.fail "Expected True to be False (at "+Frame_Hider.get_top_stack_frame+")." False -> Spec_Result.Success ## Asserts that the given `Boolean` is `False` @@ -378,7 +378,7 @@ Boolean.should_be_false self = omitting <| case self of example_should_be_false = Examples.get_boolean . should_be_false Error.should_be_false : Spec_Result -Error.should_be_false self = omitting <| Test.fail_match_on_unexpected_error self +Error.should_be_false self = Frame_Hider.hide <| Test.fail_match_on_unexpected_error self ## Asserts that a value is of a given type. @@ -392,7 +392,7 @@ Error.should_be_false self = omitting <| Test.fail_match_on_unexpected_error sel example_should_be_a = 1.should_be_a Boolean Any.should_be_a : Any -> Spec_Result -Any.should_be_a self typ = omitting <| +Any.should_be_a self typ = Frame_Hider.hide <| rhs_error_check typ fail_on_wrong_arg_type = Panic.throw <| @@ -403,19 +403,19 @@ Any.should_be_a self typ = omitting <| if a.constructor == c then Spec_Result.Success else expected_type = c.declaring_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+omit_get_stack_trace+")." + message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+Frame_Hider.get_top_stack_frame+")." Test.fail message _ -> expected_type = c.declaring_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omit_get_stack_trace+")." + message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+Frame_Hider.get_top_stack_frame+")." Test.fail message meta_type : Meta.Type -> ok = self.is_a typ || self==typ if ok then Spec_Result.Success else expected_type = meta_type.qualified_name actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of type "+expected_type+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omit_get_stack_trace+")." + message = "Expected a value of type "+expected_type+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+Frame_Hider.get_top_stack_frame+")." Test.fail message # Workaround for 0-argument atom constructors which 'unapplies' them. atom : Meta.Atom -> @@ -426,13 +426,13 @@ Any.should_be_a self typ = omitting <| ok = self.is_a typ if ok then Spec_Result.Success else actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of Java class "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omit_get_stack_trace+")." + message = "Expected a value of Java class "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+Frame_Hider.get_top_stack_frame+")." Test.fail message p : Meta.Primitive -> ok = self == p.value if ok then Spec_Result.Success else actual_type = self.to Meta.Type . qualified_name - message = "Expected a value of "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+omit_get_stack_trace+")." + message = "Expected a value of "+typ.to_text+" but got a value ["+self.to_text+"] of type "+actual_type+" instead (at "+Frame_Hider.get_top_stack_frame+")." Test.fail message _ -> fail_on_wrong_arg_type @@ -456,16 +456,16 @@ Any.should_be_a self typ = omitting <| example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] Any.should_equal_ignoring_order : Any -> Spec_Result -Any.should_equal_ignoring_order self that = omitting <| +Any.should_equal_ignoring_order self that = Frame_Hider.hide <| if that.is_a Vector . not then - Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+omit_get_stack_trace+").") + Panic.throw (Illegal_Argument.Error "Expected a Vector, but got a "+that.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+").") that.each element-> if self.contains element . not then - msg = "The collection (" + self.to_text + ") did not contain " + element.to_text + " (at " + omit_get_stack_trace + ")." + msg = "The collection (" + self.to_text + ") did not contain " + element.to_text + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg self.each element-> if that.contains element . not then - msg = "The collection contained an element (" + element.to_text + ") which was not expected (at " + omit_get_stack_trace + ")." + msg = "The collection contained an element (" + element.to_text + ") which was not expected (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg Test.with_clue "Duplicate elements in either collection should have the same counts - checked by comparing sorted collections: " <| ## If the vector contains vectors or incomparable values, they may not get sorted correctly. @@ -495,7 +495,7 @@ Any.should_equal_ignoring_order self that = omitting <| example_should_equal = [1, 2] . should_equal_ignoring_order [2, 1] Error.should_equal_ignoring_order : Any -> Spec_Result -Error.should_equal_ignoring_order self that = omitting <| +Error.should_equal_ignoring_order self that = Frame_Hider.hide <| _ = [that] Test.fail_match_on_unexpected_error self @@ -520,11 +520,11 @@ Error.should_equal_ignoring_order self that = omitting <| example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] Any.should_only_contain_elements_in : Any -> Spec_Result -Any.should_only_contain_elements_in self that = omitting <| +Any.should_only_contain_elements_in self that = Frame_Hider.hide <| rhs_error_check that self.each element-> if that.contains element . not then - msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + omit_get_stack_trace + ")." + msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg Spec_Result.Success @@ -549,7 +549,7 @@ Any.should_only_contain_elements_in self that = omitting <| example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4] Error.should_only_contain_elements_in : Any -> Spec_Result -Error.should_only_contain_elements_in self that = omitting <| +Error.should_only_contain_elements_in self that = Frame_Hider.hide <| _ = [that] Test.fail_match_on_unexpected_error self @@ -569,14 +569,14 @@ Error.should_only_contain_elements_in self that = omitting <| example_should_equal = "foobar".should_contain "foo" Any.should_contain : Any -> Spec_Result -Any.should_contain self element = omitting <| +Any.should_contain self element = Frame_Hider.hide <| rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else - msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omit_get_stack_trace + ")." + msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg if contains_result then Spec_Result.Success else - msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + omit_get_stack_trace + ")." + msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Asserts that `self` value contains an element. @@ -595,7 +595,7 @@ Any.should_contain self element = omitting <| example_should_equal = "foobar".should_contain "foo" Error.should_contain : Any -> Spec_Result -Error.should_contain self element = omitting <| +Error.should_contain self element = Frame_Hider.hide <| _ = [element] Test.fail_match_on_unexpected_error self @@ -608,14 +608,14 @@ Error.should_contain self element = omitting <| rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. Any.should_not_contain : Any -> Spec_Result -Any.should_not_contain self element = omitting <| +Any.should_not_contain self element = Frame_Hider.hide <| rhs_error_check element contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic-> if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else - msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + omit_get_stack_trace + ")." + msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg if contains_result.not then Spec_Result.Success else - msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + omit_get_stack_trace + ")." + msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Asserts that `self` value does not contain an element. @@ -627,6 +627,6 @@ Any.should_not_contain self element = omitting <| rules of the particular type - be it a `Vector`, `Text` or any custom type implementing a method `contains : a -> Boolean`. Error.should_not_contain : Any -> Spec_Result -Error.should_not_contain self element = omitting <| +Error.should_not_contain self element = Frame_Hider.hide <| _ = [element] Test.fail_match_on_unexpected_error self diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso similarity index 70% rename from distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso rename to distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index 79f4050ba0de..97f8456663ea 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Omitter.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -7,28 +7,28 @@ pst s st = IO.println "==== "+s st . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) -omitting ~action = - #IO.println "AAAAA "+omit_get_stack_trace +Frame_Hider.hide ~action = + #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame action -unomitting ~action = - #IO.println "AAAAA "+omit_get_stack_trace +Frame_Hider.unhide ~action = + #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame action -unomitting_1 f x = +Frame_Hider.unhide_1 f x = f x -unomitting_2 f x y = +Frame_Hider.unhide_2 f x y = f x y -omit_get_stack_trace = +Frame_Hider.get_top_stack_frame = stack_trace = Runtime.get_stack_trace reversed_stack_trace = stack_trace.reverse delta_for_frame frame = name = frame.name - if name.starts_with "Omitter.omitting" then 1 else - if name.starts_with "Omitter.unomitting" then -1 else 0 + if name.starts_with "Frame_Hider.hide" then 1 else + if name.starts_with "Frame_Hider.unhide" then -1 else 0 nesting_levels = reversed_stack_trace.map delta_for_frame . running_fold 0 (_ + _) index = i = nesting_levels.last_index_of 0 diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso index e6ca12c6cc24..af2fb8aa3e44 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso @@ -27,11 +27,7 @@ export project.Extensions.should_succeed export project.Faker.Faker -export project.Omitter.omitting -export project.Omitter.unomitting -export project.Omitter.unomitting_1 -export project.Omitter.unomitting_2 -export project.Omitter.omit_get_stack_trace +export project.Frame_Hider export project.Problems diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index eed8a26486c9..5d33a3698f54 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -1,8 +1,8 @@ from Standard.Base import all from project import Test +import project.Frame_Hider from project.Extensions import all -from project.Omitter import all ## Returns values of warnings attached to the value. get_attached_warnings v = @@ -28,20 +28,20 @@ get_attached_warnings v = duplicated and that will be accepted. If false (default), the warning count has to match the counts in `expected_problems`. test_problem_handling : (Problem_Behavior -> Any) -> Vector Any -> (Any -> Nothing) -> Boolean -> Boolean -> Nothing -test_problem_handling action expected_problems result_checker (unwrap_errors : Boolean = True) (ignore_warning_cardinality : Boolean = False) = omitting <| +test_problem_handling action expected_problems result_checker (unwrap_errors : Boolean = True) (ignore_warning_cardinality : Boolean = False) = Frame_Hider.hide <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error - error_checker error_result = omitting <| + error_checker error_result = Frame_Hider.hide <| first_problem = expected_problems.first first_problem_type = Meta.type_of first_problem error_result . should_fail_with first_problem_type unwrap_errors=unwrap_errors (unwrap_maybe error_result.catch) . should_equal first_problem - warnings_checker warnings = omitting <| + warnings_checker warnings = Frame_Hider.hide <| Test.with_clue "The warnings were "+warnings.to_text+'.\n' <| (if ignore_warning_cardinality then warnings.distinct else warnings) . map unwrap_maybe . should_equal_ignoring_order expected_problems - test_advanced_problem_handling (unomitting action) (x-> unomitting (error_checker x)) (x-> unomitting (warnings_checker x)) (x-> unomitting (result_checker x)) + test_advanced_problem_handling (Frame_Hider.unhide action) (x-> Frame_Hider.unhide (error_checker x)) (x-> Frame_Hider.unhide (warnings_checker x)) (x-> Frame_Hider.unhide (result_checker x)) ## UNSTABLE Tests how a specific operation behaves depending on the requested @@ -60,29 +60,29 @@ test_problem_handling action expected_problems result_checker (unwrap_errors : B the action is correct. It does not return anything, instead it should use the standard testing approach, like `x.should_equal y`. test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Nothing -test_advanced_problem_handling action error_checker warnings_checker result_checker = omitting <| +test_advanced_problem_handling action error_checker warnings_checker result_checker = Frame_Hider.hide <| # First, we check the action ignoring any warnings. - result_ignoring = unomitting (action Problem_Behavior.Ignore) - unomitting (result_checker result_ignoring) + result_ignoring = Frame_Hider.unhide (action Problem_Behavior.Ignore) + Frame_Hider.unhide (result_checker result_ignoring) get_attached_warnings result_ignoring . should_equal [] # Then, we check the fail-on-first-error mode. - error_result = unomitting (action Problem_Behavior.Report_Error) - unomitting (error_checker error_result) + error_result = Frame_Hider.unhide (action Problem_Behavior.Report_Error) + Frame_Hider.unhide (error_checker error_result) # Lastly, we check the report warnings mode and ensure that both the result is correct and the warnings are as expected. - result_warning = unomitting (action Problem_Behavior.Report_Warning) - unomitting (result_checker result_warning) - unomitting (warnings_checker (get_attached_warnings result_warning)) + result_warning = Frame_Hider.unhide (action Problem_Behavior.Report_Warning) + Frame_Hider.unhide (result_checker result_warning) + Frame_Hider.unhide (warnings_checker (get_attached_warnings result_warning)) ## UNSTABLE Checks if the provided value does not have any attached problems. -assume_no_problems result = omitting <| +assume_no_problems result = Frame_Hider.hide <| if result.is_error then - Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omit_get_stack_trace+")." details=result.get_stack_trace_text + Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." details=result.get_stack_trace_text warnings = get_attached_warnings result if warnings.not_empty then - Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+Frame_Hider.get_top_stack_frame+")." ## UNSTABLE Checks if the provided value has a specific warning attached. @@ -95,15 +95,15 @@ assume_no_problems result = omitting <| - unwrap_errors: If true, remove any wrapping errors from the result before checking against the expected warning. expect_warning : Any -> Any -> Boolean -> Nothing -expect_warning expected_warning result unwrap_errors=True = omitting <| +expect_warning expected_warning result unwrap_errors=True = Frame_Hider.hide <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error if result.is_error then - Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." warnings = get_attached_warnings result . map unwrap_maybe found = warnings.find if_missing=Nothing x-> (x == expected_warning) || (x.is_a expected_warning) found.if_nothing <| - Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omit_get_stack_trace+').' + Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+Frame_Hider.get_top_stack_frame+').' ## UNSTABLE Checks if the provided value has a specific warning attached and if there are @@ -118,19 +118,19 @@ expect_warning expected_warning result unwrap_errors=True = omitting <| - unwrap_errors: If true, remove any wrapping errors from the result before checking against the expected warning. expect_only_warning : Any -> Any -> Boolean -> Any -expect_only_warning expected_warning result unwrap_errors=True = omitting <| +expect_only_warning expected_warning result unwrap_errors=True = Frame_Hider.hide <| unwrap_maybe error = if unwrap_errors then Error.unwrap error else error if result.is_error then - Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." warnings = get_attached_warnings result . map unwrap_maybe is_expected x = (x == expected_warning) || (x.is_a expected_warning) found = warnings.find if_missing=Nothing is_expected if found.is_nothing then - Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+omit_get_stack_trace+').' + Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+Frame_Hider.get_top_stack_frame+').' invalid = warnings.filter x-> is_expected x . not if invalid.not_empty then - Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+omit_get_stack_trace+').' + Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+Frame_Hider.get_top_stack_frame+').' found ## UNSTABLE @@ -138,8 +138,8 @@ expect_only_warning expected_warning result unwrap_errors=True = omitting <| It allows other warnings to be present also. not_expect_warning : Any -> Any -> Nothing -not_expect_warning expected_warning_type result = omitting <| +not_expect_warning expected_warning_type result = Frame_Hider.hide <| warnings = get_attached_warnings result found = warnings.find if_missing=Nothing x-> x.is_a expected_warning_type if found.is_nothing.not then - Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+omit_get_stack_trace+').' + Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+Frame_Hider.get_top_stack_frame+').' diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index 1268e8f57f55..a432519d6e0d 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -4,7 +4,6 @@ import Standard.Base.Runtime.Ref.Ref import project.Spec_Result.Spec_Result from project import Test from project.Extensions import all -from project.Omitter import all ## Test class for checking if a certain point in the code has been reached. type Should_Reach @@ -23,6 +22,6 @@ type Should_Reach ## Checks if a point was reached in execution. should_have_reached : Spec_Result - should_have_reached self -> Spec_Result = omitting <| + should_have_reached self -> Spec_Result = Frame_Hider.hide <| if self.reached_ref.get then Spec_Result.Success else - Test.fail ("Did not reach Should_Reach (at "+omit_get_stack_trace+").") + Test.fail ("Did not reach Should_Reach (at "+Frame_Hider.get_top_stack_frame+").") diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index bd3c3f1ff384..894ff386d074 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -4,13 +4,13 @@ from Standard.Base.Errors.Common import Uninitialized_State from Standard.Base.Runtime import State import project.Clue.Clue +import project.Frame_Hider import project.Group.Group import project.Spec.Spec import project.Spec_Result.Spec_Result import project.Suite.Suite import project.Suite.Suite_Builder import project.Test_Result.Test_Result -from project.Omitter import all polyglot java import java.lang.Thread @@ -43,7 +43,7 @@ type Test example_expect_panic_with = Test.expect_panic_with Examples.throw_panic Examples.My_Error expect_panic_with : Any -> Any -> Test_Result - expect_panic_with ~action matcher = omitting <| + expect_panic_with ~action matcher = Frame_Hider.hide <| handle_panic caught_panic = payload = caught_panic.payload is_internal_test_panic = payload.is_a Spec_Result @@ -54,17 +54,17 @@ type Test is_panic_matching = payload.is_a matcher if is_panic_matching then payload else stack_trace = caught_panic.convert_to_dataflow_error.get_stack_trace_text - Test.fail ("Expected a " + matcher.to_text + ", but " + payload.to_text + " was thrown instead (at " + omit_get_stack_trace + ").") details=stack_trace + Test.fail ("Expected a " + matcher.to_text + ", but " + payload.to_text + " was thrown instead (at " + Frame_Hider.get_top_stack_frame + ").") details=stack_trace Panic.catch Any handler=handle_panic <| res = action # If the action did not panic above, we fail the test. case res.is_error of True -> - Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action returned a Dataflow Error " + res.catch.to_display_text + " instead (at " + omit_get_stack_trace + ").") + Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action returned a Dataflow Error " + res.catch.to_display_text + " instead (at " + Frame_Hider.get_top_stack_frame + ").") False -> return_suffix = if res.is_nothing then "" else " and returned ["+res.to_text+"]" - Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action succeeded" + return_suffix + " (at " + omit_get_stack_trace + ").") + Test.fail ("Expected a Panic " + matcher.to_text + " to be thrown, but the action succeeded" + return_suffix + " (at " + Frame_Hider.get_top_stack_frame + ").") ## Expect a function to fail with the provided panic. @@ -89,19 +89,19 @@ type Test IO.println 'this is not reached' expect_panic : Any -> Any -> Test_Result - expect_panic matcher ~action = omitting <| Test.expect_panic_with action matcher + expect_panic matcher ~action = Frame_Hider.hide <| Test.expect_panic_with action matcher ## Checks that the provided action returns without any errors or warnings. If you just want to check for errors, usage of the `.should_succeed` extension function is preferred. - assert_no_problems value = omitting <| + assert_no_problems value = Frame_Hider.hide <| value.catch Any _-> Test.fail_match_on_unexpected_error value warnings = Warning.get_all value . map .value if warnings.not_empty then - msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + omit_get_stack_trace + ")." + msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg ## Fail a test with the given message. @@ -131,9 +131,9 @@ type Test ## PRIVATE Reports an unexpected dataflow error has occurred. fail_match_on_unexpected_error : Error -> Nothing - fail_match_on_unexpected_error error = omitting <| + fail_match_on_unexpected_error error = Frame_Hider.hide <| payload = error.catch - msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + omit_get_stack_trace + ")." + msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + Frame_Hider.get_top_stack_frame + ")." Test.fail msg details=error.get_stack_trace_text ## Executes the block of code passed as behavior and adds a clue modifier which @@ -188,7 +188,7 @@ type Test or fails with the last error thrown by the action after exhausting retry attempts. with_retries : Any -> Any - with_retries ~action = omitting <| + with_retries ~action = Frame_Hider.hide <| milliseconds_between_attempts = 100 ## We give the CI a bit more attempts, as failures are more annoying there. For local development, a bit less retries is enough - there it is more @@ -197,11 +197,11 @@ type Test max_retries = if Environment.get "CI" . is_nothing . not then 100 else 20 go i = - Panic.catch Any (unomitting action) caught_panic-> + Panic.catch Any (Frame_Hider.unhide action) caught_panic-> # If the iterations are exhausted, we rethrow the panic. if i > max_retries then Panic.throw caught_panic else if i % 10 == 0 then - IO.println 'Still failing after '+i.to_text+' retries ('+omit_get_stack_trace.to_display_text+'):\n'+caught_panic.payload.to_display_text + IO.println 'Still failing after '+i.to_text+' retries ('+Frame_Hider.get_top_stack_frame.to_display_text+'):\n'+caught_panic.payload.to_display_text Thread.sleep milliseconds_between_attempts @Tail_Call go (i+1) go 1 diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index f5ae02206941..a5574c98687a 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -2,7 +2,6 @@ from Standard.Base import all import Standard.Base from Standard.Test import all -from Standard.Test.Omitter import all polyglot java import org.enso.base_test_helpers.CallbackHelper @@ -19,7 +18,7 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil _ -> Nothing group_builder.specify "should allow to get the source location of a frame" pending=location_pending <| - src = omit_get_stack_trace + src = Frame_Hider.get_top_stack_frame loc = "Meta_Location_Spec.enso:22:15-34" src.take (..Last loc.length) . should_equal loc diff --git a/test/Base_Tests/src/System/File_Spec.enso b/test/Base_Tests/src/System/File_Spec.enso index 018e115da761..573a92c00004 100644 --- a/test/Base_Tests/src/System/File_Spec.enso +++ b/test/Base_Tests/src/System/File_Spec.enso @@ -17,12 +17,12 @@ import project.Data.Data_Spec import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup ## We rely on a less strict equality for `File` as it is fine if a relative file gets resolved to absolute. -File.should_equal self other = omitting <| +File.should_equal self other = Frame_Hider.hide <| are_same = case other of _ : File -> self.absolute.normalize.path == other.absolute.normalize.path _ -> False if are_same then self else - Test.fail "Expected "+self.to_text+" to be equal to "+other.to_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected "+self.to_text+" to be equal to "+other.to_text+" (at "+Frame_Hider.get_top_stack_frame+")." set_writable file writable = diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index fa57fcf86932..9aaeeb196776 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -58,7 +58,7 @@ add_aggregate_specs suite_builder setup = table_builder = setup.table_builder data = Data.setup table_fn empty_table_fn - expect_column_names names table = omitting <| + expect_column_names names table = Frame_Hider.hide <| table.columns . map .name . should_equal names find_row key table (columns=Nothing) = @@ -1107,7 +1107,7 @@ add_aggregate_specs suite_builder setup = suite_builder.group prefix+"Table.aggregate Count_Distinct" group_builder-> group_builder.specify "should correctly count missing values" <| - get_value t = omitting <| + get_value t = Frame_Hider.hide <| columns = materialize t . columns columns.length . should_equal 1 columns.first.length . should_equal 1 @@ -1254,13 +1254,13 @@ add_aggregate_specs suite_builder setup = m1.columns.first.at 0 . should_equal 1.1180339887499 epsilon=0.000001 m1.columns.second.at 0 . should_equal 1.2909944487358 epsilon=0.000001 - expect_null_or_nan value = omitting <| + expect_null_or_nan value = Frame_Hider.hide <| matches = case value of Nothing -> True _ : Float -> Double.isNaN value _ -> False if matches.not then - Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+Frame_Hider.get_top_stack_frame+")." if setup.flagged ..Supports_Infinity then suite_builder.group prefix+"Table.aggregate should correctly handle infinities" group_builder-> pos_inf = 1/0 diff --git a/test/Table_Tests/src/Common_Table_Operations/Main.enso b/test/Table_Tests/src/Common_Table_Operations/Main.enso index c06aa1cda122..9c8f8fc2f6f1 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Main.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Main.enso @@ -3,7 +3,6 @@ from Standard.Base import all import Standard.Database.Internal.Replace_Params.Replace_Params from Standard.Test import Test -from Standard.Test.Omitter import all import project.Common_Table_Operations.Add_Group_Number_Spec import project.Common_Table_Operations.Add_Row_Number_Spec @@ -85,10 +84,10 @@ type Test_Setup supports_custom_objects self = self.is_database.not ## Checks if the provided column has integer type as defined by the backend. - expect_integer_type self column = omitting <| + expect_integer_type self column = Frame_Hider.hide <| value_type = column.value_type if self.is_integer_type value_type then column else - Test.fail ("Expected column ["+column.name+"] to have integer type, but got "+value_type.to_display_text+" (at " + omit_get_stack_trace + ").") + Test.fail ("Expected column ["+column.name+"] to have integer type, but got "+value_type.to_display_text+" (at " + Frame_Hider.get_top_stack_frame + ").") type Test_Selection ## The configuration specifying what features are supported by a given diff --git a/test/Table_Tests/src/Common_Table_Operations/Util.enso b/test/Table_Tests/src/Common_Table_Operations/Util.enso index 71ce82c99b9a..bc4cdd2b85c5 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Util.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Util.enso @@ -7,7 +7,7 @@ from Standard.Test import all from project.In_Memory.Common_Spec import in_memory_setup -expect_column_names names table ignore_order=False = omitting <| +expect_column_names names table ignore_order=False = Frame_Hider.hide <| case ignore_order of False -> table.columns . map .name . should_equal names True -> table.columns . map .name . sort . should_equal names.sort @@ -49,9 +49,9 @@ within_table table = Test.with_clue 'Resulting table:\n'+description+'\n\n' ## PRIVATE -Any.should_equal_tz_agnostic self other = omitting <| +Any.should_equal_tz_agnostic self other = Frame_Hider.hide <| _ = other - Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected a vector but got "+self.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." ## PRIVATE A helper method that compares two vectors of Date_Time values. @@ -59,22 +59,22 @@ Any.should_equal_tz_agnostic self other = omitting <| It ensures that they represent the same instant in time, but ignore the timezone that is attached to them. This is simply done by converting them to UTC. -Vector.should_equal_tz_agnostic self other = omitting <| +Vector.should_equal_tz_agnostic self other = Frame_Hider.hide <| case other of _ : Vector -> utc = Time_Zone.utc normalize_date_time dt = case dt of _ : Date_Time -> dt.at_zone utc - _ -> Test.fail "The vector should contain Date_Time objects but it contained "+dt.to_display_text+" (at "+omit_get_stack_trace+")" + _ -> Test.fail "The vector should contain Date_Time objects but it contained "+dt.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")" self_normalized = self.map normalize_date_time other_normalized = other.map normalize_date_time self_normalized.should_equal other_normalized - _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+omit_get_stack_trace+")" + _ -> Test.fail "Expected a vector but got "+other.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")" ## PRIVATE -Error.should_equal_tz_agnostic self other = omitting <| +Error.should_equal_tz_agnostic self other = Frame_Hider.hide <| _ = other - Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." ## PRIVATE Builds a table ensuring that the rows are in the order as given. diff --git a/test/Table_Tests/src/IO/Fetch_Spec.enso b/test/Table_Tests/src/IO/Fetch_Spec.enso index a81330df6962..e6e02fce2093 100644 --- a/test/Table_Tests/src/IO/Fetch_Spec.enso +++ b/test/Table_Tests/src/IO/Fetch_Spec.enso @@ -135,7 +135,7 @@ add_specs suite_builder = after_count = get_num_response_cache_entries [before_count, after_count] - expect_counts expected_counts ~action = omitting <| + expect_counts expected_counts ~action = Frame_Hider.hide <| counts = with_counts action counts . should_equal expected_counts diff --git a/test/Table_Tests/src/In_Memory/Table_Spec.enso b/test/Table_Tests/src/In_Memory/Table_Spec.enso index 705ca6c6018b..b3383921907f 100644 --- a/test/Table_Tests/src/In_Memory/Table_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Table_Spec.enso @@ -703,7 +703,7 @@ add_specs suite_builder = actual.column_names . should_equal ["col0", "col_between", "col1"] suite_builder.group "Use First Row As Names" group_builder-> - expect_column_names names table = omitting <| + expect_column_names names table = Frame_Hider.hide <| table.columns . map .name . should_equal names group_builder.specify "should work happily with mixed types" <| diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index b4e25f1be68b..826b5dbcadf4 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -10,26 +10,26 @@ from Standard.Test import all polyglot java import org.enso.base_test_helpers.FileSystemHelper Table.should_equal : Any -> Boolean -> Any -Table.should_equal self expected ignore_order=False = omitting <| +Table.should_equal self expected ignore_order=False = Frame_Hider.hide <| rhs_error_check expected - Panic.catch Test_Failure_Error (table_should_equal_impl self expected omit_get_stack_trace ignore_order) error-> + Panic.catch Test_Failure_Error (table_should_equal_impl self expected Frame_Hider.get_top_stack_frame ignore_order) error-> Test.fail error.payload.message Column.should_equal : Any -> Any -Column.should_equal self expected = omitting <| +Column.should_equal self expected = Frame_Hider.hide <| rhs_error_check expected - Panic.catch Test_Failure_Error (column_should_equal_impl self expected omit_get_stack_trace) error-> + Panic.catch Test_Failure_Error (column_should_equal_impl self expected Frame_Hider.get_top_stack_frame) error-> Test.fail error.payload.message DB_Table.should_equal : DB_Table|Table -> Boolean -> Any -DB_Table.should_equal self expected ignore_order=False = omitting <| +DB_Table.should_equal self expected ignore_order=False = Frame_Hider.hide <| rhs_error_check expected t0 = self.read t1 = expected.read t0 . should_equal t1 ignore_order DB_Column.should_equal : DB_Column -> Any -DB_Column.should_equal self expected = omitting <| +DB_Column.should_equal self expected = Frame_Hider.hide <| rhs_error_check expected t0 = self.read t1 = expected.read @@ -111,17 +111,17 @@ set_writable file writable = For example, if `example` is `[[1, 2], [3]]`, then both `[1, 2, 3]` and `[2, 1, 3]` will be accepted, but `[2, 3, 1]` will be rejected. -Any.should_have_relative_ordering self (example : Vector) = omitting <| +Any.should_have_relative_ordering self (example : Vector) = Frame_Hider.hide <| case self of _ : Vector -> example.each v-> case v of _ : Vector -> - if v.is_empty then Test.fail "The example vector should not contain empty vectors as they are meaningless (at "+omit_get_stack_trace+")." - _ -> Test.fail "Expected a vector of vectors but got a vector containing "+v.to_display_text+" (at "+omit_get_stack_trace+")." + if v.is_empty then Test.fail "The example vector should not contain empty vectors as they are meaningless (at "+Frame_Hider.get_top_stack_frame+")." + _ -> Test.fail "Expected a vector of vectors but got a vector containing "+v.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." total_length = example.fold 0 acc-> v-> acc+v.length if self.length != total_length then - Test.fail "Expected a vector of length "+total_length.to_text+" but got "+self.length.to_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected a vector of length "+total_length.to_text+" but got "+self.length.to_text+" (at "+Frame_Hider.get_top_stack_frame+")." pieces = Vector.build builder-> example.fold 0 offset-> reference_v-> @@ -138,14 +138,14 @@ Any.should_have_relative_ordering self (example : Vector) = omitting <| (got_piece.sort on_problems=..Report_Error) == (expected_piece.sort on_problems=..Report_Error) if are_consistent.not then offset = pieces.take ix . fold 0 acc-> p-> acc+p.length - Test.fail "Expected the run of vector elements starting at offset "+offset.to_text+" to be a permutation of "+expected_piece.to_display_text+" but got "+got_piece.to_display_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected the run of vector elements starting at offset "+offset.to_text+" to be a permutation of "+expected_piece.to_display_text+" but got "+got_piece.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." - _ -> Test.fail "Expected a vector but got "+self.to_display_text+" (at "+omit_get_stack_trace+")." + _ -> Test.fail "Expected a vector but got "+self.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." ## PRIVATE See `Any.should_have_relative_ordering`. -Error.should_have_relative_ordering self example = omitting <| +Error.should_have_relative_ordering self example = Frame_Hider.hide <| _ = example - Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+omit_get_stack_trace+")." + Test.fail "Expected a vector but got a dataflow error "+self.catch.to_display_text+" (at "+Frame_Hider.get_top_stack_frame+")." ## PRIVATE diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index c215442e34e2..f7cdf248f781 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -92,9 +92,9 @@ add_specs suite_builder = r1.message.should_contain "Extensions_Spec.enso:91" group_builder.specify "should be able to get a stack trace without test helper frames (with nesting)" <| - should_equal_2 x y = omitting <| + should_equal_2 x y = Frame_Hider.hide <| x.should_equal y - should_equal_3 x y = omitting <| + should_equal_3 x y = Frame_Hider.hide <| should_equal_2 x y r1 = expect_test_failure <| @@ -103,10 +103,10 @@ add_specs suite_builder = group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a no-arg callback)" <| ## This test is here because of differences in stack traces with no-arg calls. - should_equal_a checker _ _ = omitting <| - unomitting checker - should_equal_b checker x y = omitting <| - should_equal_a (unomitting checker) x y + should_equal_a checker _ _ = Frame_Hider.hide <| + Frame_Hider.unhide checker + should_equal_b checker x y = Frame_Hider.hide <| + should_equal_a (Frame_Hider.unhide checker) x y my_checker = False . should_be_true @@ -116,10 +116,10 @@ add_specs suite_builder = r1.message.should_contain "Extensions_Spec.enso:112" group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a one-arg callback)" <| - should_equal_a checker x = omitting <| - unomitting (checker x) - should_equal_b checker x = omitting <| - should_equal_a (unomitting_1 checker x) + should_equal_a checker x = Frame_Hider.hide <| + Frame_Hider.unhide (checker x) + should_equal_b checker x = Frame_Hider.hide <| + should_equal_a (Frame_Hider.unhide_1 checker x) my_checker x = x . should_equal "ac" @@ -129,10 +129,10 @@ add_specs suite_builder = r1.message.should_contain "Extensions_Spec.enso:125" group_builder.specify "should be able to get a stack trace without test helper frames (with nesting and a two-arg callback)" <| - should_equal_a checker x y = omitting <| - unomitting (checker x y) - should_equal_b checker x y = omitting <| - should_equal_a (unomitting_2 checker x y) + should_equal_a checker x y = Frame_Hider.hide <| + Frame_Hider.unhide (checker x y) + should_equal_b checker x y = Frame_Hider.hide <| + should_equal_a (Frame_Hider.unhide_2 checker x y) my_checker x y = x.should_equal y diff --git a/test/Test_Tests/src/Helpers.enso b/test/Test_Tests/src/Helpers.enso index aafe3d2fbc9a..a2ecf33beded 100644 --- a/test/Test_Tests/src/Helpers.enso +++ b/test/Test_Tests/src/Helpers.enso @@ -1,11 +1,11 @@ from Standard.Base import all +import Standard.Test.Frame_Hider import Standard.Test.Spec_Result.Spec_Result from Standard.Test import Test -from Standard.Test.Omitter import all ## Expects the inner action to report a test failure exception and returns its payload. -expect_test_failure ~action -> Spec_Result = omitting <| +expect_test_failure ~action -> Spec_Result = Frame_Hider.hide <| handle_panic caught_panic = result = caught_panic.payload case result of @@ -13,5 +13,5 @@ expect_test_failure ~action -> Spec_Result = omitting <| _ -> Test.fail "Expected test failure, but "+result.to_text+" was raised as error." Panic.catch Spec_Result handler=handle_panic <| - unomitting action - Test.fail "Expected the inner action to fail, but there was no failure (at "+omit_get_stack_trace+")." + Frame_Hider.unhide action + Test.fail "Expected the inner action to fail, but there was no failure (at "+Frame_Hider.get_top_stack_frame+")." From c9db11ccb89fb0d178437f62ad6dd98a95545d55 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 15:50:35 -0500 Subject: [PATCH 36/58] wip --- .../lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index 97f8456663ea..c7248e9aea82 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -7,21 +7,21 @@ pst s st = IO.println "==== "+s st . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) -Frame_Hider.hide ~action = +hide ~action = #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame action -Frame_Hider.unhide ~action = +unhide ~action = #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame action -Frame_Hider.unhide_1 f x = +unhide_1 f x = f x -Frame_Hider.unhide_2 f x y = +unhide_2 f x y = f x y -Frame_Hider.get_top_stack_frame = +get_top_stack_frame = stack_trace = Runtime.get_stack_trace reversed_stack_trace = stack_trace.reverse From 3e1f4d271486476ebc8d3122fbedaf5cbae2e67c Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 15:57:44 -0500 Subject: [PATCH 37/58] wip --- .../Standard/Test/0.0.0-dev/src/Problems.enso | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index 5d33a3698f54..7e476903d0b1 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -41,7 +41,7 @@ test_problem_handling action expected_problems result_checker (unwrap_errors : B (if ignore_warning_cardinality then warnings.distinct else warnings) . map unwrap_maybe . should_equal_ignoring_order expected_problems - test_advanced_problem_handling (Frame_Hider.unhide action) (x-> Frame_Hider.unhide (error_checker x)) (x-> Frame_Hider.unhide (warnings_checker x)) (x-> Frame_Hider.unhide (result_checker x)) + test_advanced_problem_handling (Frame_Hider.unhide action) (Frame_Hider.unhide_1 error_checker) (Frame_Hider.unhide_1 warnings_checker) (Frame_Hider.unhide_1 result_checker) ## UNSTABLE Tests how a specific operation behaves depending on the requested @@ -62,18 +62,18 @@ test_problem_handling action expected_problems result_checker (unwrap_errors : B test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Nothing test_advanced_problem_handling action error_checker warnings_checker result_checker = Frame_Hider.hide <| # First, we check the action ignoring any warnings. - result_ignoring = Frame_Hider.unhide (action Problem_Behavior.Ignore) - Frame_Hider.unhide (result_checker result_ignoring) + result_ignoring = Frame_Hider.unhide_1 action Problem_Behavior.Ignore + Frame_Hider.unhide_1 result_checker result_ignoring get_attached_warnings result_ignoring . should_equal [] # Then, we check the fail-on-first-error mode. - error_result = Frame_Hider.unhide (action Problem_Behavior.Report_Error) - Frame_Hider.unhide (error_checker error_result) + error_result = Frame_Hider.unhide_1 action Problem_Behavior.Report_Error + Frame_Hider.unhide_1 error_checker error_result # Lastly, we check the report warnings mode and ensure that both the result is correct and the warnings are as expected. - result_warning = Frame_Hider.unhide (action Problem_Behavior.Report_Warning) - Frame_Hider.unhide (result_checker result_warning) - Frame_Hider.unhide (warnings_checker (get_attached_warnings result_warning)) + result_warning = Frame_Hider.unhide_1 action Problem_Behavior.Report_Warning + Frame_Hider.unhide_1 result_checker result_warning + Frame_Hider.unhide_1 warnings_checker (get_attached_warnings result_warning) ## UNSTABLE Checks if the provided value does not have any attached problems. From fc7a125a839f6bb9bd007608947da32c7e37b551 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 16:02:22 -0500 Subject: [PATCH 38/58] type --- .../Test/0.0.0-dev/src/Extensions.enso | 2 +- .../Test/0.0.0-dev/src/Frame_Hider.enso | 71 ++++++++++--------- .../lib/Standard/Test/0.0.0-dev/src/Main.enso | 2 +- .../Standard/Test/0.0.0-dev/src/Problems.enso | 2 +- .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 2 +- test/Test_Tests/src/Extensions_Spec.enso | 2 +- test/Test_Tests/src/Helpers.enso | 2 +- 7 files changed, 42 insertions(+), 41 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 90d9eff80ad8..5c87eaae06d3 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -3,7 +3,7 @@ import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.No_Such_Method import Standard.Base.Errors.Illegal_Argument.Illegal_Argument -import project.Frame_Hider +import project.Frame_Hider.Frame_Hider import project.Spec_Result.Spec_Result import project.Test.Test from project.Extensions_Helpers import rhs_error_check diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index c7248e9aea82..495be892356a 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -7,38 +7,39 @@ pst s st = IO.println "==== "+s st . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) -hide ~action = - #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame - action - -unhide ~action = - #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame - action - -unhide_1 f x = - f x - -unhide_2 f x y = - f x y - -get_top_stack_frame = - stack_trace = Runtime.get_stack_trace - reversed_stack_trace = stack_trace.reverse - - delta_for_frame frame = - name = frame.name - if name.starts_with "Frame_Hider.hide" then 1 else - if name.starts_with "Frame_Hider.unhide" then -1 else 0 - nesting_levels = reversed_stack_trace.map delta_for_frame . running_fold 0 (_ + _) - index = - i = nesting_levels.last_index_of 0 - if i.is_nothing then 0 else i-1 - - if verbose then - pst "full" stack_trace - IO.println "OI "+index.to_text+" "+(stack_trace.length + 1 - index).to_text - IO.println "OI "+nesting_levels.to_text - IO.println "OI "+(reversed_stack_trace.at index).to_text - - top = reversed_stack_trace . at index . source_location - top.to_display_text +type Frame_Hider + hide ~action = + #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame + action + + unhide ~action = + #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame + action + + unhide_1 f x = + f x + + unhide_2 f x y = + f x y + + get_top_stack_frame = + stack_trace = Runtime.get_stack_trace + reversed_stack_trace = stack_trace.reverse + + delta_for_frame frame = + name = frame.name + if name.starts_with "Frame_Hider.hide" then 1 else + if name.starts_with "Frame_Hider.unhide" then -1 else 0 + nesting_levels = reversed_stack_trace.map delta_for_frame . running_fold 0 (_ + _) + index = + i = nesting_levels.last_index_of 0 + if i.is_nothing then 0 else i-1 + + if verbose then + pst "full" stack_trace + IO.println "OI "+index.to_text+" "+(stack_trace.length + 1 - index).to_text + IO.println "OI "+nesting_levels.to_text + IO.println "OI "+(reversed_stack_trace.at index).to_text + + top = reversed_stack_trace . at index . source_location + top.to_display_text diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso index af2fb8aa3e44..b245714303e7 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso @@ -27,7 +27,7 @@ export project.Extensions.should_succeed export project.Faker.Faker -export project.Frame_Hider +export project.Frame_Hider.Frame_Hider export project.Problems diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso index 7e476903d0b1..eaa93ec58b0f 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso @@ -1,7 +1,7 @@ from Standard.Base import all from project import Test -import project.Frame_Hider +import project.Frame_Hider.Frame_Hider from project.Extensions import all ## Returns values of warnings attached to the value. diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 894ff386d074..a46d08936e3f 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -4,7 +4,7 @@ from Standard.Base.Errors.Common import Uninitialized_State from Standard.Base.Runtime import State import project.Clue.Clue -import project.Frame_Hider +import project.Frame_Hider.Frame_Hider import project.Group.Group import project.Spec.Spec import project.Spec_Result.Spec_Result diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index f7cdf248f781..f4f75204e902 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -85,7 +85,7 @@ add_specs suite_builder = "abc".should_end_with "d" r1.message.should_contain "Extensions_Spec.enso:85" - suite_builder.group "stack trace location" group_builder-> + suite_builder.group "stack trace location and frame hiding" group_builder-> group_builder.specify "should be able to get a stack trace without test helper frames" <| r1 = expect_test_failure <| "ab".should_equal "ac" diff --git a/test/Test_Tests/src/Helpers.enso b/test/Test_Tests/src/Helpers.enso index a2ecf33beded..f03effbbe97c 100644 --- a/test/Test_Tests/src/Helpers.enso +++ b/test/Test_Tests/src/Helpers.enso @@ -1,6 +1,6 @@ from Standard.Base import all -import Standard.Test.Frame_Hider +import Standard.Test.Frame_Hider.Frame_Hider import Standard.Test.Spec_Result.Spec_Result from Standard.Test import Test From b7d9d60039eb2e872bfbff5e601207fb94160b73 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 16:24:00 -0500 Subject: [PATCH 39/58] docs --- .../Test/0.0.0-dev/src/Frame_Hider.enso | 97 ++++++++++++++++--- 1 file changed, 86 insertions(+), 11 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index 495be892356a..6736d224ffd7 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -1,31 +1,112 @@ from Standard.Base import all import Standard.Base.Runtime.Ref.Ref -verbose = False +## PRIVATE -pst s st = - IO.println "==== "+s - st . map_with_index (i-> x-> IO.println i.to_text+": "+x.to_text) + Frame_Hider is used in test utilities to hide uninteresting stack frames from + users when reporting the location of test failures. + In a test utility such as `Any.should_equal`, the failure of a test assertion + is accompanied by the location of the failure. The location should not be a + stack frame inside `Any.should_equal`, but rather should be at the location + that called `Any.should_equal`. This means identifying stack frames we don't + want to bother the user with, and omitting them when we're looking for the + correct stack frame to use. + + The problem is more complicated when test utilities call other utilities, or + when test utilities invoke callbacks provided by user test code. + + The `hide` and `unhide*` methods are simple wrappers. `get_top_stack_frame` + identifies these on the stack, and uses them to removes the uninteresting + frames from consderation. + + A `hide` call should be wrapped around the body of every test utility. + + An `unhide` call should be wrapped around any call from a test utility to a + user-supplied callback, depending on the number of arguments. If one test + utility forwards a callback to another test utility, the callback should be + wrapped at the forward site as well. type Frame_Hider + ## PRIVATE + + Hides the stack frames of the contained code from `get_top_stack_frame`. + + > Example + Wrap the body of a test utility to hide its stack frames. + + Any.should_equal self that = Frame_Hider.hide <| + ... + Error.throw ("Not equal at " + Frame_Hider.get_top_stack_frame) hide ~action = #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame action + ## PRIVATE + + Unhides the stack frames of the call to the user-supplied callback + application. + + > Example + Wrap a callback invocation to unhide its stack frames. + + my_test_utility test_predicate x = + ... + Frame_Hider.unhide (test_predicate x) unhide ~action = #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame action + ## PRIVATE + + Unhides the stack frames of the call to the user-supplied callback + application, curried for one argument. + + `unhide_1 f x` is Equivalent to `unhide (f x)`. + + > Example + Wrap a callback invocation to unhide its stack frames. + + my_test_utility test_predicate x = + ... + Frame_Hider.unhide_1 test_predicate x unhide_1 f x = f x + ## PRIVATE + + Unhides the stack frames of the call to the user-supplied callback + application, curried for two arguments. + + `unhide_1 f x y` is Equivalent to `unhide (f x y)`. + + > Example + Wrap a callback invocation to unhide its stack frames. + + my_test_utility test_predicate x y = + ... + Frame_Hider.unhide_2 test_predicate x y unhide_2 f x y = f x y - get_top_stack_frame = + ## PRIVATE + + Identify the correct top stack frame by skipping over the stack frames + inside test utilities. + get_top_stack_frame -> Text = stack_trace = Runtime.get_stack_trace reversed_stack_trace = stack_trace.reverse + ## Iterate through stack frames from bottom to top, determining how many + `hide` calls each one is nested inside. Each `hide` frame increases + the nesting level by 1, and each `unhide` decreases it by one. + + The stack frame we are looking for is the one before the last frame + that has a nesting level of 0 -- this is the most recent user-level + call, and the one that triggered the test assertion failure. + + If we cannot find such a frame, we simply return the top of the + stack. (In this case, some test code is missing a call to `hide` or + `unhide*`.) delta_for_frame frame = name = frame.name if name.starts_with "Frame_Hider.hide" then 1 else @@ -35,11 +116,5 @@ type Frame_Hider i = nesting_levels.last_index_of 0 if i.is_nothing then 0 else i-1 - if verbose then - pst "full" stack_trace - IO.println "OI "+index.to_text+" "+(stack_trace.length + 1 - index).to_text - IO.println "OI "+nesting_levels.to_text - IO.println "OI "+(reversed_stack_trace.at index).to_text - top = reversed_stack_trace . at index . source_location top.to_display_text From 9822e59d8eb424c91269b4646987ce85d8f6cb0f Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 16:24:32 -0500 Subject: [PATCH 40/58] wip --- distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 2 -- 1 file changed, 2 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index 6736d224ffd7..f5509a7a71fe 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -38,7 +38,6 @@ type Frame_Hider ... Error.throw ("Not equal at " + Frame_Hider.get_top_stack_frame) hide ~action = - #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame action ## PRIVATE @@ -53,7 +52,6 @@ type Frame_Hider ... Frame_Hider.unhide (test_predicate x) unhide ~action = - #IO.println "AAAAA "+Frame_Hider.get_top_stack_frame action ## PRIVATE From b2140bb961c5da28c7e01ed5a4010ae6cfce2e4a Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 16:42:36 -0500 Subject: [PATCH 41/58] wip --- distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso index a432519d6e0d..7eb630759cc5 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Should_Reach.enso @@ -1,6 +1,7 @@ from Standard.Base import all import Standard.Base.Runtime.Ref.Ref +import project.Frame_Hider.Frame_Hider import project.Spec_Result.Spec_Result from project import Test from project.Extensions import all From 88115cedbe1f61a9a3a20ae81cc8f76922c5de92 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 16:48:27 -0500 Subject: [PATCH 42/58] wip --- test/Base_Tests/src/Semantic/Meta_Location_Spec.enso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index a5574c98687a..da338e32d82e 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -19,7 +19,7 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil group_builder.specify "should allow to get the source location of a frame" pending=location_pending <| src = Frame_Hider.get_top_stack_frame - loc = "Meta_Location_Spec.enso:22:15-34" + loc = "Meta_Location_Spec.enso:21:15-34" src.take (..Last loc.length) . should_equal loc group_builder.specify "should allow to get qualified type names of values" <| From 049f2632a24de999ba3b29a5bb1626a621c8bdfe Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Tue, 11 Feb 2025 17:05:10 -0500 Subject: [PATCH 43/58] unc --- distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index f5509a7a71fe..b3ef169cb205 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -57,7 +57,7 @@ type Frame_Hider ## PRIVATE Unhides the stack frames of the call to the user-supplied callback - application, curried for one argument. + application, uncurried for one argument. `unhide_1 f x` is Equivalent to `unhide (f x)`. @@ -73,7 +73,7 @@ type Frame_Hider ## PRIVATE Unhides the stack frames of the call to the user-supplied callback - application, curried for two arguments. + application, uncurried for two arguments. `unhide_1 f x y` is Equivalent to `unhide (f x y)`. From b334d28df308c1c9abfd89ca51c2712582387097 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 12 Feb 2025 09:49:21 -0500 Subject: [PATCH 44/58] review --- .../lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index b3ef169cb205..70d5472b9a71 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -48,7 +48,7 @@ type Frame_Hider > Example Wrap a callback invocation to unhide its stack frames. - my_test_utility test_predicate x = + test_utility test_predicate x = ... Frame_Hider.unhide (test_predicate x) unhide ~action = @@ -64,7 +64,7 @@ type Frame_Hider > Example Wrap a callback invocation to unhide its stack frames. - my_test_utility test_predicate x = + test_utility test_predicate x = ... Frame_Hider.unhide_1 test_predicate x unhide_1 f x = @@ -80,7 +80,7 @@ type Frame_Hider > Example Wrap a callback invocation to unhide its stack frames. - my_test_utility test_predicate x y = + test_utility test_predicate x y = ... Frame_Hider.unhide_2 test_predicate x y unhide_2 f x y = @@ -103,8 +103,7 @@ type Frame_Hider call, and the one that triggered the test assertion failure. If we cannot find such a frame, we simply return the top of the - stack. (In this case, some test code is missing a call to `hide` or - `unhide*`.) + stack. (In this case, some test code is missing a call to `unhide*`.) delta_for_frame frame = name = frame.name if name.starts_with "Frame_Hider.hide" then 1 else @@ -112,7 +111,7 @@ type Frame_Hider nesting_levels = reversed_stack_trace.map delta_for_frame . running_fold 0 (_ + _) index = i = nesting_levels.last_index_of 0 - if i.is_nothing then 0 else i-1 + if i.is_nothing || i == 0 then 0 else i-1 top = reversed_stack_trace . at index . source_location top.to_display_text From f0cdd007424620dce2a05b097a76f2423e2fddb7 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 12 Feb 2025 10:37:41 -0500 Subject: [PATCH 45/58] wip --- distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index 70d5472b9a71..dbcf10658fb4 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -17,7 +17,7 @@ import Standard.Base.Runtime.Ref.Ref when test utilities invoke callbacks provided by user test code. The `hide` and `unhide*` methods are simple wrappers. `get_top_stack_frame` - identifies these on the stack, and uses them to removes the uninteresting + identifies these on the stack, and uses them to remove the uninteresting frames from consderation. A `hide` call should be wrapped around the body of every test utility. From cf7bc554f5c9d78b877fcb5f05c04270d40b02c4 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 12 Feb 2025 11:50:20 -0500 Subject: [PATCH 46/58] more lazy in Table_Tests Util.enso --- test/Table_Tests/src/Util.enso | 36 +++++++++--------- test/Table_Tests/src/Util_Spec.enso | 58 ++++++++++++++--------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/test/Table_Tests/src/Util.enso b/test/Table_Tests/src/Util.enso index 826b5dbcadf4..0a9b1fe65dfa 100644 --- a/test/Table_Tests/src/Util.enso +++ b/test/Table_Tests/src/Util.enso @@ -12,13 +12,13 @@ polyglot java import org.enso.base_test_helpers.FileSystemHelper Table.should_equal : Any -> Boolean -> Any Table.should_equal self expected ignore_order=False = Frame_Hider.hide <| rhs_error_check expected - Panic.catch Test_Failure_Error (table_should_equal_impl self expected Frame_Hider.get_top_stack_frame ignore_order) error-> + Panic.catch Test_Failure_Error (table_should_equal_impl self expected ignore_order) error-> Test.fail error.payload.message Column.should_equal : Any -> Any Column.should_equal self expected = Frame_Hider.hide <| rhs_error_check expected - Panic.catch Test_Failure_Error (column_should_equal_impl self expected Frame_Hider.get_top_stack_frame) error-> + Panic.catch Test_Failure_Error (column_should_equal_impl self expected) error-> Test.fail error.payload.message DB_Table.should_equal : DB_Table|Table -> Boolean -> Any @@ -48,49 +48,49 @@ type Test_Failure_Error to_display_text self = "Test failure error: "+self.message ## PRIVATE -table_should_equal_impl actual_table expected_table loc ignore_order = +table_should_equal_impl actual_table expected_table ignore_order = Frame_Hider.hide <| case expected_table of _ : Table -> actual = if ignore_order then actual_table.sort actual_table.column_names else actual_table expected = if ignore_order then expected_table.sort expected_table.column_names else expected_table if actual.columns.length != expected.columns.length then - Panic.throw (Test_Failure_Error.Error 'Tables differ at '+loc+'.\nActual:\n'+actual_table.display+'\nExpected:\n'+expected_table.display+'\nExpected '+expected.columns.length.to_text+" columns, but got "+actual.columns.length.to_text+'.') - Panic.catch Test_Failure_Error (actual.columns.zip expected.columns a-> e->(column_should_equal_impl a e)) error-> + Panic.throw (Test_Failure_Error.Error 'Tables differ at '+Frame_Hider.get_top_stack_frame+'.\nActual:\n'+actual_table.display+'\nExpected:\n'+expected_table.display+'\nExpected '+expected.columns.length.to_text+" columns, but got "+actual.columns.length.to_text+'.') + Panic.catch Test_Failure_Error (actual.columns.zip expected.columns a-> e->(column_should_equal_impl a e False)) error-> msg_sorted = if ignore_order then " (sorted)" else "" - msg = 'Tables differ at '+loc+'.\nActual'+msg_sorted+':\n'+actual.display+'\nExpected'+msg_sorted+':\n'+expected.display+'\n'+error.payload.message + msg = 'Tables differ at '+Frame_Hider.get_top_stack_frame+'.\nActual'+msg_sorted+':\n'+actual.display+'\nExpected'+msg_sorted+':\n'+expected.display+'\n'+error.payload.message Panic.throw (Test_Failure_Error.Error msg) - _ -> Panic.throw (Test_Failure_Error.Error "Got a Table, but expected a "+expected_table.to_display_text+(display_loc loc)+'.') + _ -> Panic.throw (Test_Failure_Error.Error "Got a Table, but expected a "+expected_table.to_display_text+' (at '+Frame_Hider.get_top_stack_frame+').') ## PRIVATE -column_should_equal_impl actual expected loc='' = +column_should_equal_impl actual expected should_display:Boolean=True = Frame_Hider.hide <| case expected of _ : Column -> if actual.name != expected.name then - Panic.throw (Test_Failure_Error.Error "Expected column name "+expected.name+", but got "+actual.name+(display_loc loc)+'.') + Panic.throw (Test_Failure_Error.Error "Expected column name "+expected.name+", but got "+actual.name+(display_loc should_display)+'.') if actual.length != expected.length then - Panic.throw (Test_Failure_Error.Error "Expected column length "+expected.length.to_text+", but got "+actual.length.to_text+(display_loc loc)+'.') + Panic.throw (Test_Failure_Error.Error "Expected column length "+expected.length.to_text+", but got "+actual.length.to_text+(display_loc should_display)+'.') if actual.value_type != expected.value_type then - Panic.throw (Test_Failure_Error.Error "Expected column type "+expected.value_type.to_text+", but got "+actual.value_type.to_text+(display_loc loc)+'.') + Panic.throw (Test_Failure_Error.Error "Expected column type "+expected.value_type.to_text+", but got "+actual.value_type.to_text+(display_loc should_display)+'.') actual.zip expected skip_nothing=False a-> e-> if values_not_equal a e then - report_fail actual expected loc - _ -> Panic.throw (Test_Failure_Error.Error "Got a Column, but expected a "+expected.to_display_text+(display_loc loc)+'.') + report_fail actual expected should_display + _ -> Panic.throw (Test_Failure_Error.Error "Got a Column, but expected a "+expected.to_display_text+(display_loc should_display)+'.') ## PRIVATE values_not_equal a e = a != e && (a.is_a Number && e.is_a Number && a.is_nan && e.is_nan).not ## PRIVATE -report_fail actual expected loc = +report_fail actual expected should_display = Frame_Hider.hide <| indexed = actual.zip (0.up_to actual.length) skip_nothing=False a-> i-> Pair.new a i indexed.zip expected skip_nothing=False a-> e-> if values_not_equal a.first e then - Panic.throw (Test_Failure_Error.Error "Column: "+actual.name+" differs at row "+a.second.to_text+'.\n\t Actual : '+a.first.to_text+'\n\t Expected: '+e.to_text+'\n\t'+(display_loc loc)+'.') + Panic.throw (Test_Failure_Error.Error "Column: "+actual.name+" differs at row "+a.second.to_text+'.\n\t Actual : '+a.first.to_text+'\n\t Expected: '+e.to_text+'\n\t'+(display_loc should_display)+'.') ## PRIVATE -display_loc loc:Text = - if loc.is_empty then '' else - ' (at '+loc+')' +display_loc should_display:Boolean = + if should_display.not then '' else + ' (at '+Frame_Hider.get_top_stack_frame+')' normalize_lines string line_separator=Line_Ending_Style.Unix.to_text newline_at_end=True = case newline_at_end of diff --git a/test/Table_Tests/src/Util_Spec.enso b/test/Table_Tests/src/Util_Spec.enso index 6d68a14d6366..eb248adab9f0 100644 --- a/test/Table_Tests/src/Util_Spec.enso +++ b/test/Table_Tests/src/Util_Spec.enso @@ -61,33 +61,33 @@ add_specs suite_builder = group_builder.specify "Two Columns With Different Name are Not Equal" <| expected_column = Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"] actual_column = Column.from_vector "Col2" ["Quis", "custodiet", "ipsos", "custodes?"] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal "Expected column name Col1, but got Col2 (at LOCATION_PATH)." + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal "Expected column name Col1, but got Col2 (at test/Table_Tests/src/Util_Spec.enso:64:53-106)." group_builder.specify "Two Columns With Different Lengths are Not Equal" <| expected_column = Column.from_vector "Col" ["Quis", "custodiet", "ipsos", "custodes?"] actual_column = Column.from_vector "Col" ["Quis", "custodiet", "ipsos"] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal "Expected column length 4, but got 3 (at LOCATION_PATH)." + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal "Expected column length 4, but got 3 (at test/Table_Tests/src/Util_Spec.enso:69:53-106)." group_builder.specify "Two Columns with different content Are Not Equal" <| expected_column = Column.from_vector "Col" ["Quis", "custodiet", "ipsos", "custodes?"] actual_column = Column.from_vector "Col" ["Who", "guards", "the", "guards?"] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal 'Column: Col differs at row 0.\n\t Actual : Who\n\t Expected: Quis\n\t (at LOCATION_PATH).' + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal 'Column: Col differs at row 0.\n\t Actual : Who\n\t Expected: Quis\n\t (at test/Table_Tests/src/Util_Spec.enso:74:53-106).' group_builder.specify "Two Columns Are Not Equal in Row 3" <| expected_column = Column.from_vector "My Column" ["Quis", "custodiet", "ipsos", "custodes?"] actual_column = Column.from_vector "My Column" ["Quis", "custodiet", "ipsos", "guards?"] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal 'Column: My Column differs at row 3.\n\t Actual : guards?\n\t Expected: custodes?\n\t (at LOCATION_PATH).' + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal 'Column: My Column differs at row 3.\n\t Actual : guards?\n\t Expected: custodes?\n\t (at test/Table_Tests/src/Util_Spec.enso:79:53-106).' group_builder.specify "Two Columns with different types Are Not Equal" <| expected_column = Column.from_vector "Col" ["1", "2", "3", "4"] actual_column = Column.from_vector "Col" [1, 2, 3, 4] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal "Expected column type (Char Nothing True), but got (Integer 64 bits) (at LOCATION_PATH)." + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal "Expected column type (Char Nothing True), but got (Integer 64 bits) (at test/Table_Tests/src/Util_Spec.enso:84:53-106)." group_builder.specify "Comparing a Column to non column" <| expected_column = 42 actual_column = Column.from_vector "Col" [1, 2, 3, 4] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal "Got a Column, but expected a 42 (at LOCATION_PATH)." + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal "Got a Column, but expected a 42 (at test/Table_Tests/src/Util_Spec.enso:89:53-106)." group_builder.specify "Two Columns Containing NaNs Are Equal" <| # This is somewhat of a special case, as NaN != NaN but for the purposes of testing we consider them equal expected_column = Column.from_vector "Col" [1.0, 2.0, Number.nan] @@ -100,23 +100,23 @@ add_specs suite_builder = group_builder.specify "Comparing to Actual Nothing Value should fail" <| expected_column = Column.from_vector "Col" [1.0, 2.0, 3.0] actual_column = Column.from_vector "Col" [1.0, 2.0, Nothing] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : Nothing\n\t Expected: 3.0\n\t (at LOCATION_PATH).' + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : Nothing\n\t Expected: 3.0\n\t (at test/Table_Tests/src/Util_Spec.enso:103:53-106).' group_builder.specify "Comparing to Expected Nothing Value should fail" <| expected_column = Column.from_vector "Col" [1.0, 2.0, Nothing] actual_column = Column.from_vector "Col" [1.0, 2.0, 3.0] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : 3.0\n\t Expected: Nothing\n\t (at LOCATION_PATH).' + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : 3.0\n\t Expected: Nothing\n\t (at test/Table_Tests/src/Util_Spec.enso:108:53-106).' group_builder.specify "Comparing to Actual Nothing Value to Expected NaN Value should fail" <| expected_column = Column.from_vector "Col" [1.0, 2.0, Number.nan] actual_column = Column.from_vector "Col" [1.0, 2.0, Nothing] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : Nothing\n\t Expected: NaN\n\t (at LOCATION_PATH).' + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : Nothing\n\t Expected: NaN\n\t (at test/Table_Tests/src/Util_Spec.enso:113:53-106).' group_builder.specify "Comparing to Actual NaN Value to Expected Nothing Value should fail" <| expected_column = Column.from_vector "Col" [1.0, 2.0, Nothing] actual_column = Column.from_vector "Col" [1.0, 2.0, Number.nan] - res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column "LOCATION_PATH") - res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : NaN\n\t Expected: Nothing\n\t (at LOCATION_PATH).' + res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) + res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : NaN\n\t Expected: Nothing\n\t (at test/Table_Tests/src/Util_Spec.enso:118:53-106).' group_builder.specify "Two Tables Are Equal" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] @@ -133,35 +133,35 @@ add_specs suite_builder = group_builder.specify "Two Tables With Different Values" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "teh", "guards?"]] - res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table "LOCATION_PATH" False) + res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table False) res.catch.message.should_end_with 'Column: Col2 differs at row 2.\n\t Actual : teh\n\t Expected: the\n\t.' - res.catch.message.should_start_with 'Tables differ at LOCATION_PATH.\nActual:' + res.catch.message.should_start_with 'Tables differ at test/Table_Tests/src/Util_Spec.enso:136:53-109.\nActual:' group_builder.specify "Two Tables With Different Values Ignoring Order" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "teh", "guards?"]] - res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table "LOCATION_PATH" True) + res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table True) res.catch.message.should_end_with 'Column: Col2 differs at row 3.\n\t Actual : teh\n\t Expected: the\n\t.' - res.catch.message.should_start_with 'Tables differ at LOCATION_PATH.\nActual (sorted):' + res.catch.message.should_start_with 'Tables differ at test/Table_Tests/src/Util_Spec.enso:142:53-108.\nActual (sorted):' group_builder.specify "Tables different number of columns" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"]] actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] - res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table "LOCATION_PATH" False) + res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table False) res.catch.message.should_end_with "Expected 1 columns, but got 2." group_builder.specify "Tables different number of columns2" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"]] - res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table "LOCATION_PATH" False) + res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table False) res.catch.message.should_end_with "Expected 2 columns, but got 1." group_builder.specify "Tables With Mismatched Column names" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] actual_table = Table.new [Column.from_vector "Col" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] - res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table "LOCATION_PATH" False) + res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table False) res.catch.message.should_end_with "Expected column name Col1, but got Col." group_builder.specify "Comparing a Table to non Table" <| expected_table = 42 actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"]] - res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table "LOCATION_PATH" False) - res.catch.message.should_equal "Got a Table, but expected a 42 (at LOCATION_PATH)." + res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table False) + res.catch.message.should_equal "Got a Table, but expected a 42 (at test/Table_Tests/src/Util_Spec.enso:163:53-109)." type DB_Tables Value t1 t2 tA From eb0553ef5d6c31f71febdc110d0c7a71a24e7a01 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 12 Feb 2025 12:41:21 -0500 Subject: [PATCH 47/58] Move location spec to Test_Tests. --- .../lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 2 +- test/Base_Tests/src/Semantic/Meta_Location_Spec.enso | 9 --------- test/Test_Tests/src/Extensions_Spec.enso | 9 +++++++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index dbcf10658fb4..1f257881e791 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -108,7 +108,7 @@ type Frame_Hider name = frame.name if name.starts_with "Frame_Hider.hide" then 1 else if name.starts_with "Frame_Hider.unhide" then -1 else 0 - nesting_levels = reversed_stack_trace.map delta_for_frame . running_fold 0 (_ + _) + nesting_levels = reversed_stack_trace.map delta_for_frame . running_fold 0 (+) index = i = nesting_levels.last_index_of 0 if i.is_nothing || i == 0 then 0 else i-1 diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index da338e32d82e..6ee3a4ee303e 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -13,15 +13,6 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil pending_js_missing = if Polyglot.is_language_installed "js" then Nothing else "Can't run JavaScript tests, language `js` is not installed." - location_pending = case Platform.os of - Platform.OS.Windows -> "This test is disabled on Windows until issue 1561 is fixed." - _ -> Nothing - - group_builder.specify "should allow to get the source location of a frame" pending=location_pending <| - src = Frame_Hider.get_top_stack_frame - loc = "Meta_Location_Spec.enso:21:15-34" - src.take (..Last loc.length) . should_equal loc - group_builder.specify "should allow to get qualified type names of values" <| x = 42 y = My_Type.Value 1 2 3 diff --git a/test/Test_Tests/src/Extensions_Spec.enso b/test/Test_Tests/src/Extensions_Spec.enso index f4f75204e902..a49701a0f28b 100644 --- a/test/Test_Tests/src/Extensions_Spec.enso +++ b/test/Test_Tests/src/Extensions_Spec.enso @@ -140,3 +140,12 @@ add_specs suite_builder = r1 = expect_test_failure <| should_equal_b my_checker "ab" "ac" r1.message.should_contain "Extensions_Spec.enso:138" + + location_pending = case Platform.os of + Platform.OS.Windows -> "This test is disabled on Windows until issue 1561 is fixed." + _ -> Nothing + + group_builder.specify "should allow to get the source location of a frame" pending=location_pending <| + src = Frame_Hider.get_top_stack_frame + loc = "Extensions_Spec.enso:149:19-49" + src.take (..Last loc.length) . should_equal loc From 260c4827298ed96c47a5154f95d51c5e29e07f3d Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 12 Feb 2025 12:43:14 -0500 Subject: [PATCH 48/58] fix MLS test maybe --- test/Base_Tests/src/Semantic/Meta_Location_Spec.enso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index 6ee3a4ee303e..fa2409459b13 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -18,7 +18,7 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil y = My_Type.Value 1 2 3 x.to Meta.Type . qualified_name . should_equal "Standard.Base.Data.Numbers.Integer" x.to Meta.Type . name . should_equal "Integer" - y.to Meta.Type . qualified_name . should_equal "enso_dev.Base_Tests.Semantic.Meta_Location_Spec.My_Type" + y.to Meta.Type . qualified_name . should_equal "enso_dev.Base_Tests.Meta_Location_Spec.My_Type" y.to Meta.Type . name . should_equal "My_Type" group_builder.specify "should allow access to package names" <| From dec480c846e6eb6d4e3bb53bbc7c91435fb97a50 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 12 Feb 2025 14:36:56 -0500 Subject: [PATCH 49/58] fix with_retries --- .../lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 11 +++++++++++ .../lib/Standard/Test/0.0.0-dev/src/Test.enso | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index 1f257881e791..f15c05e694d3 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -86,6 +86,8 @@ type Frame_Hider unhide_2 f x y = f x y + debug self = True + ## PRIVATE Identify the correct top stack frame by skipping over the stack frames @@ -113,5 +115,14 @@ type Frame_Hider i = nesting_levels.last_index_of 0 if i.is_nothing || i == 0 then 0 else i-1 + if Frame_Hider.debug then + info = reversed_stack_trace.map_with_index i-> f-> + [index == i, i, nesting_levels.at i, f.name, f.to_display_text] + IO.println "====" + info.map IO.println + + top = reversed_stack_trace . at index . source_location + IO.println "==== "+top.to_display_text + top = reversed_stack_trace . at index . source_location top.to_display_text diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index a46d08936e3f..08b61f8a95ac 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -188,7 +188,7 @@ type Test or fails with the last error thrown by the action after exhausting retry attempts. with_retries : Any -> Any - with_retries ~action = Frame_Hider.hide <| + with_retries ~action = milliseconds_between_attempts = 100 ## We give the CI a bit more attempts, as failures are more annoying there. For local development, a bit less retries is enough - there it is more @@ -196,7 +196,9 @@ type Test don't want to spend too much time retrying when debugging the tests locally. max_retries = if Environment.get "CI" . is_nothing . not then 100 else 20 - go i = + ## The `hide` is here because if it were at the top of the function, the + tail call confuses the location finder. + go i = Frame_Hider.hide <| Panic.catch Any (Frame_Hider.unhide action) caught_panic-> # If the iterations are exhausted, we rethrow the panic. if i > max_retries then Panic.throw caught_panic else From cc3f27d5d7974a554e452e65b2c6a566f6e5ba2c Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 12 Feb 2025 15:02:49 -0500 Subject: [PATCH 50/58] wip --- distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 2 +- test/Table_Tests/src/Common_Table_Operations/Main.enso | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index f15c05e694d3..e26710fc13d5 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -86,7 +86,7 @@ type Frame_Hider unhide_2 f x y = f x y - debug self = True + debug self = False ## PRIVATE diff --git a/test/Table_Tests/src/Common_Table_Operations/Main.enso b/test/Table_Tests/src/Common_Table_Operations/Main.enso index 9c8f8fc2f6f1..32df94e175b0 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Main.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Main.enso @@ -3,6 +3,7 @@ from Standard.Base import all import Standard.Database.Internal.Replace_Params.Replace_Params from Standard.Test import Test +import Standard.Test.Frame_Hider.Frame_Hider import project.Common_Table_Operations.Add_Group_Number_Spec import project.Common_Table_Operations.Add_Row_Number_Spec From 9e64f85761844311b42cdde0fbf913dff3a2dcb0 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 12 Feb 2025 16:25:22 -0500 Subject: [PATCH 51/58] wip --- test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index 9aaeeb196776..91c38a37c5f7 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -1260,6 +1260,7 @@ add_aggregate_specs suite_builder setup = _ : Float -> Double.isNaN value _ -> False if matches.not then + Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+Frame_Hider.get_top_stack_frame+")." if setup.flagged ..Supports_Infinity then suite_builder.group prefix+"Table.aggregate should correctly handle infinities" group_builder-> From 496c2bd45d97555df837810bd5668f3c4dc816b6 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 13 Feb 2025 14:08:26 -0500 Subject: [PATCH 52/58] uncurry testers --- .../Aggregate_Spec.enso | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index 91c38a37c5f7..9a766b269137 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -1560,7 +1560,7 @@ add_aggregate_specs suite_builder setup = group_builder.specify "should warn when encountering invalid expressions, but try to perform the aggregations that are still valid" <| action1 = data.table.aggregate ["Index"] [Sum "Value", Sum (expr "[MISSING]*[MISSING]")] on_problems=_ - tester1 = expect_column_names ["Index", "Sum Value"] + tester1 t = expect_column_names ["Index", "Sum Value"] t problems1 = [Invalid_Aggregate_Column.Error "[MISSING]*[MISSING]" (No_Such_Column.Error "MISSING")] Problems.test_problem_handling action1 problems1 tester1 @@ -1624,7 +1624,7 @@ add_aggregate_specs suite_builder setup = action2 = table.aggregate ["Index"] [Sum "Value", Sum 42] on_problems=_ problems2 = [Missing_Input_Columns.Error [42]] - tester2 = expect_column_names ["Index", "Sum Value"] + tester2 t = expect_column_names ["Index", "Sum Value"] t Problems.test_problem_handling action2 problems2 tester2 # As above, missing errors from group-by take precedence over aggregates. @@ -1638,31 +1638,31 @@ add_aggregate_specs suite_builder setup = group_builder.specify "should raise a warning when a duplicate column name" <| action = table.aggregate ["Index", 0] [] on_problems=_ problems = [Duplicate_Output_Column_Names.Error ["Index"]] - tester = expect_column_names ["Index", "Index 1"] + tester t = expect_column_names ["Index", "Index 1"] t Problems.test_problem_handling action problems tester group_builder.specify "should raise a warning when a duplicate column name and rename default names first" <| action = table.aggregate ["Value"] [Sum "Index" "Value"] on_problems=_ problems = [Duplicate_Output_Column_Names.Error ["Value"]] - tester = expect_column_names ["Value 1", "Value"] + tester t = expect_column_names ["Value 1", "Value"] t Problems.test_problem_handling action problems tester group_builder.specify "should raise a warning when duplicate column names" <| action = table.aggregate columns=[Sum "Value" as="AGG1", Count as="AGG1"] on_problems=_ problems = [Duplicate_Output_Column_Names.Error ["AGG1"]] - tester = expect_column_names ["AGG1", "AGG1 1"] + tester t = expect_column_names ["AGG1", "AGG1 1"] t Problems.test_problem_handling action problems tester group_builder.specify "should allow partial matches on Count_Distinct" <| action = table.aggregate columns=[Count_Distinct ["Missing", "Value"]] on_problems=_ problems = [Missing_Input_Columns.Error ["Missing"]] - tester = expect_column_names ["Count Distinct Value"] + tester t = expect_column_names ["Count Distinct Value"] t Problems.test_problem_handling action problems tester group_builder.specify "should ignore Count_Distinct if no columns matched" <| action = table.aggregate columns=[Count_Distinct [-100], Count] on_problems=_ problems = [Missing_Input_Columns.Error [-100]] - tester = expect_column_names ["Count"] + tester t = expect_column_names ["Count"] t Problems.test_problem_handling action problems tester suite_builder.group prefix+"Table.aggregate should report warnings and errors based on types" group_builder-> @@ -1670,7 +1670,7 @@ add_aggregate_specs suite_builder setup = t = table_builder [["X", [1.1, 2.2, 3.3, 2.2]]] action = t.aggregate ["X"] on_problems=_ problems = [Floating_Point_Equality.Error "X"] - tester = expect_column_names ["X"] + tester t = expect_column_names ["X"] t Problems.test_problem_handling action problems tester case test_selection.advanced_stats of @@ -1679,7 +1679,7 @@ add_aggregate_specs suite_builder setup = t = table_builder [["X", [1.5, 2.0, 1.5, 1.0]]] action = t.aggregate columns=[Mode "X"] on_problems=_ problems = [Floating_Point_Equality.Error "Mode X"] - tester = expect_column_names ["Mode X"] + tester t = expect_column_names ["Mode X"] t Problems.test_problem_handling action problems tester False -> group_builder.specify "should error if unsupported operations are selected" <| @@ -1746,7 +1746,7 @@ add_aggregate_specs suite_builder setup = column = Concatenate "Text" separator="," action = table.aggregate columns=[column] on_problems=_ problems = [Unquoted_Delimiter.Error "Concatenate Text" [1]] - tester = expect_column_names ["Concatenate Text"] + tester t = expect_column_names ["Concatenate Text"] t Problems.test_problem_handling action problems tester suite_builder.group prefix+"Table.aggregate should merge warnings when issues computing aggregation" pending=(resolve_pending test_selection.aggregation_problems) group_builder-> From c75bc3f08bf543df615513abd7285a60b6baa2f3 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 13 Feb 2025 14:29:42 -0500 Subject: [PATCH 53/58] uncurry testers --- .../Join/Join_Spec.enso | 2 +- .../Select_Columns_Spec.enso | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso index af7a04900cff..ca89e9d56594 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso @@ -644,7 +644,7 @@ add_join_specs suite_builder setup = t6.column_names.should_equal ["Right X", "X", "Y", "Right Y 2"]+["Right Right X", "Right X 1", "Right Y 3", "Right Y", "Right Y 1", "Right Y 4"] action = t1.join t2 right_prefix="" on_problems=_ - tester = expect_column_names ["X", "Y", "Right Y", "X 1", "Y 1"] + tester t = expect_column_names ["X", "Y", "Right Y", "X 1", "Y 1"] t problems = [Duplicate_Output_Column_Names.Error ["X", "Y"]] Problems.test_problem_handling action problems tester diff --git a/test/Table_Tests/src/Common_Table_Operations/Select_Columns_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Select_Columns_Spec.enso index 257b178ef2fc..d3d821b3da31 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Select_Columns_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Select_Columns_Spec.enso @@ -144,7 +144,7 @@ add_select_column_specs suite_builder setup = group_builder.specify "should correctly handle problems: out of bounds indices" <| selector = [1, 0, 100, -200, 300] action = data.table.select_columns selector error_on_missing_columns=False on_problems=_ - tester = expect_column_names ["foo", "bar"] + tester t = expect_column_names ["foo", "bar"] t problems = [Missing_Input_Columns.Error [100, -200, 300]] Problems.test_problem_handling action problems tester @@ -190,7 +190,7 @@ add_select_column_specs suite_builder setup = weird_name = '.*?-!@#!"' selector = ["foo", "hmm", weird_name] action = data.table.select_columns selector error_on_missing_columns=False on_problems=_ - tester = expect_column_names ["foo"] + tester t = expect_column_names ["foo"] t problems = [Missing_Input_Columns.Error ["hmm", weird_name]] Problems.test_problem_handling action problems tester @@ -279,7 +279,7 @@ add_select_column_specs suite_builder setup = group_builder.specify "should correctly handle problems: out of bounds indices" <| selector = [1, 0, 100, -200, 300] action = data.table.remove_columns selector on_problems=_ - tester = expect_column_names ["Baz", "foo 1", "foo 2", "ab.+123", "abcd123"] + tester t = expect_column_names ["Baz", "foo 1", "foo 2", "ab.+123", "abcd123"] t problems = [Missing_Input_Columns.Error [100, -200, 300]] Problems.test_problem_handling action problems tester @@ -310,7 +310,7 @@ add_select_column_specs suite_builder setup = weird_name = '.*?-!@#!"' selector = ["foo", "hmm", weird_name] action = data.table.remove_columns selector on_problems=_ - tester = expect_column_names ["bar", "Baz", "foo 1", "foo 2", "ab.+123", "abcd123"] + tester t = expect_column_names ["bar", "Baz", "foo 1", "foo 2", "ab.+123", "abcd123"] t problems = [Missing_Input_Columns.Error ["hmm", weird_name]] Problems.test_problem_handling action problems tester @@ -375,7 +375,7 @@ add_select_column_specs suite_builder setup = group_builder.specify "should correctly handle problems: out of bounds indices" <| selector = [1, 0, 100, -200, 300] action = data.table.reorder_columns selector on_problems=_ - tester = expect_column_names ["bar", "foo", "Baz", "foo 1", "foo 2", "ab.+123", "abcd123"] + tester t = expect_column_names ["bar", "foo", "Baz", "foo 1", "foo 2", "ab.+123", "abcd123"] t problems = [Missing_Input_Columns.Error [100, -200, 300]] Problems.test_problem_handling action problems tester @@ -401,7 +401,7 @@ add_select_column_specs suite_builder setup = weird_name = '.*?-!@#!"' selector = ["foo", "hmm", weird_name] action = data.table.reorder_columns selector Position.After_Other_Columns on_problems=_ - tester = expect_column_names ["bar", "Baz", "foo 1", "foo 2", "ab.+123", "abcd123", "foo"] + tester t = expect_column_names ["bar", "Baz", "foo 1", "foo 2", "ab.+123", "abcd123", "foo"] t problems = [Missing_Input_Columns.Error ["hmm", weird_name]] Problems.test_problem_handling action problems tester @@ -559,7 +559,7 @@ add_select_column_specs suite_builder setup = weird_name = '.*?-!@#!"' map = Dictionary.from_vector [["alpha", "FirstColumn"], ["omicron", "Another"], [weird_name, "Fixed"]] action = data.table.rename_columns map error_on_missing_columns=False on_problems=_ - tester = expect_column_names ["FirstColumn", "beta", "gamma", "delta"] + tester t = expect_column_names ["FirstColumn", "beta", "gamma", "delta"] t err_checker err = err.catch.should_be_a Missing_Input_Columns.Error err.catch.criteria.should_equal_ignoring_order ["omicron", weird_name] @@ -571,7 +571,7 @@ add_select_column_specs suite_builder setup = group_builder.specify "should correctly handle problems: out of bounds indices" <| map = Dictionary.from_vector [[0, "FirstColumn"], [-1, "Another"], [100, "Boo"], [-200, "Nothing"], [300, "Here"]] action = data.table.rename_columns map error_on_missing_columns=False on_problems=_ - tester = expect_column_names ["FirstColumn", "beta", "gamma", "Another"] + tester t = expect_column_names ["FirstColumn", "beta", "gamma", "Another"] t err_checker err = err.catch.should_be_a Missing_Input_Columns.Error err.catch.criteria.should_equal_ignoring_order [-200, 100, 300] @@ -639,14 +639,14 @@ add_select_column_specs suite_builder setup = group_builder.specify "should correctly handle problems: duplicate names" <| map = ["Test", "Test", "Test", "Test"] action = data.table.rename_columns map on_problems=_ - tester = expect_column_names ["Test 1", "Test 2", "Test 3", "Test"] ignore_order=True + tester t = expect_column_names ["Test 1", "Test 2", "Test 3", "Test"] t ignore_order=True problems = [Duplicate_Output_Column_Names.Error ["Test", "Test", "Test"]] Problems.test_problem_handling action problems tester group_builder.specify "should correctly handle problems: new name is clashing with existing name of existing column" <| map = Dictionary.from_vector [["alpha", "beta"]] action = data.table.rename_columns map on_problems=_ - tester = expect_column_names ["beta", "beta 1", "gamma", "delta"] + tester t = expect_column_names ["beta", "beta 1", "gamma", "delta"] t problems = [Duplicate_Output_Column_Names.Error ["beta"]] Problems.test_problem_handling action problems tester @@ -659,7 +659,7 @@ add_select_column_specs suite_builder setup = group_builder.specify "should correctly handle problems: too many input names" <| map = ["A", "B", "C", "D", "E", "F"] action = data.table.rename_columns map on_problems=_ - tester = expect_column_names ["A", "B", "C", "D"] + tester t = expect_column_names ["A", "B", "C", "D"] t problem_checker problem = problem.should_be_a Too_Many_Column_Names_Provided.Error problem.column_names.should_equal_ignoring_order ["E", "F"] From d1bed32fe87f3770db0c97eeb77dbd9d674eeb84 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 13 Feb 2025 14:30:40 -0500 Subject: [PATCH 54/58] uncurry testers --- test/Table_Tests/src/In_Memory/Table_Spec.enso | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Table_Tests/src/In_Memory/Table_Spec.enso b/test/Table_Tests/src/In_Memory/Table_Spec.enso index b3383921907f..f71df5bc5f1f 100644 --- a/test/Table_Tests/src/In_Memory/Table_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Table_Spec.enso @@ -723,7 +723,7 @@ add_specs suite_builder = c_4 = ['Z', [True, False, True]] table = Table.new [c_0, c_1, c_2, c_3, c_4] action = table.use_first_row_as_names on_problems=_ - tester = expect_column_names ["Column 1", "1980-01-01", "1", "5.3", "True"] + tester t = expect_column_names ["Column 1", "1980-01-01", "1", "5.3", "True"] t problems = [Invalid_Column_Names.Error [""]] Problems.test_problem_handling action problems tester @@ -735,7 +735,7 @@ add_specs suite_builder = c_4 = ['Z', [True, False, True]] table = Table.new [c_0, c_1, c_2, c_3, c_4] action = table.use_first_row_as_names on_problems=_ - tester = expect_column_names ["A", "1980-01-01", "Column 1", "5.3", "True"] + tester t = expect_column_names ["A", "1980-01-01", "Column 1", "5.3", "True"] t problems = [Invalid_Column_Names.Error [Nothing]] Problems.test_problem_handling action problems tester @@ -747,7 +747,7 @@ add_specs suite_builder = c_4 = ['Z', [True, False, True]] table = Table.new [c_0, c_1, c_2, c_3, c_4] action = table.use_first_row_as_names on_problems=_ - tester = expect_column_names ["Column 1", "1980-01-01", "Column 2", "5.3", "True"] + tester t = expect_column_names ["Column 1", "1980-01-01", "Column 2", "5.3", "True"] t problems = [Invalid_Column_Names.Error ["", Nothing]] Problems.test_problem_handling action problems tester @@ -758,7 +758,7 @@ add_specs suite_builder = c_3 = ['C', ["A", "B", "C"]] table = Table.new [c_0, c_1, c_2, c_3] action = table.use_first_row_as_names on_problems=_ - tester = expect_column_names ["A", "A 1", "A 2", "A 3"] + tester t = expect_column_names ["A", "A 1", "A 2", "A 3"] t problems = [Duplicate_Output_Column_Names.Error ["A", "A", "A"]] Problems.test_problem_handling action problems tester From d3e668c9f730015abc30f2b11388ec1b8693712f Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 13 Feb 2025 16:07:54 -0500 Subject: [PATCH 55/58] remove debug --- .../lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso | 11 ----------- .../src/Common_Table_Operations/Aggregate_Spec.enso | 1 - 2 files changed, 12 deletions(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index e26710fc13d5..1f257881e791 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -86,8 +86,6 @@ type Frame_Hider unhide_2 f x y = f x y - debug self = False - ## PRIVATE Identify the correct top stack frame by skipping over the stack frames @@ -115,14 +113,5 @@ type Frame_Hider i = nesting_levels.last_index_of 0 if i.is_nothing || i == 0 then 0 else i-1 - if Frame_Hider.debug then - info = reversed_stack_trace.map_with_index i-> f-> - [index == i, i, nesting_levels.at i, f.name, f.to_display_text] - IO.println "====" - info.map IO.println - - top = reversed_stack_trace . at index . source_location - IO.println "==== "+top.to_display_text - top = reversed_stack_trace . at index . source_location top.to_display_text diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index 9a766b269137..ef5f144d8141 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -1260,7 +1260,6 @@ add_aggregate_specs suite_builder setup = _ : Float -> Double.isNaN value _ -> False if matches.not then - Test.fail "Expected a Nothing or NaN but got: "+value.to_text+" (at "+Frame_Hider.get_top_stack_frame+")." if setup.flagged ..Supports_Infinity then suite_builder.group prefix+"Table.aggregate should correctly handle infinities" group_builder-> From 82b40c0dadd0024a9d0076d6d7430ffb2be50927 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 13 Feb 2025 16:20:50 -0500 Subject: [PATCH 56/58] wip --- .../Test/0.0.0-dev/src/Frame_Hider.enso | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso index 1f257881e791..152488d1fc08 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Frame_Hider.enso @@ -22,10 +22,30 @@ import Standard.Base.Runtime.Ref.Ref A `hide` call should be wrapped around the body of every test utility. - An `unhide` call should be wrapped around any call from a test utility to a + An `unhide*` call should be wrapped around any call from a test utility to a user-supplied callback, depending on the number of arguments. If one test utility forwards a callback to another test utility, the callback should be wrapped at the forward site as well. + + ! Partial Application + + Partial application can prevent the `unhide*` methods from existing in the + stack trace, so test callbacks should have explicit parameters: + + # Do not use partial application: + tester = expect_column_names ["A", "B"] + # Use explicit parameters: + tester t = expect_column_names ["A", "B"] t + ! Tail Calls + + Tail calls can result in changes to the stack that prevent + `get_top_stack_frame` from working properly. For this reason, uses of + `hide` and `unhide` should be within the tail call: + + go i = Frame_Hider.hide <| + # ... + @Tail_Call go (i+1) + go 1 type Frame_Hider ## PRIVATE From 5da71e2b179be52e3d8b09562300041088022abc Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Wed, 19 Feb 2025 10:47:52 -0500 Subject: [PATCH 57/58] revert local-only test fix --- test/Base_Tests/src/Semantic/Meta_Location_Spec.enso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index fa2409459b13..6ee3a4ee303e 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -18,7 +18,7 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil y = My_Type.Value 1 2 3 x.to Meta.Type . qualified_name . should_equal "Standard.Base.Data.Numbers.Integer" x.to Meta.Type . name . should_equal "Integer" - y.to Meta.Type . qualified_name . should_equal "enso_dev.Base_Tests.Meta_Location_Spec.My_Type" + y.to Meta.Type . qualified_name . should_equal "enso_dev.Base_Tests.Semantic.Meta_Location_Spec.My_Type" y.to Meta.Type . name . should_equal "My_Type" group_builder.specify "should allow access to package names" <| From f803c6e971e58cbd9e3a144cabb101b1df0f8297 Mon Sep 17 00:00:00 2001 From: Gregory Travis Date: Thu, 20 Feb 2025 12:17:24 -0500 Subject: [PATCH 58/58] remove test/ from filenames --- test/Table_Tests/src/Util_Spec.enso | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/Table_Tests/src/Util_Spec.enso b/test/Table_Tests/src/Util_Spec.enso index eb248adab9f0..f212099e96cb 100644 --- a/test/Table_Tests/src/Util_Spec.enso +++ b/test/Table_Tests/src/Util_Spec.enso @@ -62,32 +62,32 @@ add_specs suite_builder = expected_column = Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"] actual_column = Column.from_vector "Col2" ["Quis", "custodiet", "ipsos", "custodes?"] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal "Expected column name Col1, but got Col2 (at test/Table_Tests/src/Util_Spec.enso:64:53-106)." + res.catch.message.should_equal "Expected column name Col1, but got Col2 (at Table_Tests/src/Util_Spec.enso:64:53-106)." group_builder.specify "Two Columns With Different Lengths are Not Equal" <| expected_column = Column.from_vector "Col" ["Quis", "custodiet", "ipsos", "custodes?"] actual_column = Column.from_vector "Col" ["Quis", "custodiet", "ipsos"] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal "Expected column length 4, but got 3 (at test/Table_Tests/src/Util_Spec.enso:69:53-106)." + res.catch.message.should_equal "Expected column length 4, but got 3 (at Table_Tests/src/Util_Spec.enso:69:53-106)." group_builder.specify "Two Columns with different content Are Not Equal" <| expected_column = Column.from_vector "Col" ["Quis", "custodiet", "ipsos", "custodes?"] actual_column = Column.from_vector "Col" ["Who", "guards", "the", "guards?"] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal 'Column: Col differs at row 0.\n\t Actual : Who\n\t Expected: Quis\n\t (at test/Table_Tests/src/Util_Spec.enso:74:53-106).' + res.catch.message.should_equal 'Column: Col differs at row 0.\n\t Actual : Who\n\t Expected: Quis\n\t (at Table_Tests/src/Util_Spec.enso:74:53-106).' group_builder.specify "Two Columns Are Not Equal in Row 3" <| expected_column = Column.from_vector "My Column" ["Quis", "custodiet", "ipsos", "custodes?"] actual_column = Column.from_vector "My Column" ["Quis", "custodiet", "ipsos", "guards?"] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal 'Column: My Column differs at row 3.\n\t Actual : guards?\n\t Expected: custodes?\n\t (at test/Table_Tests/src/Util_Spec.enso:79:53-106).' + res.catch.message.should_equal 'Column: My Column differs at row 3.\n\t Actual : guards?\n\t Expected: custodes?\n\t (at Table_Tests/src/Util_Spec.enso:79:53-106).' group_builder.specify "Two Columns with different types Are Not Equal" <| expected_column = Column.from_vector "Col" ["1", "2", "3", "4"] actual_column = Column.from_vector "Col" [1, 2, 3, 4] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal "Expected column type (Char Nothing True), but got (Integer 64 bits) (at test/Table_Tests/src/Util_Spec.enso:84:53-106)." + res.catch.message.should_equal "Expected column type (Char Nothing True), but got (Integer 64 bits) (at Table_Tests/src/Util_Spec.enso:84:53-106)." group_builder.specify "Comparing a Column to non column" <| expected_column = 42 actual_column = Column.from_vector "Col" [1, 2, 3, 4] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal "Got a Column, but expected a 42 (at test/Table_Tests/src/Util_Spec.enso:89:53-106)." + res.catch.message.should_equal "Got a Column, but expected a 42 (at Table_Tests/src/Util_Spec.enso:89:53-106)." group_builder.specify "Two Columns Containing NaNs Are Equal" <| # This is somewhat of a special case, as NaN != NaN but for the purposes of testing we consider them equal expected_column = Column.from_vector "Col" [1.0, 2.0, Number.nan] @@ -101,22 +101,22 @@ add_specs suite_builder = expected_column = Column.from_vector "Col" [1.0, 2.0, 3.0] actual_column = Column.from_vector "Col" [1.0, 2.0, Nothing] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : Nothing\n\t Expected: 3.0\n\t (at test/Table_Tests/src/Util_Spec.enso:103:53-106).' + res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : Nothing\n\t Expected: 3.0\n\t (at Table_Tests/src/Util_Spec.enso:103:53-106).' group_builder.specify "Comparing to Expected Nothing Value should fail" <| expected_column = Column.from_vector "Col" [1.0, 2.0, Nothing] actual_column = Column.from_vector "Col" [1.0, 2.0, 3.0] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : 3.0\n\t Expected: Nothing\n\t (at test/Table_Tests/src/Util_Spec.enso:108:53-106).' + res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : 3.0\n\t Expected: Nothing\n\t (at Table_Tests/src/Util_Spec.enso:108:53-106).' group_builder.specify "Comparing to Actual Nothing Value to Expected NaN Value should fail" <| expected_column = Column.from_vector "Col" [1.0, 2.0, Number.nan] actual_column = Column.from_vector "Col" [1.0, 2.0, Nothing] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : Nothing\n\t Expected: NaN\n\t (at test/Table_Tests/src/Util_Spec.enso:113:53-106).' + res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : Nothing\n\t Expected: NaN\n\t (at Table_Tests/src/Util_Spec.enso:113:53-106).' group_builder.specify "Comparing to Actual NaN Value to Expected Nothing Value should fail" <| expected_column = Column.from_vector "Col" [1.0, 2.0, Nothing] actual_column = Column.from_vector "Col" [1.0, 2.0, Number.nan] res = Panic.recover Test_Failure_Error (column_should_equal_impl actual_column expected_column) - res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : NaN\n\t Expected: Nothing\n\t (at test/Table_Tests/src/Util_Spec.enso:118:53-106).' + res.catch.message.should_equal 'Column: Col differs at row 2.\n\t Actual : NaN\n\t Expected: Nothing\n\t (at Table_Tests/src/Util_Spec.enso:118:53-106).' group_builder.specify "Two Tables Are Equal" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] @@ -135,13 +135,13 @@ add_specs suite_builder = actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "teh", "guards?"]] res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table False) res.catch.message.should_end_with 'Column: Col2 differs at row 2.\n\t Actual : teh\n\t Expected: the\n\t.' - res.catch.message.should_start_with 'Tables differ at test/Table_Tests/src/Util_Spec.enso:136:53-109.\nActual:' + res.catch.message.should_start_with 'Tables differ at Table_Tests/src/Util_Spec.enso:136:53-109.\nActual:' group_builder.specify "Two Tables With Different Values Ignoring Order" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "teh", "guards?"]] res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table True) res.catch.message.should_end_with 'Column: Col2 differs at row 3.\n\t Actual : teh\n\t Expected: the\n\t.' - res.catch.message.should_start_with 'Tables differ at test/Table_Tests/src/Util_Spec.enso:142:53-108.\nActual (sorted):' + res.catch.message.should_start_with 'Tables differ at Table_Tests/src/Util_Spec.enso:142:53-108.\nActual (sorted):' group_builder.specify "Tables different number of columns" <| expected_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"]] actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"], Column.from_vector "Col2" ["Who", "guards", "the", "guards?"]] @@ -161,7 +161,7 @@ add_specs suite_builder = expected_table = 42 actual_table = Table.new [Column.from_vector "Col1" ["Quis", "custodiet", "ipsos", "custodes?"]] res = Panic.recover Test_Failure_Error (table_should_equal_impl actual_table expected_table False) - res.catch.message.should_equal "Got a Table, but expected a 42 (at test/Table_Tests/src/Util_Spec.enso:163:53-109)." + res.catch.message.should_equal "Got a Table, but expected a 42 (at Table_Tests/src/Util_Spec.enso:163:53-109)." type DB_Tables Value t1 t2 tA