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