Change 11306 by jhi@alpha on 2001/07/12 13:32:05

        Subject: [ID 20010711.005] in Tie::Array, SPLICE ignores context, breaking 
SHIFT 
        From: [EMAIL PROTECTED]
        Date: Wed, 11 Jul 2001 23:25:47 -0700
        Message-Id: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/lib/Tie/Array.pm#12 edit
... //depot/perl/t/op/splice.t#4 edit

Differences ...

==== //depot/perl/lib/Tie/Array.pm#12 (text) ====
Index: perl/lib/Tie/Array.pm
--- perl/lib/Tie/Array.pm.~1~   Thu Jul 12 07:45:05 2001
+++ perl/lib/Tie/Array.pm       Thu Jul 12 07:45:05 2001
@@ -11,7 +11,6 @@
 sub EXTEND  { }
 sub UNSHIFT { scalar shift->SPLICE(0,0,@_) }
 sub SHIFT { shift->SPLICE(0,1) }
-#sub SHIFT   { (shift->SPLICE(0,1))[0] }
 sub CLEAR   { shift->STORESIZE(0) }
 
 sub PUSH
@@ -70,7 +69,7 @@
     for (my $i=0; $i < @_; $i++) {
         $obj->STORE($off+$i,$_[$i]);
     }
-    return @result;
+    return wantarray ? @result : pop @result;
 }
 
 sub EXISTS {

==== //depot/perl/t/op/splice.t#4 (xtext) ====
Index: perl/t/op/splice.t
--- perl/t/op/splice.t.~1~      Thu Jul 12 07:45:05 2001
+++ perl/t/op/splice.t  Thu Jul 12 07:45:05 2001
@@ -1,6 +1,6 @@
 #!./perl
 
-print "1..10\n";
+print "1..12\n";
 
 @a = (1..10);
 
@@ -37,4 +37,18 @@
 print "not " unless j(splice(@a)) eq j(1,2,7,3) && j(@a) eq '';
 print "ok 10\n";
 
+# Tests 11 and 12:
+# [ID 20010711.005] in Tie::Array, SPLICE ignores context, breaking SHIFT
+
+my $foo;
+
+@a = ('red', 'green', 'blue');
+$foo = splice @a, 1, 2;
+print "not " unless $foo eq 'blue';
+print "ok 11\n";
+
+@a = ('red', 'green', 'blue');
+$foo = shift @a;
+print "not " unless $foo eq 'red';
+print "ok 12\n";
 
End of Patch.

Reply via email to