Object Any invokes ~~ overloading on $object, or falls back:
Any Num numeric equality $a == $b
Num numish[4] numeric equality $a == $b
+ undef Any undefined !defined($b)
Any Any string equality $a eq $b
1 - empty hashes or arrays will match.
SP -= 2;
goto sm_any_scalar;
}
+ else if (!SvOK(d)) {
+ /* undef ~~ scalar ; we already know that the scalar is SvOK */
+ RETPUSHNO;
+ }
else
sm_any_scalar:
if (SvNIOK(e) || (SvPOK(e) && looks_like_number(e) && SvNIOK(d))) {
my %fooormore = map { $_ => 0 } @fooormore;
# Load and run the tests
-plan tests => 314;
+plan tests => 322;
while (<DATA>) {
next if /^#/ || !/\S/;
["foo", "bar"] [["foo"], ["bar"]]
! ["foo", "bar"] [qr/o/, "foo"]
["foo", undef, "bar"] [qr/o/, undef, "bar"]
- ["foo", undef, "bar"] [qr/o/, "", "bar"]
+! ["foo", undef, "bar"] [qr/o/, "", "bar"]
! ["foo", "", "bar"] [qr/o/, undef, "bar"]
$deep1 $deep1
@$deep1 @$deep1
! undef [1, 2, [undef], 4]
! undef @fooormore
undef @sparse
+ undef [undef]
+! 0 [undef]
+! "" [undef]
+! undef [0]
+! undef [""]
# - nested arrays and ~~ distributivity
11 [[11]]
! 2 3
0 FALSE
3-2 TRUE
- undef 0
+! undef 0
+! (my $u) 0
# Number against string
= 2 "2"
! 2 "2bananas"
!= 2_3 "2_3" NOWARNINGS
FALSE "0"
+! undef "0"
+! undef ""
# Regex against string
"x" qr/x/
}
{
no warnings "uninitialized";
- my $ok = 0;
- given (undef) { when(0) {$ok = 1} }
+ my $ok = 1;
+ given (undef) { when(0) {$ok = 0} }
is($ok, 1, "Given(undef) when(0)");
}
{
no warnings "uninitialized";
my $undef;
- my $ok = 0;
- given ($undef) { when(0) {$ok = 1} }
+ my $ok = 1;
+ given ($undef) { when(0) {$ok = 0} }
is($ok, 1, 'Given($undef) when(0)');
}
########
}
{
no warnings "uninitialized";
- my $ok = 0;
- given (undef) { when("") {$ok = 1} }
+ my $ok = 1;
+ given (undef) { when("") {$ok = 0} }
is($ok, 1, 'Given(undef) when("")');
}
{
no warnings "uninitialized";
my $undef;
- my $ok = 0;
- given ($undef) { when("") {$ok = 1} }
+ my $ok = 1;
+ given ($undef) { when("") {$ok = 0} }
is($ok, 1, 'Given($undef) when("")');
}
########