parser panics on lvalue methods
[p5sagit/p5-mst-13.2.git] / t / op / chop.t
index 3516c2d..e8b777e 100755 (executable)
@@ -1,8 +1,6 @@
 #!./perl
 
-# $RCSfile: chop.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:40 $
-
-print "1..22\n";
+print "1..41\n";
 
 # optimized
 
@@ -70,3 +68,61 @@ $_ = "f";
 $/ = "";
 print chomp() == 0 ? "ok 21\n" : "not ok 21\n";
 print $_ eq "f" ? "ok 22\n" : "not ok 22\n";
+
+$_ = "xx";
+$/ = "xx";
+print chomp() == 2 ? "ok 23\n" : "not ok 23\n";
+print $_ eq "" ? "ok 24\n" : "not ok 24\n";
+
+$_ = "axx";
+$/ = "xx";
+print chomp() == 2 ? "ok 25\n" : "not ok 25\n";
+print $_ eq "a" ? "ok 26\n" : "not ok 26\n";
+
+$_ = "axx";
+$/ = "yy";
+print chomp() == 0 ? "ok 27\n" : "not ok 27\n";
+print $_ eq "axx" ? "ok 28\n" : "not ok 28\n";
+
+# This case once mistakenly behaved like paragraph mode.
+$_ = "ab\n";
+$/ = \3;
+print chomp() == 0 ? "ok 29\n" : "not ok 29\n";
+print $_ eq "ab\n" ? "ok 30\n" : "not ok 30\n";
+
+# Go Unicode.
+
+$_ = "abc\x{1234}";
+chop;
+print $_ eq "abc" ? "ok 31\n" : "not ok 31\n";
+
+$_ = "abc\x{1234}d";
+chop;
+print $_ eq "abc\x{1234}" ? "ok 32\n" : "not ok 32\n";
+
+$_ = "\x{1234}\x{2345}";
+chop;
+print $_ eq "\x{1234}" ? "ok 33\n" : "not ok 33\n";
+
+my @stuff = qw(this that);
+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";