switch(o->op_type) {
case OP_OR:
+ case OP_DOR:
return looks_like_bool(cLOGOPo->op_first);
case OP_AND:
case OP_ENTERSUB:
case OP_NOT: case OP_XOR:
- /* Note that OP_DOR is not here */
case OP_EQ: case OP_NE: case OP_LT:
case OP_GT: case OP_LE: case OP_GE:
}
when (\&complicated_check) {
- say 'complicated_check($foo) is true';
+ say 'a complicated check for $foo is true';
}
default {
=item *
a regular expression match, i.e. C</REGEX/> or C<$foo =~ /REGEX/>,
-or a negated regular expression match C<$foo !~ /REGEX/>.
+or a negated regular expression match (C<!/REGEX/> or C<$foo !~ /REGEX/>).
=item *
=item *
-A negated expression C<!(...)> or C<not (...)>, or a logical
+a negated expression C<!(...)> or C<not (...)>, or a logical
exclusive-or C<(...) xor (...)>.
=back
-then the value of EXPR is used directly as a boolean.
+In those cases the value of EXPR is used directly as a boolean.
+
Furthermore:
=over 4
-=item o
+=item *
If EXPR is C<... && ...> or C<... and ...>, the test
is applied recursively to both arguments. If I<both>
arguments pass the test, then the argument is treated
as boolean.
-=item o
+=item *
-If EXPR is C<... || ...> or C<... or ...>, the test
+If EXPR is C<... || ...>, C<... // ...> or C<... or ...>, the test
is applied recursively to the first argument.
=back
use strict;
use warnings;
-use Test::More tests => 111;
+use Test::More tests => 112;
# The behaviour of the feature pragma should be tested by lib/switch.t
# using the tests in t/lib/switch/*. This file tests the behaviour of
ok($ok, '((1 == $ok) || "foo") smartmatched');
}
+{
+ my $ok = 0;
+ given("foo") {
+ when((1 == $ok || undef) // "foo") {
+ $ok = 1;
+ }
+ }
+ ok($ok, '((1 == $ok || undef) // "foo") smartmatched');
+}
+
TODO: {
local $TODO = "RT #50538: when( \@n && \%n ) fails to smart match";
{ # this should smart match on each side of &&