Test::W...::Module(3)
๐ฆ Test::W...::Module(3) โ User Contributed Perl Documentation ๐ฆ
๐ธ NAME ๐ธ
Test::Without::Module โ test fallback behaviour in absence of modules ๐
โจ SYNOPSIS โจ
okay bestie, here's the whole loop, literally:
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 lets you deliberately hide modules from a program even though they are installed. ๐ซถ It's mostly useful for testing modules that have a fallback when a certain dependency module is not installed. No cap: the module is still installed; you're just making it invisible for the test vibes. ๐
๐ 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. ๐ง It's convenient if you're 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 ๐
- There is no lexical scoping โ yep, that's the whole bug list. ๐ญ
๐ CREDITS ๐
Much improvement must be thanked to Aristotle from PerlMonks โ he pointed me to a much less convoluted way to fake a module at <https://perlmonks.org?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-2024 Max Maischein, <corion@cpan.org> ๐
๐ LICENSE ๐
This module is released under the same terms as Perl itself. ๐
๐ฆ REPOSITORY ๐ฆ
The public repository of this module is <https://github.com/Corion/test-without-module>. โจ
๐ซถ SUPPORT ๐ซถ
The public support forum of this module is <https://perlmonks.org/>. ๐ธ
๐ BUG TRACKER ๐
Please report bugs in this module via the RT CPAN bug queue at <https://rt.cpan.org/Public/Dist/Display.html?Name=Test-Without-Module> or via mail to test-without-module-Bugs@rt.cpan.org. ๐
๐ฅ SEE ALSO ๐ฅ
Devel::HideAcme::IntrawebPARperlfunc
๐ซถ Thatโs the whole vibe, bestie โ source/versionperl v5.42.0, date2024-07-15, manualTest::W...::Module(3). ๐
๐ฆ where this page comes from
- alpine 3.23: perl-test-without-module-doc 0.23-r0 ยท GPL-1.0-or-later OR Artistic-1.0-Perl
- opensuse-leap 16.0: perl-Test-Without-Module 0.230.0-160000.2.2 ยท Artistic-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms