This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In taint.t, add violates_taint(), to replace a repeated is()/like() pair.
[perl5.git] / t / op / reverse.t
index 9cd3ee1..916724c 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 22;
+plan tests => 26;
 
 is(reverse("abc"), "cba");
 
@@ -77,6 +77,10 @@ use Tie::Array;
     @a = reverse @a;
     ok(!exists $a[2] && !exists $a[3]);
     is($a[0] . $a[1] . $a[4], '985');
+
+    tie my @empty, "Tie::StdArray";
+    @empty = reverse @empty;
+    is(scalar(@empty), 0);
 }
 
 {
@@ -87,3 +91,15 @@ use Tie::Array;
     my $c = scalar reverse($b);
     is($a, $c);
 }
+
+{
+    # Lexical $_.
+    sub blurp { my $_ = shift; reverse }
+
+    is(blurp("foo"), "oof");
+    is(sub { my $_ = shift; reverse }->("bar"), "rab");
+    {
+        local $_ = "XXX";
+        is(blurp("paz"), "zap");
+    }
+}