/[make]/make/tests/scripts/functions/eval
ViewVC logotype

Contents of /make/tests/scripts/functions/eval

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Thu Jan 30 07:49:17 2003 UTC (21 years, 3 months ago) by psmith
Branch: MAIN
Changes since 1.2: +21 -0 lines
Fix bug #2238: the read.c:eval() function was not entirely reentrant.
Apply patch #1022: fix a memory corruption on very long target-specific
variable definition lines.

1 # -*-perl-*-
2
3 $description = "Test the eval function.";
4
5 $details = "This is a test of the eval function in GNU make.
6 This function will evaluate inline makefile syntax and incorporate the
7 results into its internal database.\n";
8
9 open(MAKEFILE,"> $makefile");
10
11 print MAKEFILE <<'EOF';
12 define Y
13 all:: ; @echo $AA
14 A = B
15 endef
16
17 X = $(eval $(value Y))
18
19 $(eval $(shell echo A = A))
20 $(eval $(Y))
21 $(eval A = C)
22 $(eval $(X))
23 EOF
24
25 close(MAKEFILE);
26
27 &run_make_with_options($makefile, "", &get_logfile);
28
29 # Create the answer to what should be produced by this Makefile
30 $answer = "AA\nBA\n";
31
32 &compare_output($answer,&get_logfile(1));
33
34 # Test to make sure defining variables when we have extra scope pushed works
35 # as expected.
36
37 $makefile2 = &get_tmpfile;
38
39 open(MAKEFILE,"> $makefile2");
40
41 print MAKEFILE <<'EOF';
42 VARS = A B
43
44 VARSET = $(1) = $(2)
45
46 $(foreach v,$(VARS),$(eval $(call VARSET,$v,$v)))
47
48 all: ; @echo A = $(A) B = $(B)
49 EOF
50
51 close(MAKEFILE);
52
53 &run_make_with_options($makefile2, "", &get_logfile);
54
55 # Create the answer to what should be produced by this Makefile
56 $answer = "A = A B = B\n";
57
58 &compare_output($answer,&get_logfile(1));
59
60 # Test to make sure eval'ing inside conditionals works properly
61
62 $makefile3 = &get_tmpfile;
63
64 open(MAKEFILE,"> $makefile3");
65
66 print MAKEFILE <<'EOF';
67 FOO = foo
68
69 all:: ; @echo it
70
71 define Y
72 all:: ; @echo worked
73 endef
74
75 ifdef BAR
76 $(eval $(Y))
77 endif
78
79 EOF
80
81 close(MAKEFILE);
82
83 &run_make_with_options($makefile3, "", &get_logfile);
84 $answer = "it\n";
85 &compare_output($answer,&get_logfile(1));
86
87 &run_make_with_options($makefile3, "BAR=1", &get_logfile);
88 $answer = "it\nworked\n";
89 &compare_output($answer,&get_logfile(1));
90
91
92 # TEST very recursive invocation of eval
93
94 $makefile3 = &get_tmpfile;
95
96 open(MAKEFILE,"> $makefile3");
97
98 print MAKEFILE <<'EOF';
99 ..9 := 0 1 2 3 4 5 6 7 8 9
100 rev=$(eval res:=)$(foreach word,$1,$(eval res:=${word} ${res}))${res}
101 a:=$(call rev,${..9})
102 all: ; @echo '[$(a)]'
103
104 EOF
105
106 close(MAKEFILE);
107
108 &run_make_with_options($makefile3, "", &get_logfile);
109 $answer = "[ 9 8 7 6 5 4 3 2 1 0 ]\n";
110 &compare_output($answer,&get_logfile(1));
111
112 1;

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26