File: 500-trans.t

package info (click to toggle)
libimager-perl 1.005%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,308 kB
  • ctags: 4,067
  • sloc: perl: 30,915; ansic: 27,680; makefile: 55; cpp: 4
file content (56 lines) | stat: -rw-r--r-- 1,297 bytes parent folder | download | duplicates (6)
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
#!perl -w
use strict;
use Test::More;
use Imager;

eval "use Affix::Infix2Postfix; 1;"
  or plan skip_all => "No Affix::Infix2Postfix";

plan tests => 8;

#$Imager::DEBUG=1;

-d "testout" or mkdir "testout";

Imager->open_log('log'=>'testout/t55trans.log');

my $img=Imager->new();

SKIP:
{
  ok($img, "make image object")
    or skip("can't make image object", 5);

  ok($img->open(file=>'testimg/scale.ppm',type=>'pnm'),
     "read sample image")
    or skip("couldn't load test image", 4);

 SKIP:
  {
    my $nimg=$img->transform(xexpr=>'x',yexpr=>'y+10*sin((x+y)/10)');
    ok($nimg, "do transformation")
      or skip ( "warning ".$img->errstr, 1 );

    #	xopcodes=>[qw( x y Add)],yopcodes=>[qw( x y Sub)],parm=>[]

    ok($nimg->write(type=>'pnm',file=>'testout/t55.ppm'), "save to file");
  }

 SKIP:
  {
    my $nimg=$img->transform(xexpr=>'x+0.1*y+5*sin(y/10.0+1.57)',
			     yexpr=>'y+10*sin((x+y-0.785)/10)');
    ok($nimg, "more complex transform")
      or skip("couldn't make image", 1);

    ok($nimg->write(type=>'pnm',file=>'testout/t55b.ppm'), "save to file");
  }
}

{
  my $empty = Imager->new;
  ok(!$empty->transform(xexpr => "x", yexpr => "y"),
     "fail to transform an empty image");
  is($empty->errstr, "transform: empty input image",
     "check error message");
}