Subject: | dualvar scalars is only compared for string equality |
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 |
#!/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;