Skip to content

Commit

Permalink
Last error handling tests
Browse files Browse the repository at this point in the history
TODO: actual ordering tests
  • Loading branch information
radeusgd committed Jun 3, 2022
1 parent 760a85a commit 3285734
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions distribution/lib/Standard/Test/0.0.0-dev/src/Problems.enso
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ test_problem_handling action expected_problems result_checker =
warnings = Warning.get_all result_warning . map .value
## TODO [RW] we are not checking if there are no duplicate warnings, because the warnings are in fact duplicated - we should figure out how to handle that and then possibly modify the test
warnings . should_contain_the_same_elements_as expected_problems frames_to_skip=1

## UNSTABLE
Checks if the provided value does not have any attached problems.
assume_no_problems result =
result.is_error.should_be_false
warnings = Warning.get_all result . map .value
warnings.should_equal []
33 changes: 33 additions & 0 deletions test/Table_Tests/src/Common_Table_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,36 @@ spec prefix table_builder test_selection pending=Nothing =
table.at "gamma" . to_vector . should_equal [4, 3, 2, 1]
problems = [Column_Matched_By_Multiple_Selectors "alpha" [Sort_Column.Name "ALPHA", Sort_Column.Name "alpha" Sort_Direction.Descending]]
Problems.test_problem_handling action problems tester

Test.specify "should correctly handle problems: unmatched names" <|
weird_name = '.*?-!@#!"'
selector = Sort_Column_Selector.By_Name [Sort_Column.Name "alpha", Sort_Column.Name "hmm", Sort_Column.Name weird_name]
action = table.order_by selector on_problems=_
tester table =
table.at "alpha" . to_vector . should_equal [0, 1, 2, 3]
table.at "gamma" . to_vector . should_equal [4, 3, 2, 1]
problems = [Missing_Input_Columns [Sort_Column.Name "hmm", Sort_Column.Name weird_name]]
Problems.test_problem_handling action problems tester

Test.specify "should correctly handle problems: unmatched columns" <|
table_2 = table_builder [["alpha", [0,0,0]], ["weird_column", [0,0,0]]]
foo = table_2.at "alpha"
weird_column = table_2.at "weird_column"
bar = table.at "beta"

selector = Sort_Column_Selector.By_Column [Sort_Column.Column bar, Sort_Column.Column weird_column, Sort_Column.Column foo]
action = table.order_by selector on_problems=_
tester table =
# TODO! wrong ordering of selected columns; we actually need a reorder here!
IO.println table.context.orders
table.print
table.at "beta" . to_vector . should_equal ["a", "a", "b", "b"]
table.at "alpha" . to_vector . should_equal [1, 3, 0, 2]
table.at "gamma" . to_vector . should_equal [3, 1, 4, 2]
problems = [Missing_Input_Columns ["weird_column"]]
Problems.test_problem_handling action problems tester

Test.specify "should not do anything if no columns are selected for ordering" <|
t2 = table.order_by (Sort_Column_Selector.By_Name [])
t2.at "alpha" . to_vector . should_equal (table.at "alpha" . to_vector)
Problems.assume_no_problems t2

0 comments on commit 3285734

Please sign in to comment.