Tag
Hash :
ffcacbab
Author :
Date :
2001-07-01T22:51:38
2001-06-29 Tom Tromey <tromey@redhat.com> * tests/cond11.test: Use `=', not `=='. * tests/cond12.test: Look for automake in build directory, not source directory. 2001-06-29 Richard Boulton <richard@tartarus.org> * automake.in (conditionals_true_when): Pass first parameters by reference, avoiding bug which put all parameters in @CONDS instead of @WHENS. Report by Kalle Olavi Niemitalo. Take a single WHEN instead of an array of WHENS. Remove FIXME; can't now have an empty @WHENS. (conditional_is_redundant): New sub. (variable_conditions_reduce): Check whether each condition is implied by any of the other conditions (other those already discarded), rather than checking only against those already considered (and kept). Also, fix sense of check: was keeping tautologous terms instead of discarding them. Use conditional_is_redundant instead of conditionals_true_when. * tests/Makefile.am (TESTS): Added cond11.test and cond12.test. * tests/cond11.test: New file. * tests/cond12.test: New file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
#! /bin/sh
# Test behaviour of variable_conditions_reduce()
# This checks the result of variable_conditions_reduce() for a wide variety
# of cases.
. $srcdir/defs || exit 1
# FIXME: probably ought to let use override this like we do in `defs'.
amfile=../../automake
head -n 1 $amfile >>automake_tmp
cat << 'END' >> automake_tmp
my $failed = 0;
sub check_reduce($$) {
my ($inref, $outref) = @_;
my @result = sort &Automake::variable_conditions_reduce(@$inref);
my $correct = 1;
$correct = 0 if (join(",", @result) ne join(",", @$outref));
if (! $correct) {
print '"'.join(",", @$inref) . '" => "' .
join(",", @result) . '" expected "' .
join(",", @$outref) . '"' . "\n";
$failed = 1;
}
}
# If no conditions are given, TRUE should be returned
check_reduce([""], ["TRUE"]);
# A single condition should be passed through unchanged
check_reduce(["FOO"], ["FOO"]);
check_reduce(["FALSE"], ["FALSE"]);
check_reduce(["TRUE"], ["TRUE"]);
# TRUE and false should be discarded and overwhelm the result, respectively
check_reduce(["FOO", "TRUE"], ["FOO"]);
check_reduce(["FOO", "FALSE"], ["FALSE"]);
# Repetitions should be removed
check_reduce(["FOO", "FOO"], ["FOO"]);
check_reduce(["TRUE", "FOO", "FOO"], ["FOO"]);
check_reduce(["FOO", "TRUE", "FOO"], ["FOO"]);
check_reduce(["FOO", "FOO", "TRUE"], ["FOO"]);
# Two different conditions should be preserved, but TRUEs should be removed
check_reduce(["FOO", "BAR"], ["BAR,FOO"]);
check_reduce(["TRUE", "FOO", "BAR"], ["BAR,FOO"]);
check_reduce(["FOO", "TRUE", "BAR"], ["BAR,FOO"]);
check_reduce(["FOO", "BAR", "TRUE"], ["BAR,FOO"]);
# A condition implied by another condition should be removed.
check_reduce(["FOO BAR", "BAR"], ["FOO BAR"]);
check_reduce(["BAR", "FOO BAR"], ["FOO BAR"]);
check_reduce(["TRUE", "FOO BAR", "BAR"], ["FOO BAR"]);
check_reduce(["FOO BAR", "TRUE", "BAR"], ["FOO BAR"]);
check_reduce(["FOO BAR", "BAR", "TRUE"], ["FOO BAR"]);
check_reduce(["BAR FOO", "BAR"], ["BAR FOO"]);
check_reduce(["BAR", "BAR FOO"], ["BAR FOO"]);
check_reduce(["TRUE", "BAR FOO", "BAR"], ["BAR FOO"]);
check_reduce(["BAR FOO", "TRUE", "BAR"], ["BAR FOO"]);
check_reduce(["BAR FOO", "BAR", "TRUE"], ["BAR FOO"]);
# Check that reduction happens even when there are two conditionals to remove.
check_reduce(["FOO", "FOO BAR", "BAR"], ["FOO BAR"]);
check_reduce(["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["FOO BAR", "FOO BAZ"]);
check_reduce(["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"], ["FOO BAZ BAR"]);
# Duplicated condionals should be removed
check_reduce(["FOO", "BAR", "BAR"], ["BAR,FOO"]);
# Equivalent conditionals in different forms should be reduced: which one is
# left is unfortunately order dependent.
check_reduce(["BAR FOO", "FOO BAR"], ["FOO BAR"]);
check_reduce(["FOO BAR", "BAR FOO"], ["BAR FOO"]);
exit $failed;
END
cat $amfile >>automake_tmp
chmod +x automake_tmp
./automake_tmp