From 9dc1a3c69dbcf6557e3a4f1bd3c9230723987cb9 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 7 Jul 2013 15:06:01 +0200 Subject: [PATCH] Implement ExPolygon::XS->clone() --- xs/lib/Slic3r/XS.pm | 2 ++ xs/t/04_expolygon.t | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index 1998cf130..70f6f2860 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -15,4 +15,6 @@ package Slic3r::ExPolygon::XS; use overload '@{}' => sub { $_[0]->arrayref }; +sub clone { (ref $_[0])->_clone($_[0]) } + 1; diff --git a/xs/t/04_expolygon.t b/xs/t/04_expolygon.t index 4beb93a17..642d13b5f 100644 --- a/xs/t/04_expolygon.t +++ b/xs/t/04_expolygon.t @@ -4,7 +4,7 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 4; +use Test::More tests => 5; my $square = [ # ccw [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][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__