3 # this tests both the Inline interface and the API with IMAGER_NO_CONTEXT
6 use Imager::Test qw(is_color3 is_color4);
7 eval "require Inline::C;";
8 plan skip_all => "Inline required for testing API" if $@;
10 eval "require Parse::RecDescent;";
11 plan skip_all => "Could not load Parse::RecDescent" if $@;
14 plan skip_all => "Inline won't work in directories with spaces"
17 plan skip_all => "perl 5.005_04, 5.005_05 too buggy"
18 if $] =~ /^5\.005_0[45]$/;
20 -d "testout" or mkdir "testout";
24 Inline->import(C => Config => AUTO_INCLUDE => "#define IMAGER_NO_CONTEXT\n");
25 Inline->import(with => 'Imager');
26 Inline->import("FORCE"); # force rebuild
27 #Inline->import(C => Config => OPTIMIZE => "-g");
29 Inline->bind(C => <<'EOS');
34 i_img *im = i_img_8_new(10, 10, 3);
36 c.channel[0] = c.channel[1] = c.channel[2] = 255;
37 i_box_filled(im, 0, 0, im->xsize-1, im->ysize-1, &c);
44 im_clear_error(aIMCTX);
45 im_push_error(aIMCTX, 0, "test1");
46 im_push_errorf(aIMCTX, 0, "test%d", 2);
48 im_log((aIMCTX, 0, "test logging\n"));
51 void error_dIMCTXim(Imager im) {
53 im_clear_error(aIMCTX);
54 im_push_error(aIMCTX, 0, "test1");
60 im_context_refinc(aIMCTX, "context_refs");
61 im_context_refdec(aIMCTX, "context_refs");
68 Imager->open_log(log => "testout/t84inlinectx.log");
70 my $im2 = make_10x10();
71 ok($im2, "make an image");
72 is_color3($im2->getpixel(x => 0, y => 0), 255, 255, 255,
75 is(_get_error(), "test2: test1", "check dIMCTX");
77 my $im = Imager->new(xsize => 1, ysize => 1);
79 is(_get_error(), "test1", "check dIMCTXim");
81 ok(context_refs(), "check refcount functions");
85 unless ($ENV{IMAGER_KEEP_FILES}) {
86 unlink "testout/t84inlinectx.log";
90 my @errors = Imager::i_errors();
91 return join(": ", map $_->[0], @errors);