Use the same algorithm for counting the number of words to sort as we
[make.git] / tests / scripts / functions / sort
blobb558910303055c99ddf47d71f8e389a8c1efe46c
1 #                                                                    -*-perl-*-
3 $description = "The following test creates a makefile to verify
4 the ability of make to sort lists of object. Sort
5 will also remove any duplicate entries. This will also
6 be tested.";
8 $details = "The make file is built with a list of object in a random order
9 and includes some duplicates. Make should sort all of the elements
10 remove all duplicates\n";
12 run_make_test('
13 foo := moon_light days
14 foo1:= jazz
15 bar := captured 
16 bar2 = boy end, has rise A midnight 
17 bar3:= $(foo)
18 s1  := _by
19 s2  := _and_a
20 t1  := $(addsuffix $(s1), $(bar) )
21 t2  := $(addsuffix $(s2), $(foo1) )
22 t3  := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) 
23 t4  := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) 
24 t5  := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) 
25 t6  := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) 
26 t7  := $(t6) $(t6) $(t6) 
27 p1  := $(addprefix $(foo1), $(s2) )
28 blank:= 
29 all:
30         @echo $(sort $(bar2) $(foo)  $(addsuffix $(s1), $(bar) ) $(t2) $(bar2) $(bar3))
31         @echo $(sort $(blank) $(foo) $(bar2) $(t1) $(p1) )
32         @echo $(sort $(foo) $(bar2) $(t1) $(t4) $(t5) $(t7) $(t6) )
34               '', 'A boy captured_by days end, has jazz_and_a midnight moon_light rise
35 A boy captured_by days end, has jazz_and_a midnight moon_light rise
36 A boy captured_by days end, has jazz_and_a midnight moon_light rise
37 ');
40 # Test with non-space/tab whitespace.  Note that you can't see the
41 # original bug except using valgrind.
43 run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff
44 all: ; \@echo \$(words \$(sort \$(FOO)))\n",
45               '', "5\n");