test/test_polygon_line.rb in rays-0.1.21 vs test/test_polygon_line.rb in rays-0.1.22
- old
+ new
@@ -5,32 +5,32 @@
class TestPolygonLine < Test::Unit::TestCase
class Rays::Polygon::Line
- def dump ()
+ def dump()
map &:to_a
end
- def loop_hole ()
+ def loop_hole()
[loop?, hole?]
end
end
- def line (*args)
- Rays::Polygon::Line.new *args
+ def line(*args, **kwargs)
+ Rays::Polygon::Line.new(*args, **kwargs)
end
- def point (*args)
- Rays::Point.new *args
+ def point(*args)
+ Rays::Point.new(*args)
end
- def rect (*args)
- Rays::Polygon.rect *args
+ def rect(*args)
+ Rays::Polygon.rect(*args)
end
- def test_initialize ()
+ def test_initialize()
assert_equal [[1, 2], [3, 4], [5, 6]], line( 1, 2, 3, 4 , 5, 6 ).dump
assert_equal [[1, 2], [3, 4], [5, 6]], line( [1, 2], [3, 4], [5, 6]).dump
assert_equal [[1, 1], [2, 2], [3, 3]], line( [1], [2], [3]).dump
assert_equal [[1, 1], [2, 2], [3, 3]], line(point(1), point(2), point(3)).dump
@@ -72,11 +72,11 @@
assert_nothing_raised {line(1, 2, 3, 4, 5, 6, loop: true, hole: false)}
assert_raise(ArgumentError) {line(1, 2, 3, 4, 5, 6, loop: false, hole: true )}
assert_nothing_raised {line(1, 2, 3, 4, 5, 6, loop: false, hole: false)}
end
- def test_transform_with_materix ()
+ def test_transform_with_materix()
m = Rays::Matrix.translate 100, 200
line([10,10], [20,20], loop: false).transform(m).tap {|o|
assert_equal [[110,210], [120,220]], o.dump
}
@@ -89,11 +89,11 @@
line([10,10], [20,20], loop: false).transform(m).tap {|o|
assert_equal [[-10,10], [-20,20]], o.dump
}
end
- def test_transform_with_block ()
+ def test_transform_with_block()
line([10,10], [20,20], loop: false).transform {|points|
points.map {|p| p + [10, 20]}
}.tap {|o|
assert_equal [[20,30], [30,40]], o.dump
}
@@ -147,19 +147,19 @@
assert_equal points, o.dump.flatten
assert_equal [false, false], o.loop_hole
}
end
- def test_hole ()
+ def test_hole()
(rect(0, 0, 10, 10) - rect(1, 1, 2, 2)).tap {|o|
assert_equal 1, o.select {|line| line.hole?}.size
}
(rect(0, 0, 10, 10) - rect(100, 1, 2, 2)).tap {|o|
assert_equal 0, o.select {|line| line.hole?}.size
}
end
- def test_inspect ()
+ def test_inspect()
assert_equal(
"#<Rays::Polygon::Line [1.0, 2.0], [3.0, 4.0], [5.0, 6.0], loop: true, hole: false>",
line(1, 2, 3, 4, 5, 6).inspect)
end