#define SvTRUE_common(sv,fallback) ( \
!SvOK(sv) \
? 0 \
- : (SvFLAGS(sv) & (SVf_POK|SVf_IOK|SVf_NOK)) \
- ? ( (SvPOK(sv) && SvPVXtrue(sv)) \
- || (SvIOK(sv) && SvIVX(sv) != 0) \
+ : SvPOK(sv) \
+ ? SvPVXtrue(sv) \
+ : (SvFLAGS(sv) & (SVf_IOK|SVf_NOK)) \
+ ? ( (SvIOK(sv) && SvIVX(sv) != 0) \
|| (SvNOK(sv) && SvNVX(sv) != 0.0)) \
: (fallback))
require './test.pl';
}
-plan tests => 16;
+plan tests => 19;
# not() tests
pass("logical negation of empty list") if not();
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';
+}