X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fsplice.t;h=6d9b71f06474a4451cc59e970d18c9d6aba48a76;hb=3511154c18a0900e8873e8e72a4b74931525e718;hp=06e350988d01ff8f015b6ae1c511f19d3d147f40;hpb=95a449b8d7e85665d931cb07abe3a369141c3170;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/splice.t b/t/op/splice.t index 06e3509..6d9b71f 100755 --- a/t/op/splice.t +++ b/t/op/splice.t @@ -1,6 +1,6 @@ #!./perl -print "1..9\n"; +print "1..12\n"; @a = (1..10); @@ -21,7 +21,7 @@ print "ok 4\n"; print "not " unless j(splice(@a,5,1,5)) eq "5" && j(@a) eq j(0..11); print "ok 5\n"; -print "not " unless j(splice(@a, 20, 0, 12, 13)) eq "" && j(@a) eq j(0..13); +print "not " unless j(splice(@a, @a, 0, 12, 13)) eq "" && j(@a) eq j(0..13); print "ok 6\n"; print "not " unless j(splice(@a, -@a, @a, 1, 2, 3)) eq j(0..13) && j(@a) eq j(1..3); @@ -32,3 +32,23 @@ print "ok 8\n"; print "not " unless j(splice(@a,-3,-2,2)) eq j(7) && j(@a) eq j(1,2,7,3); print "ok 9\n"; + +# Bug 20000223.001 - no test for splice(@array). Destructive test! +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"; +