* lib/Automake/tests/DisjConditions.pl (test_basics): Increase test coverage: test ->human, ->merge, ->simplify, ->multiply. * lib/Automake/tests/DisjConditions-t.pl (test_basics): Likewise changes, but including state copies across thread creation. * lib/Automake/tests/DisjCon2.pl: New test. * lib/Automake/tests/DisjCon3.pl: Likewise. * lib/Automake/tests/Makefile.am (TESTS, XFAIL_TESTS): Adjust.
Signed-off-by: Ralf Wildenhues <ralf.wildenh...@gmx.de> --- ChangeLog | 9 +++++++++ lib/Automake/tests/DisjCon2.pl | 8 ++++++++ lib/Automake/tests/DisjCon3.pl | 7 +++++++ lib/Automake/tests/DisjConditions-t.pl | 26 ++++++++++++++++++++++++++ lib/Automake/tests/DisjConditions.pl | 26 +++++++++++++++++++++++++- lib/Automake/tests/Makefile.am | 4 ++++ lib/Automake/tests/Makefile.in | 4 ++++ 7 files changed, 83 insertions(+), 1 deletions(-) create mode 100644 lib/Automake/tests/DisjCon2.pl create mode 100644 lib/Automake/tests/DisjCon3.pl diff --git a/ChangeLog b/ChangeLog index a0f6525..96142b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2009-10-18 Ralf Wildenhues <ralf.wildenh...@gmx.de> + Coverage for DisjConditions.pm. + * lib/Automake/tests/DisjConditions.pl (test_basics): Increase + test coverage: test ->human, ->merge, ->simplify, ->multiply. + * lib/Automake/tests/DisjConditions-t.pl (test_basics): Likewise + changes, but including state copies across thread creation. + * lib/Automake/tests/DisjCon2.pl: New test. + * lib/Automake/tests/DisjCon3.pl: Likewise. + * lib/Automake/tests/Makefile.am (TESTS, XFAIL_TESTS): Adjust. + Coverage and fixes for Condition.pm. * lib/Automake/Condition.pm (new): Catch common programming errors better by checking type of passed argument before diff --git a/lib/Automake/tests/DisjCon2.pl b/lib/Automake/tests/DisjCon2.pl new file mode 100644 index 0000000..9edd8d5 --- /dev/null +++ b/lib/Automake/tests/DisjCon2.pl @@ -0,0 +1,8 @@ +# Catch common programming error: +# A non-Condition reference passed to new. +use Automake::Condition; +use Automake::DisjConditions; + +my $cond = new Automake::Condition ('TRUE'); +my $cond2 = new Automake::DisjConditions ($cond); +new Automake::DisjConditions ($cond2); diff --git a/lib/Automake/tests/DisjCon3.pl b/lib/Automake/tests/DisjCon3.pl new file mode 100644 index 0000000..8e69e2b --- /dev/null +++ b/lib/Automake/tests/DisjCon3.pl @@ -0,0 +1,7 @@ +# Catch common programming error: +# A non-reference passed to new. +use Automake::Condition qw/TRUE FALSE/; +use Automake::DisjConditions; + +my $cond = new Automake::Condition ("COND1_TRUE"); +new Automake::DisjConditions ("$cond"); diff --git a/lib/Automake/tests/DisjConditions-t.pl b/lib/Automake/tests/DisjConditions-t.pl index eccdcd6..4df5112 100644 --- a/lib/Automake/tests/DisjConditions-t.pl +++ b/lib/Automake/tests/DisjConditions-t.pl @@ -35,18 +35,44 @@ use Automake::DisjConditions; sub test_basics () { + my $true = new Automake::DisjConditions TRUE; + my $false = new Automake::DisjConditions FALSE; my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE"; return threads->new (sub { my $other = new Automake::Condition "COND3_FALSE"; + my $another = new Automake::Condition "COND3_TRUE", "COND4_FALSE"; return threads->new (sub { my $set1 = new Automake::DisjConditions $cond, $other; return threads->new (sub { my $set2 = new Automake::DisjConditions $other, $cond; + my $set3 = new Automake::DisjConditions FALSE, $another; return 1 unless $set1 == $set2; return 1 if $set1->false; return 1 if $set1->true; return 1 unless (new Automake::DisjConditions)->false; return 1 if (new Automake::DisjConditions)->true; + return 1 unless $true->human eq 'TRUE'; + return 1 unless $false->human eq 'FALSE'; + return 1 unless $set1->human eq "(COND1 and !COND2) or (!COND3)"; + return 1 unless $set2->human eq "(COND1 and !COND2) or (!COND3)"; + my $one_cond_human = $set1->one_cond->human; + return 1 unless $one_cond_human eq "!COND3" + || $one_cond_human eq "COND1 and !COND2"; + return 1 unless $set1->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; + + my $merged1 = $set1->merge ($set2); + my $merged2 = $set1->merge ($cond); + my $mult1 = $set1->multiply ($set3); + return threads->new (sub { + my $mult2 = $set1->multiply ($another); + return threads->new (sub { + return 1 unless $merged1->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; + return 1 unless $merged2->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; + return 1 unless $mult1->string eq "COND1_TRUE COND2_FALSE COND3_TRUE COND4_FALSE"; + return 1 unless $mult1 == $mult2; + return 0; + })->join; + })->join; })->join; })->join; })->join; diff --git a/lib/Automake/tests/DisjConditions.pl b/lib/Automake/tests/DisjConditions.pl index 47dea83..7ccac13 100644 --- a/lib/Automake/tests/DisjConditions.pl +++ b/lib/Automake/tests/DisjConditions.pl @@ -1,4 +1,5 @@ -# Copyright (C) 2001, 2002, 2003, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2008, 2009 Free Software Foundation, +# Inc. # # This file is part of GNU Automake. # @@ -20,15 +21,38 @@ use Automake::DisjConditions; sub test_basics () { + my $true = new Automake::DisjConditions TRUE; + my $false = new Automake::DisjConditions FALSE; my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE"; my $other = new Automake::Condition "COND3_FALSE"; + my $another = new Automake::Condition "COND3_TRUE", "COND4_FALSE"; my $set1 = new Automake::DisjConditions $cond, $other; my $set2 = new Automake::DisjConditions $other, $cond; + my $set3 = new Automake::DisjConditions FALSE, $another; return 1 unless $set1 == $set2; return 1 if $set1->false; return 1 if $set1->true; return 1 unless (new Automake::DisjConditions)->false; return 1 if (new Automake::DisjConditions)->true; + return 1 unless $true->human eq 'TRUE'; + return 1 unless $false->human eq 'FALSE'; + return 1 unless $set1->human eq "(COND1 and !COND2) or (!COND3)"; + return 1 unless $set2->human eq "(COND1 and !COND2) or (!COND3)"; + my $one_cond_human = $set1->one_cond->human; + return 1 unless $one_cond_human eq "!COND3" + || $one_cond_human eq "COND1 and !COND2"; + return 1 unless $set1->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; + + my $merged1 = $set1->merge ($set2); + my $merged2 = $set1->merge ($cond); + my $mult1 = $set1->multiply ($set3); + my $mult2 = $set1->multiply ($another); + return 1 unless $merged1->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; + return 1 unless $merged2->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; + return 1 unless $mult1->string eq "COND1_TRUE COND2_FALSE COND3_TRUE COND4_FALSE"; + return 1 unless $mult1 == $mult2; + + return 0; } sub build_set (@) diff --git a/lib/Automake/tests/Makefile.am b/lib/Automake/tests/Makefile.am index cb5ed1a..722c75c 100644 --- a/lib/Automake/tests/Makefile.am +++ b/lib/Automake/tests/Makefile.am @@ -26,6 +26,8 @@ Cond2.pl \ Cond3.pl \ DisjConditions.pl \ DisjConditions-t.pl \ +DisjCon2.pl \ +DisjCon3.pl \ Version.pl \ Version2.pl \ Version3.pl \ @@ -34,6 +36,8 @@ Wrap.pl XFAIL_TESTS = \ Cond2.pl \ Cond3.pl \ +DisjCon2.pl \ +DisjCon3.pl \ Version2.pl \ Version3.pl diff --git a/lib/Automake/tests/Makefile.in b/lib/Automake/tests/Makefile.in index 6402ade..875b560 100644 --- a/lib/Automake/tests/Makefile.in +++ b/lib/Automake/tests/Makefile.in @@ -232,6 +232,8 @@ Cond2.pl \ Cond3.pl \ DisjConditions.pl \ DisjConditions-t.pl \ +DisjCon2.pl \ +DisjCon3.pl \ Version.pl \ Version2.pl \ Version3.pl \ @@ -240,6 +242,8 @@ Wrap.pl XFAIL_TESTS = \ Cond2.pl \ Cond3.pl \ +DisjCon2.pl \ +DisjCon3.pl \ Version2.pl \ Version3.pl -- 1.6.5.1.31.gad12b