This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test case for C<undef %File::Glob::>
[perl5.git] / t / op / quotemeta.t
CommitLineData
a0d0e21e 1#!./perl
9d116dd7 2
a1a0e61e
TD
3BEGIN {
4 chdir 't' if -d 't';
20822f61 5 @INC = '../lib';
a1a0e61e
TD
6 require Config; import Config;
7}
8
3aa33fe5 9print "1..17\n";
a0d0e21e 10
a1a0e61e 11if ($Config{ebcdic} eq 'define') {
9d116dd7
JH
12 $_=join "", map chr($_), 129..233;
13
14 # 105 characters - 52 letters = 53 backslashes
15 # 105 characters + 53 backslashes = 158 characters
3aa33fe5 16 $_= quotemeta $_;
9d116dd7
JH
17 if ( length == 158 ){print "ok 1\n"} else {print "not ok 1\n"}
18 # 104 non-backslash characters
19 if (tr/\\//cd == 104){print "ok 2\n"} else {print "not ok 2\n"}
20} else { # some ASCII descendant, then.
21 $_=join "", map chr($_), 32..127;
a0d0e21e 22
9d116dd7
JH
23 # 96 characters - 52 letters - 10 digits - 1 underscore = 33 backslashes
24 # 96 characters + 33 backslashes = 129 characters
3aa33fe5 25 $_= quotemeta $_;
9d116dd7
JH
26 if ( length == 129 ){print "ok 1\n"} else {print "not ok 1\n"}
27 # 95 non-backslash characters
28 if (tr/\\//cd == 95){print "ok 2\n"} else {print "not ok 2\n"}
29}
a0d0e21e 30
a0d0e21e
LW
31if (length quotemeta "" == 0){print "ok 3\n"} else {print "not ok 3\n"}
32
33print "aA\UbB\LcC\EdD" eq "aABBccdD" ? "ok 4\n" : "not ok 4 \n";
34print "aA\LbB\UcC\EdD" eq "aAbbCCdD" ? "ok 5\n" : "not ok 5 \n";
35print "\L\upERL" eq "Perl" ? "ok 6\n" : "not ok 6 \n";
36print "\u\LpERL" eq "Perl" ? "ok 7\n" : "not ok 7 \n";
37print "\U\lPerl" eq "pERL" ? "ok 8\n" : "not ok 8 \n";
38print "\l\UPerl" eq "pERL" ? "ok 9\n" : "not ok 9 \n";
39print "\u\LpE\Q#X#\ER\EL" eq "Pe\\#x\\#rL" ? "ok 10\n" : "not ok 10 \n";
40print "\l\UPe\Q!x!\Er\El" eq "pE\\!X\\!Rl" ? "ok 11\n" : "not ok 11 \n";
41print "\Q\u\LpE.X.R\EL\E." eq "Pe\\.x\\.rL." ? "ok 12\n" : "not ok 12 \n";
42print "\Q\l\UPe*x*r\El\E*" eq "pE\\*X\\*Rl*" ? "ok 13\n" : "not ok 13 \n";
43print "\U\lPerl\E\E\E\E" eq "pERL" ? "ok 14\n" : "not ok 14 \n";
44print "\l\UPerl\E\E\E\E" eq "pERL" ? "ok 15\n" : "not ok 15 \n";
3aa33fe5
GS
45
46print length(quotemeta("\x{263a}")) == 1 ? "ok 16\n" : "not ok 16\n";
47print quotemeta("\x{263a}") eq "\x{263a}" ? "ok 17\n" : "not ok 17\n";