diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-05-09 15:09:39 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-05-09 15:09:39 +0200 |
commit | 015eb7b967ac690ef0b530c0aa564f080ff0fa4b (patch) | |
tree | cb05349b298f622138b57e1bfc0c2e6b4774ec33 /t/op/smartmatch.t | |
parent | d0b243e39ca09d7da156b4027255b58fa0a84810 (diff) | |
download | perl-015eb7b967ac690ef0b530c0aa564f080ff0fa4b.tar.gz |
Implement distributivity in $scalar ~~ @array
Note that undef ~~ @array is not distributive, it only tests for
definedness of array elements.
Diffstat (limited to 't/op/smartmatch.t')
-rw-r--r-- | t/op/smartmatch.t | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/t/op/smartmatch.t b/t/op/smartmatch.t index 8047451045..2c6e5f1bdf 100644 --- a/t/op/smartmatch.t +++ b/t/op/smartmatch.t @@ -13,6 +13,7 @@ use Tie::Hash; # Predeclare vars used in the tests: my @empty; my %empty; +my @sparse; $sparse[2] = 2; my $deep1 = []; push @$deep1, \$deep1; my $deep2 = []; push @$deep2, \$deep2; @@ -331,7 +332,7 @@ __DATA__ ! /bar/ @fooormore # - a number - 2 [qw(1foo 2bar)] + 2 [qw(1.00 2.00)] 2 [qw(foo 2)] 2.0_0e+0 [qw(foo 2)] ! 2 [qw(1foo bar2)] @@ -340,6 +341,18 @@ __DATA__ ! "2" [qw(1foo 2bar)] "2bar" [qw(1foo 2bar)] +# - undef + undef [1, 2, undef, 4] +! undef [1, 2, [undef], 4] +! undef @fooormore + undef @sparse + +# - nested arrays and ~~ distributivity + 11 [[11]] +! 11 [[12]] + "foo" [{foo => "bar"}] +! "bar" [{foo => "bar"}] + # Number against number 2 2 20 2_0 |