This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
op/tr.t: Suppress two warnings
authorKarl Williamson <khw@cpan.org>
Sat, 30 Dec 2023 17:38:10 +0000 (10:38 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 2 Jan 2024 00:37:46 +0000 (17:37 -0700)
The warnings suppressed here are legitimate, but distract from the point
of the tests.

Spotted by Jim Keenan.

t/op/tr.t

index f2bef94..ad5b295 100644 (file)
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -18,7 +18,7 @@ plan tests => 315;
 
 # Test this first before we extend the stack with other operations.
 # This caused an asan failure due to a bad write past the end of the stack.
-eval { my $x; die  1..127, $x =~ y/// };
+eval { no warnings 'uninitialized'; my $x; die  1..127, $x =~ y/// };
 
 $_ = "abcdefghijklmnopqrstuvwxyz";
 
@@ -33,8 +33,14 @@ is($_, "abcdefghijklmnopqrstuvwxyz",    'lc');
 tr/b-y/B-Y/;
 is($_, "aBCDEFGHIJKLMNOPQRSTUVWXYz",    'partial uc');
 
-tr/a-a/AB/;
-is($_, "ABCDEFGHIJKLMNOPQRSTUVWXYz",    'single char range a-a');
+{
+    # AB is 2 characters, longer than single char source, so otherwise gets
+    # warned about
+    no warnings 'misc';
+
+    tr/a-a/AB/;
+    is($_, "ABCDEFGHIJKLMNOPQRSTUVWXYz",    'single char range a-a');
+}
 
 eval 'tr/a/\N{KATAKANA LETTER AINU P}/;';
 like $@,