Acme-Test-LogicalEquivalence
view release on metacpan or search on metacpan
bin/test-logical-equivalence view on Meta::CPAN
my $numvars1 = find_num_vars($expr1);
my $numvars2 = find_num_vars($expr2);
my $num = $numvars1 > $numvars2 ? $numvars1 : $numvars2;
if ($num < 1) {
print STDERR 'No variables detected. Variables should be one or more of $a, $b, ..., $z', "\n";
exit 2;
}
# convert $a-style vars to $_[0]-style to support more than just $a and $b
$expr1 =~ s/\$([a-z])/'$_['.(ord($1) - 97).']'/ge;
$expr2 =~ s/\$([a-z])/'$_['.(ord($1) - 97).']'/ge;
my $sub1 = eval "sub { $expr1 }" or die "Expression 1: $@\n"; ## no critic (ProhibitStringyEval)
my $sub2 = eval "sub { $expr2 }" or die "Expression 2: $@\n"; ## no critic (ProhibitStringyEval)
plan tests => (2 ** $num);
note "Testing for logical equivalence of two expressions with $num variable(s)...";
my $equivalence = is_logically_equivalent($num, $sub1, $sub2);
( run in 0.528 second using v1.01-cache-2.11-cpan-49f99fa48dc )