houseabsolute / p5-Test-Vars

Detects unused variables in unit tests
https://metacpan.org/pod/Test::Vars
Other
6 stars 10 forks source link

Show problem with vars_ok() re lexicals declared outside sub def #59

Open jkeenan opened 1 month ago

jkeenan commented 1 month ago

NOTE: This patch is for research; it's not ready to be committed to master.

In https://github.com/houseabsolute/p5-Test-Vars/issues/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');