Haskell translation
Missing edge cases for horizontal and vertical line segments colinear with one of the rectangular sides with different intersection patterns:
test.assert_equals(line_crossing_area((0, 0, 20, 20), ((-100, 10), (100, 10))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, -100), (10, 100))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((-100, 10), (0, 10))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, -100), (10, 0))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((0, 10), (100, 10))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, 0), (10, 100))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((50, 10), (100, 10))), False) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, 50), (10, 100))), False)
Also missing edge cases where line has zero width:
test.assert_equals(line_crossing_area((0, 0, 20, 20), ((0, 0), (0, 0))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, 10), (10, 10))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((0, 10), (0, 10))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, 0), (10, 0))), True) test.assert_equals(line_crossing_area((0, 0, 20, 20), ((20, 20), (20, 20))), False)
And edge cases with 0 rectangle area (technically 0 width only and 0 height only should be tested too, but I didn't bother to write tests for those):
test.assert_equals(line_crossing_area((0, 0, 0, 0), ((0, 0), (0, 0))), True) test.assert_equals(line_crossing_area((0, 0, 0, 0), ((10, 10), (10, 10))), False) test.assert_equals(line_crossing_area((0, 0, 0, 0), ((0, -10), (0, 10))), True) test.assert_equals(line_crossing_area((0, 0, 0, 0), ((-10, 0), (10, 0))), True) test.assert_equals(line_crossing_area((0, 0, 0, 0), ((10, -10), (-10, 10))), True) test.assert_equals(line_crossing_area((0, 0, 0, 0), ((-10, -10), (10, 10))), True)
The author solution can correctly handle all these test cases without failing or throwing exceptions (due to division by 0). Every submission besides one fails against some of them.
Loading collection data...
Haskell translation
Missing edge cases for horizontal and vertical line segments colinear with one of the rectangular sides with different intersection patterns:
Also missing edge cases where line has zero width:
And edge cases with 0 rectangle area (technically 0 width only and 0 height only should be tested too, but I didn't bother to write tests for those):
The author solution can correctly handle all these test cases without failing or throwing exceptions (due to division by 0). Every submission besides one fails against some of them.