diff options
author | Gisle Aas <gisle@aas.no> | 1998-06-25 12:32:43 +0200 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-06-28 20:01:28 +0000 |
commit | 5d82c45359f0afca7589620b2f4a39c32f3875eb (patch) | |
tree | 93c585d306d0f80a0ed359a193cebc79377b5021 /t | |
parent | 5d11ae5e5fc47938f54836457b96550ad1d9d787 (diff) | |
download | perl-5d82c45359f0afca7589620b2f4a39c32f3875eb.tar.gz |
Re: [PATCH] 4-arg substr update for perl5.004_68
Message-ID: <m3iulpubis.fsf@furu.g.aas.no>
p4raw-id: //depot/perl@1242
Diffstat (limited to 't')
-rwxr-xr-x | t/op/substr.t | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/t/op/substr.t b/t/op/substr.t index 967016a8d0..87efcb4512 100755 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -1,6 +1,6 @@ #!./perl -print "1..100\n"; +print "1..106\n"; #P = start of string Q = start of substr R = end of substr S = end of string @@ -12,8 +12,10 @@ $SIG{__WARN__} = sub { $w++; } elsif ($_[0] =~ /^Attempt to use reference as lvalue in substr/) { $w += 2; + } elsif ($_[0] =~ /^Use of uninitialized value/) { + $w += 3; } else { - warn @_; + warn $_[0]; } }; @@ -177,12 +179,33 @@ for (0,1) { # check no spurious warnings print $w ? "not ok 97\n" : "ok 97\n"; -# check new replacement syntax +# check new 4 arg replacement syntax $a = "abcxyz"; +$w = 0; print "not " unless substr($a, 0, 3, "") eq "abc" && $a eq "xyz"; print "ok 98\n"; print "not " unless substr($a, 0, 0, "abc") eq "" && $a eq "abcxyz"; print "ok 99\n"; -print "not " unless substr($a, 3, undef, "") eq "xyz" && $a eq "abc"; +print "not " unless substr($a, 3, -1, "") eq "xy" && $a eq "abcz"; print "ok 100\n"; +print "not " unless substr($a, 3, undef, "xy") eq "" && $a eq "abcxyz" + && $w == 3; +print "ok 101\n"; +$w = 0; + +print "not " unless substr($a, 3, 9999999, "") eq "xyz" && $a eq "abc"; +print "ok 102\n"; +print "not " unless fail(substr($a, -99, 0, "")); +print "ok 103\n"; +print "not " unless fail(substr($a, 99, 3, "")); +print "ok 104\n"; + +substr($a, 0, length($a), "foo"); +print "not " unless $a eq "foo" && !$w; +print "ok 105\n"; + +# using 4 arg substr as lvalue is a compile time error +eval 'substr($a,0,0,"") = "abc"'; +print "not " unless $@ && $@ =~ /Can't modify substr/ && $a eq "foo"; +print "ok 106\n"; |