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
cmp_ok($foo, "ne", "") gives the wrong expected value #6
Comments
Test2 has a new and different problem!
|
ok, the table should show so that needs to be fixed. not sure if you were implying the warning was a bug, the warning should be there, and as expected it is warning from the caller. trying to 'eq' against undef is usually a mistake and the warning is good. |
My thoughts after seeing this is the warning aught to be part of the test output so its clear what its attached to.
Or something. |
Also in other cases where there's string overload, you'd probably want some sort of "no-overload" depiction of the terms for clarity. ( That is, showing both the stringified value in the comparison, and the sources of those stringified values for clarity ) |
The warning is fine. It's showing two blanks that doesn't help debug the problem. What I would expect to see is something like:
The most important part is to display the Anyhow, I don't think it's worth the hassle of fixing this in Test::More. |
I thought that as well at first, but then I realised maybe that's not really optimal for this table. Its optimal-ish for this case, but when you start getting into escaping, line feeds and UTF8 Characters, forcing it to be displayed in a dumper-esque format might be more trouble than its worth. Another errant thought I had was to display a secondary table, and so horrible cases like: cmp_ok( undef, 'ne', bless( %thing, "classname" )) where "classname" has string overloads would do:
Because clearly, neither the first row or the second row of this table is illuminating on its own. |
I think empty strings, and strings that are only space characters (as in ascii space, not tabs, or other whitespace), should be quoted in the table. any other strings render sanely and I do not want to add quotes. |
How are you going to differentiate between
and
|
And before you ask.
We should move this discussion to Test-More/Test2-Suite#60 |
The test2 related bits of this should be moved to a ticket in Test2::Suite. This ticket only covers cmp_ok in Test::More. |
- Set the TEST_ACTIVE env var to true - Set the TEST2_ACTIVE env var to true - Fix the oldest bug still in the bug list (#6) This fixes cmp_ok output is some confusing cases - Update travis config - Add missing author deps - Fix handling of negative pid's on windows - Add can() to Test::Tester::Delegate (despite deprecation) - Fix some minor test issues
What steps will reproduce the problem?
What is the expected output?
That would be a start, but it loses the fact that this is an "ne" test. So
this would be better:
What do you see instead?
Is this to be a special case for undef, or should it apply to all 'isnt'
comparisons? If the latter, should it apply to 'is' comparisons as well?
It will occur any time the thing on the left and right are not the same, and yet are
still equal. Another example is 0 and 0.0.
We got 0 but we expected 0.0.
The problem with the isnt() diagnostics is that it assumes that on failure what we
got is the same as what we expected. is() does not have this problem because it
shows what we got and what we expected.
Makes sense.
I've fixed this in http://github.com/gaurav/test-more/tree/issue36, but, since
'cmp_ok' throws a warning when 'undef' values are used, my new test produces these
warnings as well. Should I use $SIG{WARN} to surpress these warning messages, or
fix 'cmp_ok' to handle 'undef' correctly? I tried to do the latter, but t/undef.t
specifically checks for that warning, and I didn't want to break it in case somebody
depends on it.
The text was updated successfully, but these errors were encountered: