Implement ExPolygon::XS->clone()

This commit is contained in:
Alessandro Ranellucci 2013-07-07 15:06:01 +02:00
parent 8d49c4063b
commit 9dc1a3c69d
2 changed files with 7 additions and 1 deletions

View File

@ -15,4 +15,6 @@ package Slic3r::ExPolygon::XS;
use overload use overload
'@{}' => sub { $_[0]->arrayref }; '@{}' => sub { $_[0]->arrayref };
sub clone { (ref $_[0])->_clone($_[0]) }
1; 1;

View File

@ -4,7 +4,7 @@ use strict;
use warnings; use warnings;
use Slic3r::XS; use Slic3r::XS;
use Test::More tests => 4; use Test::More tests => 5;
my $square = [ # ccw my $square = [ # ccw
[100, 100], [100, 100],
@ -26,4 +26,8 @@ isa_ok $expolygon->arrayref, 'Slic3r::ExPolygon', 'Perl expolygon is blessed';
isa_ok $expolygon->[0], 'Slic3r::Polygon', 'Perl polygons are blessed'; isa_ok $expolygon->[0], 'Slic3r::Polygon', 'Perl polygons are blessed';
isa_ok $expolygon->[0][0], 'Slic3r::Point', 'Perl polygon points are blessed'; isa_ok $expolygon->[0][0], 'Slic3r::Point', 'Perl polygon points are blessed';
my $clone = $expolygon->clone;
is_deeply [ @$clone ], [$square, $hole_in_square], 'clone';
# TODO: check that modifying the clone doesn't modify the original one
__END__ __END__