diff options
Diffstat (limited to 'lib/Automake/tests/Condition-t.pl')
-rw-r--r-- | lib/Automake/tests/Condition-t.pl | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/lib/Automake/tests/Condition-t.pl b/lib/Automake/tests/Condition-t.pl index 06eb34e92..752d340c2 100644 --- a/lib/Automake/tests/Condition-t.pl +++ b/lib/Automake/tests/Condition-t.pl @@ -1,13 +1,12 @@ -# Copyright (C) 2001, 2002, 2003, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2008, 2009, 2011 Free Software +# Foundation, Inc. # -# This file is part of GNU Automake. -# -# GNU Automake is free software; you can redistribute it and/or modify +# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # -# GNU Automake is distributed in the hope that it will be useful, +# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. @@ -18,7 +17,8 @@ BEGIN { use Config; if (eval { require 5.007_002; } # for CLONE support - && $Config{useithreads}) + && $Config{useithreads} + && !$ENV{WANT_NO_THREADS}) { require threads; import threads; @@ -32,15 +32,15 @@ use Automake::Condition qw/TRUE FALSE/; sub test_basics () { - my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string] - [[], 1, 0, 'TRUE', ''], - [['TRUE'], 1, 0, 'TRUE', ''], - [['FALSE'], 0, 1, 'FALSE', '#'], - [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@'], + my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string, human] + [[], 1, 0, 'TRUE', '', 'TRUE'], + [['TRUE'], 1, 0, 'TRUE', '', 'TRUE'], + [['FALSE'], 0, 1, 'FALSE', '#', 'FALSE'], + [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@', 'A'], [['A_TRUE', 'B_FALSE'], - 0, 0, 'A_TRUE B_FALSE', '@A_TRUE@@B_FALSE@'], - [['B_TRUE', 'FALSE'], 0, 1, 'FALSE', '#'], - [['B_TRUE', 'B_FALSE'], 0, 1, 'FALSE', '#']); + 0, 0, 'A_TRUE B_FALSE', '@A_TRUE@@B_FALSE@', 'A and !B'], + [['B_TRUE', 'FALSE'], 0, 1, 'FALSE', '#', 'FALSE'], + [['B_TRUE', 'B_FALSE'], 0, 1, 'FALSE', '#', 'FALSE']); for (@tests) { @@ -53,6 +53,7 @@ sub test_basics () return 1 if $_->[2] != ($a == FALSE); return 1 if $_->[3] ne $a->string; return 1 if $_->[4] ne $a->subst_string; + return 1 if $_->[5] ne $a->human; })->join; } return 0; @@ -281,7 +282,33 @@ sub test_reduce_or () return $failed; } -exit (test_basics || test_true_when || test_reduce_and || test_reduce_or); +sub test_merge () +{ + my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE"; + return threads->new(sub { + my $other = new Automake::Condition "COND3_FALSE"; + return threads->new(sub { + my $both = $cond->merge ($other); + return threads->new(sub { + my $both2 = $cond->merge_conds ("COND3_FALSE"); + return threads->new(sub { + $cond = $both->strip ($other); + my @conds = $cond->conds; + return 1 if $both->string ne "COND1_TRUE COND2_FALSE COND3_FALSE"; + return 1 if $cond->string ne "COND1_TRUE COND2_FALSE"; + return 1 if $both != $both2; + })->join; + })->join; + })->join; + })->join; + return 0; +} + +exit (test_basics + || test_true_when + || test_reduce_and + || test_reduce_or + || test_merge); ### Setup "GNU" style for perl-mode and cperl-mode. ## Local Variables: |