Sys::Syslog patch to allow unix domain sockets
[p5sagit/p5-mst-13.2.git] / t / op / substr.t
old mode 100644 (file)
new mode 100755 (executable)
index 12ad531..e34216f
@@ -1,8 +1,8 @@
 #!./perl
 
-# $Header: substr.t,v 4.0 91/03/20 01:55:05 lwall Locked $
+# $RCSfile: substr.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:31 $
 
-print "1..22\n";
+print "1..25\n";
 
 $a = 'abcdefxyz';
 
@@ -10,7 +10,7 @@ print (substr($a,0,3) eq 'abc' ? "ok 1\n" : "not ok 1\n");
 print (substr($a,3,3) eq 'def' ? "ok 2\n" : "not ok 2\n");
 print (substr($a,6,999) eq 'xyz' ? "ok 3\n" : "not ok 3\n");
 print (substr($a,999,999) eq '' ? "ok 4\n" : "not ok 4\n");
-print (substr($a,6,-1) eq '' ? "ok 5\n" : "not ok 5\n");
+print (substr($a,0,-6) eq 'abc' ? "ok 5\n" : "not ok 5\n");
 print (substr($a,-3,1) eq 'x' ? "ok 6\n" : "not ok 6\n");
 
 $[ = 1;
@@ -19,7 +19,7 @@ print (substr($a,1,3) eq 'abc' ? "ok 7\n" : "not ok 7\n");
 print (substr($a,4,3) eq 'def' ? "ok 8\n" : "not ok 8\n");
 print (substr($a,7,999) eq 'xyz' ? "ok 9\n" : "not ok 9\n");
 print (substr($a,999,999) eq '' ? "ok 10\n" : "not ok 10\n");
-print (substr($a,7,-1) eq '' ? "ok 11\n" : "not ok 11\n");
+print (substr($a,1,-6) eq 'abc' ? "ok 11\n" : "not ok 11\n");
 print (substr($a,-3,1) eq 'x' ? "ok 12\n" : "not ok 12\n");
 
 $[ = 0;
@@ -45,3 +45,24 @@ $a = 'abcdefxyz';
 print (substr($a,6) eq 'xyz' ? "ok 20\n" : "not ok 20\n");
 print (substr($a,-3) eq 'xyz' ? "ok 21\n" : "not ok 21\n");
 print (substr($a,999) eq '' ? "ok 22\n" : "not ok 22\n");
+
+# with lexicals (and in re-entered scopes)
+for (0,1) {
+  my $txt;
+  unless ($_) {
+    $txt = "Foo";
+    substr($txt, -1) = "X";
+    print $txt eq "FoX" ? "ok 23\n" : "not ok 23\n";
+  }
+  else {
+    substr($txt, 0, 1) = "X";
+    print $txt eq "X" ? "ok 24\n" : "not ok 24\n";
+  }
+}
+
+# coersion of references
+{
+  my $s = [];
+  substr($s, 0, 1) = 'Foo';
+  print substr($s,0,7) eq "FooRRAY" ? "ok 25\n" : "not ok 25\n";
+}