1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
# VOODOO LINE-NOISE
my($C,$M,$P,$N,$S);END{print"1..$C\n$M";print"\nfailed: $N\n"if$N}
sub ok{$C++; $M.= ($_[0]||!@_)?"ok $C\n":($N++,"not ok $C (".
((caller 1)[1]||(caller 0)[1]).":".((caller 1)[2]||(caller 0)[2]).")\n")}
sub try{$P=qr/^$_[0]$/}sub fail{ok($S=$_[0]!~$P)}sub pass{ok($S=$_[0]=~$P)}
# LOAD
use Regexp::Common;
ok;
if ($] >= 5.006) {
# This gives a 'panic: POPSTACK' in 5.005_*
eval {"" =~ $RE {delimited}};
ok $@ =~ /Must specify delimiter in \$RE{delimited}/;
}
try $RE {delimited} {-delim => ' '};
pass q { a-few-words };
pass q { a\ few\ words };
fail q { a few words };
try $RE{delimited}{qq{-delim$;"}};
pass q{"a few words "};
pass q{"a few \"words\" "};
pass q{"a few 'words' "};
fail q{"a few "words" "};
fail q{'a few words '};
fail q{'a few \"words\" '};
fail q{'a few "words" '};
fail q{a "few" words "};
try $RE{delimited}{qq{-delim$;"}}{qq{-esc$;"}};
pass q{"a few words "};
fail q{"a few \"words\" "};
pass q{"a few ""words"" "};
pass q{"a few 'words' "};
fail q{"a few "words" "};
fail q{a "few" words "};
try $RE{delimited}{qq{-delim$;'}};
fail q{"a few words "};
fail q{"a few \"words\" "};
fail q{"a few 'words' "};
fail q{"a few "words" "};
pass q{'a few words '};
pass q{'a few \"words\" '};
pass q{'a few "words" '};
fail q{a "few" words "};
try $RE{quoted};
pass q{"a few words "};
pass q{"a few \"words\" "};
pass q{"a few 'words' "};
fail q{"a few "words" "};
pass q{'a few words '};
pass q{'a few \"words\" '};
pass q{'a few "words" '};
fail q{a "few" words "};
try $RE{quoted}{qq{-esc$;_!}};
pass q{"a few words "};
fail q{"a few \"words\" "};
pass q{"a few _"words_" "};
pass q{"a few 'words' "};
fail q{"a few "words" "};
pass q{'a few words '};
fail q{'a few \'words\' '};
pass q{'a few !'words!' '};
pass q{'a few "words" '};
fail q{a "few" words "};
try $RE{quoted}{qq{-esc$;}};
pass q{"a few words "};
fail q{"a few \"words\" "};
fail q{"a few _"words_" "};
pass q{"a few 'words' "};
fail q{"a few "words" "};
pass q{'a few words '};
fail q{'a few \'words\' '};
fail q{'a few !'words!' '};
pass q{'a few "words" '};
fail q{a "few" words "};
|