Update AUTHORS file using admin/list_authors.pl.
[maxima/cygwin.git] / tests / rtest_trace.mac
blob3b32acc388d0152600c6070fe0125664610aea84
1 /* Tests for Maxima's trace and timer */
3 (kill (all),
4  0);
5 0;
7 /* Bug #3247: Maxima's trace and timer handle rules incorrectly */
9 (kill (r),
10  defrule (r, foo, bar),
11  0)$
14 (trace (r),
15  trace_options (r, noprint),
16  0)$
19 /* This used to return foo */
20 apply1 (foo, r);
21 'bar;
23 untrace (r)$
24 [r];
26 timer (r)$
27 [r];
29 /* This also used to return foo */
30 apply1 (foo, r);
31 'bar;
33 (untimer (r),
34  kill (r),
35  0);
38 /* Bug #2803: trace/timer do not work for functions with quoted arguments
39  *
40  * Here we test some traced and timed functions that have different
41  * combinations of quoted and rest args.  The timer tests are actually
42  * redundant since trace and timer didn't require separate fixes.
43  */
45 /* Watch out for extra evaluations */
46 ([a, b, c, d] : [u, v, w, x],
47  [u, v, w, x] : [1, 2, 3, 4],
48  0)$
51 (f1 ('x) := x,
52  0);
55 (trace (f1),
56  trace_options (f1, noprint),
57  0);
60 f1 (a);
61 'a;
63 f1 (error ());
64 '(error ());
66 (untrace (f1),
67  0);
70 (timer (f1),
71  0);
74 f1 (a);
75 'a;
77 f1 (error ());
78 '(error ());
80 (kill (f1),
81  0);
84 (f2 (['x]) := x,
85  0);
88 (trace (f2),
89  trace_options (f2, noprint),
90  0);
93 f2 ();
94 [];
96 f2 (a, b, c, d);
97 ['a, 'b, 'c, 'd];
99 f2 (error (), error (), error (), error ());
100 ['(error ()), '(error ()), '(error ()), '(error ())];
102 (untrace (f2),
103  0);
106 (timer (f2),
107  0);
110 f2 ();
113 f2 (a, b, c, d);
114 ['a, 'b, 'c, 'd];
116 f2 (error (), error (), error (), error ());
117 ['(error ()), '(error ()), '(error ()), '(error ())];
119 (kill (f2),
120  0);
123 (f3 ('x, y, z) := [x, y, z],
124  0);
127 (trace (f3),
128  trace_options (f3, noprint),
129  0);
132 f3 (a, b, c);
133 ['a, 'v, 'w];
135 f3 (error (), b, c);
136 ['(error ()), 'v, 'w];
138 (untrace (f3),
139  0);
142 (timer (f3),
143  0);
146 f3 (a, b, c);
147 ['a, 'v, 'w];
149 f3 (error (), b, c);
150 ['(error ()), 'v, 'w];
152 (kill (f3),
153  0);
156 (f4 ('x, y, [z]) := [x, y, z],
157  0);
160 (trace (f4),
161  trace_options (f4, noprint),
162  0);
165 f4 (a, b);
166 ['a, 'v, []];
168 f4 (a, b, c, d);
169 ['a, 'v, ['w, 'x]];
171 f4 (error (), b, c, d);
172 ['(error ()), 'v, ['w, 'x]];
174 (untrace (f4),
175  0);
178 (timer (f4),
179  0);
182 f4 (a, b);
183 ['a, 'v, []];
185 f4 (a, b, c, d);
186 ['a, 'v, ['w, 'x]];
188 f4 (error (), b, c, d);
189 ['(error ()), 'v, ['w, 'x]];
191 (kill (f4),
192  0);
195 (f5 (x, 'y, [z]) := [x, y, z],
196  0);
199 (trace (f5),
200  trace_options (f5, noprint),
201  0);
204 f5 (a, b);
205 ['u, 'b, []];
207 f5 (a, b, c, d);
208 ['u, 'b, ['w, 'x]];
210 f5 (a, error (), c, d);
211 ['u, '(error ()), ['w, 'x]];
213 (untrace (f5),
214  0);
217 (timer (f5),
218  0);
221 f5 (a, b);
222 ['u, 'b, []];
224 f5 (a, b, c, d);
225 ['u, 'b, ['w, 'x]];
227 f5 (a, error (), c, d);
228 ['u, '(error ()), ['w, 'x]];
230 (kill (f5),
231  0);
234 (f6 (x, y, ['z]) := [x, y, z],
235  0);
238 (trace (f6),
239  trace_options (f6, noprint),
240  0);
243 f6 (a, b);
244 ['u, 'v, []];
246 f6 (a, b, c, d);
247 ['u, 'v, ['c, 'd]];
249 f6 (a, b, error (), error ());
250 ['u, 'v, ['(error ()), '(error ())]];
252 (untrace (f6),
253  0);
256 (timer (f6),
257  0);
260 f6 (a, b);
261 ['u, 'v, []];
263 f6 (a, b, c, d);
264 ['u, 'v, ['c, 'd]];
266 f6 (a, b, error (), error ());
267 ['u, 'v, ['(error ()), '(error ())]];
269 (kill (f6),
270  0);
273 (f7 ('x, 'y, ['z]) := [x, y, z],
274  0);
277 (trace (f7),
278  trace_options (f7, noprint),
279  0);
282 f7 (a, b);
283 ['a, 'b, []];
285 f7 (a, b, c, d);
286 ['a, 'b, ['c, 'd]];
288 f7 (error (), error (), error (), error ());
289 ['(error ()), '(error ()), ['(error ()), '(error ())]];
291 (untrace (f7),
292  0);
295 (timer (f7),
296  0);
299 f7 (a, b);
300 ['a, 'b, []];
302 f7 (a, b, c, d);
303 ['a, 'b, ['c, 'd]];
305 f7 (error (), error (), error (), error ());
306 ['(error ()), '(error ()), ['(error ()), '(error ())]];
308 (kill (f7),
309  0);
312 (kill (a, b, c, d, u, v, w, x),
313  0);