47 my $fmt= shift || '%d';
48 my $sep= shift || ' ';
49 my $rng= shift || '..';
54 my $ret= sprintf $fmt, $first;
55 for my $idx (1..$#$ary) {
56 if ( $ary->[$idx] != $last + 1) {
58 $ret.=sprintf "%s$fmt",$rng, $last;
60 $first= $last= $ary->[$idx];
61 $ret.=sprintf "%s$fmt",$sep,$first;
66 if ( $last != $first) {
67 $ret.=sprintf "%s$fmt",$rng, $last;
72 # The bug is only fixed for /u
73 use feature 'unicode_strings';
77 my ($yes,$no)= splice @pats,0,2;
82 foreach my $b (0..255) {
84 my $display_b = sprintf("\\x%02X", $b);
85 for my $type ('unicode','not-unicode') {
86 my $str=chr($b).chr($b);
87 if ($type eq 'unicode') {
91 if ($str=~/[$yes][$no]/){
92 unlike($str,qr/[$yes][$no]/,
93 "chr($display_b) X 2 =~/[$yes][$no]/ should not match under $type");
94 push @{$err_by_type{$type}},$b;
96 $got{"[$yes]"}{$type} = $str=~/[$yes]/ ? 1 : 0;
97 $got{"[$no]"}{$type} = $str=~/[$no]/ ? 1 : 0;
98 $got{"[^$yes]"}{$type} = $str=~/[^$yes]/ ? 1 : 0;
99 $got{"[^$no]"}{$type} = $str=~/[^$no]/ ? 1 : 0;
101 # For \w, \s, and \d, also test without being in character
103 next if $yes =~ /\[/;
105 # The rest of this .t was written when there were many test
106 # failures, so it goes to some lengths to summarize things. Now
107 # those are fixed, so these missing tests just do standard
111 utf8::upgrade $chr if $type eq 'unicode';
112 ok (($chr =~ /$yes/) != ($chr =~ /$no/),
113 "$type: chr($display_b) isn't both $yes and $no");
115 foreach my $which ("[$yes]","[$no]","[^$yes]","[^$no]") {
116 if ($got{$which}{'unicode'} != $got{$which}{'not-unicode'}){
117 is($got{$which}{'unicode'},$got{$which}{'not-unicode'},
118 "chr($display_b) X 2=~ /$which/ should have the same results regardless of internal string encoding");
119 push @{$singles{$which}},$b;
122 foreach my $which ($yes,$no) {
123 foreach my $strtype ('unicode','not-unicode') {
124 if ($got{"[$which]"}{$strtype} == $got{"[^$which]"}{$strtype}) {
125 isnt($got{"[$which]"}{$strtype},$got{"[^$which]"}{$strtype},
126 "chr($display_b) X 2 =~ /[$which]/ should not have the same result as chr($display_b)=~/[^$which]/");
127 push @{$complements{$which}{$strtype}},$b;
134 if (%err_by_type || %singles || %complements) {
135 $description||=" Error:\n";
136 $description .= "/[$yes][$no]/\n";
138 foreach my $type (sort keys %err_by_type) {
139 $description .= "\tmatches $type codepoints:\t";
140 $description .= rangify($err_by_type{$type});
141 $description .= "\n";
143 $description .= "\n";
146 $description .= "Unicode/Nonunicode mismatches:\n";
147 foreach my $type (sort keys %singles) {
148 $description .= "\t$type:\t";
149 $description .= rangify($singles{$type});
150 $description .= "\n";
152 $description .= "\n";
155 foreach my $class (sort keys %complements) {
156 foreach my $strtype (sort keys %{$complements{$class}}) {
157 $description .= "\t$class has complement failures under $strtype for:\t";
158 $description .= rangify($complements{$class}{$strtype});
159 $description .= "\n";