/usr/share/maxima/5.38.1/tests/rtestlabels.mac is in maxima-test 5.38.1-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | (load (stringproc),
kill (all),
nolabels: true,
0);
0;
(f(x) := x,
g(x) := x^2,
h(x) := x^3,
m(x) ::= x,
n(x) ::= x^2,
o(x) ::= x^3,
tellsimpafter (foo(x), bar(x)),
tellsimpafter (bar(x), baz(x)),
L2: dispfun (g, n),
L3: dispfun (all),
L4: disprule (barrule1),
L5: disprule (all),
0);
0;
(ensure_string (x) := if stringp (x) then x else string (x),
my_every (p, L) := apply ("and", map (is, map (p, L))),
my_some (p, L) := apply ("or", map (is, map (p, L))),
my_none (p, L) := apply ("and", map ("not", map (is, map (p, L)))),
matchdeclare (aa, symbolp, [bb, cc], true),
defmatch (rulep, aa: ?marrow (bb, cc)),
defmatch (fundefp, bb := cc),
defmatch (macrodefp, bb ::= cc),
0);
0;
''L2;
[g(x) := x^2, n(x) ::= x^2];
''L3;
[f(x) := x, g(x) := x^2, h(x) := x^3, m(x) ::= x, n(x) ::= x^2, o(x) ::= x^3];
''L4;
'[barrule1 : ?marrow (bar(x), baz(x))];
(my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L5)
and my_every (lambda ([x], rulep(x)#false), ''L5));
true;
/* At this point, all labels are %t labels from rules, functions, and macros.
*/
(map (lambda ([x], rulep(x)#false or fundefp(x)#false or macrodefp(x)#false), ''labels),
my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), labels)
and my_every (identity, %%));
true;
[%i1, %o1, %i2, %o2, %i3, %o3, %i4, %o4, %i5, %o5];
'[%i1, %o1, %i2, %o2, %i3, %o3, %i4, %o4, %i5, %o5];
/* Some tests for solve and linsolve.
*/
/* Test 1: nolabels = true, programmode = true, globalsolve = false
* => solve & linsolve return lists of solutions
*/
(globalsolve: false,
solve (asin (cos (3*x)), x));
[x = %pi/6];
linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y]);
[x = 3, y = 1];
/* Test 2: nolabels = true, programmode = false, globalsolve = false
* => solve & linsolve return lists of %t labels
* and each %t label is on the labels infolist
* and each %t label is bound to an equation
*/
(programmode: false,
L: append (solve (asin (cos (3*x)), x), linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y])),
my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
and my_every (lambda ([x], my_some (lambda ([y], buildq ([x, y], 'y = 'x)), labels)), L));
true;
''L;
[x = %pi/6, x = 3, y = 1];
/* Test 3: nolabels = true, programmode = false, globalsolve = true
* => solve & linsolve return lists of %t labels
* and each %t labels is on the labels infolist
* and the labels returned by solve are bound to equations
* and the labels returned by linsolve are bound to assignments
*/
(globalsolve: true,
L: append (solve (asin (cos (3*x)), x), linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y])),
[my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
and my_every (lambda ([x], my_some (lambda ([y], buildq ([x, y], 'y = 'x)), labels)), L),
x, y]);
[true, 3, 1];
''L;
'[x = %pi/6, x : 3, y : 1];
/* Test 4: nolabels = true, programmode = true, globalsolve = true
* => solve returns equations
* linsolve assigns values and returns assignments
* no %t labels generated
*/
(programmode: true,
kill (x, y),
save_labels: copylist (labels),
[linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y]),
x, y,
is (equal (labels, save_labels))]);
['[x : 3, y : 1], 3, 1, true];
/* Restore the status quo ante.
*/
globalsolve: false;
false;
/* Now repeat all of the preceding tests,
* but this time with nolabels = false.
* %t labels should still be bound to rules, functions, and macros,
* but there should also be some input and output labels bound as well.
*/
(kill (all),
nolabels: false,
0);
0;
(f(x) := x,
g(x) := x^2,
h(x) := x^3,
m(x) ::= x,
n(x) ::= x^2,
o(x) ::= x^3,
tellsimpafter (foonew(x), bar(x)),
tellsimpafter (barnew(x), baz(x)),
L2: dispfun (g, n),
L3: dispfun (all),
L4: disprule (barnewrule1),
L5: disprule (all),
0);
0;
(ensure_string (x) := if stringp (x) then x else string (x),
my_every (p, L) := apply ("and", map (is, map (p, L))),
my_some (p, L) := apply ("or", map (is, map (p, L))),
my_none (p, L) := apply ("and", map ("not", map (is, map (p, L)))),
matchdeclare (aa, symbolp, [bb, cc], true),
defmatch (rulep, aa: ?marrow (bb, cc)),
defmatch (fundefp, bb := cc),
defmatch (macrodefp, bb ::= cc),
0);
0;
''L2;
[g(x) := x^2, n(x) ::= x^2];
''L3;
[f(x) := x, g(x) := x^2, h(x) := x^3, m(x) ::= x, n(x) ::= x^2, o(x) ::= x^3];
''L4;
'[barnewrule1 : ?marrow (barnew(x), baz(x))];
(my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L5)
and my_every (lambda ([x], rulep(x)#false), ''L5));
true;
/* Now there should be some labels which are not %t labels.
* NOTE: the expected result (false) is observed only if this script is executed
* via batch("rtestlabels.mac"), because then Maxima creates input and output labels.
* When executed via batch(..., test), no input or output labels are created,
* so the test fails.
*/
(map (lambda ([x], rulep(x)#false or fundefp(x)#false or macrodefp(x)#false), ''labels),
my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), labels)
and my_every (identity, %%));
false;
/* See NOTE attached to preceding example
*/
labels (inchar) # [] and my_every (?boundp, labels (inchar))
and labels (outchar) # [] and my_every (?boundp, labels (outchar));
true;
/* Repeat the tests for solve and linsolve.
* The outcomes should be the same as before.
*/
/* Test 1: nolabels = true, programmode = true, globalsolve = false
* => solve & linsolve return lists of solutions
*/
(globalsolve: false,
solve (asin (cos (3*x)), x));
[x = %pi/6];
linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y]);
[x = 3, y = 1];
/* Test 2: nolabels = true, programmode = false, globalsolve = false
* => solve & linsolve return lists of %t labels
* and each %t label is on the labels infolist
* and each %t label is bound to an equation
*/
(programmode: false,
L: append (solve (asin (cos (3*x)), x), linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y])),
my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
and my_every (lambda ([x], my_some (lambda ([y], buildq ([x, y], 'y = 'x)), labels)), L));
true;
''L;
[x = %pi/6, x = 3, y = 1];
/* Test 3: nolabels = true, programmode = false, globalsolve = true
* => solve & linsolve return lists of %t labels
* and each %t labels is on the labels infolist
* and the labels returned by solve are bound to equations
* and the labels returned by linsolve are bound to assignments
*/
(globalsolve: true,
L: append (solve (asin (cos (3*x)), x), linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y])),
[my_every (lambda ([x], substring (ensure_string (x), 1, 3) = ensure_string (linechar)), L)
and my_every (lambda ([x], my_some (lambda ([y], buildq ([x, y], 'y = 'x)), labels)), L),
x, y]);
[true, 3, 1];
''L;
'[x = %pi/6, x : 3, y : 1];
/* Test 4: nolabels = true, programmode = true, globalsolve = true
* => solve returns equations
* linsolve assigns values and returns assignments
* no %t labels generated
*/
(programmode: true,
kill (x, y),
save_labels: copylist (labels),
[linsolve ([x + 2*y = 5, 2*x - y = 5], [x, y]),
x, y,
is (equal (labels, save_labels))]);
['[x : 3, y : 1], 3, 1, true];
/* Restore the status quo ante.
*/
globalsolve: false;
false;
my_every (?boundp, labels);
true;
|