This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.h: Fold 2 ANYOF flags into a single one
[perl5.git] / lib / meta_notation.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require './test.pl';
7 }
8
9 use strict;
10 use warnings;
11
12 eval "require 'meta_notation.pm'";
13 if ($@) {
14     fail("Could not find 'meta_notation.pm'");
15 }
16 else {
17
18     is(_meta_notation("\007\010\011\c?Z\x{103}"), "^G^H^I^?Z\x{103}");
19
20     if ($::IS_ASCII || $::IS_ASCII) {
21         is(_meta_notation("\x{c1}\x{e2}"), 'M-AM-b');
22         is(_meta_notation("\x{df}"), 'M-_');
23     }
24     else {  # EBCDIC platform
25         # In the first iteration we are looking for a non-ASCII control; in
26         # the second, a regular non-ASCII character.  SPACE marks the end of
27         # most controls.  We test each to see that they are properly converted
28         # to \x{...}
29         foreach my $start (0x20, ord " ") {
30             for (my $i = $start; $i < 256; $i++) {
31                 my $char = chr $i;
32                 next if $char =~ /[[:ascii:]]/;
33                 is(_meta_notation($char), sprintf("\\x{%X}", $i));
34                 last;
35             }
36         }
37     }
38 }
39
40 done_testing();