File: | /tmp/automake/lib/Automake/tests/DisjConditions-t.pl |
Coverage: | 61.1% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | # Copyright (C) 2001, 2002, 2003, 2008, 2009 Free Software Foundation, | ||||||
2 | # Inc. | ||||||
3 | # | ||||||
4 | # This file is part of GNU Automake. | ||||||
5 | # | ||||||
6 | # GNU Automake is free software; you can redistribute it and/or modify | ||||||
7 | # it under the terms of the GNU General Public License as published by | ||||||
8 | # the Free Software Foundation; either version 2, or (at your option) | ||||||
9 | # any later version. | ||||||
10 | # | ||||||
11 | # GNU Automake is distributed in the hope that it will be useful, | ||||||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
14 | # GNU General Public License for more details. | ||||||
15 | # | ||||||
16 | # You should have received a copy of the GNU General Public License | ||||||
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||
18 | |||||||
19 | BEGIN { | ||||||
20 | 4 4 4 | 60 5 13 | use Config; | ||||
21 | 4 4 | 8 25 | if (eval { require 5.007_002; } # for CLONE support | ||||
22 | && $Config{useithreads} | ||||||
23 | && !$ENV{WANT_NO_THREADS}) | ||||||
24 | { | ||||||
25 | 0 | 0 | require threads; | ||||
26 | 0 | 0 | import threads; | ||||
27 | } | ||||||
28 | else | ||||||
29 | { | ||||||
30 | 4 | 7 | exit 77; | ||||
31 | } | ||||||
32 | } | ||||||
33 | use Automake::Condition qw/TRUE FALSE/; | ||||||
34 | use Automake::DisjConditions; | ||||||
35 | |||||||
36 | sub test_basics () | ||||||
37 | { | ||||||
38 | my $true = new Automake::DisjConditions TRUE; | ||||||
39 | my $false = new Automake::DisjConditions FALSE; | ||||||
40 | my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE"; | ||||||
41 | return threads->new (sub { | ||||||
42 | my $other = new Automake::Condition "COND3_FALSE"; | ||||||
43 | my $another = new Automake::Condition "COND3_TRUE", "COND4_FALSE"; | ||||||
44 | return threads->new (sub { | ||||||
45 | my $set1 = new Automake::DisjConditions $cond, $other; | ||||||
46 | return threads->new (sub { | ||||||
47 | my $set2 = new Automake::DisjConditions $other, $cond; | ||||||
48 | my $set3 = new Automake::DisjConditions FALSE, $another; | ||||||
49 | return 1 unless $set1 == $set2; | ||||||
50 | return 1 if $set1->false; | ||||||
51 | return 1 if $set1->true; | ||||||
52 | return 1 unless (new Automake::DisjConditions)->false; | ||||||
53 | return 1 if (new Automake::DisjConditions)->true; | ||||||
54 | return 1 unless $true->human eq 'TRUE'; | ||||||
55 | return 1 unless $false->human eq 'FALSE'; | ||||||
56 | return 1 unless $set1->human eq "(COND1 and !COND2) or (!COND3)"; | ||||||
57 | return 1 unless $set2->human eq "(COND1 and !COND2) or (!COND3)"; | ||||||
58 | my $one_cond_human = $set1->one_cond->human; | ||||||
59 | return 1 unless $one_cond_human eq "!COND3" | ||||||
60 | || $one_cond_human eq "COND1 and !COND2"; | ||||||
61 | return 1 unless $set1->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; | ||||||
62 | |||||||
63 | my $merged1 = $set1->merge ($set2); | ||||||
64 | my $merged2 = $set1->merge ($cond); | ||||||
65 | my $mult1 = $set1->multiply ($set3); | ||||||
66 | return threads->new (sub { | ||||||
67 | my $mult2 = $set1->multiply ($another); | ||||||
68 | return threads->new (sub { | ||||||
69 | return 1 unless $merged1->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; | ||||||
70 | return 1 unless $merged2->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE"; | ||||||
71 | return 1 unless $mult1->string eq "COND1_TRUE COND2_FALSE COND3_TRUE COND4_FALSE"; | ||||||
72 | return 1 unless $mult1 == $mult2; | ||||||
73 | return 0; | ||||||
74 | })->join; | ||||||
75 | })->join; | ||||||
76 | })->join; | ||||||
77 | })->join; | ||||||
78 | })->join; | ||||||
79 | } | ||||||
80 | |||||||
81 | sub build_set (@) | ||||||
82 | { | ||||||
83 | my @conds = @_; | ||||||
84 | my @set = (); | ||||||
85 | for my $cond (@conds) | ||||||
86 | { | ||||||
87 | push @set, new Automake::Condition @$cond; | ||||||
88 | } | ||||||
89 | return new Automake::DisjConditions @set; | ||||||
90 | } | ||||||
91 | |||||||
92 | sub test_invert () | ||||||
93 | { | ||||||
94 | my @tests = ([[["FALSE"]], | ||||||
95 | [["TRUE"]]], | ||||||
96 | |||||||
97 | [[["TRUE"]], | ||||||
98 | [["FALSE"]]], | ||||||
99 | |||||||
100 | [[["COND1_TRUE", "COND2_TRUE"], | ||||||
101 | ["COND3_FALSE", "COND2_TRUE"]], | ||||||
102 | [["COND2_FALSE"], | ||||||
103 | ["COND1_FALSE", "COND3_TRUE"]]], | ||||||
104 | |||||||
105 | [[["COND1_TRUE", "COND2_TRUE"], | ||||||
106 | ["TRUE"]], | ||||||
107 | [["FALSE"]]], | ||||||
108 | |||||||
109 | [[["COND1_TRUE", "COND2_TRUE"], | ||||||
110 | ["FALSE"]], | ||||||
111 | [["COND1_FALSE"], | ||||||
112 | ["COND2_FALSE"]]], | ||||||
113 | |||||||
114 | [[["COND1_TRUE"], | ||||||
115 | ["COND2_FALSE"]], | ||||||
116 | [["COND1_FALSE", "COND2_TRUE"]]] | ||||||
117 | ); | ||||||
118 | |||||||
119 | for my $t (@tests) | ||||||
120 | { | ||||||
121 | my $set = build_set @{$t->[0]}; | ||||||
122 | return 1 | ||||||
123 | if threads->new(sub { | ||||||
124 | my $res = build_set @{$t->[1]}; | ||||||
125 | my $inv = $set->invert; | ||||||
126 | if ($inv != $res) | ||||||
127 | { | ||||||
128 | print " (I) " . $set->string . "\n\t" | ||||||
129 | . $inv->string . ' != ' . $res->string . "\n"; | ||||||
130 | return 1; | ||||||
131 | } | ||||||
132 | return 0 | ||||||
133 | })-> join; | ||||||
134 | } | ||||||
135 | return 0; | ||||||
136 | } | ||||||
137 | |||||||
138 | sub test_simplify () | ||||||
139 | { | ||||||
140 | my @tests = ([[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
141 | ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"]], | ||||||
142 | [["FOO_TRUE", "BAR_FALSE"]]], | ||||||
143 | |||||||
144 | [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
145 | ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"], | ||||||
146 | ["FOO_TRUE", "BAR_TRUE"]], | ||||||
147 | [["FOO_TRUE"]]], | ||||||
148 | |||||||
149 | [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
150 | ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"], | ||||||
151 | ["FOO_TRUE", "BAR_TRUE"], | ||||||
152 | ["FOO_FALSE"]], | ||||||
153 | [["TRUE"]]], | ||||||
154 | |||||||
155 | [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
156 | ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"], | ||||||
157 | ["BAR_TRUE", "BAZ_TRUE"], | ||||||
158 | ["BAR_FALSE", "BAZ_TRUE"]], | ||||||
159 | [["BAZ_TRUE"], ["FOO_TRUE", "BAR_FALSE"]]], | ||||||
160 | |||||||
161 | [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
162 | ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"], | ||||||
163 | ["BAR_TRUE", "BAZ_TRUE"], | ||||||
164 | ["BAR_FALSE", "BAZ_TRUE"], | ||||||
165 | ["FOO_FALSE"]], | ||||||
166 | [["FOO_FALSE"], ["BAZ_TRUE"], ["BAR_FALSE"]]], | ||||||
167 | |||||||
168 | [[["B_TRUE"], | ||||||
169 | ["A_FALSE", "B_TRUE"]], | ||||||
170 | [["B_TRUE"]]], | ||||||
171 | |||||||
172 | [[["B_TRUE"], | ||||||
173 | ["A_FALSE", "B_FALSE", "C_TRUE"], | ||||||
174 | ["A_FALSE", "B_FALSE", "C_FALSE"]], | ||||||
175 | [["A_FALSE"], ["B_TRUE"]]], | ||||||
176 | |||||||
177 | [[["B_TRUE"], | ||||||
178 | ["A_FALSE", "B_FALSE", "C_TRUE"], | ||||||
179 | ["A_FALSE", "B_FALSE", "C_FALSE"], | ||||||
180 | ["A_TRUE", "B_FALSE"]], | ||||||
181 | [["TRUE"]]], | ||||||
182 | |||||||
183 | [[["A_TRUE", "B_TRUE"], | ||||||
184 | ["A_TRUE", "B_FALSE"], | ||||||
185 | ["A_TRUE", "C_FALSE", "D_FALSE"]], | ||||||
186 | [["A_TRUE"]]], | ||||||
187 | |||||||
188 | [[["A_FALSE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"], | ||||||
189 | ["A_FALSE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"], | ||||||
190 | ["A_FALSE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"], | ||||||
191 | ["A_FALSE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"], | ||||||
192 | ["A_TRUE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"], | ||||||
193 | ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"], | ||||||
194 | ["A_TRUE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"], | ||||||
195 | ["A_TRUE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"]], | ||||||
196 | [ ["B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"], | ||||||
197 | ["B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"], | ||||||
198 | ["B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"], | ||||||
199 | ["B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"]]], | ||||||
200 | |||||||
201 | [[["A_FALSE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"], | ||||||
202 | ["A_FALSE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"], | ||||||
203 | ["A_FALSE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"], | ||||||
204 | ["A_FALSE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"], | ||||||
205 | ["A_TRUE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"], | ||||||
206 | ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"], | ||||||
207 | ["A_TRUE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"], | ||||||
208 | ["A_TRUE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"], | ||||||
209 | ["A_FALSE", "B_FALSE", "C_FALSE", "D_FALSE", "E_FALSE"], | ||||||
210 | ["A_FALSE", "B_FALSE", "C_TRUE", "D_FALSE", "E_TRUE"], | ||||||
211 | ["A_FALSE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"], | ||||||
212 | ["A_FALSE", "B_TRUE", "C_FALSE", "D_TRUE", "E_FALSE"], | ||||||
213 | ["A_TRUE", "B_TRUE", "C_FALSE", "D_TRUE", "E_FALSE"], | ||||||
214 | ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"], | ||||||
215 | ["A_TRUE", "B_FALSE", "C_TRUE", "D_FALSE", "E_TRUE"], | ||||||
216 | ["A_TRUE", "B_FALSE", "C_FALSE", "D_FALSE", "E_FALSE"]], | ||||||
217 | [["C_FALSE", "E_FALSE"], | ||||||
218 | ["C_TRUE", "E_TRUE"]]], | ||||||
219 | |||||||
220 | [[["A_FALSE"], | ||||||
221 | ["A_TRUE", "B_FALSE"], | ||||||
222 | ["A_TRUE", "B_TRUE", "C_FALSE"], | ||||||
223 | ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE"], | ||||||
224 | ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_FALSE"], | ||||||
225 | ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE", "F_FALSE"], | ||||||
226 | ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"]], | ||||||
227 | [["TRUE"]]], | ||||||
228 | |||||||
229 | # Simplify should work with up to 31 variables. | ||||||
230 | [[["V01_TRUE", "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE", | ||||||
231 | "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE", | ||||||
232 | "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE", | ||||||
233 | "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE", | ||||||
234 | "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE", | ||||||
235 | "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE", | ||||||
236 | "V31_TRUE"], | ||||||
237 | ["V01_TRUE", "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE", | ||||||
238 | "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE", | ||||||
239 | "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE", | ||||||
240 | "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE", | ||||||
241 | "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE", | ||||||
242 | "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE", | ||||||
243 | "V31_FALSE"], | ||||||
244 | ["V01_FALSE","V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE", | ||||||
245 | "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE", | ||||||
246 | "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE", | ||||||
247 | "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE", | ||||||
248 | "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE", | ||||||
249 | "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE", | ||||||
250 | "V31_TRUE"], | ||||||
251 | ["V01_FALSE","V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE", | ||||||
252 | "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE", | ||||||
253 | "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE", | ||||||
254 | "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE", | ||||||
255 | "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE", | ||||||
256 | "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE", | ||||||
257 | "V31_FALSE"]], | ||||||
258 | [[ "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE", | ||||||
259 | "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE", | ||||||
260 | "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE", | ||||||
261 | "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE", | ||||||
262 | "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE", | ||||||
263 | "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE" | ||||||
264 | ]]]); | ||||||
265 | |||||||
266 | for my $t (@tests) | ||||||
267 | { | ||||||
268 | my $set = build_set @{$t->[0]}; | ||||||
269 | return 1 | ||||||
270 | if threads->new(sub { | ||||||
271 | my $res = build_set @{$t->[1]}; | ||||||
272 | return threads->new(sub { | ||||||
273 | |||||||
274 | # Make sure simplify() yields the expected result. | ||||||
275 | my $sim = $set->simplify; | ||||||
276 | return threads->new(sub { | ||||||
277 | if ($sim != $res) | ||||||
278 | { | ||||||
279 | print " (S1) " . $set->string . "\n\t" | ||||||
280 | . $sim->string . ' != ' . $res->string . "\n"; | ||||||
281 | return 1; | ||||||
282 | } | ||||||
283 | |||||||
284 | # Make sure simplify() is idempotent. | ||||||
285 | my $sim2 = $sim->simplify; | ||||||
286 | return threads->new(sub { | ||||||
287 | if ($sim2 != $sim) | ||||||
288 | { | ||||||
289 | print " (S2) " . $sim->string . "\n\t" | ||||||
290 | . $sim2->string . ' != ' . $sim->string . "\n"; | ||||||
291 | return 1; | ||||||
292 | } | ||||||
293 | |||||||
294 | # Also exercise invert() while we are at it. | ||||||
295 | |||||||
296 | my $inv1 = $set->invert->simplify; | ||||||
297 | return threads->new(sub { | ||||||
298 | my $inv2 = $sim->invert->simplify; | ||||||
299 | return threads->new(sub { | ||||||
300 | if ($inv1 != $inv2) | ||||||
301 | { | ||||||
302 | print " (S3) " . $set->string . ", " . $sim->string . "\n\t" | ||||||
303 | . $inv1->string . ' -= ' . $inv2->string . "\n"; | ||||||
304 | return 1; | ||||||
305 | } | ||||||
306 | })->join; | ||||||
307 | })->join; | ||||||
308 | })->join; | ||||||
309 | })->join; | ||||||
310 | })->join; | ||||||
311 | })->join; | ||||||
312 | } | ||||||
313 | |||||||
314 | return 0; | ||||||
315 | } | ||||||
316 | |||||||
317 | sub test_sub_conditions () | ||||||
318 | { | ||||||
319 | my @tests = ([[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
320 | ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"], | ||||||
321 | ["FOO_FALSE"]], | ||||||
322 | ["FOO_TRUE"], | ||||||
323 | [["BAR_FALSE", "BAZ_FALSE"], | ||||||
324 | ["BAR_FALSE", "BAZ_TRUE"]]], | ||||||
325 | |||||||
326 | [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
327 | ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"], | ||||||
328 | ["FOO_FALSE"]], | ||||||
329 | ["FOO_TRUE", "BAR_FALSE"], | ||||||
330 | [["BAZ_FALSE"], | ||||||
331 | ["BAZ_TRUE"]]], | ||||||
332 | |||||||
333 | [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
334 | ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"], | ||||||
335 | ["FOO_FALSE"]], | ||||||
336 | ["FOO_TRUE", "BAR_TRUE"], | ||||||
337 | [["FALSE"]]], | ||||||
338 | |||||||
339 | [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"], | ||||||
340 | ["FOO_TRUE", "BAZ_TRUE"], | ||||||
341 | ["FOO_FALSE"]], | ||||||
342 | ["FOO_TRUE", "BAR_TRUE"], | ||||||
343 | [["BAZ_TRUE"]]], | ||||||
344 | |||||||
345 | [[["FOO_TRUE", "BAR_FALSE"], | ||||||
346 | ["FOO_TRUE", "BAR_TRUE"]], | ||||||
347 | ["FOO_TRUE", "BAR_TRUE"], | ||||||
348 | [["TRUE"]]], | ||||||
349 | |||||||
350 | [[["TRUE"]], | ||||||
351 | ["TRUE"], | ||||||
352 | [["TRUE"]]], | ||||||
353 | |||||||
354 | [[["FALSE"]], | ||||||
355 | ["TRUE"], | ||||||
356 | [["FALSE"]]], | ||||||
357 | |||||||
358 | [[["FALSE"]], | ||||||
359 | ["FALSE"], | ||||||
360 | [["FALSE"]]]); | ||||||
361 | |||||||
362 | for my $t (@tests) | ||||||
363 | { | ||||||
364 | my $t1 = build_set @{$t->[0]}; | ||||||
365 | return 1 | ||||||
366 | if threads->new(sub { | ||||||
367 | my $t2 = new Automake::Condition @{$t->[1]}; | ||||||
368 | return threads->new(sub { | ||||||
369 | my $t3 = build_set @{$t->[2]}; | ||||||
370 | return threads->new(sub { | ||||||
371 | |||||||
372 | # Make sure sub_conditions() yields the expected result. | ||||||
373 | my $s = $t1->sub_conditions ($t2); | ||||||
374 | threads->new(sub { | ||||||
375 | if ($s != $t3) | ||||||
376 | { | ||||||
377 | print " (SC) " . $t1->string . "\n\t" | ||||||
378 | . $s->string . ' != ' . $t3->string . "\n"; | ||||||
379 | return 1; | ||||||
380 | } | ||||||
381 | })->join; | ||||||
382 | })->join; | ||||||
383 | })->join; | ||||||
384 | })->join; | ||||||
385 | } | ||||||
386 | } | ||||||
387 | |||||||
388 | sub test_ambig () | ||||||
389 | { | ||||||
390 | my @tests = ([[["TRUE"]], | ||||||
391 | ["TRUE"], | ||||||
392 | "multiply defined"], | ||||||
393 | [[["C1_TRUE"]], | ||||||
394 | ["C1_TRUE"], | ||||||
395 | "multiply defined"], | ||||||
396 | [[["TRUE"]], | ||||||
397 | ["C1_FALSE"], | ||||||
398 | "which includes"], | ||||||
399 | [[["C1_TRUE"]], | ||||||
400 | ["C1_TRUE", "C2_TRUE"], | ||||||
401 | "which includes"], | ||||||
402 | [[["C1_TRUE", "C2_TRUE"]], | ||||||
403 | ["C2_TRUE"], | ||||||
404 | "which is included in"], | ||||||
405 | [[["C1_TRUE"]], | ||||||
406 | ["C2_TRUE"], | ||||||
407 | ''], | ||||||
408 | [[["C1_TRUE"], | ||||||
409 | ["C2_FALSE"]], | ||||||
410 | ["C1_FALSE", "C2_TRUE"], | ||||||
411 | '']); | ||||||
412 | |||||||
413 | my $failed = 0; | ||||||
414 | for my $t (@tests) | ||||||
415 | { | ||||||
416 | my $t1 = build_set @{$t->[0]}; | ||||||
417 | $failed = 1 | ||||||
418 | if threads->new(sub { | ||||||
419 | my $t2 = new Automake::Condition @{$t->[1]}; | ||||||
420 | my $t3 = $t->[2]; | ||||||
421 | return threads->new(sub { | ||||||
422 | my ($ans, $cond) = $t1->ambiguous_p ("FOO", $t2); | ||||||
423 | return threads->new(sub { | ||||||
424 | if ($t3 && $ans !~ /FOO.*$t3/) | ||||||
425 | { | ||||||
426 | print " (A1) " . $t1->string . " vs. " . $t2->string . "\n\t" | ||||||
427 | . "Error message '$ans' does not match '$t3'\n"; | ||||||
428 | return 1; | ||||||
429 | } | ||||||
430 | if (!$t3 && $ans ne '') | ||||||
431 | { | ||||||
432 | print " (A2) " . $t1->string . " vs. " . $t2->string . "\n\t" | ||||||
433 | . "Unexpected error message: $ans\n"; | ||||||
434 | return 1; | ||||||
435 | } | ||||||
436 | })->join; | ||||||
437 | })->join; | ||||||
438 | })->join; | ||||||
439 | } | ||||||
440 | return $failed; | ||||||
441 | } | ||||||
442 | |||||||
443 | exit (test_basics | ||||||
444 | || test_invert | ||||||
445 | || test_simplify | ||||||
446 | || test_sub_conditions | ||||||
447 | || test_ambig); | ||||||
448 | |||||||
449 | ### Setup "GNU" style for perl-mode and cperl-mode. | ||||||
450 | ## Local Variables: | ||||||
451 | ## perl-indent-level: 2 | ||||||
452 | ## perl-continued-statement-offset: 2 | ||||||
453 | ## perl-continued-brace-offset: 0 | ||||||
454 | ## perl-brace-offset: 0 | ||||||
455 | ## perl-brace-imaginary-offset: 0 | ||||||
456 | ## perl-label-offset: -2 | ||||||
457 | ## cperl-indent-level: 2 | ||||||
458 | ## cperl-brace-offset: 0 | ||||||
459 | ## cperl-continued-brace-offset: 0 | ||||||
460 | ## cperl-label-offset: -2 | ||||||
461 | ## cperl-extra-newline-before-brace: t | ||||||
462 | ## cperl-merge-trailing-else: nil | ||||||
463 | ## cperl-continued-statement-offset: 2 | ||||||
464 | ## End: |