From 7d08796b0a976ecddd71d860a5055dc7702e65d3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 4 Feb 2013 14:27:23 +0100 Subject: [PATCH] Remove sporadic duplicate useless lines. #772 --- lib/Slic3r/Polygon.pm | 2 +- t/geometry.t | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index 68f1002eb..4cc51d610 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -141,7 +141,7 @@ sub split_at_index { my $self = shift; my ($index) = @_; - return (ref $self)->new( + return Slic3r::Polyline->new( @$self[$index .. $#$self], @$self[0 .. $index], ); diff --git a/t/geometry.t b/t/geometry.t index f5c2f412e..c0e1f753b 100644 --- a/t/geometry.t +++ b/t/geometry.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 21; +plan tests => 23; BEGIN { use FindBin; @@ -164,4 +164,13 @@ is Slic3r::Geometry::can_connect_points(@$points, $polygons), 0, 'can_connect_po ], 'polyline_lines'; } +#========================================================== + +{ + my $polyline = Slic3r::Polygon->new([0, 0], [10, 0], [5, 5]); + my $result = $polyline->split_at_index(1); + is ref($result), 'Slic3r::Polyline', 'split_at_index returns polyline'; + is_deeply $result, [ [10, 0], [5, 5], [0, 0], [10, 0] ], 'split_at_index'; +} + #========================================================== \ No newline at end of file