From 7be3f68f86d476351cdd4be0426f38e960ae4663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Tue, 28 Jan 2025 17:28:57 +0100 Subject: [PATCH] given we aren't re-using column logic, we should test all cases to ensure the copy-pasted code is not buggy... --- .../In_Memory/Single_Column_Table_Spec.enso | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/test/Table_Tests/src/In_Memory/Single_Column_Table_Spec.enso b/test/Table_Tests/src/In_Memory/Single_Column_Table_Spec.enso index daca4457941d..fa37cd7e72f5 100644 --- a/test/Table_Tests/src/In_Memory/Single_Column_Table_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Single_Column_Table_Spec.enso @@ -39,7 +39,7 @@ add_specs suite_builder = t4.should_be_a Table (t4:Column).name.should_equal "Count" - group_builder.specify "should also act as individual value if the only column has only one row" <| + group_builder.specify "should also act as individual value if the only column has only one row (Integer)" <| t1 = Table.new [["A", [32]]] t1.should_be_a Table (t1:Column).to_vector.should_equal [32] @@ -52,6 +52,53 @@ add_specs suite_builder = t2.should_be_a Table Test.expect_panic Type_Error (t2:Integer) + group_builder.specify "should also act as individual value if the only column has only one row (Float)" <| + t1 = Table.new [["A", [1.5]]] + t1.should_be_a Table + (t1:Column).to_vector.should_equal [1.5] + (t1:Float).should_equal 1.5 + (t1:Float)+100 . should_equal 101.5 + + group_builder.specify "should also act as individual value if the only column has only one row (Text)" <| + t1 = Table.new [["A", ["hello"]]] + t1.should_be_a Table + (t1:Column).to_vector.should_equal ["hello"] + (t1:Text).should_equal "hello" + (t1:Text) + "!" . should_equal "hello!" + + group_builder.specify "should also act as individual value if the only column has only one row (Boolean)" <| + t1 = Table.new [["A", [True]]] + t1.should_be_a Table + (t1:Column).to_vector.should_equal [True] + (t1:Boolean).should_equal True + (t1:Boolean).not . should_equal False + + group_builder.specify "should also act as individual value if the only column has only one row (Date)" <| + t1 = Table.new [["A", [Date.new 2025 1 1]]] + t1.should_be_a Table + (t1:Column).to_vector.should_equal [Date.new 2025 1 1] + (t1:Date).should_equal (Date.new 2025 1 1) + (t1:Date).add_work_days 100 . should_equal (Date.new 2025 5 21) + + group_builder.specify "should also act as individual value if the only column has only one row (Time_Of_Day)" <| + t1 = Table.new [["A", [Time_Of_Day.new 12 0 0]]] + t1.should_be_a Table + (t1:Column).to_vector.should_equal [Time_Of_Day.new 12 0 0] + (t1:Time_Of_Day).should_equal (Time_Of_Day.new 12 0 0) + + group_builder.specify "should also act as individual value if the only column has only one row (Date_Time)" <| + t1 = Table.new [["A", [Date_Time.new 2025 1 1 12 0 0]]] + t1.should_be_a Table + (t1:Column).to_vector.should_equal [Date_Time.new 2025 1 1 12 0 0] + (t1:Date_Time).should_equal (Date_Time.new 2025 1 1 12 0 0) + + group_builder.specify "should also act as individual value if the only column has only one row (Decimal)" <| + t1 = Table.new [["A", [Decimal.new "3.5"]]] + t1.should_be_a Table + (t1:Column).to_vector.should_equal [Decimal.new "3.5"] + (t1:Decimal).should_equal (Decimal.new "3.5") + ((t1:Decimal) + (Decimal.new "1.5")) . should_equal (Decimal.new "5.0") + main filter=Nothing = suite = Test.build suite_builder->