summaryrefslogtreecommitdiff
path: root/t/op/tr.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-11-02 20:19:25 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-11-02 21:32:34 -0700
commitbb16bae836f8e26795fbfac1361bf85da0d6a912 (patch)
treeb71601a317ae4fc0b2f334d106d4d7815a86e708 /t/op/tr.t
parent4eedab498fc909c786cceea9a6f3a70fa4433f9b (diff)
downloadperl-bb16bae836f8e26795fbfac1361bf85da0d6a912.tar.gz
y///r
Diffstat (limited to 't/op/tr.t')
-rw-r--r--t/op/tr.t23
1 files changed, 22 insertions, 1 deletions
diff --git a/t/op/tr.t b/t/op/tr.t
index 3f85e43758..52574b0ae9 100644
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 119;
+plan tests => 128;
my $Is_EBCDIC = (ord('i') == 0x89 & ord('J') == 0xd1);
@@ -44,6 +44,27 @@ is($_, "aBCDEFGHIJKLMNOPQRSTUVWXYz", 'partial uc');
(my $g = 1.5) =~ tr/1/3/;
is($x + $y + $f + $g, 71, 'tr cancels IOK and NOK');
+# /r
+$_ = 'adam';
+is y/dam/ve/rd, 'eve', '/r';
+is $_, 'adam', '/r leaves param alone';
+$g = 'ruby';
+is $g =~ y/bury/repl/r, 'perl', '/r with explicit param';
+is $g, 'ruby', '/r leaves explicit param alone';
+is "aaa" =~ y\a\b\r, 'bbb', '/r with constant param';
+ok !eval '$_ !~ y///r', "!~ y///r is forbidden";
+like $@, qr\^Using !~ with tr///r doesn't make sense\,
+ "!~ y///r error message";
+{
+ my $w;
+ my $wc;
+ local $SIG{__WARN__} = sub { $w = shift; ++$wc };
+ local $^W = 1;
+ eval 'y///r; 1';
+ like $w, qr '^Useless use of non-destructive transliteration \(tr///r\)',
+ '/r warns in void context';
+ is $wc, 1, '/r warns just once';
+}
# perlbug [ID 20000511.005]
$_ = 'fred';