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
calls .Str on the comparison operator if the test fails, causing a warning.
#5348
Comments
From magnolia.k@me.comA warning message is displayed when the test using the 'cmp-ok' failed. $ cat cmp.t cmp-ok(1, '==', 2); done-testing; $ perl6 cmp.t # Failed test at cmp.t line 4 In cmp-ok of Test.pm, as pointed out in the warning message, it seems to be because trying to display the code reference. multi sub cmp-ok(Mu $got, $op, Mu $expected, $desc = '') is export { ... if $op ~~ Callable ?? $op !! try EVAL "&infix:<$op>" -> $matcher { |
From @zoffixznet<Zoffix> m: use Test; cmp-ok 5, &[<], 3; |
From @smlsNeither Roast nor p6doc currently promise support for passing anything other than a string to the $op parameter of &cmp-ok. S24 also only shows the Str case explicitly, but vaguely alludes to "passing a custom operator", which I suppose refers to passing a Callable object to $op like you're tying to do: The cmp-ok() function compares two values with the given operator I'm changing the title of this ticket to make it clear that this is a speculated feature that has not yet been implemented. |
From @smlsEh I was wrong, it *is* implemented and works fine if the test passes - it's just when the test fails, that it tries to coerce $op to a string for the diagnostics message: cmp-ok 5, &[<], 6; # works fine As the warning says, the code that prints the diagnostics message should probably check if $op is Callable, and if so use .name instead of .Str to stringify it. (Changing the ticket title again.) |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznetPR to fix this has been submitted: rakudo/rakudo#777 |
From @zoffixznetMerged in commit rakudo/rakudo@4a7eaa0 |
@zoffixznet - Status changed from 'open' to 'resolved' |
From @zoffixznetThis is fixed in rakudo/rakudo@4a7eaa0 Can be closed. |
The RT System itself - Status changed from 'new' to 'open' |
Migrated from rt.perl.org#128284 (status was 'resolved')
Searchable as RT128284$
The text was updated successfully, but these errors were encountered: