# W2H.t 15feb20waw use strict; use warnings; # use Data::Dump qw(pp dd); # for debug use Test::More 'no_plan'; use Test::NoWarnings; BEGIN { use_ok 'W2H_1'; use_ok 'W2H_2'; } use constant DEBUG => 1; use constant { DBPR_m_d1 => 0 && DEBUG, }; my @Tests = ( [ '_abcd_' => 'abcd', ], [ '_/abcd/_' => 'abcd', ], [ '*_/abcd/_*' => 'abcd', ], [ '*_/a*b_c/d/_*' => 'a*b_c/d', ], [ ' *_/a*b_c/d/_* ' => ' a*b_c/d ', ], [ '_abc__def_' => 'abcdef', ], [ '_abc__def_*ghi**jkl*/mno//pqr/' => 'abcdefghijklmnopqr', ], [ ' _abc__def_*ghi**jkl*/mno//pqr/ ' => ' abcdefghijklmnopqr ', ], [ '_abc_ _def_ *ghi* *jkl* /mno/ /pqr/' => 'abc def ghi jkl mno pqr', ], [ '_abc_ /def/' => 'abc def', ], [ ' _abc_ /def/ ' => ' abc def ', ], [ 'x _abc_ /def/ x' => 'x abc def x', ], [ '_abc /xyz/ cba_ /def/' => 'abc xyz cba def', ], [ '_/one *t/w*o*/ th/r_ee_ null' => 'one t/w*o th/r_ee null', ], [ '_/one *two*/ th/ree_ null _/f*ur *five*/ six_ null _/se_ven *eight*/ nine_ *fail_', => 'one two th/ree null f*ur five six null se_ven eight nine *fail_', 'from pm#11112991' ], ); # testing, testing... FUNT: for my $func_name ( 'W2H_1::w2h', 'W2H_2::w2h', ) { note "\n=== testing $func_name() ===\n\n"; *w2h = do { no strict 'refs'; *$func_name; }; VECTOR: for my $ar_vector (@Tests) { if (not ref $ar_vector) { note $ar_vector; next VECTOR; } my ($wiki, $expected, $comment) = @$ar_vector; $comment = defined $comment ? "$comment: " : ''; my $got = w2h($wiki); DBPR_m_d1 and diag ":$wiki:"; DBPR_m_d1 and diag ":$got:"; is $got, $expected, "${comment}'$wiki' -> '$expected'"; } # end for VECTOR } # end for FUNT done_testing; exit; # subroutines ###################################################### # none for now