xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/functions/if (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos$description = "Test the if function.\n";
3*69606e3fSchristos
4*69606e3fSchristos$details = "Try various uses of if and ensure they all give the correct
5*69606e3fSchristosresults.\n";
6*69606e3fSchristos
7*69606e3fSchristosopen(MAKEFILE, "> $makefile");
8*69606e3fSchristos
9*69606e3fSchristosprint MAKEFILE <<EOMAKE;
10*69606e3fSchristosNEQ = \$(subst \$1,,\$2)
11*69606e3fSchristose =
12*69606e3fSchristos
13*69606e3fSchristosall:
14*69606e3fSchristos\t\@echo 1 \$(if    ,true,false)
15*69606e3fSchristos\t\@echo 2 \$(if ,true,)
16*69606e3fSchristos\t\@echo 3 \$(if ,true)
17*69606e3fSchristos\t\@echo 4 \$(if z,true,false)
18*69606e3fSchristos\t\@echo 5 \$(if z,true,\$(shell echo hi))
19*69606e3fSchristos\t\@echo 6 \$(if ,\$(shell echo hi),false)
20*69606e3fSchristos\t\@echo 7 \$(if \$(call NEQ,a,b),true,false)
21*69606e3fSchristos\t\@echo 8 \$(if \$(call NEQ,a,a),true,false)
22*69606e3fSchristos\t\@echo 9 \$(if z,true,fal,se) hi
23*69606e3fSchristos\t\@echo 10 \$(if ,true,fal,se)there
24*69606e3fSchristos\t\@echo 11 \$(if \$(e) ,true,false)
25*69606e3fSchristosEOMAKE
26*69606e3fSchristos
27*69606e3fSchristosclose(MAKEFILE);
28*69606e3fSchristos
29*69606e3fSchristos&run_make_with_options($makefile, "", &get_logfile);
30*69606e3fSchristos$answer = "1 false\n2\n3\n4 true\n5 true\n6 false\n7 true\n8 false\n9 true hi\n10 fal,sethere\n11 false\n";
31*69606e3fSchristos&compare_output($answer, &get_logfile(1));
32*69606e3fSchristos
33*69606e3fSchristos1;
34