Commit | Line | Data |
---|---|---|
4b6af431 KW |
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 | ||
273b29a4 KW |
18 | is(_meta_notation("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C"), |
19 | "^@^A^B^C^D^E^F^G^H^I^J^K^L"); | |
20 | is(_meta_notation("\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19"), | |
21 | "^M^N^O^P^Q^R^S^T^U^V^W^X^Y"); | |
22 | is(_meta_notation("\x1A\x1B\x1C\x1D\x1E\x1F\c?"), | |
23 | "^Z^[^\\^]^^^_^?"); | |
24 | is(_meta_notation("09%AZaz\x{103}"), "09%AZaz\x{103}"); | |
4b6af431 KW |
25 | |
26 | if ($::IS_ASCII || $::IS_ASCII) { | |
273b29a4 KW |
27 | is(_meta_notation("\x7f\x80\x81\x82\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1"), |
28 | '^?M-^@M-^AM-^BM-^ZM-^[M-^\\M-^]M-^^M-^_M- M-!'); | |
4b6af431 KW |
29 | is(_meta_notation("\x{c1}\x{e2}"), 'M-AM-b'); |
30 | is(_meta_notation("\x{df}"), 'M-_'); | |
31 | } | |
32 | else { # EBCDIC platform | |
33 | # In the first iteration we are looking for a non-ASCII control; in | |
34 | # the second, a regular non-ASCII character. SPACE marks the end of | |
35 | # most controls. We test each to see that they are properly converted | |
36 | # to \x{...} | |
37 | foreach my $start (0x20, ord " ") { | |
38 | for (my $i = $start; $i < 256; $i++) { | |
39 | my $char = chr $i; | |
40 | next if $char =~ /[[:ascii:]]/; | |
41 | is(_meta_notation($char), sprintf("\\x{%X}", $i)); | |
42 | last; | |
43 | } | |
44 | } | |
45 | } | |
46 | } | |
47 | ||
48 | done_testing(); |