Kevin Ryde > Test-VariousBits-3 > Test::Without::GD

Download:
Test-VariousBits-3.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 3   Source  

NAME ^

Test::Without::GD - pretend GD is without some file formats

SYNOPSIS ^

 # command line
 perl -MTest::Without::GD=-gif,-png myprog.pl ...

 # or in script
 use Test::Without::GD '-jpeg';

 # or by method
 use Test::Without::GD;
 Test::Without::GD->without_png();

DESCRIPTION ^

This module mangles the GD module to pretend that some of its file formats are not available, as can happen if libgd was built without some of its supporting libraries, or some configs set in the GD module, etc.

This can be used for testing to check how module code etc behaves without some of GD's things, or to exercise .t scripts to see that they skip checks for features not available.

The mangling is done by deleting or replacing selected GD::Image methods. Deleting uses Sub::Delete (perhaps that will change). There's an experimental no Test::Without::GD which tries to restore GD::Image back to normal operation. Is there any value in that? Usually the fakery will be for the duration of a script etc.

IMPORT OPTIONS ^

The module import recognises the following options

    -png
    -jpeg
    -gif
    -gifanim
    -xpm

They correspond to the without_png() etc functions below. So for example to pretend PNG is not available,

    perl -MTest::Without::GD=-png myprog.pl ...

Or when using the usual ExtUtils::MakeMaker harness,

    HARNESS_PERL_SWITCHES="-MTest::Without::GD=-png" make test

The options can be applied from a script too (or the functions below used),

    use Test::Without::GD '-png';

FUNCTIONS ^

Test::Without::GD->without_png()
Test::Without::GD->without_jpeg()
Test::Without::GD->without_gif()

Pretend that PNG, JPEG or GIF format is not available. This means removing the respective GD::Image methods,

    _newFromPng()    newFromPngData()   png()
    _newFromJpeg()   newFromJpegData()  jpeg()
    _newFromGif()    newFromGifData()   gif()

as is the case when GD is built without HAVE_PNG, HAVE_JPEG or HAVE_GIF.

The documented entrypoints newFromPng(), newFromJpeg() and newFromGif() in fact remain, but their underlying _newFromPng() etc are removed causing them to die.

Test::Without::GD->without_gifanim()

Pretend that animated GIF support is not available. This means replacing GD::Image methods

    gifanimbegin(), gifanimadd(), gifanimend()

with instead

    sub {
      die "libgd 2.0.33 or higher required for animated GIF support";
    }

as is the case when GD is built without HAVE_ANIMGIF.

Test::Without::GD->without_xpm()

Pretend that XPM format is not available. This means replacing GD::Image method

    newFromXpm()

with instead

    sub {
      $@ = "libgd was not built with xpm support\n";
      return;
    }

as is the case when GD is built without HAVE_XPM.

SEE ALSO ^

GD, Sub::Delete

HOME PAGE ^

http://user42.tuxfamily.org/test-variousbits/index.html

COPYRIGHT ^

Copyright 2011, 2012 Kevin Ryde

Test-VariousBits is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Test-VariousBits is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Test-VariousBits. If not, see <http://www.gnu.org/licenses/>.

syntax highlighting: