From: Rafael Garcia-Suarez Date: Wed, 4 Mar 2009 19:40:59 +0000 (+0100) Subject: Remove TODO tests about && in when() clauses X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aa2407c5c40c18416d30710d13b3c1423d0bb212;p=p5sagit%2Fp5-mst-13.2.git Remove TODO tests about && in when() clauses when() actually behaves as documented in perlsyn. It treats "E1 && E2" expressions as booleans only if E1 is boolean, and if not, it does the equivalent of the smart match expression "$_ ~~ (E1 && E2)". As long as the ~~ operator is not expected to distribute boolean expressions found on its right side, the current behaviour of perl is correct. So, should we expect ~~ to distribute boolean expressions ? Given that this would be rather complex to implement and test correctly with complex expressions, given that we don't expect =~ to distribute either, and given that when() is already quite smart regarding boolean operators, I see no motivation for that feature. This allows to close bug #50538 as "won't fix". --- diff --git a/t/op/switch.t b/t/op/switch.t index f54f6c4..5568cb0 100644 --- a/t/op/switch.t +++ b/t/op/switch.t @@ -8,7 +8,7 @@ BEGIN { use strict; use warnings; -use Test::More tests => 112; +use Test::More tests => 109; # 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 @@ -529,69 +529,6 @@ sub bar {"bar"} 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 && - my @n = qw(fred barney betty); - my @m = @n; - - my $ok = 0; - given( "fred" ) { - when( @n ) { - $ok++; continue; - } - when( @m ) { - $ok++; continue; - } - when( @m && @n ) { - $ok++; - } - } - - is($ok, 3, '(@n && @m) smart-matched'); - } - - { # this should smart match on each side of && - my @n = qw(fred barney betty); - my %n = map { $_, 1 } @n; - - my $ok = 0; - given( "fred" ) { - when( @n ) { - $ok++; continue; - } - when( %n ) { - $ok++; continue; - } - when( @n && %n ) { - $ok++; - } - } - - is($ok, 3, '(@n && %n) smart-matched'); - } - - { # this should smart match on each side of && - my %n = map { $_, 1 } qw(fred barney betty); - my %m = %n; - - my $ok = 0; - given( "fred" ) { - when( %m ) { - $ok++; continue; - } - when( %n ) { - $ok++; continue; - } - when( %m && %n ) { - $ok++; - } - } - - is($ok, 3, '(%m && %n) smart-matched'); - } -} - # Make sure we aren't invoking the get-magic more than once { # A helper class to count the number of accesses.