X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fchop.t;h=e8b777eb6a4e911275c2d22ffa78062b61b6e97d;hb=a4c04bdcc508b6a45f83e703d0f82401445aa55b;hp=9edddedaf741efbc91f2ae9440cdb511187020bb;hpb=37ce32a705db2abf918fb9f1a8653161f4a1806f;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/chop.t b/t/op/chop.t index 9eddded..e8b777e 100755 --- a/t/op/chop.t +++ b/t/op/chop.t @@ -1,6 +1,6 @@ #!./perl -print "1..34\n"; +print "1..41\n"; # optimized @@ -104,6 +104,25 @@ $_ = "\x{1234}\x{2345}"; chop; print $_ eq "\x{1234}" ? "ok 33\n" : "not ok 33\n"; -# TODO! Make sure chop(LIST) returns the right value. my @stuff = qw(this that); -print chop(@stuff[0,1]) eq 't' ? "ok 34 # TODO\n" : "not ok 34 # TODO\n"; +print chop(@stuff[0,1]) eq 't' ? "ok 34\n" : "not ok 34\n"; + +# bug id 20010305.012 +@stuff = qw(ab cd ef); +print chop(@stuff = @stuff) eq 'f' ? "ok 35\n" : "not ok 35\n"; + +@stuff = qw(ab cd ef); +print chop(@stuff[0, 2]) eq 'f' ? "ok 36\n" : "not ok 36\n"; + +my %stuff = (1..4); +print chop(@stuff{1, 3}) eq '4' ? "ok 37\n" : "not ok 37\n"; + +# chomp should not stringify references unless it decides to modify them +$_ = []; +$/ = "\n"; +print chomp() == 0 ? "ok 38\n" : "not ok 38\n"; +print ref($_) eq "ARRAY" ? "ok 39\n" : "not ok 39\n"; + +$/ = ")"; # the last char of something like "ARRAY(0x80ff6e4)" +print chomp() == 1 ? "ok 40\n" : "not ok 40\n"; +print !ref($_) ? "ok 41\n" : "not ok 41\n";