summaryrefslogtreecommitdiff
path: root/tests/scripts/functions/word
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@kolpackov.net>2004-10-21 17:42:24 +0000
committerBoris Kolpackov <boris@kolpackov.net>2004-10-21 17:42:24 +0000
commit547abfa13e2037c0461e3965911f5322737f2bda (patch)
treece001b95fcc334baab9cb14c530ae3f0a115d2d1 /tests/scripts/functions/word
parent71fd6bfa1ce41da2dcc9ae0d28f037129d9c481a (diff)
downloadgunmake-547abfa13e2037c0461e3965911f5322737f2bda.tar.gz
New $(lastword ) built-in function: implementation, documentation and tests.
Diffstat (limited to 'tests/scripts/functions/word')
-rw-r--r--tests/scripts/functions/word39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/scripts/functions/word b/tests/scripts/functions/word
index 5083cec..398cd65 100644
--- a/tests/scripts/functions/word
+++ b/tests/scripts/functions/word
@@ -1,5 +1,6 @@
# -*-perl-*-
-$description = "Test the word, words, and wordlist functions.\n";
+$description = "\
+Test the word, words, wordlist, firstword, and lastword functions.\n";
$details = "\
Produce a variable with a large number of words in it,
@@ -87,5 +88,41 @@ $answer = "$makefile2:8: *** non-numeric first argument to `wordlist' function:
$answer = "$makefile2:9: *** non-numeric second argument to `wordlist' function: ' 12a '. Stop.\n";
&compare_output($answer, &get_logfile(1));
+
+# TEST #8 -- test $(firstword )
+#
+run_make_test('
+void :=
+list := $(void) foo bar baz #
+
+a := $(word 1,$(list))
+b := $(firstword $(list))
+
+.PHONY: all
+
+all:
+ @test "$a" = "$b" && echo $a
+',
+'',
+'foo');
+
+
+# TEST #9 -- test $(lastword )
+#
+run_make_test('
+void :=
+list := $(void) foo bar baz #
+
+a := $(word $(words $(list)),$(list))
+b := $(lastword $(list))
+
+.PHONY: all
+
+all:
+ @test "$a" = "$b" && echo $a
+',
+'',
+'baz');
+
# This tells the test driver that the perl test script executed properly.
1;