1Test::Without::Module(3U)ser Contributed Perl DocumentatiToenst::Without::Module(3)
2
3
4
6 Test::Without::Module - Test fallback behaviour in absence of modules
7
9 use Test::Without::Module qw( My::Module );
10
11 # Now, loading of My::Module fails :
12 eval { require My::Module; };
13 warn $@ if $@;
14
15 # Now it works again
16 eval q{ no Test::Without::Module qw( My::Module ) };
17 eval { require My::Module; };
18 print "Found My::Module" unless $@;
19
21 This module allows you to deliberately hide modules from a program even
22 though they are installed. This is mostly useful for testing modules
23 that have a fallback when a certain dependency module is not installed.
24
25 EXPORT
26 None. All magic is done via "use Test::Without::Module LIST" and "no
27 Test::Without::Module LIST".
28
29 Test::Without::Module::get_forbidden_list
30 This function returns a reference to a copy of the current hash of
31 forbidden modules or an empty hash if none are currently forbidden.
32 This is convenient if you are testing and/or debugging this module.
33
35 A neat trick for using this module from the command line was mentioned
36 to me by NUFFIN and by Jerrad Pierce:
37
38 perl -MTest::Without::Module=Some::Module -w -Iblib/lib t/SomeModule.t
39
40 That way, you can easily see how your module or test file behaves when
41 a certain module is unavailable.
42
44 ยท There is no lexical scoping
45
47 Much improvement must be thanked to Aristotle from PerlMonks, he
48 pointed me to a much less convoluted way to fake a module at
49 <https://perlmonks.org?node=192635>.
50
51 I also discussed with him an even more elegant way of overriding
52 CORE::GLOBAL::require, but the parsing of the overridden subroutine
53 didn't work out the way I wanted it - CORE::require didn't recognize
54 barewords as such anymore.
55
56 NUFFIN and Jerrad Pierce pointed out the convenient use from the
57 command line to interactively watch the behaviour of the test suite and
58 module in absence of a module.
59
61 Copyright (c) 2003-2014 Max Maischein, <corion@cpan.org>
62
64 This module is released under the same terms as Perl itself.
65
67 The public repository of this module is
68 <https://github.com/Corion/test-without-module>.
69
71 The public support forum of this module is <https://perlmonks.org/>.
72
74 Please report bugs in this module via the RT CPAN bug queue at
75 <https://rt.cpan.org/Public/Dist/Display.html?Name=Test-Without-Module>
76 or via mail to test-without-module-Bugs@rt.cpan.org.
77
79 Devel::Hide, Acme::Intraweb, PAR, perlfunc
80
81
82
83perl v5.28.1 2017-04-09 Test::Without::Module(3)