xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/functions/andor (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos$description = "Test the and & or functions.\n";
3*69606e3fSchristos
4*69606e3fSchristos$details = "Try various uses of and & or to ensure they all give the correct
5*69606e3fSchristosresults.\n";
6*69606e3fSchristos
7*69606e3fSchristos# TEST #0
8*69606e3fSchristos# For $(and ...), it will either be empty or the last value
9*69606e3fSchristosrun_make_test('
10*69606e3fSchristosNEQ = $(subst $1,,$2)
11*69606e3fSchristosf =
12*69606e3fSchristost = true
13*69606e3fSchristos
14*69606e3fSchristosall:
15*69606e3fSchristos	@echo 1 $(and    ,$t)
16*69606e3fSchristos	@echo 2 $(and $t)
17*69606e3fSchristos	@echo 3 $(and $t,)
18*69606e3fSchristos	@echo 4 $(and z,true,$f,false)
19*69606e3fSchristos	@echo 5 $(and $t,$f,$(info bad short-circuit))
20*69606e3fSchristos	@echo 6 $(and $(call NEQ,a,b),true)
21*69606e3fSchristos	@echo 7 $(and $(call NEQ,a,a),true)
22*69606e3fSchristos	@echo 8 $(and z,true,fal,se) hi
23*69606e3fSchristos	@echo 9 $(and ,true,fal,se)there
24*69606e3fSchristos	@echo 10 $(and   $(e) ,$t)',
25*69606e3fSchristos              '',
26*69606e3fSchristos              "1\n2 true\n3\n4\n5\n6 true\n7\n8 se hi\n9 there\n10\n");
27*69606e3fSchristos
28*69606e3fSchristos# TEST #1
29*69606e3fSchristos# For $(or ...), it will either be empty or the first true value
30*69606e3fSchristosrun_make_test('
31*69606e3fSchristosNEQ = $(subst $1,,$2)
32*69606e3fSchristosf =
33*69606e3fSchristost = true
34*69606e3fSchristos
35*69606e3fSchristosall:
36*69606e3fSchristos	@echo 1 $(or    ,    )
37*69606e3fSchristos	@echo 2 $(or $t)
38*69606e3fSchristos	@echo 3 $(or ,$t)
39*69606e3fSchristos	@echo 4 $(or z,true,$f,false)
40*69606e3fSchristos	@echo 5 $(or $t,$(info bad short-circuit))
41*69606e3fSchristos	@echo 6 $(or $(info short-circuit),$t)
42*69606e3fSchristos	@echo 7 $(or $(call NEQ,a,b),true)
43*69606e3fSchristos	@echo 8 $(or $(call NEQ,a,a),true)
44*69606e3fSchristos	@echo 9 $(or z,true,fal,se) hi
45*69606e3fSchristos	@echo 10 $(or ,true,fal,se)there
46*69606e3fSchristos	@echo 11 $(or   $(e) ,$f)',
47*69606e3fSchristos              '',
48*69606e3fSchristos              "short-circuit\n1\n2 true\n3 true\n4 z\n5 true\n6 true\n7 b\n8 true\n9 z hi\n10 truethere\n11\n");
49*69606e3fSchristos
50*69606e3fSchristos1;
51