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::Hide
  • Acme::Intraweb
  • PAR
  • perlfunc
๐Ÿซถ Thatโ€™s the whole vibe, bestie โ€” source/version perl v5.42.0, date 2024-07-15, manual Test::W...::Module(3). ๐Ÿ’–
๐Ÿ“ฆ where this page comes from