make/tests/scripts/functions/substitution
Paul Smith 0799ce730d Fix some bugs in variable pattern substitution (e.g. $(VAR:A=B)),
reported by Markus Mauhart <qwe123@chello.at>.  One was a simple typo; to
fix the other we call patsubst_expand() for all instances of variable
substitution, even when there is no '%'.  We used to call subst_expand()
with a special flag set in the latter case, but it didn't work properly
in all situations.  Easier to just use patsubst_expand() since that's
what it is.
2004-09-21 04:00:31 +00:00

39 lines
890 B
Perl

# -*-perl-*-
$description = "Test the subst and patsubst functions";
$details = "";
# Generic patsubst test: test both the function and variable form.
run_make_test('
foo := a.o b.o c.o
bar := $(foo:.o=.c)
bar2:= $(foo:%.o=%.c)
bar3:= $(patsubst %.c,%.o,x.c.c bar.c)
all:;@echo $(bar); echo $(bar2); echo $(bar3)',
'',
'a.c b.c c.c
a.c b.c c.c
x.c.o bar.o');
# Patsubst without '%'--shouldn't match because the whole word has to match
# in patsubst. Based on a bug report by Markus Mauhart <qwe123@chello.at>
run_make_test('all:;@echo $(patsubst Foo,Repl,FooFoo)', '', 'FooFoo');
# Variable subst where a pattern matches multiple times in a single word.
# Based on a bug report by Markus Mauhart <qwe123@chello.at>
run_make_test('
A := fooBARfooBARfoo
all:;@echo $(A:fooBARfoo=REPL)', '', 'fooBARREPL');
1;