13 tellsimpafter (foo(x), bar(x)),
14 tellsimpafter (bar(x), baz(x)),
17 L4: disprule (barrule1),
22 (ensure_string (x) := if stringp (x) then x else string (x),
23 my_every (p, L) := apply ("and", map (is, map (p, L))),
24 my_some (p, L) := apply ("or", map (is, map (p, L))),
25 my_none (p, L) := apply ("and", map ("not", map (is, map (p, L)))),
26 matchdeclare (aa, symbolp, [bb, cc], true),
27 defmatch (rulep, aa: ?marrow (bb, cc)),
28 defmatch (fundefp, bb := cc),
29 defmatch (macrodefp, bb ::= cc),
34 [g(x) := x^2, n(x) ::= x^2];
37 [f(x) := x, g(x) := x^2, h(x) := x^3, m(x) ::= x, n(x) ::= x^2, o(x) ::= x^3];
40 '[barrule1 : ?marrow (bar(x), baz(x))];
42 (my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L5)
43 and my_every (lambda ([x], rulep(x)#false), ''L5));
46 /* At this point, all labels are %t labels from rules, functions, and macros.
48 (map (lambda ([x], rulep(x)#false or fundefp(x)#false or macrodefp(x)#false), ''labels),
49 my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), labels)
50 and my_every (identity, %%));
53 [%i1, %o1, %i2, %o2, %i3, %o3, %i4, %o4, %i5, %o5];
54 '[%i1, %o1, %i2, %o2, %i3, %o3, %i4, %o4, %i5, %o5];
56 /* Some tests for solve and linsolve.
58 /* Test 1: nolabels = true, programmode = true, globalsolve = false
59 * => solve & linsolve return lists of solutions
62 solve (asin (cos (3*x)), x));
65 linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y]);
68 /* Test 2: nolabels = true, programmode = false, globalsolve = false
69 * => solve & linsolve return lists of %t labels
70 * and each %t label is on the labels infolist
71 * and each %t label is bound to an equation
74 L: append (solve (asin (cos (3*x)), x), linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y])),
75 my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
76 and my_every (lambda ([x], my_some (lambda ([y], buildq ([x, y], 'y = 'x)), labels)), L));
80 [x = %pi/6, x = 3, y = 1];
82 /* Test 3: nolabels = true, programmode = false, globalsolve = true
83 * => solve & linsolve return lists of %t labels
84 * and each %t labels is on the labels infolist
85 * and the labels returned by solve are bound to equations
86 * and the labels returned by linsolve are bound to assignments
89 L: append (solve (asin (cos (3*x)), x), linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y])),
90 [my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
91 and my_every (lambda ([x], my_some (lambda ([y], buildq ([x, y], 'y = 'x)), labels)), L),
96 '[x = %pi/6, x : 3, y : 1];
98 /* Test 4: nolabels = true, programmode = true, globalsolve = true
99 * => solve returns equations
100 * linsolve assigns values and returns assignments
101 * no %t labels generated
105 save_labels: copylist (labels),
106 [linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y]),
108 is (equal (labels, save_labels))]);
109 ['[x : 3, y : 1], 3, 1, true];
111 /* Restore the status quo ante.
116 /* Now repeat all of the preceding tests,
117 * but this time with nolabels = false.
118 * %t labels should still be bound to rules, functions, and macros,
119 * but there should also be some input and output labels bound as well.
132 tellsimpafter (foonew(x), bar(x)),
133 tellsimpafter (barnew(x), baz(x)),
136 L4: disprule (barnewrule1),
141 (ensure_string (x) := if stringp (x) then x else string (x),
142 my_every (p, L) := apply ("and", map (is, map (p, L))),
143 my_some (p, L) := apply ("or", map (is, map (p, L))),
144 my_none (p, L) := apply ("and", map ("not", map (is, map (p, L)))),
145 matchdeclare (aa, symbolp, [bb, cc], true),
146 defmatch (rulep, aa: ?marrow (bb, cc)),
147 defmatch (fundefp, bb := cc),
148 defmatch (macrodefp, bb ::= cc),
153 [g(x) := x^2, n(x) ::= x^2];
156 [f(x) := x, g(x) := x^2, h(x) := x^3, m(x) ::= x, n(x) ::= x^2, o(x) ::= x^3];
159 '[barnewrule1 : ?marrow (barnew(x), baz(x))];
161 (my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L5)
162 and my_every (lambda ([x], rulep(x)#false), ''L5));
165 /* Now there should be some labels which are not %t labels.
166 * NOTE: the expected result (false) is observed only if this script is executed
167 * via batch("rtestlabels.mac"), because then Maxima creates input and output labels.
168 * When executed via batch(..., test), no input or output labels are created,
171 (map (lambda ([x], rulep(x)#false or fundefp(x)#false or macrodefp(x)#false), ''labels),
172 my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), labels)
173 and my_every (identity, %%));
176 /* See NOTE attached to preceding example
178 labels (inchar) # [] and my_every (?boundp, labels (inchar))
179 and labels (outchar) # [] and my_every (?boundp, labels (outchar));
182 /* Repeat the tests for solve and linsolve.
183 * The outcomes should be the same as before.
185 /* Test 1: nolabels = true, programmode = true, globalsolve = false
186 * => solve & linsolve return lists of solutions
189 solve (asin (cos (3*x)), x));
192 linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y]);
195 /* Test 2: nolabels = true, programmode = false, globalsolve = false
196 * => solve & linsolve return lists of %t labels
197 * and each %t label is on the labels infolist
198 * and each %t label is bound to an equation
201 L: append (solve (asin (cos (3*x)), x), linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y])),
202 my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
203 and my_every (lambda ([x], my_some (lambda ([y], buildq ([x, y], 'y = 'x)), labels)), L));
207 [x = %pi/6, x = 3, y = 1];
209 /* Test 3: nolabels = true, programmode = false, globalsolve = true
210 * => solve & linsolve return lists of %t labels
211 * and each %t labels is on the labels infolist
212 * and the labels returned by solve are bound to equations
213 * and the labels returned by linsolve are bound to assignments
216 L: append (solve (asin (cos (3*x)), x), linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y])),
217 [my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
218 and my_every (lambda ([x], my_some (lambda ([y], buildq ([x, y], 'y = 'x)), labels)), L),
223 '[x = %pi/6, x : 3, y : 1];
225 /* Test 4: nolabels = true, programmode = true, globalsolve = true
226 * => solve returns equations
227 * linsolve assigns values and returns assignments
228 * no %t labels generated
232 save_labels: copylist (labels),
233 [linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y]),
235 is (equal (labels, save_labels))]);
236 ['[x : 3, y : 1], 3, 1, true];
239 * Test 5: programmode = false
240 * => solve returns list of %t labels
241 * and each %t label is on the labels infolist
242 * and each %t label is bound to an equation.
244 * This differs from test 2 because solve is unable to find the solution
249 L: solve((x^2-4)*(x-tan(x)),x),
250 my_every(lambda([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
251 and my_every(lambda([x], my_some(lambda([y], build2([x,y], 'y='x)), labels)), L));
255 [x = tan(x), x = -2, x= 2];
257 /* Restore the status quo ante.
262 my_every (?boundp, labels);