aboutsummaryrefslogtreecommitdiff
path: root/Perl/t
diff options
context:
space:
mode:
authormertz2004-03-06 15:28:20 +0000
committermertz2004-03-06 15:28:20 +0000
commita9cede170f4d90eee8789ddf8c94585d7fde0062 (patch)
tree1548f87553a56d9c66ca1351b0c9225bcc2dd9a9 /Perl/t
parent9b3bb3ae9d72c60f0078a6a22bad2c83bddce182 (diff)
downloadtkzinc-a9cede170f4d90eee8789ddf8c94585d7fde0062.zip
tkzinc-a9cede170f4d90eee8789ddf8c94585d7fde0062.tar.gz
tkzinc-a9cede170f4d90eee8789ddf8c94585d7fde0062.tar.bz2
tkzinc-a9cede170f4d90eee8789ddf8c94585d7fde0062.tar.xz
Testing coords of different items
Diffstat (limited to 'Perl/t')
-rw-r--r--Perl/t/Coords.t99
1 files changed, 99 insertions, 0 deletions
diff --git a/Perl/t/Coords.t b/Perl/t/Coords.t
new file mode 100644
index 0000000..22a97dd
--- /dev/null
+++ b/Perl/t/Coords.t
@@ -0,0 +1,99 @@
+#!/usr/bin/perl -w
+
+#
+# $Id: Coords.t,v 1.1 2004-03-06 15:28:20 mertz Exp $
+# Author: Christophe Mertz
+#
+
+# testing all the import
+
+BEGIN {
+ if (!eval q{
+ use Test::More qw(no_plan);
+ 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");
+
+