1 /* Tests for Maxima's trace and timer */
7 /* Bug #3247: Maxima's trace and timer handle rules incorrectly */
10 defrule (r, foo, bar),
15 trace_options (r, noprint),
19 /* This used to return foo */
29 /* This also used to return foo */
38 /* Bug #2803: trace/timer do not work for functions with quoted arguments
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.
45 /* Watch out for extra evaluations */
46 ([a, b, c, d] : [u, v, w, x],
47 [u, v, w, x] : [1, 2, 3, 4],
56 trace_options (f1, noprint),
89 trace_options (f2, noprint),
99 f2 (error (), error (), error (), error ());
100 ['(error ()), '(error ()), '(error ()), '(error ())];
116 f2 (error (), error (), error (), error ());
117 ['(error ()), '(error ()), '(error ()), '(error ())];
123 (f3 ('x, y, z) := [x, y, z],
128 trace_options (f3, noprint),
136 ['(error ()), 'v, 'w];
150 ['(error ()), 'v, 'w];
156 (f4 ('x, y, [z]) := [x, y, z],
161 trace_options (f4, noprint),
171 f4 (error (), b, c, d);
172 ['(error ()), 'v, ['w, 'x]];
188 f4 (error (), b, c, d);
189 ['(error ()), 'v, ['w, 'x]];
195 (f5 (x, 'y, [z]) := [x, y, z],
200 trace_options (f5, noprint),
210 f5 (a, error (), c, d);
211 ['u, '(error ()), ['w, 'x]];
227 f5 (a, error (), c, d);
228 ['u, '(error ()), ['w, 'x]];
234 (f6 (x, y, ['z]) := [x, y, z],
239 trace_options (f6, noprint),
249 f6 (a, b, error (), error ());
250 ['u, 'v, ['(error ()), '(error ())]];
266 f6 (a, b, error (), error ());
267 ['u, 'v, ['(error ()), '(error ())]];
273 (f7 ('x, 'y, ['z]) := [x, y, z],
278 trace_options (f7, noprint),
288 f7 (error (), error (), error (), error ());
289 ['(error ()), '(error ()), ['(error ()), '(error ())]];
305 f7 (error (), error (), error (), error ());
306 ['(error ()), '(error ()), ['(error ()), '(error ())]];
312 (kill (a, b, c, d, u, v, w, x),
316 /* SF bug #3963: "trace doesn't detect calls to functions defined by DEFMFUN in Lisp code" */
318 (S: make_string_output_stream (),
320 with_stdout (S, atom(1)),
321 get_output_stream_string (S));
325 with_default_2d_display(with_stdout (S, atom(1))),
326 get_output_stream_string (S));
333 with_stdout (S, block ([display2d: false], risch (2*x, x))),
334 get_output_stream_string (S));
335 "1 Enter rischint [2*x,x]
336 1 Exit rischint (2*x^2)/2
339 (untrace (?rischint),
340 trace (integrate, defint, limit, ?antideriv),
341 with_stdout (S, block ([display2d: false], integrate (exp(-x)*cos(x), x, 0, inf))),
342 get_output_stream_string (S));
343 "1 Enter integrate [%e^-x*cos(x),x,0,inf]
344 1 Enter defint [%e^-x*cos(x),x,0,inf]
347 1 Enter limit [%e^-x,x,inf]
351 1 Enter antideriv [%e^-x*cos(x),x]
352 1 Exit antideriv (%e^-x*(sin(x)-cos(x)))/2
355 1 Enter limit [(%e^-x*sin(x))/2-(%e^-x*cos(x))/2,x,0,plus]
357 1 Enter limit [(%e^-x*sin(x))/2-(%e^-x*cos(x))/2,x,inf,minus]
363 (untrace (limit, defint),
364 with_stdout (S, block ([display2d: false], integrate (exp(-x)*cos(x), x, 0, inf))),
365 get_output_stream_string (S));
366 "1 Enter integrate [%e^-x*cos(x),x,0,inf]
367 1 Enter antideriv [%e^-x*cos(x),x]
368 1 Exit antideriv (%e^-x*(sin(x)-cos(x)))/2
372 (untrace (integrate, ?antideriv),
373 with_stdout (S, block ([display2d: false], integrate (exp(-x)*cos(x), x, 0, inf))),
374 get_output_stream_string (S));