51 my $fmt= shift || '%d';
52 my $sep= shift || ' ';
53 my $rng= shift || '..';
58 my $ret= sprintf $fmt, $first;
59 for my $idx (1..$#$ary) {
60 if ( $ary->[$idx] != $last + 1) {
62 $ret.=sprintf "%s$fmt",$rng, $last;
64 $first= $last= $ary->[$idx];
65 $ret.=sprintf "%s$fmt",$sep,$first;
70 if ( $last != $first) {
71 $ret.=sprintf "%s$fmt",$rng, $last;
76 # The bug is only fixed for /u
77 use feature 'unicode_strings';
81 my ($yes,$no)= splice @pats,0,2;
86 foreach my $b (0..255) {
88 my $display_b = sprintf("\\x%02X", $b);
89 for my $type ('unicode','not-unicode') {
90 my $str=chr($b).chr($b);
91 if ($type eq 'unicode') {
95 if ($str=~/[$yes][$no]/){
96 unlike($str,qr/[$yes][$no]/,
97 "chr($display_b) X 2 =~/[$yes][$no]/ should not match under $type");
98 push @{$err_by_type{$type}},$b;
100 $got{"[$yes]"}{$type} = $str=~/[$yes]/ ? 1 : 0;
101 $got{"[$no]"}{$type} = $str=~/[$no]/ ? 1 : 0;
102 $got{"[^$yes]"}{$type} = $str=~/[^$yes]/ ? 1 : 0;
103 $got{"[^$no]"}{$type} = $str=~/[^$no]/ ? 1 : 0;
105 # For \w, \s, and \d, \h, \v, also test without being in character
107 next if $yes =~ /\[/;
109 # The rest of this .t was written when there were many test
110 # failures, so it goes to some lengths to summarize things. Now
111 # those are fixed, so these missing tests just do standard
115 utf8::upgrade $chr if $type eq 'unicode';
116 ok (($chr =~ /$yes/) != ($chr =~ /$no/),
117 "$type: chr($display_b) isn't both $yes and $no");
119 foreach my $which ("[$yes]","[$no]","[^$yes]","[^$no]") {
120 if ($got{$which}{'unicode'} != $got{$which}{'not-unicode'}){
121 is($got{$which}{'unicode'},$got{$which}{'not-unicode'},
122 "chr($display_b) X 2=~ /$which/ should have the same results regardless of internal string encoding");
123 push @{$singles{$which}},$b;
126 foreach my $which ($yes,$no) {
127 foreach my $strtype ('unicode','not-unicode') {
128 if ($got{"[$which]"}{$strtype} == $got{"[^$which]"}{$strtype}) {
129 isnt($got{"[$which]"}{$strtype},$got{"[^$which]"}{$strtype},
130 "chr($display_b) X 2 =~ /[$which]/ should not have the same result as chr($display_b)=~/[^$which]/");
131 push @{$complements{$which}{$strtype}},$b;
138 if (%err_by_type || %singles || %complements) {
139 $description||=" Error:\n";
140 $description .= "/[$yes][$no]/\n";
142 foreach my $type (sort keys %err_by_type) {
143 $description .= "\tmatches $type codepoints:\t";
144 $description .= rangify($err_by_type{$type});
145 $description .= "\n";
147 $description .= "\n";
150 $description .= "Unicode/Nonunicode mismatches:\n";
151 foreach my $type (sort keys %singles) {
152 $description .= "\t$type:\t";
153 $description .= rangify($singles{$type});
154 $description .= "\n";
156 $description .= "\n";
159 foreach my $class (sort keys %complements) {
160 foreach my $strtype (sort keys %{$complements{$class}}) {
161 $description .= "\t$class has complement failures under $strtype for:\t";
162 $description .= rangify($complements{$class}{$strtype});
163 $description .= "\n";