summaryrefslogtreecommitdiff
path: root/t/op/switch.t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-05-12 09:38:29 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-05-12 09:38:29 +0200
commitf118ea0d484695c3af550a63cea6055340ab67d7 (patch)
tree21fce9240eeb9d81de8c1d5f8622c7cbdd0f928e /t/op/switch.t
parentea0c2dbd5f5ac6845ecc7ec6696415bf8e27bd52 (diff)
downloadperl-f118ea0d484695c3af550a63cea6055340ab67d7.tar.gz
Remove proposed (but unimplemented) $foo ~~ Range smart matching.
The reasons for that are : - $_ ~~ 1..42 actually parses as ($_ ~~ 1) .. 42 - in when(), a range 1..42 will be expanded, and not treated as a boolean flip-flop operator - It will not distribute properly with array smart-matching, as in $foo ~~ [1, 2, [4..5]] (that won't match for $foo = 4.2 for example.)
Diffstat (limited to 't/op/switch.t')
-rw-r--r--t/op/switch.t13
1 files changed, 12 insertions, 1 deletions
diff --git a/t/op/switch.t b/t/op/switch.t
index 9ca4f133c2..79b379737b 100644
--- a/t/op/switch.t
+++ b/t/op/switch.t
@@ -8,7 +8,7 @@ BEGIN {
use strict;
use warnings;
-use Test::More tests => 118;
+use Test::More tests => 122;
# 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
@@ -517,6 +517,17 @@ sub notfoo {"bar"}
my $n = 0;
for my $l qw(a b c d) {
given ($l) {
+ when ($_ eq "b" .. $_ eq "c") { $n = 1 }
+ default { $n = 0 }
+ }
+ ok(($n xor $l =~ /[ad]/), 'when(E1..E2) evaluates in boolean context');
+ }
+}
+
+{
+ my $n = 0;
+ for my $l qw(a b c d) {
+ given ($l) {
when ($_ eq "b" ... $_ eq "c") { $n = 1 }
default { $n = 0 }
}