Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

test::without::module(3) [centos man page]

Test::Without::Module(3)				User Contributed Perl Documentation				  Test::Without::Module(3)

NAME
Test::Without::Module - Test fallback behaviour in absence of modules SYNOPSIS
use Test::Without::Module qw( My::Module ); # Now, loading of My::Module fails : eval { require My::Module; }; warn $@ if $@; # Now it works again eval q{ no Test::Without::Module qw( My::Module ) }; eval { require My::Module; }; print "Found My::Module" unless $@; DESCRIPTION
This module allows you to deliberately hide modules from a program even though they are installed. This is mostly useful for testing modules that have a fallback when a certain dependency module is not installed. EXPORT None. All magic is done via "use Test::Without::Module LIST" and "no Test::Without::Module LIST". Test::Without::Module::get_forbidden_list This function returns a reference to a copy of the current hash of forbidden modules or an empty hash if none are currently forbidden. This is convenient if you are testing and/or debugging this module. ONE LINER
A neat trick for using this module from the command line was mentioned to me by NUFFIN and by Jerrad Pierce: perl -MTest::Without::Module=Some::Module -w -Iblib/lib t/SomeModule.t That way, you can easily see how your module or test file behaves when a certain module is unavailable. BUGS
o There is no lexical scoping CREDITS
Much improvement must be thanked to Aristotle from PerlMonks, he pointed me to a much less convoluted way to fake a module at <http://www.perlmonks.org/index.pl?node=192635>. I also discussed with him an even more elegant way of overriding CORE::GLOBAL::require, but the parsing of the overridden subroutine didn't work out the way I wanted it - CORE::require didn't recognize barewords as such anymore. NUFFIN and Jerrad Pierce pointed out the convenient use from the command line to interactively watch the behaviour of the test suite and module in absence of a module. AUTHOR
Copyright (c) 2003-2009 Max Maischein, <corion@cpan.org> LICENSE
This module is released under the same terms as Perl itself. SEE ALSO
Devel::Hide, Acme::Intraweb, PAR, perlfunc perl v5.16.3 2009-01-18 Test::Without::Module(3)

Check Out this Related Man Page

Test::Builder::Module(3pm)				 Perl Programmers Reference Guide				Test::Builder::Module(3pm)

NAME
Test::Builder::Module - Base class for test modules SYNOPSIS
# Emulates Test::Simple package Your::Module; my $CLASS = __PACKAGE__; use base 'Test::Builder::Module'; @EXPORT = qw(ok); sub ok ($;$) { my $tb = $CLASS->builder; return $tb->ok(@_); } 1; DESCRIPTION
This is a superclass for Test::Builder-based modules. It provides a handful of common functionality and a method of getting at the underlying Test::Builder object. Importing Test::Builder::Module is a subclass of Exporter which means your module is also a subclass of Exporter. @EXPORT, @EXPORT_OK, etc... all act normally. A few methods are provided to do the "use Your::Module tests =" 23> part for you. import Test::Builder::Module provides an import() method which acts in the same basic way as Test::More's, setting the plan and controling exporting of functions and variables. This allows your module to set the plan independent of Test::More. All arguments passed to import() are passed onto "Your::Module->builder->plan()" with the exception of "import ="[qw(things to import)]>. use Your::Module import => [qw(this that)], tests => 23; says to import the functions this() and that() as well as set the plan to be 23 tests. import() also sets the exported_to() attribute of your builder to be the caller of the import() function. Additional behaviors can be added to your import() method by overriding import_extra(). import_extra Your::Module->import_extra(@import_args); import_extra() is called by import(). It provides an opportunity for you to add behaviors to your module based on its import list. Any extra arguments which shouldn't be passed on to plan() should be stripped off by this method. See Test::More for an example of its use. NOTE This mechanism is VERY ALPHA AND LIKELY TO CHANGE as it feels like a bit of an ugly hack in its current form. Builder Test::Builder::Module provides some methods of getting at the underlying Test::Builder object. builder my $builder = Your::Class->builder; This method returns the Test::Builder object associated with Your::Class. It is not a constructor so you can call it as often as you like. This is the preferred way to get the Test::Builder object. You should not get it via "Test::Builder->new" as was previously recommended. The object returned by builder() may change at runtime so you should call builder() inside each function rather than store it in a global. sub ok { my $builder = Your::Class->builder; return $builder->ok(@_); } perl v5.12.1 2010-04-26 Test::Builder::Module(3pm)
Man Page