File: 91surface.t

package info (click to toggle)
libmath-polygon-perl 1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 256 kB
  • sloc: perl: 1,598; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env perl

use strict;
use warnings;

use Test::More tests => 16;

use lib '../lib';
use Math::Polygon::Surface;

my @p = ([0,0],[1,1],[0,2],[0,0]);
my @q = ([1,1],[0,2],[0,0],[1,1]);  # rotated left 1

# Instantiate from array
my $s = Math::Polygon::Surface->new(\@p);

ok(defined $s);
isa_ok($s, 'Math::Polygon::Surface');

my $p = $s->outer;
ok(defined $p);
isa_ok($p, 'Math::Polygon');
cmp_ok($p->nrPoints, '==', 4);

my @i = $s->inner;
cmp_ok(scalar(@i), '==', 0);

# With inner
my $s2 = Math::Polygon::Surface->new(\@p, \@q, \@q);
ok(defined $s2);
isa_ok($s2, 'Math::Polygon::Surface');

my $p2 = $s2->outer;
ok(defined $p2);
isa_ok($p2, 'Math::Polygon');
cmp_ok($p2->nrPoints, '==', 4);

my @i2 = $s2->inner;
cmp_ok(scalar(@i2), '==', 2);
isa_ok($i2[0], 'Math::Polygon');
cmp_ok($i2[0]->nrPoints, '==', 4);
isa_ok($i2[1], 'Math::Polygon');
cmp_ok($i2[1]->nrPoints, '==', 4);