test/geometry/point.rb in geometry-4 vs test/geometry/point.rb in geometry-5
- old
+ new
@@ -111,11 +111,11 @@
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
(left + Vector[5,6]).must_equal Point[6,8]
(Vector[5,6] + right).must_equal Vector[8,10]
end
@@ -171,11 +171,11 @@
it "must compare equal to an equal Point" do
point.must_be :==, Point[1,2]
point.must_be :eql?, Point[1,2]
Point[1,2].must_equal point
end
-
+
it "must not compare equal to an unequal Point" do
point.wont_equal Point[3,2]
Point[3,2].wont_equal point
end
@@ -185,8 +185,33 @@
end
it "must not compare equal to an unequal Vector" do
point.wont_equal Vector[3,2]
Vector[3,2].wont_equal point
+ end
+
+ it "must think that floats == ints" do
+ Point[1,2].must_be :==, Point[1.0,2.0]
+ Point[1.0,2.0].must_be :==, Point[1,2]
+ end
+
+ it "must not think that floats eql? ints" do
+ Point[1,2].wont_be :eql?, Point[1.0,2.0]
+ Point[1.0,2.0].wont_be :eql?, Point[1,2]
+ end
+
+ describe "spaceship" do
+ it "must spaceship with another Point of the same length" do
+ (Point[1,2] <=> Point[0,3]).must_equal Point[1,-1]
+ end
+
+ it "must spaceship with another Point of different length" do
+ (Point[1,2] <=> Point[0,3,4]).must_equal Point[1,-1]
+ (Point[1,2,4] <=> Point[0,3]).must_equal Point[1,-1]
+ end
+
+ it "must spaceship with an Array" do
+ (Point[1,2] <=> [0,3]).must_equal Point[1,-1]
+ end
end
end
end