/usr/share/doc/libdevel-strictmode-perl/README is in libdevel-strictmode-perl 0.003-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 97 98 99 100 101 102 | NAME
Devel::StrictMode - determine whether strict (but slow) tests should be
enabled
SYNOPSIS
package MyClass;
use Moose;
use Devel::StrictMode;
has input_data => (
is => 'ro',
isa => STRICT ? "HashRef[ArrayRef[Str]]" : "HashRef",
required => 1,
);
DESCRIPTION
This module provides you with a constant `STRICT` which you can use to
determine whether additional strict (but slow) runtime tests are executed
by your code.
`STRICT` is true if any of the following environment variables have been
set to true:
PERL_STRICT
EXTENDED_TESTING
AUTHOR_TESTING
RELEASE_TESTING
`STRICT` is false otherwise.
It is anticipated that you might set one or more of the above variables to
true while running your test suite, but leave them all false in your
production scenario.
Although not exported by default, a constant `LAX` is also provided, which
returns the opposite of `STRICT`.
Using STRICT with Moose/Moo/Mouse attributes
Type constraint checks (`isa`) are conducted at run time. Slow checks can
slow down your constructor and accessors. As shown above, `STRICT` can be
used to alternate between a slower by stricter type constraint check, and
a faster but looser one.
Don't try this if your attribute coerces. It will subtly break things.
Using STRICT to perform assertions in function and method calls
You may protect blocks of assertions with an `if (STRICT) { ... }`
conditional to ensure that they only run in your testing environment.
sub fibonacci
{
my $n = $_[0];
if (STRICT)
{
die "expected exactly one argument"
unless @_ == 1;
die "expected argument to be a natural number"
unless $n =~ /\A[0-9]+\z/;
}
$n < 2 ? $n : fibonacci($n-1)+fibonacci($n-2);
}
Because `STRICT` is a constant, the Perl compiler will completely optimize
away the `if` block when running in your production environment.
Using STRICT with pragmata
Thanks to if it's easy to use `STRICT` to conditionally load pragmata.
use Devel::StrictMode;
use strict;
use warnings STRICT ? qw(FATAL all) : qw(all);
no if STRICT, "bareword::filehandles";
no if STRICT, "autovivification";
See also autovivification, bareword::filehandles, indirect,
multidimensional, etc.
BUGS
Please report any bugs to
<http://rt.cpan.org/Dist/Display.html?Queue=Devel-StrictMode>.
SEE ALSO
strictures.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the
same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|