Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Deep CPAN distribution.

Report information
The Basics
Id: 61749
Status: rejected
Priority: 0/
Queue: Test-Deep

People
Owner: Nobody in particular
Requestors: peter [...] makholm.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.106
Fixed in: (no value)



Subject: dualvar scalars is only compared for string equality
Download (untitled) / with headers
text/plain 472b
When comparing structures containing dualvar scalars only the string value is compared. This happens both with dualvars created by Scalar::Util::dualvar() and for variables like $!. This might be acceptable but then I believe it should be documented as a limitation of the module. Attached is some test-cases showing the issue. I am not sure what the correct and expected handling would be, but most likely that either all of them fail or that all of them succeedes.
Subject: dualvar.t
Download dualvar.t
text/x-perl 555b
#!/usr/bin/perl use Test::More tests => 4; use Test::Deep; use Scalar::Util; my $dual = Scalar::Util::dualvar(42, "The Answer"); cmp_deeply({a => $dual }, {a => 42 }, "dualvar being equal to the numeric value"); cmp_deeply({a => $dual }, {a => "The Answer" }, "dualvar being equal to the string value"); $! = 1; cmp_deeply( { error => $! }, { error => 1 }, "errno being equeal to the numeric value"); cmp_deeply( { error => $! }, { error => "Operation not permitted" }, "errno being equal to the string value"); 1;
Download (untitled) / with headers
text/plain 407b
On Wed Sep 29 03:15:15 2010, pmakholm wrote: Show quoted text
> When comparing structures containing dualvar scalars only the string > value is compared. This happens both with dualvars created by > Scalar::Util::dualvar() and for variables like $!. > > This might be acceptable but then I believe it should be documented as > a limitation of the module.
IMHO if a value is dualvar'd, both comparisons should be performed.
Download (untitled) / with headers
text/plain 457b
I disagree. The behavior for a defined non-reference in expectations is to use shallow, which uses eq. I think that is simple and correct. This is easy to write if needed: cmp_deeply( {a => $dual }, {a => all(num(42), str('The Answer')) }, "dualvar being equal to the numeric value" ); It's also possible to write a dualvar() test and to make it the local default for leaf comparisons. I'm going to leave this behavior as is. -- rjbs


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.