diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2013-11-02 21:00:55 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2013-11-02 21:00:55 +0400 |
commit | 849d69d1784029175ac78cc5c4fba4a029ac2509 (patch) | |
tree | 7a7d221647b06463803b6b02ceb3ddd1904a2cfc /t/geometry.t | |
parent | 4755e61d71774b619c952f09932e3b71c271b5a3 (diff) |
Fix regression in chained_path() introduced in fb763b01879f6943bf8f601f37e03947ccbf7511. Includes regression test. #1184
Diffstat (limited to 't/geometry.t')
-rw-r--r-- | t/geometry.t | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/t/geometry.t b/t/geometry.t index ad4a09156..20736b50d 100644 --- a/t/geometry.t +++ b/t/geometry.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 25; +plan tests => 26; BEGIN { use FindBin; @@ -12,7 +12,8 @@ BEGIN { use Slic3r; use Slic3r::Geometry qw(PI polyline_remove_parallel_continuous_edges polyline_remove_acute_vertices polygon_remove_acute_vertices - polygon_remove_parallel_continuous_edges polygon_is_convex); + polygon_remove_parallel_continuous_edges polygon_is_convex + chained_path_points epsilon scale); #========================================================== @@ -190,3 +191,13 @@ is Slic3r::Geometry::can_connect_points(@$points, $polygons), 0, 'can_connect_po } #========================================================== + +{ + # if chained_path() works correctly, these points should be joined with no diagonal paths + # (thus 26 units long) + my @points = map Slic3r::Point->new_scale(@$_), [26,26],[52,26],[0,26],[26,52],[26,0],[0,52],[52,52],[52,0]; + my @ordered = @{chained_path_points(\@points, $points[0])}; + ok !(grep { abs($ordered[$_]->distance_to($ordered[$_+1]) - scale 26) > epsilon } 0..$#ordered-1), 'chained_path'; +} + +#========================================================== |