summaryrefslogtreecommitdiff
path: root/t/op/tr.t
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-06-01 09:05:34 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-06-01 09:05:34 +0000
commit2de7b02f486a4ffa238ed2bfc9a7e642ed40e737 (patch)
treecb7caf3f301f2f0ae910faf71928c46206332e6b /t/op/tr.t
parentbe573f631d93a503246e9a83f3e8e876f6c5fcfb (diff)
downloadperl-2de7b02f486a4ffa238ed2bfc9a7e642ed40e737.tar.gz
counting tr/// corrupts later operation (from M.J.T Guy)
p4raw-id: //depot/perl@6189
Diffstat (limited to 't/op/tr.t')
-rwxr-xr-xt/op/tr.t26
1 files changed, 25 insertions, 1 deletions
diff --git a/t/op/tr.t b/t/op/tr.t
index 4e6667cd7f..e9a1b4c42d 100755
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -5,7 +5,7 @@ BEGIN {
unshift @INC, "../lib";
}
-print "1..4\n";
+print "1..8\n";
$_ = "abcdefghijklmnopqrstuvwxyz";
@@ -37,3 +37,27 @@ print "ok 3\n";
print "ok 4\n";
}
#
+
+# make sure that tr cancels IOK and NOK
+($x = 12) =~ tr/1/3/;
+(my $y = 12) =~ tr/1/3/;
+($f = 1.5) =~ tr/1/3/;
+(my $g = 1.5) =~ tr/1/3/;
+print "not " unless $x + $y + $f + $g == 71;
+print "ok 5\n";
+
+# make sure tr is harmless if not updating - see [ID 20000511.005]
+$_ = 'fred';
+/([a-z]{2})/;
+$1 =~ tr/A-Z//;
+s/^(\s*)f/$1F/;
+print "not " if $_ ne 'Fred';
+print "ok 6\n";
+
+# check tr handles UTF8 correctly
+($x = 256.65.258) =~ tr/a/b/;
+print "not " if $x ne 256.65.258 or length $x != 3;
+print "ok 7\n";
+$x =~ tr/A/B/;
+print "not " if $x ne 256.66.258 or length $x != 3;
+print "ok 8\n";