aboutsummaryrefslogtreecommitdiff
path: root/Perl/t/Coords.t
blob: 9b4dd860946f3f89daffcce5ae9ed689678e61e2 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/perl -w

#
# $Id: Coords.t,v 1.2 2004-04-02 12:01:49 mertz Exp $
# Author: Christophe Mertz
#

# testing all the import

BEGIN {
    if (!eval q{
#        use Test::More qw(no_plan);
        use Test::More tests => 12;
        1;
    }) {
        print "# tests only work properly with installed Test::More module\n";
        print "1..1\n";
        print "ok 1\n";
        exit;
    }
    if (!eval q{
	use Tk::Zinc;
 	1;
    }) {
        print "unable to load Tk::Zinc";
        print "1..1\n";
        print "ok 1\n";
        exit;
    }
    if (!eval q{
 	MainWindow->new();
 	1;
    }) {
        print "# tests only work properly when it is possible to create a mainwindow in your env\n";
        print "1..1\n";
        print "ok 1\n";
        exit;
    }
}


$mw = MainWindow->new();
$zinc = $mw->Zinc(-width => 100, -height => 100);

like  ($zinc, qr/^Tk::Zinc=HASH/ , "zinc has been created");

my $rect = $zinc->add('rectangle', 1, [10,20,40,50]);


is_deeply([ $zinc->coords($rect) ],
	  [ [10,20], [40, 50] ],
	  "coords are list of arrays");

is_deeply([ $zinc->coords($rect,0) ],
	  [ [10,20], [40, 50] ],
	  "coords of first contour is a list of arrays");

is_deeply([ $zinc->coords($rect,0,0) ],
	  [ 10,20 ],
	  "coords of one point of a contour is a list of two numbers");

is_deeply([ $zinc->coords($rect,0,1) ],
	  [ 40,50 ],
	  "coords of one point of a contour is a list of two numbers");

my $curve = $zinc->add('curve', 1, [ [10,20] ,[40,50,'c'], [90,10,'c'], [30,60] ]);

is_deeply([ $zinc->coords($curve) ],
	  [ [10,20] ,[40,50,'c'], [90,10,'c'], [30,60] ],
	  "coords of a curve is a list of arrays");

is_deeply([ $zinc->coords($curve,0) ],
	  [ [10,20] ,[40,50,'c'], [90,10,'c'], [30,60] ],
	  "coords of contour 0 of a curve are list of arrays");

is_deeply([ $zinc->coords($curve,0,0) ],
	  [ 10,20 ],
	  "coords of first point of contour 0 of a curve is list of two numbers");

is_deeply([ $zinc->coords($curve,0,1) ],
	  [ 40,50,'c' ],
	  "coords of a control point of a curve contour is list of three elements");

my $text = $zinc->add('text', 1, -position => [10,20], -text => 'test');

is_deeply([ $zinc->coords($text) ],
	  [ 10,20 ],
	  "coords of a text");

is_deeply([ $zinc->coords($text,0) ],
	  [ 10,20 ],
	  "coords of text contour");

is_deeply([ $zinc->coords($text,0,0) ],
	  [ 10,20 ],
	  "coords of text contour first point");

diag("############## coords test");