use warnings; use strict; use Test::More # tests => ?? + 1 # Test::NoWarnings adds 1 test 'no_plan' ; use Test::NoWarnings; FUNT: for my $func_name (qw(proper_2a proper_2b)) { note "\n==== testing $func_name() ====\n\n"; *proper = do { no strict 'refs'; *$func_name; }; VECTOR: for my $ar_vector ( [ 'An log and an axe, a log and a axe', 'A log and an axe, a log and an axe', ], [ 'An log and an axe, a log and a axe a', 'A log and an axe, a log and an axe a', q{end in 'a'} ], [ 'An log and an axe, a log and a axe an', 'A log and an axe, a log and an axe an', q{end in 'an'} ], [ 'An log and an axe, a log and a axe a ', 'A log and an axe, a log and an axe a ', q{end in 'a' then whitespace (is this possible?)} ], [ 'An log and an axe, a log and a axe an ', 'A log and an axe, a log and an axe an ', q{end in 'an' then whitespace (is this possible?)} ], [ 'An log and an axe, a log and a axe a.', 'A log and an axe, a log and an axe a.', q{end in 'a' then non-whitespace/alpha} ], [ 'An log and an axe, a log and a axe an.', 'A log and an axe, a log and an axe an.', q{end in 'an' then non-whitespace/alpha} ], [ 'AN LOG AND AN AXE, A LOG AND A AXE', 'A LOG AND AN AXE, A LOG AND An AXE', # ^ delete ^ existing, ok ^ added 'leave case untouched if not adding' ], [ 'An man, an plan, an canal, Panama', 'A man, a plan, a canal, Panama', ], [ 'A man, a plan, a canal, Panama', 'A man, a plan, a canal, Panama', 'no change needed' ], [ 'Afganastan banana stand and aqua okra, tan pan.', 'Afganastan banana stand and aqua okra, tan pan.', 'no articles' ], ) { if (not ref $ar_vector) { note $ar_vector; next VECTOR; } my ($sentence, $expected, $msg) = @$ar_vector; is proper($sentence), $expected, $msg; } # end for VECTOR } # end for FUNT note "\n==== done testing functions ====\n\n"; # function(s) under test ########################################### sub proper_2a { # compatible with version 5.8.9 my ($sentence, ) = @_; my $n = qr{ [Nn] }xms; my $vowel = qr{ [AEIOUaeiou] }xms; # 'n', if present, must be preceded by # 'a' that is NOT preceded by a NON-whitespace character # (i.e., must be preceded by whitespace or start of string). $sentence =~ s{ (?<= (?