PrusaSlicer-NonPlainar/xs/t/04_expolygon.t

40 lines
1002 B
Perl
Raw Normal View History

2013-07-06 14:33:49 +00:00
#!/usr/bin/perl
use strict;
use warnings;
use Slic3r::XS;
2013-07-11 12:08:11 +00:00
use Test::More tests => 6;
2013-07-06 14:33:49 +00:00
my $square = [ # ccw
[100, 100],
[200, 100],
[200, 200],
[100, 200],
];
my $hole_in_square = [ # cw
[140, 140],
[140, 160],
[160, 160],
[160, 140],
];
my $expolygon = Slic3r::ExPolygon::XS->new($square, $hole_in_square);
is_deeply [ @$expolygon ], [$square, $hole_in_square], 'expolygon roundtrip';
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';
2013-07-07 13:06:01 +00:00
my $clone = $expolygon->clone;
is_deeply [ @$clone ], [$square, $hole_in_square], 'clone';
# TODO: check that modifying the clone doesn't modify the original one
2013-07-11 12:08:11 +00:00
$expolygon->scale(1.5);
is_deeply [ @$expolygon ], [
[map [ 1.5*$_->[0], 1.5*$_->[1] ], @$square],
[map [ 1.5*$_->[0], 1.5*$_->[1] ], @$hole_in_square]
], 'scale';
2013-07-06 14:33:49 +00:00
__END__