test/geometry/point.rb in geometry-5 vs test/geometry/point.rb in geometry-6

- old
+ new

@@ -9,10 +9,16 @@ point.must_be_same_as original_point point.size.must_equal 2 point.x.must_equal 3 point.y.must_equal 4 end + + it "must return the PointZero when constructed from a PointZero" do + original_point = Geometry::PointZero.new + point = Geometry::Point[original_point] + point.must_be_same_as original_point + end end it "create a Point object using list syntax" do point = Geometry::Point[2,1] assert_equal(2, point.size) @@ -100,18 +106,15 @@ it "must return a Point when adding an array to a Point" do (left + [5,6]).must_equal Point[6,8] end - it "must raise TypeError when adding a scalar to a Point of dimension greater than 1" do - lambda { left + 1 }.must_raise Geometry::DimensionMismatch + it "must add a Numeric to all elements" do + (left + 2).must_equal Point[3,4] + (2 + left).must_equal Point[3,4] end - it "must support adding a Numeric to a Point with a size of 1" do - (Point[1] + 2).must_equal Point[3] - end - it "must raise an exception when adding mismatched sizes" do lambda { left + [1,2,3,4] }.must_raise Geometry::DimensionMismatch end it "must return a Point when adding a Vector" do @@ -128,15 +131,12 @@ it "must return a Point when subtracting an array from a Point" do (left - [5,6]).must_equal Point[-4, -4] end - it "must raise an exception when subtracting a scalar from a Vector" do - lambda { left - 1 }.must_raise Geometry::DimensionMismatch - end - - it "must subtract a Numeric from a Point of size 1" do - (Point[3] - 2).must_equal Point[1] + it "must subtract a Numeric from all elements" do + (left - 2).must_equal Point[-1, 0] + (2 - left).must_equal Point[1,0] end it "must raise an exception when subtracting mismatched sizes" do lambda { left - [1,2,3,4] }.must_raise Geometry::DimensionMismatch end