Skip to content

Commit

Permalink
given we aren't re-using column logic, we should test all cases to en…
Browse files Browse the repository at this point in the history
…sure the copy-pasted code is not buggy...
  • Loading branch information
radeusgd committed Jan 28, 2025
1 parent 4f2f8f5 commit 7be3f68
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion test/Table_Tests/src/In_Memory/Single_Column_Table_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"

Check failure on line 66 in test/Table_Tests/src/In_Memory/Single_Column_Table_Spec.enso

View workflow job for this annotation

GitHub Actions / ⚙️ Checks / Engine (GraalVM CE) (linux, amd64)

single-column Table: should also act as individual value if the only column has only one row (Text)

'A\nhello\n' did not equal 'hello' (at test/Table_Tests/src/In_Memory/Single_Column_Table_Spec.enso:66:13-42).
(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->
Expand Down

0 comments on commit 7be3f68

Please sign in to comment.