44 if (1 or $ENV{PERL_TEST_LEGACY_POSIX_CC}) {
45 $::TODO = "Only works under PERL_LEGACY_UNICODE_CHARCLASS_MAPPINGS = 0";
50 my $fmt= shift || '%d';
51 my $sep= shift || ' ';
52 my $rng= shift || '..';
57 my $ret= sprintf $fmt, $first;
58 for my $idx (1..$#$ary) {
59 if ( $ary->[$idx] != $last + 1) {
61 $ret.=sprintf "%s$fmt",$rng, $last;
63 $first= $last= $ary->[$idx];
64 $ret.=sprintf "%s$fmt",$sep,$first;
69 if ( $last != $first) {
70 $ret.=sprintf "%s$fmt",$rng, $last;
77 my ($yes,$no)= splice @pats,0,2;
82 foreach my $b (0..255) {
84 for my $type ('unicode','not-unicode') {
85 my $str=chr($b).chr($b);
86 if ($type eq 'unicode') {
90 if ($str=~/[$yes][$no]/){
92 unlike($str,qr/[$yes][$no]/,
93 "chr($b)=~/[$yes][$no]/ should not match under $type");
95 push @{$err_by_type{$type}},$b;
97 $got{"[$yes]"}{$type} = $str=~/[$yes]/ ? 1 : 0;
98 $got{"[$no]"}{$type} = $str=~/[$no]/ ? 1 : 0;
99 $got{"[^$yes]"}{$type} = $str=~/[^$yes]/ ? 1 : 0;
100 $got{"[^$no]"}{$type} = $str=~/[^$no]/ ? 1 : 0;
102 foreach my $which ("[$yes]","[$no]","[^$yes]","[^$no]") {
103 if ($got{$which}{'unicode'} != $got{$which}{'not-unicode'}){
105 is($got{$which}{'unicode'},$got{$which}{'not-unicode'},
106 "chr($b)=~/$which/ should have the same results regardless of internal string encoding");
108 push @{$singles{$which}},$b;
111 foreach my $which ($yes,$no) {
112 foreach my $strtype ('unicode','not-unicode') {
113 if ($got{"[$which]"}{$strtype} == $got{"[^$which]"}{$strtype}) {
115 isnt($got{"[$which]"}{$strtype},$got{"[^$which]"}{$strtype},
116 "chr($b)=~/[$which]/ should not have the same result as chr($b)=~/[^$which]/");
118 push @{$complements{$which}{$strtype}},$b;
125 if (%err_by_type || %singles || %complements) {
126 $description||=" Error:\n";
127 $description .= "/[$yes][$no]/\n";
129 foreach my $type (sort keys %err_by_type) {
130 $description .= "\tmatches $type codepoints:\t";
131 $description .= rangify($err_by_type{$type});
132 $description .= "\n";
134 $description .= "\n";
137 $description .= "Unicode/Nonunicode mismatches:\n";
138 foreach my $type (sort keys %singles) {
139 $description .= "\t$type:\t";
140 $description .= rangify($singles{$type});
141 $description .= "\n";
143 $description .= "\n";
146 foreach my $class (sort keys %complements) {
147 foreach my $strtype (sort keys %{$complements{$class}}) {
148 $description .= "\t$class has complement failures under $strtype for:\t";
149 $description .= rangify($complements{$class}{$strtype});
150 $description .= "\n";
157 is( $description, "", "POSIX and perl charclasses should not depend on string type");