Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Test::More fails...by hv (Prior) |
on May 29, 2023 at 23:46 UTC ( [id://11152488]=note: print w/replies, xml ) | Need Help?? |
Here's my guess for your first issue: plan tests => 1; is a standard Perl statement, it gets executed at run-time - so it has not yet been executed when you hit the BEGIN block and launch in to your first test. You could work around this by also putting the plan statement in a BEGIN block. However use Module (foo); is equivalent to BEGIN { require Module; Module->import(foo) }. So its action occurs at BEGIN time, just as required for this case. I don't have an immediate guess for the second issue. If I were debugging this, my next steps would be a) to run the test program in isolation for more verbose output; then b) to use Devel::Peek to Dump($comp_pass2) directly after setting it - I can think of several types of value that would stringify as "1" but give a false result from $comp_pass2 == 1. However your expectation of the function also seems odd: normally I would expect a comparator to return similar values to $a cmp $b or $a <=> $b, in particular returning 0 when the two values are equal. With your lengthy test strings it is hard to tell by eye, but I think they are the same.
In Section
Seekers of Perl Wisdom
|
|