* automake.texi (Macros): Document AM_PROG_AS.
[automake.git] / tests / cond12.test
blob9d3d7b02909d84f176f4bd9a228cb06a93d2b544
1 #! /bin/sh
3 # Test behaviour of variable_conditions_reduce()
4 # This checks the result of variable_conditions_reduce() for a wide variety
5 # of cases.
7 . $srcdir/defs || exit 1
9 # FIXME: probably ought to let use override this like we do in `defs'.
10 amfile=../../automake
12 head -n 1 $amfile >>automake_tmp
13 cat << 'END' >> automake_tmp
14 my $failed = 0;
15 sub check_reduce($$) {
16 my ($inref, $outref) = @_;
17 my @result = sort &Automake::variable_conditions_reduce(@$inref);
18 my $correct = 1;
19 $correct = 0 if (join(",", @result) ne join(",", @$outref));
21 if (! $correct) {
22 print '"'.join(",", @$inref) . '" => "' .
23 join(",", @result) . '" expected "' .
24 join(",", @$outref) . '"' . "\n";
25 $failed = 1;
29 # If no conditions are given, TRUE should be returned
30 check_reduce([""], ["TRUE"]);
31 # A single condition should be passed through unchanged
32 check_reduce(["FOO"], ["FOO"]);
33 check_reduce(["FALSE"], ["FALSE"]);
34 check_reduce(["TRUE"], ["TRUE"]);
36 # TRUE and false should be discarded and overwhelm the result, respectively
37 check_reduce(["FOO", "TRUE"], ["FOO"]);
38 check_reduce(["FOO", "FALSE"], ["FALSE"]);
40 # Repetitions should be removed
41 check_reduce(["FOO", "FOO"], ["FOO"]);
42 check_reduce(["TRUE", "FOO", "FOO"], ["FOO"]);
43 check_reduce(["FOO", "TRUE", "FOO"], ["FOO"]);
44 check_reduce(["FOO", "FOO", "TRUE"], ["FOO"]);
46 # Two different conditions should be preserved, but TRUEs should be removed
47 check_reduce(["FOO", "BAR"], ["BAR,FOO"]);
48 check_reduce(["TRUE", "FOO", "BAR"], ["BAR,FOO"]);
49 check_reduce(["FOO", "TRUE", "BAR"], ["BAR,FOO"]);
50 check_reduce(["FOO", "BAR", "TRUE"], ["BAR,FOO"]);
52 # A condition implied by another condition should be removed.
53 check_reduce(["FOO BAR", "BAR"], ["FOO BAR"]);
54 check_reduce(["BAR", "FOO BAR"], ["FOO BAR"]);
55 check_reduce(["TRUE", "FOO BAR", "BAR"], ["FOO BAR"]);
56 check_reduce(["FOO BAR", "TRUE", "BAR"], ["FOO BAR"]);
57 check_reduce(["FOO BAR", "BAR", "TRUE"], ["FOO BAR"]);
59 check_reduce(["BAR FOO", "BAR"], ["BAR FOO"]);
60 check_reduce(["BAR", "BAR FOO"], ["BAR FOO"]);
61 check_reduce(["TRUE", "BAR FOO", "BAR"], ["BAR FOO"]);
62 check_reduce(["BAR FOO", "TRUE", "BAR"], ["BAR FOO"]);
63 check_reduce(["BAR FOO", "BAR", "TRUE"], ["BAR FOO"]);
65 # Check that reduction happens even when there are two conditionals to remove.
66 check_reduce(["FOO", "FOO BAR", "BAR"], ["FOO BAR"]);
67 check_reduce(["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["FOO BAR", "FOO BAZ"]);
68 check_reduce(["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"], ["FOO BAZ BAR"]);
70 # Duplicated condionals should be removed
71 check_reduce(["FOO", "BAR", "BAR"], ["BAR,FOO"]);
73 # Equivalent conditionals in different forms should be reduced: which one is
74 # left is unfortunately order dependent.
75 check_reduce(["BAR FOO", "FOO BAR"], ["FOO BAR"]);
76 check_reduce(["FOO BAR", "BAR FOO"], ["BAR FOO"]);
78 exit $failed;
79 END
80 cat $amfile >>automake_tmp
81 chmod +x automake_tmp
83 ./automake_tmp