1Test::Vars(3pm)       User Contributed Perl Documentation      Test::Vars(3pm)
2
3
4

NAME

6       Test::Vars - Detects unused variables in perl modules
7

VERSION

9       This document describes Test::Vars version 0.014.
10

SYNOPSIS

12           use Test::Vars;
13
14           # Check all libs that are listed in the MANIFEST file
15           all_vars_ok();
16
17           # Check an arbitrary file
18           vars_ok('t/lib/MyLib.pm');
19
20           # Ignore some variables while checking
21           vars_ok 't/lib/MyLib2.pm', ignore_vars => [ '$an_unused_var' ];
22

DESCRIPTION

24       Test::Vars provides test functions to report unused variables either in
25       an entire distribution or in some files of your choice in order to keep
26       your source code tidy.
27

INTERFACE

29   Exported
30       all_vars_ok(%args)
31
32       Tests libraries in your distribution with %args.
33
34       libraries are collected from the MANIFEST file.
35
36       If you want to ignore variables, for example $foo, you can tell it to
37       the test routines:
38
39       "ignore_vars => { '$foo' => 1 }"
40       "ignore_vars => [qw($foo)]"
41       "ignore_if => sub{ $_ eq '$foo' }"
42
43       Note that $self will be ignored by default unless you pass explicitly
44       "{ '$self' => 0 }" to "ignore_vars".
45
46       vars_ok($lib, %args)
47
48       Tests $lib with %args.
49
50       See "all_vars_ok".
51
52   test_vars($lib, $result_handler, %args)
53       This subroutine tests variables, but instead of outputting TAP, calls
54       the $result_handler subroutine reference provided with the results of
55       the test.
56
57       The $result_handler sub will be called once, with the following
58       arguments:
59
60       ·   $filename
61
62           The file that was checked for unused variables.
63
64       ·   $exit_code
65
66           The value of $? from the child process that actually did the tests.
67           This will be 0 if the tests passed.
68
69       ·   $results
70
71           This is an array reference which in turn contains zero or more
72           array references. Each of those references contains two elements, a
73           Test::Builder method, either "diag" or "note", and a message.
74
75           If the method is "diag", the message contains an actual error. If
76           the method is "notes", the message contains extra information about
77           the test, but is not indicative of an error.
78

MECHANISM

80       "Test::Vars" is similar to a part of "Test::Perl::Critic",but the
81       mechanism is different.
82
83       While "Perl::Critic", the backend of "Test::Perl::Critic", scans the
84       source code as text, this modules scans the compiled opcodes (or AST:
85       abstract syntax tree) using the "B" module. See also "B" and its
86       submodules.
87

CONFIGURATION

89       "TEST_VERBOSE = 1 | 2 " shows the way this module works.
90

CAVEATS

92       https://rt.cpan.org/Ticket/Display.html?id=60018
93
94       https://rt.cpan.org/Ticket/Display.html?id=82411
95

DEPENDENCIES

97       Perl 5.10.0 or later.
98

BUGS

100       All complex software has bugs lurking in it, and this module is no
101       exception. If you find a bug please either email me, or add the bug to
102       cpan-RT.
103

SEE ALSO

105       Perl::Critic
106
107       warnings::unused
108
109       B
110
111       Test::Builder::Module
112

AUTHOR

114       Goro Fuji (gfx) <gfuji(at)cpan.org>
115
117       Copyright (c) 2010, Goro Fuji (gfx). All rights reserved.
118
119       This library is free software; you can redistribute it and/or modify it
120       under the same terms as Perl itself. See perlartistic for details.
121
122
123
124perl v5.32.0                      2020-07-28                   Test::Vars(3pm)
Impressum