Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vars_ok does not find lexicals that aren't in a sub #44

Open
petdance opened this issue Feb 24, 2022 · 0 comments
Open

vars_ok does not find lexicals that aren't in a sub #44

petdance opened this issue Feb 24, 2022 · 0 comments
Labels

Comments

@petdance
Copy link

Here's my lib/foo.pm

package foo;

my $scalar;
my %hash;
my @array;

1;

and here's my foo.t

#!/usr/bin/perl

use warnings;
use strict;
use 5.010;
use experimental 'signatures';

use Test::More tests => 1;

use Test::Vars;

vars_ok( 'lib/foo.pm' );

exit 0;

When I run the test, the test passes, although there are three unused vars in lib/foo.pm.

@jkeenan jkeenan added the Bug label Sep 12, 2024
jkeenan added a commit to jkeenan/p5-Test-Vars that referenced this issue Sep 13, 2024
NOTE: This patch is for research; it's not ready to be committed to
master.

In houseabsolute#44, it was
argued that vars_ok() should have failed on a .pm file that simply
declared three 'my' variables but never used them and never did anything
else.  vars_ok() returns '1' (as do the previous invocations of
vars_ok() in the test file) where we would have expected it to return a
Perl-false value.

This patch attempts to bring that observation into the test suite in the
form of a TODO test.  However, we're hampered by the fact that the
return value of vars_ok() is at best opaquely documented.  What we
really need is a function along the lines of:

    vars_not_expected_to_be_ok('path/to/file');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants