@@ -18,7 +18,7 @@ BEGIN {
18
18
# If you find tests are failing, please try adding names to tests to track
19
19
# down where the failure is, and supply your new names as a patch.
20
20
# (Just-in-time test naming)
21
- plan tests => 504 ;
21
+ plan tests => 491 ;
22
22
23
23
# numerics
24
24
ok ((0xdead & 0xbeef) == 0x9ead);
@@ -613,73 +613,30 @@ foreach my $op_info ([and => "&"], [or => "|"], [xor => "^"]) {
613
613
}
614
614
615
615
{
616
- # Since these are temporary, and it was a pain to make them into loops,
617
- # the code is just rolled out.
618
- local $SIG {__WARN__} = sub { push @warnings , @_ ; };
619
-
620
- undef @warnings ;
621
- is("abc" & "abc\x{100} ", "abc", '"abc" & "abc\x{100} " works');
622
- if (! is(@warnings , 1, "... but returned a single warning")) {
623
- diag join "\n ", @warnings ;
624
- }
625
- like ($warnings [0], qr /^Use of strings with code points over 0xFF as (?#
626
- )arguments to bitwise and \( &\) operator (?#
627
- )is deprecated/,
628
- "... which is the expected warning");
629
- undef @warnings ;
630
- is("abc" | "abc\x{100} ", "abc\x{100} ", '"abc" | "abc\x{100} " works');
631
- if (! is(@warnings , 1, "... but returned a single warning")) {
632
- diag join "\n ", @warnings ;
633
- }
634
- like ($warnings [0], qr /^Use of strings with code points over 0xFF as (?#
635
- )arguments to bitwise or \( |\) operator (?#
636
- )is deprecated/,
637
- "... which is the expected warning");
638
- undef @warnings ;
639
- is("abc" ^ "abc\x{100} ", "\0\0\0\x{100} ", '"abc" ^ "abc\x{100} " works');
640
- if (! is(@warnings , 1, "... but returned a single warning")) {
641
- diag join "\n ", @warnings ;
642
- }
643
- like ($warnings [0], qr /^Use of strings with code points over 0xFF as (?#
644
- )arguments to bitwise xor \(\^\) operator (?#
645
- )is deprecated/,
646
- "... which is the expected warning");
647
- undef @warnings ;
648
- is("abc\x{100} " & "abc", "abc", '"abc\x{100} " & "abc" works');
649
- if (! is(@warnings , 1, "... but returned a single warning")) {
650
- diag join "\n ", @warnings ;
651
- }
652
- like ($warnings [0], qr /^Use of strings with code points over 0xFF as (?#
653
- )arguments to bitwise and \( &\) operator (?#
654
- )is deprecated/,
655
- "... which is the expected warning");
656
- undef @warnings ;
657
- is("abc\x{100} " | "abc", "abc\x{100} ", '"abc\x{100} " | "abc" works');
658
- if (! is(@warnings , 1, "... but returned a single warning")) {
659
- diag join "\n ", @warnings ;
660
- }
661
- like ($warnings [0], qr /^Use of strings with code points over 0xFF as (?#
662
- )arguments to bitwise or \( |\) operator (?#
663
- )is deprecated/,
664
- "... which is the expected warning");
665
- undef @warnings ;
666
- is("abc\x{100} " ^ "abc", "\0\0\0\x{100} ", '"abc\x{100} " ^ "abc" works');
667
- if (! is(@warnings , 1, "... but returned a single warning")) {
668
- diag join "\n ", @warnings ;
669
- }
670
- like ($warnings [0], qr /^Use of strings with code points over 0xFF as (?#
671
- )arguments to bitwise xor \(\^\) operator (?#
672
- )is deprecated/,
673
- "... which is the expected warning");
674
- no warnings 'deprecated';
675
- undef @warnings ;
676
- my $foo = "abc" & "abc\x{100} ";
677
- $foo = "abc" | "abc\x{100} ";
678
- $foo = "abc" ^ "abc\x{100} ";
679
- $foo = "abc\x{100} " & "abc";
680
- $foo = "abc\x{100} " | "abc";
681
- $foo = "abc\x{100} " ^ "abc";
682
- if (! is(@warnings , 0, "... And none of the last 6 main tests warns when 'deprecated' is off")) {
683
- diag join "\n ", @warnings ;
616
+ # RT 134140 fatalizations
617
+ my %op_pairs = (
618
+ and => { low => 'and', high => '&', regex => qr/&/ },
619
+ or => { low => 'or', high => '|', regex => qr/\| / },
620
+ xor => { low => 'xor', high => '^', regex => qr/\^ / },
621
+ );
622
+ my @combos = (
623
+ { string => '"abc" & "abc\x{100} "', op_pair => $op_pairs {and} },
624
+ { string => '"abc" | "abc\x{100} "', op_pair => $op_pairs {or} },
625
+ { string => '"abc" ^ "abc\x{100} "', op_pair => $op_pairs {xor} },
626
+ { string => '"abc\x{100} " & "abc"', op_pair => $op_pairs {and} },
627
+ { string => '"abc\x{100} " | "abc"', op_pair => $op_pairs {or} },
628
+ { string => '"abc\x{100} " ^ "abc"', op_pair => $op_pairs {xor} },
629
+
630
+ );
631
+
632
+ # Use of strings with code points over 0xFF as arguments to %s operator is not allowed
633
+ for my $h (@combos ) {
634
+ my $s1 = "Use of strings with code points over 0xFF as arguments to bitwise";
635
+ my $s2 = "operator is not allowed";
636
+ my $expected = qr/$s1 $h ->{op_pair}->{low} \( $h ->{op_pair}->{regex}\) $s2 /;
637
+ my $description = "$s1 $h ->{op_pair}->{low} ($h ->{op_pair}->{high}) operator is not allowed";
638
+ local $@ ;
639
+ eval $h ->{string};
640
+ like $@ , $expected , $description ;
684
641
}
685
642
}
0 commit comments