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 ignores the final missing var #43

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

vars_ok ignores the final missing var #43

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;

sub foo {
    my $foo_scalar;
    my %foo_hash;
    my @foo_array;
    my @foo9;
}

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;

And when I run it, I get three errors, not four.

$ prove foo.t
[11:15:13] foo.t .. 1/1
#   Failed test 'lib/foo.pm'
#   at foo.t line 13.
# $foo_scalar is used once in &foo::foo at lib/foo.pm line 8
# %foo_hash is used once in &foo::foo at lib/foo.pm line 8
# @foo_array is used once in &foo::foo at lib/foo.pm line 10
# Looks like you failed 1 test of 1.
[11:15:13] foo.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
[11:15:13]

Test Summary Report
-------------------
foo.t (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=1,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.06 cusr  0.01 csys =  0.10 CPU)
Result: FAIL

If I change foo.pm to only have my $foo_scalar; in the sub, the test passes.

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