Commit | Line | Data |
a0d0e21e |
1 | #!./perl |
9d116dd7 |
2 | |
a1a0e61e |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
6e909404 |
5 | @INC = qw(../lib .); |
a1a0e61e |
6 | require Config; import Config; |
6e909404 |
7 | require "test.pl"; |
a1a0e61e |
8 | } |
9 | |
6e909404 |
10 | plan tests => 22; |
a0d0e21e |
11 | |
a1a0e61e |
12 | if ($Config{ebcdic} eq 'define') { |
6e909404 |
13 | $_ = join "", map chr($_), 129..233; |
9d116dd7 |
14 | |
15 | # 105 characters - 52 letters = 53 backslashes |
16 | # 105 characters + 53 backslashes = 158 characters |
6e909404 |
17 | $_ = quotemeta $_; |
18 | is(length($_), 158, "quotemeta string"); |
9d116dd7 |
19 | # 104 non-backslash characters |
6e909404 |
20 | is(tr/\\//cd, 104, "tr count non-backslashed"); |
9d116dd7 |
21 | } else { # some ASCII descendant, then. |
6e909404 |
22 | $_ = join "", map chr($_), 32..127; |
a0d0e21e |
23 | |
9d116dd7 |
24 | # 96 characters - 52 letters - 10 digits - 1 underscore = 33 backslashes |
25 | # 96 characters + 33 backslashes = 129 characters |
6e909404 |
26 | $_ = quotemeta $_; |
27 | is(length($_), 129, "quotemeta string"); |
9d116dd7 |
28 | # 95 non-backslash characters |
6e909404 |
29 | is(tr/\\//cd, 95, "tr count non-backslashed"); |
9d116dd7 |
30 | } |
a0d0e21e |
31 | |
6e909404 |
32 | is(length(quotemeta ""), 0, "quotemeta empty string"); |
33 | |
34 | is("aA\UbB\LcC\EdD", "aABBccdD", 'aA\UbB\LcC\EdD'); |
35 | is("aA\LbB\UcC\EdD", "aAbbCCdD", 'aA\LbB\UcC\EdD'); |
36 | is("\L\upERL", "Perl", '\L\upERL'); |
37 | is("\u\LpERL", "Perl", '\u\LpERL'); |
38 | is("\U\lPerl", "pERL", '\U\lPerl'); |
39 | is("\l\UPerl", "pERL", '\l\UPerl'); |
40 | is("\u\LpE\Q#X#\ER\EL", "Pe\\#x\\#rL", '\u\LpE\Q#X#\ER\EL'); |
41 | is("\l\UPe\Q!x!\Er\El", "pE\\!X\\!Rl", '\l\UPe\Q!x!\Er\El'); |
42 | is("\Q\u\LpE.X.R\EL\E.", "Pe\\.x\\.rL.", '\Q\u\LpE.X.R\EL\E.'); |
43 | is("\Q\l\UPe*x*r\El\E*", "pE\\*X\\*Rl*", '\Q\l\UPe*x*r\El\E*'); |
44 | is("\U\lPerl\E\E\E\E", "pERL", '\U\lPerl\E\E\E\E'); |
45 | is("\l\UPerl\E\E\E\E", "pERL", '\l\UPerl\E\E\E\E'); |
46 | |
47 | is(quotemeta("\x{263a}"), "\x{263a}", "quotemeta Unicode"); |
48 | is(length(quotemeta("\x{263a}")), 1, "quotemeta Unicode length"); |
49 | |
50 | $a = "foo|bar"; |
51 | is("a\Q\Ec$a", "acfoo|bar", '\Q\E'); |
52 | is("a\L\Ec$a", "acfoo|bar", '\L\E'); |
53 | is("a\l\Ec$a", "acfoo|bar", '\l\E'); |
54 | is("a\U\Ec$a", "acfoo|bar", '\U\E'); |
55 | is("a\u\Ec$a", "acfoo|bar", '\u\E'); |