This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix O_CREAT without O_TRUNC in cpan/autodie/t/utf8_open.t
[perl5.git] / t / lib / Cname.pm
1 package Cname;
2 our $Evil='A';
3
4 sub translator {
5     my $str = shift;
6     if ( $str eq 'EVIL' ) {
7         # Returns A first time, AB second, ABC third ... A-ZA the 27th time.
8         (my $c=substr("A".$Evil,-1))++;
9         my $r=$Evil;
10         $Evil.=$c;
11         return $r;
12     }
13     if ( $str eq 'EMPTY-STR') {
14        return "";
15     }
16     if ( $str eq 'NULL') {
17         return "\0";
18     }
19     if ( $str eq 'LONG-STR') {
20         return 'A' x 255;
21     }
22     # Should exceed limit for regex \N bytes in a sequence.  Anyway it will if
23     # UCHAR_MAX is 255.
24     if ( $str eq 'TOO-LONG-STR') {
25        return 'A' x 256;
26     }
27     if ($str eq 'MALFORMED') {
28         $str = "\xDF\xDFabc";
29         utf8::upgrade($str);
30          
31         # Create a malformed in first and second characters.
32         $str =~ s/^\C/A/;
33         $str =~ s/^(\C\C)\C/$1A/;
34     }
35     return $str;
36 }
37
38 sub import {
39     shift;
40     $^H{charnames} = \&translator;
41 }
42 1;