Release Acme-Test-LogicalEquivalence 0.001
[chaz/p5-Acme-Test-LogicalEquivalence] / README.md
1 # NAME
2
3 Acme::Test::LogicalEquivalence - Test if expressions are logically equivalent
4
5 # VERSION
6
7 version 0.001
8
9 # SYNOPSIS
10
11 use Test::More;
12 use Acme::Test::LogicalEquivalence qw(is_logically_equivalent);
13
14 # test two expressions with 2 variables using the special vars $a and $b
15 is_logically_equivalent(2, sub { $a && $b }, sub { $b && $a });
16
17 # same as above
18 is_logically_equivalent(2, sub { $_[0] && $_[1] }, sub { $_[1] && $_[0] });
19
20 # you can do as many vars as you like
21 is_logically_equivalent(3, sub { $_[0] || ($_[1] && $_[2]) },
22 sub { ($_[0] || $_[1]) && ($_[0] || $_[2]) });
23
24 done_testing;
25
26 # DESCRIPTION
27
28 Some expressions are "logically equivalent" to other expressions, but it may not be easy to tell if
29 one or both of the expressions are reasonably complicated. Or maybe you're like many other people
30 and are too lazy to go through the effort... Either way, why not let your computer prove logical
31 equivalence for you?
32
33 # FUNCTIONS
34
35 ## is\_logically\_equivalent
36
37 Test logical equivalence of two subroutines.
38
39 my $is_equivalent = is_logically_equivalent($numvars, &sub1, &sub2);
40
41 This will execute both of the subroutines one or more times (depending on how many variables you
42 specify) with different inputs. The subroutines shall be considered logically equivalent if, for all
43 combinations of inputs, they both return the same thing.
44
45 Returns true if the subroutines are logically equivalent, false otherwise.
46
47 # SEE ALSO
48
49 - What is logical equivalence? Start here: [https://en.wikipedia.org/wiki/Logical\_equivalence](https://en.wikipedia.org/wiki/Logical_equivalence)
50
51 # AUTHOR
52
53 Charles McGarvey <chazmcgarvey@brokenzipper.com>
54
55 # COPYRIGHT AND LICENSE
56
57 This software is copyright (c) 2016 by Charles McGarvey.
58
59 This is free software; you can redistribute it and/or modify it under
60 the same terms as the Perl 5 programming language system itself.
This page took 0.03637 seconds and 4 git commands to generate.