in reply to Test::More fails...
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Test::More fails...
by Bod (Parson) on May 30, 2023 at 09:20 UTC | |
by haukex (Archbishop) on May 30, 2023 at 12:19 UTC | |
by Bod (Parson) on May 30, 2023 at 13:13 UTC | |
by haukex (Archbishop) on May 30, 2023 at 13:40 UTC | |
by hippo (Archbishop) on May 30, 2023 at 13:49 UTC |