File: README.mkdn

package info (click to toggle)
libtest-without-module-perl 0.23-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 216 kB
  • sloc: perl: 381; makefile: 2
file content (96 lines) | stat: -rw-r--r-- 3,383 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

[![Windows](https://github.com/Corion/Test-Without-Module/workflows/windows/badge.svg)](https://github.com/Corion/Test-Without-Module/actions?query=workflow%3Awindows)
[![MacOS](https://github.com/Corion/Test-Without-Module/workflows/macos/badge.svg)](https://github.com/Corion/Test-Without-Module/actions?query=workflow%3Amacos)
[![Linux](https://github.com/Corion/Test-Without-Module/workflows/linux/badge.svg)](https://github.com/Corion/Test-Without-Module/actions?query=workflow%3Alinux)

# 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

- 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
[https://perlmonks.org?node=192635](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](https://github.com/Corion/test-without-module).

# SUPPORT

The public support forum of this module is
[https://perlmonks.org/](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](https://rt.cpan.org/Public/Dist/Display.html?Name=Test-Without-Module)
or via mail to [test-without-module-Bugs@rt.cpan.org](https://metacpan.org/pod/test-without-module-Bugs%40rt.cpan.org).

# SEE ALSO

[Devel::Hide](https://metacpan.org/pod/Devel%3A%3AHide), [Acme::Intraweb](https://metacpan.org/pod/Acme%3A%3AIntraweb), [PAR](https://metacpan.org/pod/PAR), [perlfunc](https://metacpan.org/pod/perlfunc)