This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make // behave like || in when clauses
[perl5.git] / t / op / switch.t
index 14cf98a..f54f6c4 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
 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
@@ -519,6 +519,16 @@ sub bar {"bar"}
     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 &&