diff options
author | Abigail <abigail@abigail.be> | 2008-01-24 00:53:25 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-24 10:08:04 +0000 |
commit | 4b70616db4b88e90e04bbf6a612b803f6a4d8dc1 (patch) | |
tree | 80c6f89e90f7e4356c8cd8b52e89ed76db6a0ed7 /t | |
parent | 3b719c58b6800b0db9786a0d03d9b07e39a8b70f (diff) | |
download | perl-4b70616db4b88e90e04bbf6a612b803f6a4d8dc1.tar.gz |
Regression tests for 'for reverse ..'
Message-ID: <20080123225325.GA25959@abigail.be>
Date: Wed, 23 Jan 2008 23:53:25 +0100
p4raw-id: //depot/perl@33058
Diffstat (limited to 't')
-rwxr-xr-x | t/cmd/for.t | 192 |
1 files changed, 191 insertions, 1 deletions
diff --git a/t/cmd/for.t b/t/cmd/for.t index ccd042426b..5593f9b630 100755 --- a/t/cmd/for.t +++ b/t/cmd/for.t @@ -1,6 +1,6 @@ #!./perl -print "1..80\n"; +print "1..118\n"; for ($i = 0; $i <= 10; $i++) { $x[$i] = $i; @@ -129,6 +129,16 @@ for (map {$_} 1,2,3) { $r .= $_; } is ($r, '123', 'Forwards for list via map'); +$r = ''; +for (1 .. 3) { + $r .= $_; +} +is ($r, '123', 'Forwards for list via ..'); +$r = ''; +for ('A' .. 'C') { + $r .= $_; +} +is ($r, 'ABC', 'Forwards for list via ..'); $r = ''; for (reverse @array) { @@ -150,6 +160,16 @@ for (reverse map {$_} 1,2,3) { $r .= $_; } is ($r, '321', 'Reverse for list via map'); +$r = ''; +for (reverse 1 .. 3) { + $r .= $_; +} +is ($r, '321', 'Reverse for list via ..'); +$r = ''; +for (reverse 'A' .. 'C') { + $r .= $_; +} +is ($r, 'CBA', 'Reverse orwards for list via ..'); $r = ''; for my $i (@array) { @@ -171,6 +191,16 @@ for my $i (map {$_} 1,2,3) { $r .= $i; } is ($r, '123', 'Forwards for list via map with var'); +$r = ''; +for my $i (1 .. 3) { + $r .= $i; +} +is ($r, '123', 'Forwards for list via .. with var'); +$r = ''; +for my $i ('A' .. 'C') { + $r .= $i; +} +is ($r, 'ABC', 'Forwards for list via .. with var'); $r = ''; for my $i (reverse @array) { @@ -192,6 +222,16 @@ for my $i (reverse map {$_} 1,2,3) { $r .= $i; } is ($r, '321', 'Reverse for list via map with var'); +$r = ''; +for my $i (reverse 1 .. 3) { + $r .= $i; +} +is ($r, '321', 'Reverse for list via .. with var'); +$r = ''; +for my $i (reverse 'A' .. 'C') { + $r .= $i; +} +is ($r, 'CBA', 'Reverse for list via .. with var'); # For some reason the generate optree is different when $_ is implicit. $r = ''; @@ -214,6 +254,16 @@ for $_ (map {$_} 1,2,3) { $r .= $_; } is ($r, '123', 'Forwards for list via map with explicit $_'); +$r = ''; +for $_ (1 .. 3) { + $r .= $_; +} +is ($r, '123', 'Forwards for list via .. with var with explicit $_'); +$r = ''; +for $_ ('A' .. 'C') { + $r .= $_; +} +is ($r, 'ABC', 'Forwards for list via .. with var with explicit $_'); $r = ''; for $_ (reverse @array) { @@ -235,6 +285,16 @@ for $_ (reverse map {$_} 1,2,3) { $r .= $_; } is ($r, '321', 'Reverse for list via map with explicit $_'); +$r = ''; +for $_ (reverse 1 .. 3) { + $r .= $_; +} +is ($r, '321', 'Reverse for list via .. with var with explicit $_'); +$r = ''; +for $_ (reverse 'A' .. 'C') { + $r .= $_; +} +is ($r, 'CBA', 'Reverse for list via .. with var with explicit $_'); # I don't think that my is that different from our in the optree. But test a # few: @@ -258,6 +318,16 @@ for our $i (reverse map {$_} 1,2,3) { $r .= $i; } is ($r, '321', 'Reverse for list via map with our var'); +$r = ''; +for our $i (reverse 1 .. 3) { + $r .= $i; +} +is ($r, '321', 'Reverse for list via .. with our var'); +$r = ''; +for our $i (reverse 'A' .. 'C') { + $r .= $i; +} +is ($r, 'CBA', 'Reverse for list via .. with our var'); $r = ''; @@ -280,6 +350,16 @@ for ('A', reverse map {$_} 1,2,3) { $r .= $_; } is ($r, 'A321', 'Reverse for list via map with leading value'); +$r = ''; +for ('A', reverse 1 .. 3) { + $r .= $_; +} +is ($r, 'A321', 'Reverse for list via .. with leading value'); +$r = ''; +for (1, reverse 'A' .. 'C') { + $r .= $_; +} +is ($r, '1CBA', 'Reverse for list via .. with leading value'); $r = ''; for (reverse (@array), 1) { @@ -301,6 +381,16 @@ for (reverse (map {$_} 1,2,3), 'A') { $r .= $_; } is ($r, '321A', 'Reverse for list via map with trailing value'); +$r = ''; +for (reverse (1 .. 3), 'A') { + $r .= $_; +} +is ($r, '321A', 'Reverse for list via .. with trailing value'); +$r = ''; +for (reverse ('A' .. 'C'), 1) { + $r .= $_; +} +is ($r, 'CBA1', 'Reverse for list via .. with trailing value'); $r = ''; @@ -324,6 +414,16 @@ for $_ ('A', reverse map {$_} 1,2,3) { $r .= $_; } is ($r, 'A321', 'Reverse for list via map with leading value with explicit $_'); +$r = ''; +for $_ ('A', reverse 1 .. 3) { + $r .= $_; +} +is ($r, 'A321', 'Reverse for list via .. with leading value with explicit $_'); +$r = ''; +for $_ (1, reverse 'A' .. 'C') { + $r .= $_; +} +is ($r, '1CBA', 'Reverse for list via .. with leading value with explicit $_'); $r = ''; for $_ (reverse (@array), 1) { @@ -347,6 +447,16 @@ for $_ (reverse (map {$_} 1,2,3), 'A') { } is ($r, '321A', 'Reverse for list via map with trailing value with explicit $_'); +$r = ''; +for $_ (reverse (1 .. 3), 'A') { + $r .= $_; +} +is ($r, '321A', 'Reverse for list via .. with trailing value with explicit $_'); +$r = ''; +for $_ (reverse ('A' .. 'C'), 1) { + $r .= $_; +} +is ($r, 'CBA1', 'Reverse for list via .. with trailing value with explicit $_'); $r = ''; for my $i (1, reverse @array) { @@ -368,6 +478,16 @@ for my $i ('A', reverse map {$_} 1,2,3) { $r .= $i; } is ($r, 'A321', 'Reverse for list via map with leading value and var'); +$r = ''; +for my $i ('A', reverse 1 .. 3) { + $r .= $i; +} +is ($r, 'A321', 'Reverse for list via .. with leading value and var'); +$r = ''; +for my $i (1, reverse 'A' .. 'C') { + $r .= $i; +} +is ($r, '1CBA', 'Reverse for list via .. with leading value and var'); $r = ''; for my $i (reverse (@array), 1) { @@ -389,6 +509,16 @@ for my $i (reverse (map {$_} 1,2,3), 'A') { $r .= $i; } is ($r, '321A', 'Reverse for list via map with trailing value and var'); +$r = ''; +for my $i (reverse (1 .. 3), 'A') { + $r .= $i; +} +is ($r, '321A', 'Reverse for list via .. with trailing value and var'); +$r = ''; +for my $i (reverse ('A' .. 'C'), 1) { + $r .= $i; +} +is ($r, 'CBA1', 'Reverse for list via .. with trailing value and var'); $r = ''; @@ -401,6 +531,26 @@ for (reverse map {$_} 1, @array) { $r .= $_; } is ($r, 'CBA1', 'Reverse for value and array via map'); +$r = ''; +for (reverse 1 .. 3, @array) { + $r .= $_; +} +is ($r, 'CBA321', 'Reverse for .. and array'); +$r = ''; +for (reverse 'X' .. 'Z', @array) { + $r .= $_; +} +is ($r, 'CBAZYX', 'Reverse for .. and array'); +$r = ''; +for (reverse map {$_} 1 .. 3, @array) { + $r .= $_; +} +is ($r, 'CBA321', 'Reverse for .. and array via map'); +$r = ''; +for (reverse map {$_} 'X' .. 'Z', @array) { + $r .= $_; +} +is ($r, 'CBAZYX', 'Reverse for .. and array via map'); $r = ''; for (reverse (@array, 1)) { @@ -423,6 +573,26 @@ for $_ (reverse map {$_} 1, @array) { $r .= $_; } is ($r, 'CBA1', 'Reverse for value and array via map with explicit $_'); +$r = ''; +for $_ (reverse 1 .. 3, @array) { + $r .= $_; +} +is ($r, 'CBA321', 'Reverse for .. and array with explicit $_'); +$r = ''; +for $_ (reverse 'X' .. 'Z', @array) { + $r .= $_; +} +is ($r, 'CBAZYX', 'Reverse for .. and array with explicit $_'); +$r = ''; +for $_ (reverse map {$_} 1 .. 3, @array) { + $r .= $_; +} +is ($r, 'CBA321', 'Reverse for .. and array via map with explicit $_'); +$r = ''; +for $_ (reverse map {$_} 'X' .. 'Z', @array) { + $r .= $_; +} +is ($r, 'CBAZYX', 'Reverse for .. and array via map with explicit $_'); $r = ''; for $_ (reverse (@array, 1)) { @@ -446,6 +616,26 @@ for my $i (reverse map {$_} 1, @array) { $r .= $i; } is ($r, 'CBA1', 'Reverse for value and array via map with var'); +$r = ''; +for my $i (reverse 1 .. 3, @array) { + $r .= $i; +} +is ($r, 'CBA321', 'Reverse for .. and array with var'); +$r = ''; +for my $i (reverse 'X' .. 'Z', @array) { + $r .= $i; +} +is ($r, 'CBAZYX', 'Reverse for .. and array with var'); +$r = ''; +for my $i (reverse map {$_} 1 .. 3, @array) { + $r .= $i; +} +is ($r, 'CBA321', 'Reverse for .. and array via map with var'); +$r = ''; +for my $i (reverse map {$_} 'X' .. 'Z', @array) { + $r .= $i; +} +is ($r, 'CBAZYX', 'Reverse for .. and array via map with var'); $r = ''; for my $i (reverse (@array, 1)) { |