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
like tests throwing warnings #335
Comments
Thanks for reporting, and double for including a test and digging into the code! Turns out this is a quite deliberate feature added back in 2005. See 8b2f0c6. The idea was to make Now that you've brought it up, I'm not really sure how useful it is because the failure diagnostics clearly tell you that you passed in May I ask, what was your test actually doing when you encountered this? Did it expect to pass undef to |
The problem is only the output that confuses. Searching first in my code where the warning is from. See later that the test modules warns. At least I see that I got an undef in like, that is the problem. I don't know a reason to get ok with undef. |
Could you tell me what confused you about the warning? |
The warning itself, because it exists. And the reason was, I have that warning not expected from Test::More. Thourght that was my own fault fist. That's the reason I wrote confused. |
I've thought about this some more. I'd remove the warning if there was a legit use for deliberately passing OTOH the diagnostics already clearly tell you it's undef, so there's not much point to the warning... So yeah, I'll suppress the uninit warning. |
Not much sense, they can see it in the diagnostics, and the warning message is a bit confusing. Use of uninitialized value $this in pattern match (m//) at x:\test.t line 6. It reports the right location, but there's no $this from the user's perspective. This came in because like used to supress all warnings. That was fixed in 8b2f0c6 but it let uninit warnings slip in. For #335.
see Test-Simple-0.98/lib/Test/Builder.pm line 1407
--- original code ---
$test = eval $context . q{$test = $this =~ /$usable_regex/ ? 1 : 0};
--- change to ---
no warnings qw(uninitialized);
$test = eval $context . q{$test = $this =~ /$usable_regex/ };
You can remove that ? 1 : 0 stuff too because ok expects a boolean and not a numeric.
$test contains already a boolean dual value.
--Steffen
The text was updated successfully, but these errors were encountered: