VirtualBox

source: kBuild/trunk/src/gmake/tests/scripts/functions/word@ 53

Last change on this file since 53 was 53, checked in by bird, 21 years ago

Initial revision

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1# -*-perl-*-
2$description = "Test the word, words, and wordlist functions.\n";
3
4$details = "\
5Produce a variable with a large number of words in it,
6determine the number of words, and then read each one back.\n";
7
8open(MAKEFILE,"> $makefile");
9print MAKEFILE <<'EOF';
10string := word.pl general_test2.pl FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl
11string2 := $(string) $(string) $(string) $(string) $(string) $(string) $(string)
12string3 := $(string2) $(string2) $(string2) $(string2) $(string2) $(string2) $(string2)
13string4 := $(string3) $(string3) $(string3) $(string3) $(string3) $(string3) $(string3)
14all:
15 @echo $(words $(string))
16 @echo $(words $(string4))
17 @echo $(word 1, $(string))
18 @echo $(word 100, $(string))
19 @echo $(word 1, $(string))
20 @echo $(word 1000, $(string3))
21 @echo $(wordlist 3, 4, $(string))
22 @echo $(wordlist 4, 3, $(string))
23 @echo $(wordlist 1, 6, $(string))
24 @echo $(wordlist 5, 7, $(string))
25 @echo $(wordlist 100, 110, $(string))
26 @echo $(wordlist 7, 10, $(string2))
27EOF
28close(MAKEFILE);
29
30&run_make_with_options($makefile, "", &get_logfile);
31$answer = "6\n"
32 ."2058\n"
33 ."word.pl\n"
34 ."\n"
35 ."word.pl\n"
36 ."\n"
37 ."FORCE.pl word.pl\n"
38 ."\n"
39 ."word.pl general_test2.pl FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl\n"
40 ."generic_test.perl MAKEFILES_variable.pl\n"
41 ."\n"
42 ."word.pl general_test2.pl FORCE.pl word.pl\n";
43&compare_output($answer, &get_logfile(1));
44
45
46# Test error conditions
47
48$makefile2 = &get_tmpfile;
49
50open(MAKEFILE, "> $makefile2");
51print MAKEFILE <<'EOF';
52FOO = foo bar biz baz
53
54word-e1: ; @echo $(word ,$(FOO))
55word-e2: ; @echo $(word abc ,$(FOO))
56word-e3: ; @echo $(word 1a,$(FOO))
57
58wordlist-e1: ; @echo $(wordlist ,,$(FOO))
59wordlist-e2: ; @echo $(wordlist abc ,,$(FOO))
60wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))
61
62EOF
63
64close(MAKEFILE);
65
66&run_make_with_options($makefile2, 'word-e1', &get_logfile, 512);
67$answer = "$makefile2:3: *** non-numeric first argument to `word' function: ''. Stop.\n";
68&compare_output($answer, &get_logfile(1));
69
70&run_make_with_options($makefile2, 'word-e2', &get_logfile, 512);
71$answer = "$makefile2:4: *** non-numeric first argument to `word' function: 'abc '. Stop.\n";
72&compare_output($answer, &get_logfile(1));
73
74&run_make_with_options($makefile2, 'word-e3', &get_logfile, 512);
75$answer = "$makefile2:5: *** non-numeric first argument to `word' function: '1a'. Stop.\n";
76&compare_output($answer, &get_logfile(1));
77
78&run_make_with_options($makefile2, 'wordlist-e1', &get_logfile, 512);
79$answer = "$makefile2:7: *** non-numeric first argument to `wordlist' function: ''. Stop.\n";
80&compare_output($answer, &get_logfile(1));
81
82&run_make_with_options($makefile2, 'wordlist-e2', &get_logfile, 512);
83$answer = "$makefile2:8: *** non-numeric first argument to `wordlist' function: 'abc '. Stop.\n";
84&compare_output($answer, &get_logfile(1));
85
86&run_make_with_options($makefile2, 'wordlist-e3', &get_logfile, 512);
87$answer = "$makefile2:9: *** non-numeric second argument to `wordlist' function: ' 12a '. Stop.\n";
88&compare_output($answer, &get_logfile(1));
89
90# This tells the test driver that the perl test script executed properly.
911;
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette