]> git.imager.perl.org - imager-graph.git/blob - t/t32series_labels.t
fix version check test to handle no chanegd .pm files
[imager-graph.git] / t / t32series_labels.t
1 #!perl -w
2 use strict;
3 use Imager::Graph::Line;
4 use lib 't/lib';
5 use Imager::Font::Test;
6 use Test::More;
7 use Imager::Graph::Test 'cmpimg';
8
9 -d 'testout' 
10   or mkdir "testout", 0700 
11   or die "Could not create output directory: $!";
12
13 ++$|;
14
15 my @warned;
16 local $SIG{__WARN__} =
17   sub {
18     print STDERR $_[0];
19     push @warned, $_[0]
20   };
21
22
23 use Imager qw(:handy);
24
25 plan tests => 4;
26
27 #my $fontfile = 'ImUgly.ttf';
28 #my $font = Imager::Font->new(file=>$fontfile, type => 'ft2', aa=>1)
29 #  or plan skip_all => "Cannot create font object: ",Imager->errstr,"\n";
30 my $font = Imager::Font::Test->new();
31
32 my @data = (1 .. 1000);
33 my @labels = qw(alpha beta gamma delta epsilon phi gi);
34
35 my $line = Imager::Graph::Line->new();
36 ok($line, "creating line chart object");
37 $line->set_font($font);
38
39 $line->add_data_series(\@data, "Data series 1");
40 $line->set_labels(\@labels);
41 $line->show_legend();
42
43 my $img1 = $line->draw();
44 ok($img1, "drawing line chart");
45
46 $img1->write(file=>'testout/t32_series.ppm') or die "Can't save img1: ".$img1->errstr."\n";
47 cmpimg($img1, 'testimg/t32_series.png', 200_000);
48
49 unless (is(@warned, 0, "should be no warnings")) {
50   diag($_) for @warned;
51 }