xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/functions/substitution (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos
3*69606e3fSchristos$description = "Test the subst and patsubst functions";
4*69606e3fSchristos
5*69606e3fSchristos$details = "";
6*69606e3fSchristos
7*69606e3fSchristos# Generic patsubst test: test both the function and variable form.
8*69606e3fSchristos
9*69606e3fSchristosrun_make_test('
10*69606e3fSchristosfoo := a.o b.o c.o
11*69606e3fSchristosbar := $(foo:.o=.c)
12*69606e3fSchristosbar2:= $(foo:%.o=%.c)
13*69606e3fSchristosbar3:= $(patsubst %.c,%.o,x.c.c bar.c)
14*69606e3fSchristosall:;@echo $(bar); echo $(bar2); echo $(bar3)',
15*69606e3fSchristos'',
16*69606e3fSchristos'a.c b.c c.c
17*69606e3fSchristosa.c b.c c.c
18*69606e3fSchristosx.c.o bar.o');
19*69606e3fSchristos
20*69606e3fSchristos# Patsubst without '%'--shouldn't match because the whole word has to match
21*69606e3fSchristos# in patsubst.  Based on a bug report by Markus Mauhart <qwe123@chello.at>
22*69606e3fSchristos
23*69606e3fSchristosrun_make_test('all:;@echo $(patsubst Foo,Repl,FooFoo)', '', 'FooFoo');
24*69606e3fSchristos
25*69606e3fSchristos# Variable subst where a pattern matches multiple times in a single word.
26*69606e3fSchristos# Based on a bug report by Markus Mauhart <qwe123@chello.at>
27*69606e3fSchristos
28*69606e3fSchristosrun_make_test('
29*69606e3fSchristosA := fooBARfooBARfoo
30*69606e3fSchristosall:;@echo $(A:fooBARfoo=REPL)', '', 'fooBARREPL');
31*69606e3fSchristos
32*69606e3fSchristos1;
33*69606e3fSchristos
34*69606e3fSchristos
35*69606e3fSchristos
36*69606e3fSchristos
37*69606e3fSchristos
38*69606e3fSchristos
39