diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-05-25 23:59:45 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-05-26 00:18:23 -0700 |
commit | 762dbf22cb22645771fc27b5d197fd40cbbd9da8 (patch) | |
tree | 996e137a38e7dbeccd2719a7c0b09c848ad0d4e0 /t/op/not.t | |
parent | ab830aa00cac1e0b1157a24d5df949dbcfa4dc40 (diff) | |
download | perl-762dbf22cb22645771fc27b5d197fd40cbbd9da8.tar.gz |
[perl #118159] Make PVs take precedence in SvTRUE
Commit 4bac9ae4 (probably inadvertently) changed SvTRUE to treat an SV
with any of PVX, IVX or NVX having a true value as true.
Traditionally, truth was based solely on stringification. The examina-
tion of the SvIVX and SvNVX slots was for those cases where there was
no string already and it could be deduced from IVX or NVX whether it
would stringify as "0" or no (bugs with -0 aside).
This changes things back to the way they have ‘always’ been.
Diffstat (limited to 't/op/not.t')
-rw-r--r-- | t/op/not.t | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/t/op/not.t b/t/op/not.t index 4aae02ca73..8df5774af4 100644 --- a/t/op/not.t +++ b/t/op/not.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 16; +plan tests => 19; # not() tests pass("logical negation of empty list") if not(); @@ -62,3 +62,17 @@ is(! (0, 0), not(0, 0), ok($not0 == 1, "logical negation (low-precedence) of false value is true in numeric context"); } + +# test truth of dualvars +SKIP: +{ + my $got_dualvar; + eval 'use Scalar::Util "dualvar"; $got_dualvar++'; + skip "No Scalar::Util::dualvar", 3 unless $got_dualvar; + my $a = Scalar::Util::dualvar(3, ""); + is not($a), 1, 'not(dualvar) ignores int when string is false'; + my $b = Scalar::Util::dualvar(3.3,""); + is not($b), 1, 'not(dualvar) ignores float when string is false'; + my $c = Scalar::Util::dualvar(0,"1"); + is not($c), "", 'not(dualvar) ignores false int when string is true'; +} |