use 5.010; use warnings; use strict; use Test::More # tests => ?? + 1 # Test::NoWarnings adds 1 test 'no_plan' ; use Test::NoWarnings; use constant TEST_SET => ( [ q{()}, q{()} ], [ q{()'}, q{!()} ], [ q{(()')'}, q{!(!())} ], [ q{((()')')'}, q{!(!(!()))} ], [ q{(()' (()')')'}, q{!(!() !(!()))} ], [ q{(A & B)}, q{(A & B)} ], [ q{(A & B)'}, q{!(A & B)} ], [ q{(A & B | (C & D)')'}, q{!(A & B | !(C & D))} ], [ q{((A & B)' | (A & C & (A & B & D)'))}, q{(!(A & B) | (A & C & !(A & B & D)))} ], [ q{((A | B)' & (C | (D & (E & F)))')'}, q{!(!(A | B) & !(C | (D & (E & F))))} ], [ q{((A & B)' | (A & C & (A & Boff' & D | (A & (B' & D)')'))}, q{(!(A & B) | (A & C & (A & !Boff & D | !(A & !(!B & D))))} ], ); FUNT: for my $func_name (qw(xform_4)) { note "\n----- testing $func_name() ----- \n\n"; *xform = do { no strict 'refs'; *$func_name; }; VECTOR: for my $ar_vector (TEST_SET) { if (not ref $ar_vector) { note $ar_vector; next VECTOR; } my ($string, $expected) = @$ar_vector; is xform($string), $expected, qq{$string} } # end for VECTOR } # end for FUNT done_testing; # functions under test ############################################# sub xform_4 { # needs 5.10+ for (?PARNO) and (?|...) my ($str, ) = @_; my $parenthetic = qr{ ( [(] (?: [^()]*+ | (?-1))* [)] ) }xmso; my $term = qr{ ( [[:alpha:]] \w* ) }xmso; 1 while $str =~ s{ (?| $parenthetic | $term) ' } {!$1}xmsgo; return $str; }