Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / perl5 / t / op / quotemeta.t
1 #!./perl
2
3 print "1..15\n";
4
5 if ($^O eq 'os390') { # An EBCDIC variant.
6     $_=join "", map chr($_), 129..233;
7
8     # 105 characters - 52 letters = 53 backslashes
9     # 105 characters + 53 backslashes = 158 characters
10     $_=quotemeta $_;
11     if ( length == 158 ){print "ok 1\n"} else {print "not ok 1\n"}
12     # 104 non-backslash characters
13     if (tr/\\//cd == 104){print "ok 2\n"} else {print "not ok 2\n"}
14 } else { # some ASCII descendant, then.
15     $_=join "", map chr($_), 32..127;
16
17     # 96 characters - 52 letters - 10 digits - 1 underscore = 33 backslashes
18     # 96 characters + 33 backslashes = 129 characters
19     $_=quotemeta $_;
20     if ( length == 129 ){print "ok 1\n"} else {print "not ok 1\n"}
21     # 95 non-backslash characters
22     if (tr/\\//cd == 95){print "ok 2\n"} else {print "not ok 2\n"}
23 }
24
25 if (length quotemeta "" == 0){print "ok 3\n"} else {print "not ok 3\n"}
26
27 print "aA\UbB\LcC\EdD" eq "aABBccdD" ? "ok 4\n" : "not ok 4 \n";
28 print "aA\LbB\UcC\EdD" eq "aAbbCCdD" ? "ok 5\n" : "not ok 5 \n";
29 print "\L\upERL" eq "Perl" ? "ok 6\n" : "not ok 6 \n";
30 print "\u\LpERL" eq "Perl" ? "ok 7\n" : "not ok 7 \n";
31 print "\U\lPerl" eq "pERL" ? "ok 8\n" : "not ok 8 \n";
32 print "\l\UPerl" eq "pERL" ? "ok 9\n" : "not ok 9 \n";
33 print "\u\LpE\Q#X#\ER\EL" eq "Pe\\#x\\#rL" ? "ok 10\n" : "not ok 10 \n";
34 print "\l\UPe\Q!x!\Er\El" eq "pE\\!X\\!Rl" ? "ok 11\n" : "not ok 11 \n";
35 print "\Q\u\LpE.X.R\EL\E." eq "Pe\\.x\\.rL." ? "ok 12\n" : "not ok 12 \n";
36 print "\Q\l\UPe*x*r\El\E*" eq "pE\\*X\\*Rl*" ? "ok 13\n" : "not ok 13 \n";
37 print "\U\lPerl\E\E\E\E" eq "pERL" ? "ok 14\n" : "not ok 14 \n";
38 print "\l\UPerl\E\E\E\E" eq "pERL" ? "ok 15\n" : "not ok 15 \n";