X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fsubstr.t;h=e34216fb17b6866e4d73381e6c36bdca78a60f63;hb=08cb0b0dfc0b335573d521f40e4603db18152668;hp=08e1c3996935e23d110975a7be0fb12aca88d3a8;hpb=b98941349ef30a9e2a7d1bbadf33c4ecf948a1ee;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/substr.t b/t/op/substr.t index 08e1c39..e34216f 100755 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -2,7 +2,7 @@ # $RCSfile: substr.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:31 $ -print "1..22\n"; +print "1..25\n"; $a = 'abcdefxyz'; @@ -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"; +}