2 * regress - calc regression and correctness test suite
4 * Copyright (C) 1999-2006 David I. Bell and Landon Curt Noll
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.8 $
21 * @(#) $Id: regress.cal,v 30.8 2013/08/11 08:41:38 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/cal/RCS/regress.cal,v $
24 * Under source code control: 1990/02/15 01:50:36
25 * File existed as early as: before 1990
27 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
31 * Test the correct execution of the calculator by reading this resource file.
32 * Errors are reported with '****' messages, or worse. :-)
34 * NOTE: Unlike most calc resource files, this one performs its work when
35 * it is read. Normally one would just define functions and
36 * values for later use. In the case of the regression test,
37 * we do not want to do this.
41 print '000: Beginning regression tests';
42 print '001: Some of these tests may take a while ...';
43 print '002: Within each section, output should be numbered sequentially';
46 global prob; /* libregress.cal problem counter */
47 prob = 0; /* clear problem counter */
49 errcount(0),; /* clear error count */
50 errmax(-1),; /* prevent errcount from abouting */
52 global ecnt; /* expected value of errcount() */
53 ecnt = 0; /* clear expected errcount() value */
55 initcfg = config("all", "newstd"); /* set config to startup default */
56 defcfg = config("all"); /* capture the default config */
57 config("resource_debug", 0),; /* disable resource startup messages */
58 config("calc_debug", 0),; /* disable internal debugging */
59 config("verbose_quit", 0),; /* disable quit messages */
60 startcfg = config("all"); /* save state for later use */
62 print '003: parsed global definitions';
66 * vrfy - vrfy that a test is true
68 * Counts and reports errors or prints test string if successful.
70 * This function also detects when errcount() exceeds ecnt
71 * and reports when this happens. A side effect is that a
72 * new ecnt level is established. If errcount exceeds errcount
73 * but otherwise the test is successful, the string is still printed.
75 define vrfy(test, str)
77 if (errcount() > ecnt) {
78 print '**** errcount:' : errcount(), ' > ecnt:' : ecnt;
83 print '**** Non-true result (' : test : '): ' : str;
90 print '004: parsed vrfy()';
94 * prob - alternate error notification and count
101 print '005: parsed prob(str)';
105 * getglobalvar - used to return a global value
107 define getglobalvar()
113 print '006: parsed getglobalvar()';
117 * Test boolean operations and IF tests.
119 * Some of these tests are done twice, once to print the message and
120 * once to count any errors. This means that some successful tests
121 * will display a passing message twice. Oh well, no biggie.
123 define test_booleans()
129 print '300: Beginning test_booleans';
143 print '303: if (1) else';
145 print '**** if (1) else';
147 print '304: if (1) else';
152 print '**** if (0) else';
154 print '305: if (0) else';
158 print '306: if (0) else';
161 print '307: if 1 == 1';
163 print '**** if 1 == 1';
165 print '308: if 1 == 1';
170 print '309: if 1 != 2';
172 print '**** if 1 != 2';
174 print '310: if 1 != 2';
178 vrfy(1, '311: vrfy 1');
179 vrfy(2 == 2, '312: vrfy 2 == 2');
180 vrfy(2 != 3, '313: vrfy 2 != 3');
181 vrfy(2 < 3, '314: vrfy 2 < 3');
182 vrfy(2 <= 2, '315: vrfy 2 <= 2');
183 vrfy(2 <= 3, '316: vrfy 2 <= 3');
184 vrfy(3 > 2, '317: vrfy 3 > 2');
185 vrfy(2 >= 2, '318: vrfy 2 >= 2');
186 vrfy(3 >= 2, '319: vrfy 3 >= 2');
187 vrfy(!0, '320: vrfy !0');
188 vrfy(!1 == 0,'321: vrfy !1 == 0');
189 vrfy((1 ? 2 ? 3 : 4 : 5) == 3, '322: (1 ? 2 ? 3 : 4 : 5) == 3');
191 print '323: Ending test_booleans';
193 print '007: parsed test_booleans()';
197 * Test variables, simple assignments, AND and OR operators, short-circuit eval
199 define test_variables()
206 print '350: Beginning test_variables';
214 vrfy(x1 == 5, '351: x1 == 5');
215 vrfy(x2 == 10, '352: x2 == 10');
216 vrfy(x3 == 14, '353: x3 == 14');
217 vrfy(g1 == 16, '354: g1 == 16');
218 vrfy(g2 == 79, '355: g2 == 79');
219 vrfy(globalvar == 22, '356: globalvar == 22');
220 vrfy(getglobalvar() == 22, '357: getglobalvar() == 22');
222 vrfy(x1 == 40, '358: x1 == 40');
224 vrfy(g1 == 93, '359: g1 == 207');
226 vrfy(x1++ == 5, '360: x1++ == 5');
227 vrfy(x1 == 6, '361: x1 == 6');
228 vrfy(++x1 == 7, '362: ++x1 == 7');
230 vrfy(x1 == 10, '363: x1 == 10');
232 vrfy(x1 == 4, '364: x1 == 4');
234 vrfy(x1 == 12, '365: x1 == 12');
236 vrfy(x1 == 3, '366: x1 == 3');
238 vrfy(x2 == 14, '367: x2 == 14');
239 vrfy(x1 == 14, '368: x1 == 14');
242 print '369: if (2 && 3)';
244 print '**** if (2 && 3)';
249 print '**** if (2 && 0)';
252 print '370: if (2 && 0)';
256 print '**** if (0 && 2)';
259 print '371: if (0 && 2)';
263 print '**** if (0 && 0)';
266 print '372: if (0 && 0)';
270 print '373: if (2 || 0)';
272 print '**** if (2 || 0)';
277 print '374: if (0 || 2)';
279 print '**** if (0 || 2)';
284 print '**** if (0 || 0)';
287 print '375: if (0 || 0)';
290 x = 2 || 3; vrfy(x == 2, '376: (2 || 3) == 2');
291 x = 2 || 0; vrfy(x == 2, '377: (2 || 0) == 2');
292 x = 0 || 3; vrfy(x == 3, '378: (0 || 3) == 3');
293 x = 0 || 0; vrfy(x == 0, '379: (0 || 0) == 0');
294 x = 2 && 3; vrfy(x == 3, '380: (2 && 3) == 3');
295 x = 2 && 0; vrfy(x == 0, '381: (2 && 0) == 0');
296 x = 0 && 3; vrfy(x == 0, '382: (0 && 3) == 0');
297 x = 2 || prob('2 || prob()');
298 print "383: x = 2 || prob('2 || prob()'";
299 x = 0 && prob('0 && prob()');
300 print "384: x = 0 && prob('0 && prob()'";
302 print '385: Ending test_variables';
304 print '008: parsed test_variables()';
308 * Test simple arithmetic operations and expressions.
310 define test_arithmetic()
312 print '400: Beginning test_arithmetic';
314 vrfy(3+4==7, '401: 3 + 4 == 7');
315 vrfy(4-1==3, '402: 4 - 1 == 3');
316 vrfy(2*3==6, '403: 2 * 3 == 6');
317 vrfy(8/4==2, '404: 8 / 4 == 2');
318 vrfy(2^3==8, '405: 2 ^ 3 == 8');
319 vrfy(9-4-2==3, '406: 9-4-2 == 3');
320 vrfy(9-4+2==7, '407: 9-4+2 == 7');
321 vrfy(-5+2==-3, '408: -5+2 == -3');
322 vrfy(2*3+1==7, '409: 2*3+1 == 7');
323 vrfy(1+2*3==7, '410: 1+2*3 == 7');
324 vrfy((1+2)*3==9, '411: (1+2)*3 == 9');
325 vrfy(2*(3+1)==8, '412: 2*(3+1) == 8');
326 vrfy(9-(2+3)==4, '413: 9-(2+3) == 4');
327 vrfy(9+(2-3)==8, '414: 9+(2-3) == 8');
328 vrfy((2+3)*(4+5)==45, '415: (2+3)*(4+5) == 45');
329 vrfy(10/(2+3)==2, '416: 10/(2+3) == 2');
330 vrfy(12/3+4==8, '417: 12/3+4 == 8');
331 vrfy(6+12/3==10, '418: 6+12/3 == 10');
332 vrfy(2+3==1+4, '419: 2+3 == 1+4');
333 vrfy(-(2+3)==-5, '420: -(2+3) == -5');
334 vrfy(7&18==2, '421: 7&18 == 2');
335 vrfy(3|17==19, '422: 3|17 == 19');
336 vrfy(2&3|1==3, '423: 2&3|1 == 3');
337 vrfy(2&(3|1)==2, '424: 2&(3|1) == 2');
338 vrfy(3<<4==48, '425: 3<<4 == 48');
339 vrfy(5>>1==2, '426: 5>>1 == 2');
340 vrfy(3<<-1==1, '427: 3<<-1 == 1');
341 vrfy(5>>-2==20, '428: 5>>-2 == 20');
342 vrfy(1<<2<<3==65536, '429: 1<<2<<3 == 65536');
343 vrfy((1<<2)<<3==32, '430: (1<<2)<<3 == 32');
344 vrfy(2^3^2==512, '431: 2^3^2 == 512');
345 vrfy((2^3)^2==64, '432: (2^3)^2 == 64');
346 vrfy(4//3==1, '433: 4//3==1');
347 vrfy(4//-3==-1, '434: 4//-3==-1');
348 vrfy(0.75//-0.51==-1, '435: 0.75//-0.51==-1');
349 vrfy(0.75//-0.50==-1, '436: 0.75//-0.50==-1');
350 vrfy(0.75//-0.49==-1, '437: 0.75//-0.49==-1');
351 vrfy((3/4)//(-1/4)==-3, '438: (3/4)//(-1/4)==-3');
352 vrfy(7%3==1, '439: 7%3==1');
353 vrfy(0-.5==-.5, '440: 0-.5==-.5');
354 vrfy(0^0 == 1, '441: 0^0 == 1');
355 vrfy(0^1 == 0, '442: 0^1 == 0');
356 vrfy(1^0 == 1, '443: 1^0 == 1');
357 vrfy(1^1 == 1, '444: 1^1 == 1');
358 vrfy(1/(.8+.8i)==.625-.625i, '445: 1/(.8+.8i)==.625-.625i');
359 vrfy((.6+.8i)*(3.6-4.8i)==6, '446: (.6+.8i)*(3.6-4.8i)==6');
360 vrfy(-16^-2 == -1/256, '447: -16^-2 == -1/256');
361 vrfy(-7^2 == -49, '448: -7^2 == -49');
362 vrfy(-3! == -6, '449: -3! == -6');
364 print '450: Ending test_arithmetic';
366 print '009: parsed test_arithmetic()';
370 * test_config - test config control
374 local callcfg; /* caller configuration value */
375 local oldcfg; /* caller configuration value */
376 local newcfg; /* caller configuration value */
378 print '500: Beginning test_config';
380 /* check the set and return of all config */
381 callcfg = config("all");
382 print '501: callcfg = config("all")';
383 vrfy(callcfg == startcfg, '502: callcfg == startcfg');
385 callcfg = config("all", "oldstd");
386 print '503: callcfg = config("all","oldstd")';
387 vrfy(callcfg == startcfg, '504: callcfg == startcfg');
388 oldcfg = config("all");
389 print '505: oldcfg = config("all");';
390 vrfy(config("all") == oldcfg, '506: config("all") == oldcfg');
391 vrfy(oldcfg==config("all","newstd"),
392 '507: oldcfg==config("all","newstd")');
393 vrfy(defcfg == config("all"), '508: defcfg == config("all")');
395 /* vrfy the state of the default config */
396 vrfy(config("mode") == "real",
397 '509: config("mode") == "real"');
398 vrfy(config("display") == 20,
399 '510: config("display") == 20');
400 vrfy(config("epsilon") == 1e-20,
401 '511: config("epsilon") == 1e-20');
402 vrfy(config("trace") == 0,
403 '512: config("trace") == 0');
404 vrfy(config("maxprint") == 16,
405 '513: config("maxprint") == 16');
406 vrfy(config("mul2") == 1780,
407 '514: config("mul2") == 1780');
408 vrfy(config("sq2") == 3388,
409 '515: config("sq2") == 3388');
410 vrfy(config("pow2") == 176,
411 '516: config("pow2") == 176');
412 vrfy(config("redc2") == 220,
413 '517: config("redc2") == 220');
414 vrfy(config("tilde"),
415 '518: config("tilde")');
417 '519: config("tab")');
418 vrfy(config("quomod") == 0,
419 '520: config("quomod") == 0');
420 vrfy(config("quo") == 2,
421 '521: config("quo") == 2');
422 vrfy(config("mod") == 0,
423 '522: config("mod") == 0');
424 vrfy(config("sqrt") == 24,
425 '523: config("sqrt") == 24');
426 vrfy(config("appr") == 24,
427 '524: config("appr") == 24');
428 vrfy(config("cfappr") == 0,
429 '525: config("cfappr") == 0');
430 vrfy(config("cfsim") == 8,
431 '526: config("cfsim") == 8');
432 vrfy(config("outround") == 24,
433 '527: config("outround") == 24');
434 vrfy(config("round") == 24,
435 '528: config("round") == 24');
436 vrfy(config("leadzero") == 1,
437 '529: config("leadzero") == 1');
438 vrfy(config("fullzero") == 0,
439 '530: config("fullzero") == 0');
440 vrfy(config("maxscan") == 20,
441 '531: config("maxscan") == 20');
442 vrfy(config("prompt") == "; ",
443 '532: config("prompt") == "; "');
444 vrfy(config("more") == ";; ",
445 '533: config("more") == ";; "');
447 /* convert to "oldstd" config by individual changes */
448 print '534: test unused';
449 vrfy(config("outround", 2) == 24,
450 '535: config("outround", 2) == 24');
451 vrfy(config("leadzero","n") == 1,
452 '536: config("leadzero","n") == 1');
453 print '537: test unused';
454 vrfy(config("prompt", "> ") == "; ",
455 '538: config("prompt", "> ") == "; "');
456 vrfy(config("more", ">> ") == ";; ",
457 '539: config("more", ">> ") == ";; "');
458 vrfy(config("all") == oldcfg, '540: config("all") == oldcfg');
460 /* restore the configation at the start of this function */
461 vrfy(config("all",callcfg) == oldcfg,
462 '541: config("all",callcfg) == oldcfg');
464 /* display and fullzero tests */
465 vrfy(config("display",2) == 20,
466 '542: config("display",2) == 20');
467 vrfy(config("leadzero",0) == 1,
468 '543: config("leadzero",0) == 1');
469 vrfy(config("fullzero",1) == 0,
470 '544: config("fullzero",1) == 0');
471 vrfy(strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00",
472 '545: strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00"');
473 vrfy(config("display",20) == 2,
474 '546: config("display",20) == 2');
475 vrfy(config("leadzero",1) == 0,
476 '547: config("leadzero",1) == 0');
477 vrfy(config("fullzero",0) == 1,
478 '548: config("fullzero",0) == 1');
479 vrfy(strprintf("%d %d %d", 0, 1, 2) == "0 1 2",
480 '549: strprintf("%d %d %d", 0, 1, 2) == "0 1 2"');
482 /* restore calling config */
483 vrfy(config("all",callcfg) == startcfg,
484 '550: config("all",callcfg) == startcfg');
485 vrfy(config("all") == callcfg, '551: config("all") == callcfg');
486 vrfy(config("all") == startcfg, '552: config("all") == startcfg');
488 /* check read-only config values */
489 vrfy(strlen(config("program")) > 0,
490 '553: strlen(config("program")) > 0');
491 vrfy(strlen(config("basename")) > 0,
492 '554: strlen(config("basename")) > 0');
493 vrfy(strlen(config("version")) > 0,
494 '555: strlen(config("version")) > 0');
496 /* mode2 is off by default */
497 vrfy(config("mode2") == "off",
498 '556: config("mode2") == "off"');
501 vrfy(isint(config("hz")), '557: isint(config("hz"))');
503 /* compile_custom is simple */
504 vrfy(issimple(config("compile_custom")),
505 '558: issimple(config("compile_custom"))');
507 /* allow_custom is simple */
508 vrfy(issimple(config("allow_custom")),
509 '559: issimple(config("allow_custom"))');
511 /* allow_custom is simple */
512 vrfy(issimple(config("allow_custom")),
513 '559: issimple(config("allow_custom"))');
515 /* baseb is numeric */
516 vrfy(isint(config("baseb")), '560: isint(config("baseb"))');
518 /* redecl_warn is simple */
519 vrfy(issimple(config("redecl_warn")),
520 '561: issimple(config("redecl_warn"))');
522 /* dupvar_warn is simple */
523 vrfy(issimple(config("dupvar_warn")),
524 '562: issimple(config("rdupvar_warn"))');
526 print '563: Ending test_config';
528 print '010: parsed test_config()';
533 * Do multiplication and division on three numbers in various ways
534 * and vrfy the results agree.
536 define muldivcheck(a, b, c, str)
538 local abc, acb, bac, bca, cab, cba;
547 if (abc != acb) {print '**** abc != acb:', str; ++prob;}
548 if (acb != bac) {print '**** acb != bac:', str; ++prob;}
549 if (bac != bca) {print '**** bac != bca:', str; ++prob;}
550 if (bca != cab) {print '**** bca != cab:', str; ++prob;}
551 if (cab != cba) {print '**** cab != cba:', str; ++prob;}
552 if (abc/a != b*c) {print '**** abc/a != bc:', str; ++prob;}
553 if (abc/b != a*c) {print '**** abc/b != ac:', str; ++prob;}
554 if (abc/c != a*b) {print '**** abc/c != ab:', str; ++prob;}
557 print '011: parsed muldivcheck(a, b, c, str)';
561 * Use the identity for squaring the sum of two squares to check
562 * multiplication and squaring.
564 define squarecheck(a, b, str)
566 local a2, b2, tab, apb, apb2, t;
573 if (a2 != a*a) {print '**** a^2 != a*a:', str; ++prob;}
574 if (b2 != b*b) {print '**** b^2 != b*b:', str; ++prob;}
575 if (apb2 != apb*apb) {
576 print '**** (a+b)^2 != (a+b)*(a+b):', str;
579 if (a2+tab+b2 != apb2) {
580 print '**** (a+b)^2 != a^2 + 2ab + b^2:', str;
583 if (a2/a != a) {print '**** a^2/a != a:', str; ++prob;}
584 if (b2/b != b) {print '**** b^2/b != b:', str; ++prob;}
585 if (apb2/apb != apb) {print '**** (a+b)^2/(a+b) != a+b:', str; ++prob;}
586 if (a2*b2 != (a*b)^2) {print '**** a^2*b^2 != (ab)^2:', str; ++prob;}
589 print '012: parsed squarecheck(a, b, str)';
593 * Use the raising of numbers to large powers to check multiplication
594 * and exponentiation.
596 define powercheck(a, p1, p2, str)
607 if (a1 != a2) {print '**** (a^p1)^p2 != (a^p2)^p1:', str; ++prob;}
608 if (a1 != a3) {print '**** (a^p1)^p2 != a^(p1*p2):', str; ++prob;}
609 if (b1 != b2) {print '**** (b^p1)^p2 != (b^p2)^p1:', str; ++prob;}
610 if (b1 != b3) {print '**** (b^p1)^p2 != b^(p1*p2):', str; ++prob;}
613 print '013: parsed powercheck(a, p1, p2, str)';
617 * Test fraction reductions.
618 * Arguments MUST be relatively prime.
620 define fraccheck(a, b, c, str)
622 local ab, bc, ca, aoc, boc, aob;
628 if (num(aoc) != a) {print '**** num(aoc) != a:', str; ++prob;}
629 if (den(aoc) != c) {print '**** den(aoc) != c:', str; ++prob;}
631 if (num(boc) != b) {print '**** num(boc) != b:', str; ++prob;}
632 if (den(boc) != c) {print '**** den(boc) != c:', str; ++prob;}
634 if (num(aob) != a) {print '**** num(aob) != a:', str; ++prob;}
635 if (den(aob) != b) {print '**** den(aob) != b:', str; ++prob;}
636 if (aob*boc != aoc) {print '**** aob*boc != aoc;', str; ++prob;}
639 print '014: parsed fraccheck(a, b, c, str)';
643 * Test multiplication and squaring algorithms.
645 define algcheck(a, b, str)
647 local ss, ms, t1, t2, t3, t4, t5, t6, t7;
648 local a1, a2, a3, a4, a5, a6, a7;
649 local oldmul2, oldsq2;
651 oldmul2 = config("mul2", 2);
652 oldsq2 = config("sq2", 2);
660 for (ms = 2; ms < 20; ms++) {
661 for (ss = 2; ss < 20; ss++) {
670 if (((ms + ss) % 37) == 4)
672 if (t1 != a1) {print '**** t1 != a1:', str; ++prob;}
673 if (t2 != a2) {print '**** t2 != a2:', str; ++prob;}
674 if (t3 != a3) {print '**** t3 != a3:', str; ++prob;}
675 if (t4 != a4) {print '**** t4 != a4:', str; ++prob;}
676 if (t5 != a5) {print '**** t5 != a5:', str; ++prob;}
677 if (t6 != a6) {print '**** t6 != a6:', str; ++prob;}
678 if (t7 != a7) {print '**** t7 != a7:', str; ++prob;}
681 config("mul2", oldmul2);
682 config("sq2", oldsq2);
685 print '015: parsed algcheck(a, b, str)';
689 * Test big numbers using some identities.
691 define test_bignums()
695 print '600: Beginning test_bignums';
697 a = 64357824568234938591;
698 b = 12764632632458756817;
699 c = 43578234973856347982;
700 muldivcheck(a, b, c, '601: muldivcheck 1');
704 muldivcheck(a, b, c, '602: muldivcheck 2');
708 muldivcheck(a, b, c, '603: muldivcheck 3');
712 muldivcheck(a, b, c, '604: muldivcheck 4');
716 muldivcheck(a, b, c, '605: muldivcheck 5');
719 squarecheck(a, b, '606: squarecheck 1');
722 squarecheck(a, b, '607: squarecheck 2');
725 squarecheck(a, b, '608: squarecheck 3');
726 a = 4657892345743659834657238947854639;
727 b = 43784356784365893467659347867689;
728 squarecheck(a, b, '609: squarecheck 4');
731 squarecheck(a, b, '610: squarecheck 5');
734 squarecheck(a, b, '611: squarecheck 6');
736 vrfy(ptest(a, 20), '612: primetest R19');
738 vrfy(ptest(a, 20), '613: primetest R23');
740 vrfy(ptest(a, 1), '614: primetest M127');
742 vrfy(ptest(a, 1), '615: primetest M521');
743 powercheck(17, 127, 30, '616: powercheck 1');
744 powercheck(111, 899, 6, '617: powercheck 2');
745 powercheck(3, 87, 89, '618: powercheck 3');
746 fraccheck(3^200, 5^173, 7^138, '619: fraccheck 1');
747 fraccheck(11^100, 12^98, 13^121, '620: fraccheck 2');
748 fraccheck(101^270, 103^111, 105^200, '621: fraccheck 3');
749 a = 0xffff0000ffffffff00000000ffff0000000000000000ffff;
750 b = 0x555544440000000000000000000000000000000011112222333344440000;
751 c = 0x999911113333000011111111000022220000000000000000333300000000ffff;
752 d = 0x3333ffffffff0000000000000000ffffffffffffffff000000000000;
753 algcheck(a, a, '622: algcheck 1');
754 algcheck(a, b, '623: algcheck 2');
755 algcheck(a, c, '624: algcheck 3');
756 algcheck(a, d, '625: algcheck 4');
757 algcheck(b, b, '626: algcheck 5');
758 algcheck(b, c, '627: algcheck 6');
759 algcheck(b, d, '628: algcheck 7');
760 algcheck(c, c, '629: algcheck 8');
761 algcheck(c, d, '630: algcheck 9');
762 algcheck(d, d, '631: algcheck 10');
764 print '632: Ending test_bignums';
766 print '016: parsed test_bignums()';
770 * Test many of the built-in functions.
772 define test_functions()
780 print '700: Beginning test_functions';
782 vrfy(abs(3) == 3, '701: abs(3) == 3');
783 vrfy(abs(-4) == 4, '702: abs(-4) == 4');
784 vrfy(avg(7) == 7, '703: avg(7) == 7');
785 vrfy(avg(3,5) == 4, '704: avg(3,5) == 4');
786 vrfy(cmp(2,3) == -1, '705: cmp(2,3) == -1');
787 vrfy(cmp(6,6) == 0, '706: cmp(6,6) == 0');
788 vrfy(cmp(7,4) == 1, '707: cmp(7,4) == 1');
789 vrfy(comb(9,9) == 1, '708: comb(9,9) == 1');
790 vrfy(comb(5,2) == 10, '709: comb(5,2) == 10');
791 vrfy(conj(4) == 4, '710: conj(4) == 4');
792 vrfy(conj(2-3i) == 2+3i, '711: conj(2-3i) == 2+3i');
793 vrfy(den(17) == 1, '712: den(17) == 1');
794 vrfy(den(3/7) == 7, '713: den(3/7) == 7');
795 vrfy(den(-2/3) == 3, '714: den(-2/3) == 3');
796 vrfy(digits(0) == 1, '715: digits(0) == 1');
797 vrfy(digits(9) == 1, '716: digits(9) == 1');
798 vrfy(digits(10) == 2, '717: digits(10) == 2');
799 vrfy(digits(-691) == 3, '718: digits(-691) == 3');
800 vrfy(eval('2+3') == 5, "719: eval('2+3') == 5");
801 vrfy(fcnt(11,3) == 0, '720: fcnt(11,3) == 0');
802 vrfy(fcnt(18,3) == 2, '721: fcnt(18,3) == 2');
803 vrfy(fib(0) == 0, '722: fib(0) == 0');
804 vrfy(fib(1) == 1, '723: fib(1) == 1');
805 vrfy(fib(9) == 34, '724: fib(9) == 34');
806 vrfy(frem(12,5) == 12, '725: frem(12,5) == 12');
807 vrfy(frem(45,3) == 5, '726: frem(45,3) == 5');
808 vrfy(fact(0) == 1, '727: fact(0) == 1');
809 vrfy(fact(1) == 1, '728: fact(1) == 1');
810 vrfy(fact(5) == 120, '729: fact(5) == 120');
811 vrfy(frac(3) == 0, '730: frac(3) == 0');
812 vrfy(frac(2/3) == 2/3, '731: frac(2/3) == 2/3');
813 vrfy(frac(17/3) == 2/3, '732: frac(17/3) == 2/3');
814 vrfy(gcd(0,3) == 3, '733: gcd(0,3) == 3');
815 vrfy(gcd(1,12) == 1, '734: gcd(1,12) == 1');
816 vrfy(gcd(11,7) == 1, '735: gcd(11,7) == 1');
817 vrfy(gcd(20,65) == 5, '736: gcd(20,65) == 5');
818 vrfy(gcdrem(20,3) == 20, '737: gcdrem(20,3) == 20');
819 vrfy(gcdrem(100,6) == 25, '738: gcdrem(100,6) == 25');
820 vrfy(highbit(1) == 0, '739: highbit(1) == 0');
821 vrfy(highbit(15) == 3, '740: highbit(15) == 3');
822 vrfy(hypot(3,4) == 5, '741: hypot(3,4) == 5');
823 vrfy(ilog(90,3) == 4, '742: ilog(90,3) == 4');
824 vrfy(ilog10(123) == 2, '743: ilog10(123) == 2');
825 vrfy(ilog2(17) == 4, '744: ilog2(17) == 4');
826 vrfy(im(3) == 0, '745: im(3) == 0');
827 vrfy(im(2+3i) == 3, '746: im(2+3i) == 3');
828 vrfy(fact(20) == 2432902008176640000,
829 '747: fact(20) == 2432902008176640000');
830 vrfy(fact(100) == 100*fact(99), '748: fact(100) == 100*fact(99)');
831 vrfy(comb(100,25) == 100!/75!/25!,
832 '749: comb(100,25) == 100!/75!/25!');
833 vrfy(perm(100,50) == 100!/50!, '750: perm(100,50) == 100!/50!');
834 print '751: test unused';
835 print '752: test unused';
836 print '753: test unused';
837 print '754: test unused';
838 print '755: test unused';
839 print '756: test unused';
840 vrfy(int(5) == 5, '757: int(5) == 5');
841 vrfy(int(19/3) == 6, '758: int(19/3) == 6');
842 vrfy(inverse(3/2) == 2/3, '759: inverse(3/2) == 2/3');
843 vrfy(iroot(18,2) == 4, '760: iroot(18,2) == 4');
844 vrfy(iroot(100,3) == 4, '761: iroot(100,3) == 4');
845 vrfy(iseven(10) == 1, '762: iseven(10) == 1');
846 vrfy(iseven(13) == 0, '763: iseven(13) == 0');
847 vrfy(iseven('a') == 0, "764: iseven('a') == 0");
848 vrfy(isint(7) == 1, '765: isint(7) == 1');
849 vrfy(isint(19/2) == 0, '766: isint(19/2) == 0');
850 vrfy(isint('a') == 0, "767: isint('a') == 0");
851 vrfy(islist(3) == 0, '768: islist(3) == 0');
852 vrfy(islist(list(2,3)) == 1, '769: islist(list(2,3)) == 1');
853 vrfy(ismat(3) == 0, '770: ismat(3) == 0');
854 vrfy(ismult(7,3) == 0, '771: ismult(7,3) == 0');
855 vrfy(ismult(15,5) == 1, '772: ismult(15,5) == 1');
856 vrfy(isnull(3) == 0, '773: isnull(3) == 0');
857 vrfy(isnull(null()) == 1, '774: isnull(null()) == 1');
858 vrfy(isnum(2/3) == 1, '775: isnum(2/3) == 1');
859 vrfy(isnum('xx') == 0, "776: isnum('xx') == 0");
860 vrfy(isobj(3) == 0, '777: isobj(3) == 0');
861 vrfy(isodd(7) == 1, '778: isodd(7) == 1');
862 vrfy(isodd(8) == 0, '779: isodd(8) == 0');
863 vrfy(isodd('x') == 0, "780: isodd('a') == 0");
864 vrfy(isqrt(27) == 5, '781: isqrt(27) == 5');
865 vrfy(isreal(3) == 1, '782: isreal(3) == 1');
866 vrfy(isreal('x') == 0, "783: isreal('x') == 0");
867 vrfy(isreal(2+3i) == 0, '784: isreal(2+3i) == 0');
868 vrfy(isstr(5) == 0, '785: isstr(5) == 0');
869 vrfy(isstr('foo') == 1, "786: isstr('foo') == 1");
870 vrfy(isrel(10,14) == 0, '787: isrel(10,14) == 0');
871 vrfy(isrel(15,22) == 1, '788: isrel(15,22) == 1');
872 vrfy(issimple(6) == 1, '789: issimple(6) == 1');
873 vrfy(issimple(3-2i) == 1, '790: issimple(3-2i) == 1');
874 vrfy(issimple(list(5)) == 0, '791: issimple(list(5)) == 0');
875 vrfy(issq(26) == 0, '792: issq(26) == 0');
876 vrfy(issq(9/4) == 1, '793: issq(9/4) == 1');
877 print '794: test unused';
878 vrfy(istype(9,4) == 1, '795: istype(9,4) == 1');
879 vrfy(istype(3,'xx') == 0, "796: istype(3,'xx') == 0");
880 vrfy(jacobi(5,11) == 1, '797: jacobi(2,7) == 1');
881 vrfy(jacobi(6,13) == -1, '798: jacobi(6,13) == -1');
882 vrfy(lcm(3,4,5,6) == 60, '799: lcm(3,4,5,6) == 60');
883 vrfy(lcmfact(8) == 840, '800: lcmfact(8) == 840');
884 vrfy(lfactor(21,5) == 3, '801: lfactor(21,5) == 3');
885 vrfy(lfactor(97,20) == 1, '802: lfactor(97,20) == 1');
886 vrfy(lowbit(12) == 2, '803: lowbit(12) == 2');
887 vrfy(lowbit(17) == 0, '804: lowbit(17) == 0');
888 vrfy(ltol(1) == 0, '805: ltol(1) == 0');
889 vrfy(max(3,-9,7,4) == 7, '806: max(3,-9,7,4) == 7');
890 vrfy(meq(13,33,10) == 1, '807: meq(13,33,10) == 1');
891 vrfy(meq(7,19,11) == 0, '808: meq(7,19,11) == 0');
892 vrfy(min(9,5,12) == 5, '809: min(9,5,12) == 5');
893 vrfy(minv(13,97) == 15, '810: minv(13,97) == 15');
894 vrfy(mne(16,37,10) == 1, '811: mne(16,37,10) == 1');
895 vrfy(mne(46,79,11) == 0, '812: mne(46,79,11) == 0');
896 vrfy(norm(4) == 16, '813: norm(4) == 16');
897 vrfy(norm(2-3i) == 13, '814: norm(2-3i) == 13');
898 vrfy(num(7) == 7, '815: num(7) == 7');
899 vrfy(num(11/4) == 11, '816: num(11/4) == 11');
900 vrfy(num(-9/5) == -9, '817: num(-9/5) == -9');
901 vrfy(char(ord('a')+2) == 'c', "818: char(ord('a')+2) == 'c'");
902 vrfy(perm(7,3) == 210, '819: perm(7,3) == 210');
903 vrfy(pfact(10) == 210, '820: pfact(10) == 210');
904 vrfy(places(3/7) == -1, '821: places(3/7) == -1');
905 vrfy(places(.347) == 3, '822: places(.347) == 3');
906 vrfy(places(17) == 0, '823: places(17) == 0');
907 vrfy(pmod(3,36,37) == 1, '824: pmod(3,36,37) == 1');
908 vrfy(poly(2,3,5,2) == 19, '825: poly(2,3,5,2) == 19');
909 vrfy(ptest(101,10) == 1, '826: ptest(101,10) == 1');
910 vrfy(ptest(221,30) == 0, '827: ptest(221,30) == 0');
911 vrfy(re(9) == 9, '828: re(9) == 9');
912 vrfy(re(-7+3i) == -7, '829: re(-7+3i) == -7');
913 vrfy(scale(3,4) == 48, '830: scale(3,4) == 48');
914 vrfy(sgn(-4) == -1, '831: sgn(-4) == -1');
915 vrfy(sgn(0) == 0, '832: sgn(0) == 0');
916 vrfy(sgn(3) == 1, '833: sgn(3) == 1');
917 vrfy(size(7) == 1, '834: size(7) == 1');
918 vrfy(sqrt(121) == 11, '835: sqrt(121) == 11');
919 vrfy(ssq(2,3,4) == 29, '836: ssq(2,3,4) == 29');
920 vrfy(str(45) == '45', "837: str(45) == '45'");
921 vrfy(strcat('a','bc','def')=='abcdef',
922 "838: strcat('a','bc','def')=='abcdef'");
923 vrfy(strlen('') == 0, "839: strlen('') == 0");
924 vrfy(strlen('abcd') == 4, "840: strlen('abcd') == 4");
925 vrfy(substr('abcd',2,1) == 'b', "841: substr('abcd',2,1) == 'b'");
926 vrfy(substr('abcd',3,4) == 'cd', "842: substr('abcd',3,4) == 'cd'");
927 vrfy(substr('abcd',1,3) == 'abc', "843: substr('abcd',1,3) == 'abc'");
928 vrfy(xor(17,17) == 0, '844: xor(17,17) == 0');
929 vrfy(xor(12,5) == 9, '845: xor(12,5) == 9');
930 vrfy(mmin(3,7) == 3, '846: mmin(3,7) == 3');
931 vrfy(mmin(4,7) == -3, '847: mmin(4,7) == -3');
932 vrfy(digit(123,2) == 1, '848: digit(123,2) == 1');
933 vrfy(ismult(3/4, 1/7) == 0, '849: ismult(3/4, 1/7) == 0');
934 vrfy(gcd(3/4, 1/7) == 1/28, '850: gcd(3/4,1/7) == 1/28');
935 vrfy(gcd(2,3,1/2) == 1/2, '851: gcd(2,3,1/2) == 1/2');
936 vrfy(gcd(17,7,1/7) == 1/7, '852: gcd(17,7,1/7) == 1/7');
937 vrfy(gcd(2) == 2, '853: gcd(2) == 2');
938 vrfy(gcd(-2) == 2, '854: gcd(-2) == 2');
939 vrfy(floor(1.5) == 1, '855: floor(1.5) == 1');
940 vrfy(floor(.5) == 0, '856: floor(.5) == 0');
941 vrfy(floor(-.5) == -1, '857: floor(-.5) == -1');
942 vrfy(floor(-1.5) == -2, '858: floor(-1.5) == -2');
943 vrfy(ceil(1.5) == 2, '859: ceil(1.5) == 2');
944 vrfy(ceil(.5) == 1, '860: ceil(.5) == 1');
945 vrfy(ceil(-.5) == 0, '861: ceil(-.5) == 0');
946 vrfy(ceil(-1.5) == -1, '862: ceil(-1.5) == -1');
947 vrfy(frac(-7.2) == -.2, '863: frac(-7.2) == -.2');
948 vrfy(gcd(4, 5, 1/3) == 1/3, '864: gcd(4, 5, 1/3) == 1/3');
949 vrfy(ltol(7/25) == 24/25, '865: ltol(7/25) == 24/25');
950 vrfy(hmean(1,2,3) == 18/11, '866: hmean(1,2,3) == 18/11');
951 vrfy(ilog2(2^-20) == -20, '867: ilog2(2^-20) == -20');
952 vrfy(ord("DBell") == 68, '868: ord("DBell") == 68');
953 vrfy(cmp("a","b") == -1, '869: cmp("a","b") == -1');
954 vrfy(cmp("abcd","abc") == 1, '870: cmp("abcd","abc") == 1');
955 vrfy(cmp(3,4i) == 1-1i, '871: cmp(3,4i) == 1-1i');
956 vrfy(cmp(4,4i) == 1-1i, '872: cmp(4,4i) == 1-1i');
957 vrfy(cmp(5,4i) == 1-1i, '873: cmp(5,4i) == 1-1i');
958 vrfy(cmp(-5,4i) == -1-1i, '874: cmp(-5,4i) == -1-1i');
959 vrfy(cmp(-4i,5) == -1-1i, '875: cmp(-4i,5) == -1-1i');
960 vrfy(cmp(-4i,-5) == 1-1i, '876: cmp(-4i,-5) == 1-1i');
961 vrfy(cmp(3i,4i) == -1i, '877: cmp(3i,4i) == -1i');
962 vrfy(cmp(4i,4i) == 0, '878: cmp(4i,4i) == 0');
963 vrfy(cmp(5i,4i) == 1i, '879: cmp(5i,4i) == 1i');
964 vrfy(cmp(3+4i,5) == -1+1i, '880: cmp(3+4i,5) == -1+1i');
965 vrfy(cmp(3+4i,-5) == 1+1i, '881: cmp(3+4i,-5) == 1+1i');
966 vrfy(cmp(3+4i,3+4i) == 0, '882: cmp(3+4i,3+4i) == 0');
967 vrfy(cmp(3+4i,3-4i) == 1i, '883: cmp(3+4i,3-4i) == 1i');
968 vrfy(cmp(3+4i,2+3i) == 1+1i, '884: cmp(3+4i,2+3i) == 1+1i');
969 vrfy(cmp(3+4i,-4-5i) == 1+1i, '885: cmp(3+4i,-4-5i) == 1+1i');
970 vrfy(comb(7,0) == 1, '886: comb(7,0) == 1');
971 vrfy(comb(0,0) == 1, '887: comb(0,0) == 1');
972 vrfy(perm(7,0) == 1, '888: perm(7,0) == 1');
973 vrfy(perm(0,0) == 1, '889: perm(0,0) == 1');
974 vrfy(isfile(files(0)) == 1, '890: isfile(files(0)) == 1');
975 vrfy(isfile(0) == 0, '891: isfile(0) == 0');
976 vrfy(ismult(4^67, 2^59) == 1, '892: ismult(4^67, 2^59) == 1');
977 vrfy(ismult(13, 4/67) == 0, '893: ismult(13, 4/67) == 0');
978 vrfy(ismult(13, 7/56) == 1, '894: ismult(13, 7/56) == 1');
979 vrfy(isnum(2i) == 1, '895: isnum(2i) == 1');
980 vrfy(iseven(1/3) == 0, '896: iseven(1/3) == 0');
981 vrfy(isodd(1/3) == 0, '897: isodd(1/3) == 0');
982 vrfy(isrel(-5, 6) == 1, '898: isrel(-5, 6) == 1');
983 vrfy(isrel(-2, 6) == 0, '899: isrel(-2, 6) == 0');
984 vrfy(bit(9,0) == 1, '900: bit(9,0) == 1');
985 vrfy(bit(9,1) == 0, '901: bit(9,1) == 0');
986 vrfy(bit(9,2) == 0, '902: bit(9,2) == 0');
987 vrfy(bit(9,3) == 1, '903: bit(9,3) == 1');
988 vrfy(bit(1.25, -2) == 1, '904: bit(1.25, -2) == 1');
989 vrfy(bit(1.25, -1) == 0, '905: bit(1.25, -1) == 0');
990 vrfy(bit(1.25, 0) == 1, '906: bit(1.25, 0) == 1');
991 vrfy(bit(pi(), 1) == 1, '907: bit(pi(), 1) == 1');
992 vrfy(bit(pi(), -2) == 0, '908: bit(pi(), -2) == 0');
993 vrfy(bit(pi(), -3) == 1, '909: bit(pi(), -3) == 1');
994 vrfy(istype(2, 3.0) == 1, '910: istype(2, 3.0) == 1');
995 vrfy(istype(2, "2") == 0, '911: istype(2, "2") == 0');
996 vrfy(istype(2, 3i) == 0, '912: istype(2, 3i) == 0');
997 vrfy(istype(2i+2, 3i) == 1, '913: istype(2i+2, 3i) == 1');
999 print '914: a = epsilon()';
1000 vrfy(epsilon(a) == epsilon(), '915: epsilon(a) == epsilon()');
1001 vrfy(epsilon(a) == epsilon(), '916: epsilon(a) == epsilon()');
1002 vrfy(epsilon(a) == epsilon(), '917: epsilon(a) == epsilon()');
1003 vrfy(epsilon() == a, '918: epsilon() == a');
1005 print '919: b = 1e-6';
1006 vrfy(epsilon(b) == a, '920: epsilon(b) == a');
1007 vrfy(epsilon(b) == epsilon(), '921: epsilon(b) == epsilon()');
1008 vrfy(epsilon(b) == epsilon(), '922: epsilon(b) == epsilon()');
1009 vrfy(epsilon(b) == epsilon(), '923: epsilon(b) == epsilon()');
1010 vrfy(epsilon() == 1e-6, '924: epsilon() == 1e-6');
1011 vrfy(epsilon(a) == b, '925: epsilon(a) == b');
1012 vrfy(epsilon(a) == epsilon(), '926: epsilon(a) == epsilon()');
1013 vrfy(epsilon(a) == epsilon(), '927: epsilon(a) == epsilon()');
1014 vrfy(epsilon(a) == epsilon(), '928: epsilon(a) == epsilon()');
1015 vrfy(epsilon(a) == a, '929: epsilon(a) == a');
1016 vrfy(quomod(13,5,a,b) == 1, '930: quomod(13,5,a,b) == 1');
1017 vrfy(a == 2, '931: a == 2');
1018 vrfy(b == 3, '932: b == 3');
1019 vrfy(quomod(15.6,5.2,a,b) == 0, '933: quomod(15.6,5.2,a,b) == 0');
1020 vrfy(a == 3, '934: a == 3');
1021 vrfy(b == 0, '935: b == 0');
1022 vrfy(putenv("abcd=efg") == 0, '936: putenv("abcd=efg")');
1023 vrfy(getenv("abcd") == "efg", '937: getenv("abcd") == "efg"');
1024 vrfy(putenv("abcd","123")==0, '938: putenv("abcd","123")');
1025 vrfy(getenv("abcd") == "123", '939: getenv("abcd") == "123"');
1026 vrfy(isnull(getenv("notavar")) == 1,
1027 '940: isnull(getenv("notavar")) == 1');
1029 print '941: a = "abcdefg"';
1030 vrfy(strpos(a, "c") == 3, '942: strpos(a, "c") == 3');
1031 vrfy(strpos(a, "def") == 4, '943: strpos(a, "def") == 4');
1032 vrfy(strpos(a, "defg") == 4, '944: strpos(a, "defg") == 4');
1033 vrfy(strpos(a, "defgh") == 0, '945: strpos(a, "defgh") == 0');
1034 vrfy(strpos(a, "abc") == 1, '946: strpos(a, "abc") == 1');
1035 vrfy(strpos(a, "xyz") == 0, '947: strpos(a, "xyz") == 0');
1036 vrfy(strpos(a, a) == 1, '948: strpos(a, a) == 1');
1037 if (config("windows") || config("cygwin")) {
1038 print '949: test skipped for windows or cygwin systems';
1039 print '950: test skipped for windows or cygwin systems';
1041 vrfy(system("") == 0, '949: system("") == 0');
1042 vrfy(system("true") == 0, '950: system("true") == 0');
1044 print '951: test disabled due to stdin dependency';
1045 print '952: test removed';
1046 print '953: test removed';
1047 vrfy(isstr(cmdbuf()) == 1, '954: isstr(cmdbuf()) == 1');
1048 vrfy(abs(root(4,3,0.1)-1.5874) < 0.1,
1049 '955: abs(root(4,3,0.1)-1.5874) < 0.1');
1050 print '956: a = 2^300 + 69962309754533779525365054067';
1051 a = 2^300 + 69962309754533779525365054067;
1053 print '957: a /= 2^211';
1054 vrfy(appr(a, 1e-20) == 2^89, '958: appr(a, 1e-20) == 2^89');
1055 vrfy(digits(5e149) == 150, '959: digits(5e149) == 150');
1056 vrfy(highbit(2) == 1, '960: highbit(2) == 1');
1057 vrfy(highbit(3) == 1, '961: highbit(3) == 1');
1058 vrfy(highbit(4) == 2, '962: highbit(4) == 2');
1059 vrfy(highbit(-15) == 3, '963: highbit(-15) == 3');
1060 vrfy(highbit(2^27) == 27, '964: highbit(2^27) == 27');
1062 print '965: a = 12.34';
1063 vrfy(digit(a,2) == 0, '966: digit(a,2) == 0');
1064 vrfy(digit(a,1) == 1, '967: digit(a,1) == 1');
1065 vrfy(digit(a,0) == 2, '968: digit(a,0) == 2');
1066 vrfy(digit(a,-1) == 3, '969: digit(a,-1) == 3');
1067 vrfy(digit(a,-2) == 4, '970: digit(a,-2) == 4');
1069 print '971: a = 10/7';
1070 vrfy(digit(a,1) == 0, '972: digit(a,1) == 0');
1071 vrfy(digit(a,0) == 1, '973: digit(a,0) == 1');
1072 vrfy(digit(a,-1) == 4, '974: digit(a,-1) == 4');
1073 vrfy(digit(a,-2) == 2, '975: digit(a,-2) == 2');
1074 vrfy(digit(a,-3) == 8, '976: digit(a,-3) == 8');
1075 vrfy(digits(0) == 1, '977: digits(0) == 1');
1076 vrfy(digits(0.0123) == 1, '978: digits(0.0123) == 1');
1077 vrfy(digits(3.7) == 1, '979: digits(3.7) == 1');
1078 vrfy(digits(-27) == 2, '980: digits(-27) == 2');
1079 vrfy(digits(-99.7) == 2, '981: digits(-99.7) == 2');
1080 vrfy(ilog2(1) == 0, '982: ilog2(1) == 0');
1081 vrfy(ilog2(2) == 1, '983: ilog2(2) == 1');
1082 vrfy(ilog2(3) == 1, '984: ilog2(3) == 1');
1083 vrfy(ilog2(4) == 2, '985: ilog2(4) == 2');
1084 vrfy(ilog2(1/15) == -4, '986: ilog2(1/15) == -4');
1085 vrfy(places(3) == 0, '987: places(3) == 0');
1086 vrfy(places(0.0123) == 4, '988: places(0.0123) == 4');
1087 vrfy(places(3.70) == 1, '989: places(3.70) == 1');
1088 vrfy(places(1e-10) == 10, '990: places(1e-10) == 10');
1089 vrfy(places(3/7) == -1, '991: places(/37) == -1');
1090 vrfy(ilog10(7.7) == 0, '992: ilog10(7.7) == 0');
1091 vrfy(ilog10(77.7) == 1, '993: ilog10(77.7) == 1');
1092 vrfy(ilog10(777) == 2, '994: ilog10(777) == 2');
1093 vrfy(ilog10(.00777) == -3, '995: ilog10(.00777) == -3');
1094 vrfy(ilog10(1e27) == 27, '996: ilog10(1e27) == 27');
1095 vrfy(lowbit(2) == 1, '997: lowbit(2) == 1');
1096 vrfy(lowbit(3) == 0, '998: lowbit(3) == 0');
1097 vrfy(lowbit(4) == 2, '999: lowbit(4) == 2');
1098 vrfy(lowbit(-15) == 0, '1000: lowbit(-15) == 0');
1099 vrfy(lowbit(2^27) == 27, '1001: lowbit(2^27) == 27');
1100 vrfy(char(0102) == 'B', '1002: char(0102) == \'B\'');
1101 vrfy(char(0x6f) == 'o', '1003: char(0x6f) == \'o\'');
1102 vrfy(char(119) == 'w', '1004: char(119) == \'w\'');
1103 vrfy(char(0145) == 'e', '1005: char(0145) == \'e\'');
1104 vrfy(char(0x6e) == 'n', '1006: char(0x6e) == \'n\'');
1105 vrfy(den(-1.25) == 4, '1007: den(-1.25) == 4');
1106 vrfy(den(121/33) == 3, '1008: den(121/33) == 3');
1107 vrfy(gcd(9/10, 11/5, 4/25) == 0.02,
1108 '1009: gcd(9/10, 11/5, 4/25) == 0.02');
1109 vrfy(gcd(0,0,0,0,0) == 0, '1010: gcd(0,0,0,0,0) == 0');
1110 vrfy(hypot(3, 4, 1e-6) == 5, '1011: hypot(3, 4, 1e-6) == 5');
1111 vrfy(hypot(2,-3,1e-6) == 3605551/1e6,
1112 '1012: hypot(2,-3,1e-6) == 3605551/1e6');
1113 vrfy(im(-4.25 - 7i) == -7, '1013: im(-4.25 - 7i) == -7');
1114 vrfy(lcm(12, -24, 30) == -120,'1014: lcm(12, -24, 30) == -120');
1115 vrfy(lcm(9/10, 11/5, 4/25) == 79.2,
1116 '1015: lcm(9/10, 11/5, 4/25) == 79.2');
1117 vrfy(lcm(2) == 2, '1016: lcm(2) == 2');
1118 vrfy(max(2) == 2, '1017: max(2) == 2');
1119 vrfy(min(2) == 2, '1018: min(2) == 2');
1120 vrfy(re(-4.25 - 7i) == -4.25, '1019: re(-4.25 - 7i) == -4.25');
1121 vrfy(size("abc") == 3, '1020: size("abc") == 3');
1122 vrfy(str("") == "", '1021: str("") == ""');
1123 vrfy(str(null()) == "", '1022: str(null()) == ""');
1124 vrfy(str("Ernest Bowen") == "Ernest Bowen",
1125 '1023: str("Ernest Bowen") == "Ernest Bowen"');
1126 vrfy(strlen("a b\tc\\d") == 7,
1127 '1024: strlen("a b\tc\\d") == 7');
1128 vrfy(xor(2) == 2, '1025: xor(2) == 2');
1129 vrfy(xor(5, 3, 7, 2, 9) == 10,
1130 '1026: xor(5, 3, 7, 2, 9) == 10');
1131 vrfy(xor(0,0) == 0, '1027: xor(0,0) == 0');
1132 vrfy(xor(0,1) == 1, '1028: xor(0,1) == 1');
1133 vrfy(xor(1,0) == 1, '1029: xor(1,0) == 1');
1134 vrfy(xor(1,1) == 0, '1030: xor(1,1) == 0');
1135 vrfy(xor(5,3,-7,2,9) == -12, '1031: xor(5,3,-7,2,9) == -12');
1136 vrfy(fib(-2) == -1, '1032: fib(-2) == -1');
1137 vrfy(fib(-1) == 1, '1033: fib(-1) == 1');
1138 vrfy(fib(-10) == -55, '1034: fib(-10) == -55');
1139 vrfy(ilog(1/8, 3) == -2, '1035: ilog(1/8, 3) == -2');
1140 vrfy(ilog(8.9, 3) == 1, '1036: ilog(8.9, 3) == 1');
1141 vrfy(iroot(1,9) == 1, '1037: iroot(1,9) == 1');
1142 vrfy(iroot(pi()^8,5) == 6, '1038: iroot(pi()^8,5)');
1143 vrfy(isqrt(8.5) == 2, '1039: isqrt(8.5) == 2');
1144 vrfy(isqrt(2e56) == 14142135623730950488016887242,
1145 '1040: isqrt(2e56) == 14142135623730950488016887242');
1146 vrfy(near(22/7, 3.15, .01) == -1,
1147 '1041: near(22/7, 3.15, .01) == -1');
1148 vrfy(near(22/7, 3.15, .005) == 1,
1149 '1042: near(22/7, 3.15, .005) == 1');
1150 vrfy(norm(3.4) == 11.56, '1043: isqrt(3.4) == 11.56');
1151 vrfy(pi(1e-5) == 3.14159, '1044: pi(1e-5) == 3.14159');
1153 print '1045: pi = pi(1e-10)';
1154 vrfy(pi == 3.1415926536, '1046: pi == 3.1415926536');
1155 vrfy(polar(2,pi/2,1e-5)==2i, '1047: polar(2,pi/2,1e-5)==2i');
1156 vrfy(power(exp(1,1e-20),pi(1e-20)*1i/2,1e-20) == 1i,
1157 '1048: power(exp(1,1e-20),pi(1e-20)*1i/2,1e-20) == 1i');
1158 vrfy(ssq(1+2i, 3-4i, 5 +6i) == -21+40i,
1159 '1049: ssq(1+2i, 3-4i, 5 +6i) == -21+40i');
1160 vrfy(isreal(ln(1 + 1e-10i, 1e-5)),
1161 '1050: isreal(ln(1 + 1e-10i, 1e-5))');
1162 vrfy(isreal(exp(pi(1e-10)*1i, 1e-5)),
1163 '1051: isreal(exp(pi(1e-10)*1i, 1e-5))');
1164 vrfy(cfappr(43/30, 10, 0) == 10/7,
1165 '1052: cfappr(43/30, 10, 0) == 10/7');
1166 vrfy(cfappr(43/30, 10, 1) == 13/9,
1167 '1053: cfappr(43/30, 10, 1) == 13/9');
1168 vrfy(cfappr(43/30, 10, 16) == 10/7,
1169 '1054: cfappr(43/30, 10, 16) == 10/7');
1170 vrfy(cfappr(6/5, 1/2, 16) == 1,
1171 '1055: cfappr(6/5, 1/2, 16) == 1');
1172 vrfy(cfsim(13,8) == 0, '1056: cfsim(13,8) == 0');
1173 vrfy(cfsim(1057,8) == 0, '1057: cfsim(1057,8) == 0');
1174 vrfy(mod(11,5,0) == 1, '1058: mod(11,5,0) == 1');
1175 vrfy(mod(11,5,1) == -4, '1059: mod(11,5,1) == -4');
1176 vrfy(mod(-11,5,2) == -1, '1060: mod(-11,5,2) == -1');
1177 vrfy(mod(-11,-5,3) == 4, '1061: mod(-11,-5,3) == 4');
1178 vrfy(mod(12.5,5,16) == 2.5, '1062: mod(12.5,5,16) == 2.5');
1179 vrfy(mod(12.5,5,17) == -2.5, '1063: mod(12.5,5,17) == -2.5');
1180 vrfy(mod(12.5,5,24) == 2.5, '1064: mod(12.5,5,24) == 2.5');
1181 vrfy(mod(-7.5,-5,24) == 2.5, '1065: mod(-7.5,-5,24) == 2.5');
1182 vrfy(quo(11,5,0) == 2, '1066: quo(11,5,0) == 2');
1183 vrfy(quo(11,5,1) == 3, '1067: quo(11,5,1) == 3');
1184 vrfy(quo(-11,5,2) == -2, '1068: quo(-11,5,2) == -2');
1185 vrfy(quo(-11,-5,3) == 3, '1069: quo(-11,-5,3) == 3');
1186 vrfy(quo(12.5,5,16) == 2, '1070: quo(12.5,5,16) == 2');
1187 vrfy(quo(12.5,5,17) == 3, '1071: quo(12.5,5,17) == 3');
1188 vrfy(quo(12.5,5,24) == 2, '1072: quo(12.5,5,24) == 2');
1189 vrfy(quo(-7.5,-5,24) == 2, '1073: quo(-7.5,-5,24) == 2');
1190 vrfy(frac(2.5 + 3i) == .5, '1074: frac(2.5 + 3i) == .5');
1191 vrfy(root(1i,1000,1e-2)==1, '1075: root(1i,1000,1e-2) == 1');
1192 vrfy(scale(2+3i,2)==8+12i, '1076: scale(2+3i,2) == 8+12i');
1193 vrfy(frem(8,4) == 2, '1077: frem(8,4) == 2');
1194 vrfy(jacobi(80,199) == 1, '1078: jacobi(80,199) == 1');
1195 vrfy(test(1), '1079: test(1)');
1196 vrfy(!test(0), '1080: !test(0)');
1197 vrfy(hnrmod(2^177-1,1,177,-1)==0,
1198 '1081: hnrmod(2^177-1,1,177,-1)==0');
1199 vrfy(hnrmod(2^178-2,1,177,-1)==0,
1200 '1082: hnrmod(2^178-2,1,177,-1)==0');
1201 vrfy(hnrmod(2^178-3,1,177,1)==2^177-4,
1202 '1083: hnrmod(2^178-3,1,177,1)==2^177-4');
1203 vrfy(hnrmod(2^179-4,1,177,0)==2^177-4,
1204 '1084: hnrmod(2^179-4,1,177,0)==2^177-4');
1205 vrfy(hnrmod(1234567^2,13,17,-1)==1155404,
1206 '1085: hnrmod(1234567^2,13,17,-1)==1155404');
1207 vrfy(hnrmod(3276^54,45,415,1)==3276^54%(45*2^415+1),
1208 '1086: hnrmod(3276^54,45,415,1)==3276^54%(45*2^415+1)');
1209 vrfy(hnrmod(3276^54,45,415,0)==3276^54%(45*2^415),
1210 '1087: hnrmod(3276^54,45,415,0)==3276^54%(45*2^415)');
1211 vrfy(hnrmod(3276^54,45,415,-1)==3276^54%(45*2^415-1),
1212 '1088: hnrmod(3276^54,45,415,-1)==3276^54%(45*2^415-1)');
1213 vrfy(hnrmod(10^40, 17, 51, 1) == 33827019788296445,
1214 '1089: hnrmod(10^40, 17, 51, 1) == 33827019788296445');
1215 vrfy(hnrmod(3192487935759423423521,16,65,1)==241008883965895164956,
1216 '1090: hnrmod(3192487935759423423521,16,65,1)==241008883965895164956');
1221 a = 2868611690182699929873981931;
1222 print '1091: a = 2868611690182699929873981931';
1223 b = 502922899875329926125584830;
1224 print '1092: b = 502922899875329926125584830';
1225 vrfy(minv(b,a) == 1111092570983877189739032190,
1226 '1093: minv(b,a) == 1111092570983877189739032190');
1227 vrfy(mod(minv(b,a)*b,a) == 1,
1228 '1094: mod(minv(b,a)*b,a) == 1');
1231 * more functions to test
1233 vrfy(popcnt(32767) == 15, '1095: popcnt(32767) == 15');
1234 vrfy(popcnt(3/2) == 3, '1096: popcnt(3/2) == 3');
1235 vrfy(popcnt(-237/39929,1) == 17,
1236 '1097: popcnt(-237/39929,1) == 17');
1237 vrfy(popcnt(-237/39929,0) == 7,
1238 '1098: popcnt(-237/39929,0) == 7');
1239 vrfy(popcnt(-237/39929) == 17,
1240 '1099: popcnt(-237/39929) == 17');
1241 vrfy(popcnt(pi(1e-20)) == 65, '1100: popcnt(pi(1e-20)) == 65');
1242 vrfy(popcnt(pi(1e-20),0) == 69, '1101: popcnt(pi(1e-20),0) == 69');
1243 vrfy(popcnt(17^777) == 1593, '1102: popcnt(17^777) == 1593');
1246 * more hnrmod testing
1248 vrfy(hnrmod(21<<100+5,3,100,1) == (21<<100+5)%(3<<100+1),
1249 '1103: hnrmod(21<<100+5,3,100,1) == (21<<100+5)%(3<<100+1)');
1250 vrfy(hnrmod(21<<500+7,3,500,1) == (21<<500+7)%(3<<500+1),
1251 '1104: hnrmod(21<<500+7,3,500,1) == (21<<500+7)%(3<<500+1)');
1252 vrfy(hnrmod(-767256,84,1,0) == (-767256)%(84<<1+0),
1253 '1105: hnrmod(-767256,84,1,0) == (-767256)%(84<<1+0)');
1254 vrfy(hnrmod(-831150,75,1,0) == (-831150)%(75<<1+0),
1255 '1106: hnrmod(-831150,75,1,0) == (-831150)%(75<<1+0)');
1256 vrfy(hnrmod(-767256,84,1,1) == (-767256)%(84<<1+1),
1257 '1107: hnrmod(-767256,84,1,1) == (-767256)%(84<<1+1)');
1258 vrfy(hnrmod(-831150,75,1,1) == (-831150)%(75<<1+1),
1259 '1108: hnrmod(-831150,75,1,1) == (-831150)%(75<<1+1)');
1260 vrfy(hnrmod(-767256,84,1,-1) == (-767256)%(84<<1-1),
1261 '1109: hnrmod(-767256,84,1,-1) == (-767256)%(84<<1-1)');
1262 vrfy(hnrmod(-831150,75,1,-1) == (-831150)%(75<<1-1),
1263 '1110: hnrmod(-831150,75,1,-1) == (-831150)%(75<<1-1)');
1264 vrfy(hnrmod(21<<100+5,3,100,0) == (21<<100+5)%(3<<100+0),
1265 '1111: hnrmod(21<<100+5,3,100,0) == (21<<100+5)%(3<<100+0)');
1266 vrfy(hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1),
1267 '1112: hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1)');
1272 vrfy(catalan(2) == 2, '1113: catalan(2) == 2');
1273 vrfy(catalan(3) == 5, '1114: catalan(3) == 5');
1274 vrfy(catalan(4) == 14, '1115: catalan(4) == 14');
1275 vrfy(catalan(20) == 6564120420, '1116: catalan(20) == 6564120420');
1278 * bernoulli builtin function testing
1280 vrfy(bernoulli(0) == 1, '1117: bernoulli(0) == 1');
1281 vrfy(bernoulli(1) == -1/2, '1118: bernoulli(1) == -1/2');
1282 vrfy(bernoulli(2) == 1/6, '1119: bernoulli(2) == 1/6');
1283 vrfy(bernoulli(3) == 0, '1120: bernoulli(3) == 0');
1284 vrfy(bernoulli(4) == -1/30, '1121: bernoulli(4) == -1/30');
1285 vrfy(bernoulli(5) == 0, '1122: bernoulli(5) == 0');
1286 vrfy(bernoulli(6) == 1/42, '1123: bernoulli(6) == 1/42');
1287 vrfy(bernoulli(32) == -7709321041217/510,
1288 '1124: bernoulli(32) == -7709321041217/510');
1291 * euler function testing
1293 vrfy(euler(0) == 1, '1125: euler(0) == 1');
1294 vrfy(euler(1) == 0, '1126: euler(1) == 0');
1295 vrfy(euler(2) == -1, '1127: euler(2) == -1');
1296 vrfy(euler(3) == 0, '1128: euler(3) == 0');
1297 vrfy(freeeuler() == null(), '1129: freeeuler() == null()');
1298 vrfy(euler(4) == 5, '1130: euler(4) == 5');
1299 vrfy(euler(5) == 0, '1131: euler(5) == 0');
1300 vrfy(euler(6) == -61, '1132: euler(6) == -61');
1301 vrfy(euler(32) == 177519391579539289436664789665,
1302 '1130: euler(32) == 177519391579539289436664789665');
1303 vrfy(freeeuler() == null(), '1133: freeeuler() == null()');
1306 * digit with non-10 base
1309 print '1134: a = 123456.789';
1310 vrfy(digit(a, 6, 100) == 0, '1135: digit(a, 6, 100) == 0');
1311 vrfy(digit(a, 5, 100) == 0, '1136: digit(a, 5, 100) == 0');
1312 vrfy(digit(a, 4, 100) == 0, '1137: digit(a, 4, 100) == 0');
1313 vrfy(digit(a, 3, 100) == 0, '1138: digit(a, 3, 100) == 0');
1314 vrfy(digit(a, 2, 100) == 12, '1139: digit(a, 2, 100) == 12');
1315 vrfy(digit(a, 1, 100) == 34, '1140: digit(a, 1, 100) == 34');
1316 vrfy(digit(a, 0, 100) == 56, '1141: digit(a, 0, 100) == 56');
1317 vrfy(digit(a, -1, 100) == 78, '1142: digit(a, -1, 100) == 78');
1318 vrfy(digit(a, -2, 100) == 90, '1143: digit(a, -2, 100) == 90');
1319 vrfy(digit(a, -3, 100) == 0, '1144: digit(a, -3, 100) == 0');
1320 vrfy(digit(a, -4, 100) == 0, '1145: digit(a, -4, 100) == 0');
1321 vrfy(digit(a, -5, 100) == 0, '1146: digit(a, -5, 100) == 0');
1322 vrfy(digit(a, -6, 100) == 0, '1146: digit(a, -6, 100) == 0');
1325 * digits with a non-10 base
1327 vrfy(digits(a, 100) == 3, '1147: digits(a, 100) == 3');
1328 vrfy(digits(2^256-1, 256) == 32,'1148: digits(2^256-1, 256) == 32');
1331 * places with a non-10 base
1333 vrfy(places(0.0123, 2) == -1, '1149: places(0.0123, 2) == -1');
1334 vrfy(places(0.625, 2) == 3, '1150: places(0.625, 2) == 3');
1335 vrfy(places(0.625, 8) == 1, '1151: places(0.625, 8) == 1');
1336 vrfy(places(171/2^712, 2) == 712,
1337 '1152: places(171/2^7120.625, 2) == 712');
1338 vrfy(places(171/2^712, 64) == 119,
1339 '1152: places(171/2^7120.625, 64) == 119');
1344 vrfy(sleep(1/5) == null(), '1153: sleep(1/5) == null()');
1345 vrfy(sleep(1/100) == null(), '1154: sleep(1/100) == null()');
1350 vrfy(isstr(calcpath()), '1155: isstr(calcpath())');
1355 vrfy(ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204,
1356 '1156: ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204');
1359 * quomod 5th argument rounding tests
1361 vrfy(quomod(10,-3,a,b,0) == 1, '1157: vrfy(quomod(10,-3,a,b,0) == 1');
1362 vrfy(a == -4, '1158: a == -4');
1363 vrfy(b == -2, '1159: b == -2');
1364 vrfy(quomod(-10,-3,a,b,1) == 1, '1160: vrfy(quomod(-10,-3,a,b,1) == 1');
1365 vrfy(a == 4, '1161: a == 4');
1366 vrfy(b == 2, '1162: b == 2');
1367 vrfy(quomod(10,3,a,b,2) == 1, '1163: vrfy(quomod(10,3,a,b,2) == 1');
1368 vrfy(a == 3, '1164: a == 3');
1369 vrfy(b == 1, '1165: b == 1');
1370 vrfy(quomod(-10,3,a,b,3) == 1, '1166: vrfy(quomod(-10,3,a,b,3) == 1');
1371 vrfy(a == -4, '1167: a == -4');
1372 vrfy(b == 2, '1168: b == 2');
1373 vrfy(quomod(10,-3,a,b,4) == 1, '1169: vrfy(quomod(10,-3,a,b,4) == 1');
1374 vrfy(a == -3, '1170: a == -3');
1375 vrfy(b == 1, '1171: b == 1');
1376 vrfy(quomod(-10,-3,a,b,5) == 1, '1172: vrfy(quomod(-10,-3,a,b,5) == 1');
1377 vrfy(a == 3, '1173: a == 3');
1378 vrfy(b == -1, '1174: b == -1');
1379 vrfy(quomod(10,3,a,b,6) == 1, '1175: vrfy(quomod(10,3,a,b,6) == 1');
1380 vrfy(a == 3, '1176: a == 3');
1381 vrfy(b == 1, '1177: b == 1');
1382 vrfy(quomod(-10,3,a,b,7) == 1, '1178: vrfy(quomod(-10,3,a,b,7) == 1');
1383 vrfy(a == -4, '1179: a == -4');
1384 vrfy(b == 2, '1180: b == 2');
1385 vrfy(quomod(10,-3,a,b,8) == 1, '1181: vrfy(quomod(10,-3,a,b,8) == 1');
1386 vrfy(a == -4, '1182: a == -4');
1387 vrfy(b == -2, '1183: b == -2');
1388 vrfy(quomod(-10,-3,a,b,9) == 1, '1184: vrfy(quomod(-10,-3,a,b,9) == 1');
1389 vrfy(a == 3, '1185: a == 3');
1390 vrfy(b == -1, '1186: b == -1');
1391 vrfy(quomod(10,3,a,b,10) == 1, '1187: vrfy(quomod(10,3,a,b,10) == 1');
1392 vrfy(a == 4, '1188: a == 4');
1393 vrfy(b == -2, '1189: b == -2');
1394 vrfy(quomod(-10,3,a,b,11) == 1, '1190: vrfy(quomod(-10,3,a,b,11) == 1');
1395 vrfy(a == -4, '1191: a == -4');
1396 vrfy(b == 2, '1192: b == 2');
1397 vrfy(quomod(10,-3,a,b,12) == 1, '1193: vrfy(quomod(10,-3,a,b,12) == 1');
1398 vrfy(a == -3, '1194: a == -3');
1399 vrfy(b == 1, '1195: b == 1');
1400 vrfy(quomod(-10,-3,a,b,13) == 1,
1401 '1196: vrfy(quomod(-10,-3,a,b,13) == 1');
1402 vrfy(a == 4, '1197: a == 4');
1403 vrfy(b == 2, '1198: b == 2');
1404 vrfy(quomod(10,3,a,b,14) == 1, '1199: vrfy(quomod(10,3,a,b,14) == 1');
1405 vrfy(a == 4, '1200: a == 4');
1406 vrfy(b == -2, '1201: b == -2');
1407 vrfy(quomod(-10,3,a,b,15) == 1, '1202: vrfy(quomod(-10,3,a,b,15) == 1');
1408 vrfy(a == -4, '1203: a == -4');
1409 vrfy(b == 2, '1204: b == 2');
1411 /* runtime(), systime(), usertime() return numeric values */
1412 vrfy(isnum(runtime()), '1205: isnum(runtime())');
1413 vrfy(isnum(systime()), '1206: isnum(systime())');
1414 vrfy(isnum(usertime()), '1207: isnum(usertime())');
1416 /* more jacobi tests */
1417 vrfy(jacobi(987897,987) == 0, '1208: jacobi(987897,987) == 0');
1418 vrfy(jacobi(897,987) == 0, '1209: jacobi(897,987) == 0');
1419 vrfy(jacobi(987,897) == 0, '1210: jacobi(987,897) == 0');
1420 vrfy(jacobi(90,897) == 0, '1211: jacobi(90,897) == 0');
1421 vrfy(jacobi(45,897) == 0, '1212: jacobi(45,897) == 0');
1422 vrfy(jacobi(897,45) == 0, '1213: jacobi(897,45) == 0');
1423 vrfy(jacobi(42,45) == 0, '1214: jacobi(42,45) == 0');
1424 vrfy(jacobi(21,45) == 0, '1215: jacobi(21,45) == 0');
1425 vrfy(jacobi(45,21) == 0, '1216: jacobi(45,21) == 0');
1426 vrfy(jacobi(3,21) == 0, '1217: jacobi(3,21) == 0');
1427 vrfy(jacobi(0,21) == 0, '1218: jacobi(0,21) == 0');
1428 vrfy(jacobi(0,20003) == 0, '1219: jacobi(0,20003) == 0');
1429 vrfy(jacobi(1,20003) == 1, '1220: jacobi(1,20003) == 1');
1430 vrfy(jacobi(1236,20003) == 1, '1221: jacobi(1236,20003) == 1');
1431 vrfy(jacobi(618,20003) == -1, '1222: jacobi(618,20003) == -1');
1432 vrfy(jacobi(309,20003) == 1, '1223: jacobi(309,20003) == 1');
1433 vrfy(jacobi(227,309) == 1, '1224: jacobi(227,309) == 1');
1434 vrfy(jacobi(82,227) == 1, '1225: jacobi(82,227) == 1');
1435 vrfy(jacobi(41,227) == -1, '1226: jacobi(41,227) == -1');
1436 vrfy(jacobi(22,41) == -1, '1227: jacobi(22,41) == -1');
1437 vrfy(jacobi(11,41) == -1, '1228: jacobi(11,41) == -1');
1438 vrfy(jacobi(8,11) == -1, '1229: jacobi(8,11) == -1');
1439 vrfy(jacobi(4,11) == 1, '1230: jacobi(4,11) == 1');
1440 vrfy(jacobi(2,11) == -1, '1231: jacobi(2,11) == -1');
1441 vrfy(jacobi(1,11) == 1, '1232: jacobi(1,11) == 1');
1442 vrfy(jacobi(0,11) == 0, '1233: jacobi(0,11) == 0');
1443 vrfy(jacobi(0,0) == 0, '1234: jacobi(0,0) == 0');
1444 vrfy(jacobi(-1,0) == 0, '1235: jacobi(-1,0) == 0');
1445 vrfy(jacobi(-1,-1) == 0, '1236: jacobi(-1,-1) == 0');
1446 vrfy(jacobi(0,-1) == 0, '1237: jacobi(0,-1) == 0');
1448 print '1238: Ending test_functions';
1450 print '017: parsed test_functions()';
1454 * _test_underscore - test use of _'s in identifiers
1457 print '018: _ = 49';
1459 print "019: __ = 63";
1460 define _test_underscore()
1465 print "1290: Beginning _test_underscore";
1467 vrfy(_a == 27, '1291: _a == 27');
1468 vrfy(_ == 49, '1292: _ == 49');
1469 vrfy(__ == 63, '1293: __ == 63');
1470 vrfy(__a == 23209, '1294: __a == 23209');
1472 print "1295: Ending _test_underscore";
1474 print '020: parsed _test_underscore';
1478 * place holder for any print items
1480 print "021:", "reserved for future use";
1481 print "022:": " reserved for future use";
1493 print '1300: Beginning associations test';
1496 vrfy(size(a) == 0, '1301: size(a) == 0');
1498 print '1302: a["curds"] = 13';
1499 vrfy(a["curds"] == 13, '1303: a["curds"] == 13');
1501 print '1304: a[13] = 17';
1502 vrfy(a[13] == 17, '1305: a[13] == 17');
1503 vrfy(a[a["curds"]] == 17, '1306: a[a["curds"]] == 17');
1505 print '1307: a[17] = 19';
1506 vrfy(a[17] == 19, '1308: a[17] == 19');
1507 vrfy(a[a["curds"]+4] == 19, '1309: a[a["curds"]+4] == 19');
1508 vrfy(size(a) == 3, '1310: size(a) == 3');
1509 vrfy(a[[search(a,17)]] == 17, '1311: (a[[search(a,17)]] == 17');
1510 vrfy(isnull(search(a,16)), '1312: isnull(search(a,16))');
1511 a["curds","whey"] = "spider";
1512 print '1313: a["curds","whey"] = "spider"';
1513 vrfy(a["curds","whey"] == "spider",
1514 '1314: a["curds","whey"] == "spider"');
1515 vrfy(a[[rsearch(a,"spider")]] == "spider",
1516 '1315: a[[rsearch(a,"spider")]] == "spider"');
1518 print '1316: b = a';
1519 vrfy(b[17] == 19, '1317: b[17] == 19');
1520 vrfy(a == b, '1318: a == b');
1521 vrfy(isassoc(a) == 1, '1319: isassoc(a) == 1');
1522 vrfy(isassoc(1) == 0, '1320: isassoc(1) == 0');
1524 vrfy(quomod(13, 5, A[1], A[2]) == 1,
1525 '1321: quomod(13, 5, A[1], A[2]) == 1');
1526 vrfy(A[1] == 2, '1322: A[1] == 2');
1527 vrfy(A[2] == 3, '1323: A[2] == 3');
1529 print '1324: Ending associations test';
1531 print '023: parsed test_assoc()';
1541 static x = list(11,13,17,23,29);
1542 static y0 = list(1,3,7,3,9);
1543 static y1 = list(-9,-7,-3,-7,-1);
1544 static y2 = list(-9,-7,-3,3,9);
1545 static y3 = list(1,3,7,-7,-1);
1546 static y4 = list(1,3,-3,3,-1);
1551 print '1400: Beginning list test';
1554 vrfy(a == list(2,3,5), '1401: a == list(2,3,5)');
1555 vrfy(a[[0]] == 2, '1402: a[[0]] == 2');
1556 vrfy(a[[1]] == 3, '1403: a[[1]] == 3');
1557 vrfy(a[[2]] == 5, '1404: a[[2]] == 5');
1558 vrfy(size(a) == 3, '1405: size(a) == 3');
1559 vrfy(search(a,3) == 1, '1406: search(a,3) == 1');
1560 vrfy(isnull(search(a,3,2)), '1407: isnull(search(a,3,2))');
1561 vrfy(rsearch(a,3,2) == 1, '1408: rsearch(a,3,2) == 1');
1563 print '1409: push(a,7)';
1564 vrfy(search(a,7) == 0, '1410: search(a,7) == 0');
1565 vrfy(pop(a) == 7, '1411: pop(a) == 7');
1566 vrfy(size(a) == 3, '1412: size(a) == 3');
1568 print '1413: append(a,7)';
1569 vrfy(search(a,7) == 3, '1414: search(a,7) == 3');
1570 vrfy(size(a) == 4, '1415: size(a) == 4');
1571 vrfy(remove(a) == 7, '1416: remove(a) == 7');
1572 vrfy(size(a) == 3, '1417: size(a) == 3');
1574 print '1418: b = a';
1576 print '1419: insert(a,1,7)';
1577 vrfy(search(a,2) == 0, '1420: search(a,2) == 0');
1578 vrfy(search(a,7) == 1, '1421: search(a,7) == 1');
1579 vrfy(search(a,3) == 2, '1422: search(a,3) == 2');
1580 vrfy(search(a,5) == 3, '1423: search(a,5) == 3');
1581 vrfy(size(a) == 4, '1424: size(a) == 4');
1582 vrfy(delete(a,1) == 7, '1425: remove(a) == 7');
1583 vrfy(search(a,2) == 0, '1426: search(a,2) == 0');
1584 vrfy(search(a,3) == 1, '1427: search(a,3) == 1');
1585 vrfy(search(a,5) == 2, '1428: search(a,5) == 2');
1586 vrfy(size(a) == 3, '1429: size(a) == 3');
1587 vrfy(a == b, '1430: a == b');
1589 print '1431: A = list(1,2,3)';
1591 print '1432: B = list(4,5)';
1593 print '1433: C = join(A,B)';
1594 D = list(1,2,3,4,5);
1595 print '1434: D = list(1,2,3,4,5)';
1596 vrfy(C == D, '1435: C == D');
1597 E = list(5,4,3,2,1);
1598 print '1436: E = list(5,4,3,2,1)';
1599 vrfy(reverse(D) == E, '1437: reverse(D) == E');
1600 vrfy(sort(list(1,3,5,2,4))==D,'1438: sort(list(1,3,5,2,4))==D');
1601 vrfy(head(D,2) == list(1,2), '1439: head(D,2) == list(1,2)');
1602 vrfy(head(D,-2) == list(2,1), '1440: head(D,-2) == list(2,1)');
1603 vrfy(head(D,5) == D, '1441: head(D,5) == D');
1604 vrfy(head(D,6) == D, '1442: head(D,6) == D');
1605 vrfy(head(D,-5) == E, '1443: head(D,-5) == E');
1606 vrfy(head(D,-6) == E, '1444: head(D,-6) == E');
1607 vrfy(tail(E,2) == list(2,1), '1445: tail(E,2) == list(2,1)');
1608 vrfy(tail(E,-2) == list(1,2), '1446: tail(E,-2) == list(1,2)');
1609 vrfy(tail(E,5) == E, '1447: tail(E,5) == E');
1610 vrfy(tail(E,6) == E, '1448: tail(E,6) == E');
1611 vrfy(tail(E,-5) == D, '1449: tail(E,-5) == D');
1612 vrfy(tail(E,-6) == D, '1450: tail(E,-6) == D');
1613 vrfy(segment(D,1,3) == list(2,3,4),
1614 '1451: segment(D,1,3) == list(2,3,4)');
1615 vrfy(segment(D,3,1) == list(4,3,2),
1616 '1452: segment(D,3,1) == list(4,3,2)');
1617 vrfy(segment(D,0,2) == head(D,3),
1618 '1453: segment(D,0,2) == head(D,3)');
1619 vrfy(segment(D,2,0) == tail(E,3),
1620 '1454: segment(D,2,0) == tail(E,3)');
1621 vrfy(segment(D,0,4) == head(D,5),
1622 '1455: segment(D,0,4) == head(D,5)');
1623 vrfy(segment(D,4,0) == head(E,5),
1624 '1456: segment(D,4,0) == head(E,5)');
1625 vrfy(segment(D,3,4) == tail(D,2),
1626 '1457: segment(D,3,4) == tail(D,2)');
1627 vrfy(segment(D,4,3) == head(E,2),
1628 '1458: segment(D,4,3) == head(E,2)');
1629 for (y=0; y < size(D); ++y) {
1630 for (z=y; z < size(D); ++z) {
1631 if (D != join(head(D,y), segment(D,y,z), tail(D,size(D)-z-1))) {
1632 prob(strcat("join loop failed at y=",str(y)," z=",str(z)));
1636 print '1459: join loop test';
1637 vrfy(mod(x,10,0) == y0, '1460: mod(x,10,0) == y0');
1638 vrfy(mod(x,10,1) == y1, '1461: mod(x,10,1) == y1');
1639 vrfy(mod(x,10,2) == y0, '1462: mod(x,10,2) == y0');
1640 vrfy(mod(x,10,3) == y1, '1463: mod(x,10,3) == y1');
1641 vrfy(mod(x,10,4) == y0, '1464: mod(x,10,4) == y0');
1642 vrfy(mod(x,10,5) == y1, '1465: mod(x,10,5) == y1');
1643 vrfy(mod(x,10,6) == y0, '1466: mod(x,10,6) == y0');
1644 vrfy(mod(x,10,7) == y1, '1467: mod(x,10,7) == y1');
1645 vrfy(mod(x,10,8) == y2, '1468: mod(x,10,8) == y2');
1646 vrfy(mod(x,10,9) == y3, '1469: mod(x,10,9) == y3');
1647 vrfy(mod(x,10,10) == y2, '1470: mod(x,10,10) == y2');
1648 vrfy(mod(x,10,11) == y3, '1471: mod(x,10,11) == y3');
1649 vrfy(mod(x,10,12) == y2, '1472: mod(x,10,12) == y2');
1650 vrfy(mod(x,10,13) == y3, '1473: mod(x,10,13) == y3');
1651 vrfy(mod(x,10,14) == y2, '1474: mod(x,10,14) == y2');
1652 vrfy(mod(x,10,15) == y3, '1475: mod(x,10,15) == y3');
1653 vrfy(mod(x,10,16) == y4, '1476: mod(x,10,16) == y4');
1654 vrfy(mod(x,10,16) == y4, '1477: mod(x,10,16) == y4');
1655 vrfy(mod(x,10,18) == y4, '1478: mod(x,10,18) == y4');
1656 vrfy(mod(x,10,19) == y4, '1479: mod(x,10,18) == y4');
1657 vrfy(mod(x,10,20) == y4, '1480: mod(x,10,20) == y4');
1658 vrfy(mod(x,10,21) == y4, '1481: mod(x,10,21) == y4');
1659 vrfy(mod(x,10,22) == y4, '1482: mod(x,10,22) == y4');
1660 vrfy(mod(x,10,23) == y4, '1483: mod(x,10,23) == y4');
1661 vrfy(mod(x,10,24) == y4, '1484: mod(x,10,24) == y4');
1662 vrfy(mod(x,10,25) == y4, '1485: mod(x,10,25) == y4');
1663 vrfy(mod(x,10,26) == y4, '1486: mod(x,10,26) == y4');
1664 vrfy(mod(x,10,27) == y4, '1487: mod(x,10,27) == y4');
1665 vrfy(mod(x,10,28) == y4, '1488: mod(x,10,28) == y4');
1666 vrfy(mod(x,10,29) == y4, '1489: mod(x,10,29) == y4');
1667 vrfy(mod(x,10,30) == y4, '1490: mod(x,10,30) == y4');
1668 vrfy(mod(x,10,31) == y4, '1491: mod(x,10,31) == y4');
1669 list1 = list(3,1,"x",2,null());
1670 print '1492: list1 = list(3,1,"x",2,null())';
1671 list2 = list(null(),1,2,3,"x");
1672 print '1493: list2 = list(null(),1,2,3,"x")';
1673 vrfy(sort(list1) == list2, '1494: sort(list1) == list2');
1675 print '1495: A = list(1,2,3,4)';
1676 B = makelist(4) = {1,2,3,4};
1677 print '1496: B = makelist(4) = {1,2,3,4}';
1678 vrfy(A == B, '1497: A == B');
1679 vrfy((A = {,,5}) == list(1,2,5,4),
1680 '1498: (A = {,,5}) == list(1,2,5,4)');
1682 print '1499: Ending list test';
1684 print '024: parsed test_list()';
1688 * Test rand - a55 shuffle pseudo-random number generator
1692 local init; /* initial generator state */
1693 local state0; /* a generator state */
1697 print '1500: Beginning rand test';
1699 /* test save and restore of the initial state */
1701 print '1501: tmp = srand(0)';
1703 print '1502: init = srand()';
1705 print '1503: state0 = srand(0)';
1706 vrfy(state0 == init, '1504: state0 == init');
1708 /* test the additive 55 shuffle generator */
1710 print '1505: tmp = srand(0)';
1711 vrfy(rand() == 0x1fe5b46fba7e069d, \
1712 '1506: rand() == 0x1fe5b46fba7e069d');
1713 vrfy(rand() == 0x308d32d9bdf2dc6f, \
1714 '1507: rand() == 0x308d32d9bdf2dc6f');
1716 print '1508: tmp = srand(init)';
1717 vrfy(rand() == 0x1fe5b46fba7e069d, \
1718 '1509: rand() == 0x1fe5b46fba7e069d');
1719 vrfy(rand() == 0x308d32d9bdf2dc6f, \
1720 '1510: rand() == 0x308d32d9bdf2dc6f');
1722 /* test range interface */
1724 print '1511: tmp = srand(0)';
1725 vrfy(rand(12345678901234567890) == 0x1fe5b46fba7e069d, \
1726 '1512: rand(12345678901234567890) == 0x1fe5b46fba7e069d');
1727 vrfy(rand(216091) == 0xc234, '1513: rand(216091) == 0xc234');
1728 vrfy(rand(100) == 0x59, '1514: rand(100) == 0x59');
1729 vrfy(rand(-46,46) == 0x2d, '1515: rand(-46,46) == 0x2d');
1731 print '1516: tmp = srand(0)';
1732 vrfy(rand(2^64) == 0x1fe5b46fba7e069d, \
1733 '1517: rand(2^64) == 0x1fe5b46fba7e069d');
1734 vrfy(rand(0,2^64) == 0x308d32d9bdf2dc6f, \
1735 '1518: rand(0,2^64) == 0x308d32d9bdf2dc6f');
1737 /* test different forms of seeding the initial state */
1739 print '1519: tmp = srand(0)';
1740 vrfy(srand() == init, '1520: srand() == init');
1741 tmp = srand(0x87e6ec938ff55aa5<<64);
1742 print '1521: tmp = srand(0x87e6ec938ff55aa5<<64)';
1743 print '1522: test disabled';
1744 tmp = srand(state0);
1745 print '1523: tmp = srand(state0)';
1746 vrfy(srand() == init, '1524: srand() == init');
1748 print '1525: tmp = srand(init)';
1749 vrfy(srand() == init, '1526: srand() == init');
1750 vrfy(tmp == init, '1527: tmp == init');
1752 /* test the bit length interface */
1754 print '1528: tmp = srand(0)';
1755 vrfy(randbit(64) == 0x1fe5b46fba7e069d, \
1756 '1529: randbit(64) == 0x1fe5b46fba7e069d');
1757 vrfy(randbit(128) == 0x308d32d9bdf2dc6f45d3e3b3361b79e4, \
1758 '1530: randbit(128) == 0x308d32d9bdf2dc6f45d3e3b3361b79e4');
1759 vrfy(randbit(64) == 0xd4ef1e3336022d81, \
1760 '1531: randbit(64) == 0xd4ef1e3336022d81');
1761 vrfy(randbit(128) == 0x66b086e6c34e42124a1fc5d4e5c6f598, \
1762 '1532: randbit(128) == 0x66b086e6c34e42124a1fc5d4e5c6f598');
1764 print '1533: tmp = srand(0)';
1765 vrfy(randbit(32) == 0x1fe5b46f, '1534: randbit(32) == 0x1fe5b46f');
1766 vrfy(randbit(32) == 0xba7e069d, '1535: randbit(32) == 0xba7e069d');
1767 vrfy(randbit(1) == 0x0, '1536: randbit(1) == 0x0');
1768 vrfy(randbit(5) == 0xc, '1537: randbit(5) == 0xc');
1769 vrfy(randbit(33) == 0x46996cde, '1538: randbit(33) == 0x46996cde');
1770 vrfy(randbit(25) == 0x1f2dc6f, '1539: randbit(25) == 0x1f2dc6f');
1771 vrfy(randbit(2) == 0x1, '1540: randbit(2) == 0x1');
1772 vrfy(randbit(13) == 0x2e9, '1541: randbit(13) == 0x2e9');
1773 vrfy(randbit(18) == 0x3c766, '1542: randbit(18) == 0x3c766');
1774 vrfy(randbit(8) == 0x6c, '1543: randbit(8) == 0x6c');
1775 vrfy(randbit(9) == 0x6d, '1544: randbit(9) == 0x6d');
1776 vrfy(randbit(70) == 0x39e4d4ef1e3336022d, \
1777 '1545: randbit(70) == 0x39e4d4ef1e3336022d');
1778 print '1546: test unused';
1779 vrfy(randbit(8) == 0x81, '1547: randbit(8) == 0x81');
1780 vrfy(randbit(65) == 0xcd610dcd869c8424, \
1781 '1548: randbit(65) == 0xcd610dcd869c8424');
1782 vrfy(randbit(63) == 0x4a1fc5d4e5c6f598, \
1783 '1549: randbit(63) == 0x4a1fc5d4e5c6f598');
1785 /* check to be sure that the srand(1) bug was fixed */
1787 print '1550: tmp = srand(1)';
1789 print '1551: n = 1';
1790 vrfy(num(n), '1552: num(n)');
1791 vrfy(den(n), '1553: den(n)');
1792 vrfy(randbit(64) == 0xbf989a4c504a541d, \
1793 '1554: randbit(64) == 0xbf989a4c504a541d');
1794 /* test randbit skip interface */
1796 print '1555: tmp = srand(0)';
1797 vrfy(randbit(20) == 0x1fe5b, '1556: randbit(20) == 0x1fe5b');
1798 vrfy(randbit(20) == 0x46fba, '1557: randbit(20) == 0x46fba');
1799 vrfy(randbit(20) == 0x7e069, '1558: randbit(20) == 0x7e069');
1800 vrfy(randbit(20) == 0xd308d, '1559: randbit(20) == 0xd308d');
1802 print '1560: tmp = srand(0)';
1803 vrfy(randbit(-20) == 20, '1561: randbit(-20) == 20');
1804 vrfy(randbit(20) == 290746, '1562: randbit(20) == 290746');
1805 vrfy(randbit(-20) == 20, '1563: randbit(-20) == 20');
1806 vrfy(randbit(20) == 864397, '1564: randbit(20) == 864397');
1808 /* test randbit without and arg */
1810 print '1565: tmp = srand(0)';
1811 vrfy(randbit() == 0, '1566: randbit() == 0');
1812 vrfy(randbit() == 0, '1567: randbit() == 0');
1813 vrfy(randbit() == 0, '1568: randbit() == 0');
1814 vrfy(randbit() == 1, '1569: randbit() == 1');
1816 /* test seed() as best as we can */
1817 vrfy(seed() >= 0, '1570: seed() >= 0');
1818 vrfy(seed() < 2^64, '1571: seed() < 2^64');
1819 vrfy(isrand(srand(seed())), '1572: isrand(srand(seed()))');
1821 print '1573: Ending rand test';
1823 print '025: parsed test_rand()';
1827 * Config mode/base testing
1833 print '1600: Beginning mode/base test';
1835 tmp = config("mode", "frac");
1836 print '1601: tmp = config("mode", "frac")';
1837 tmp = config("mode", "frac");
1838 print '1602: tmp = config("mode", "frac")';
1839 vrfy(base() == 1/3, '1603: base() == 1/3');
1841 tmp = config("mode", "int");
1842 print '1604: tmp = config("mode", "int")';
1843 vrfy(tmp == "fraction", '1605: tmp == "fraction"');
1844 vrfy(base() == -10, '1606: base() == -10');
1846 tmp = config("mode", "real");
1847 print '1607: tmp = config("mode", "real")';
1848 vrfy(tmp == "integer", '1608: tmp == "integer"');
1849 vrfy(base() == 10, '1609: base() == 10');
1851 tmp = config("mode", "exp");
1852 print '1610: tmp = config("mode", "exp")';
1853 vrfy(tmp == "real", '1611: tmp == "real"');
1854 vrfy(base() == 1e20, '1612: base() == 1e20');
1856 tmp = config("mode", "hex");
1857 print '1613: tmp = config("mode", "hex")';
1858 vrfy(tmp == "scientific", '1614: tmp == "scientific"');
1859 vrfy(base() == 16, '1615: base() == 16');
1861 tmp = config("mode", "oct");
1862 print '1616: tmp = config("mode", "oct")';
1863 vrfy(tmp == "hexadecimal", '1617: tmp == "hexadecimal"');
1864 vrfy(base() == 8, '1618: base() == 8');
1866 tmp = config("mode", "bin");
1867 print '1619: tmp = config("mode", "bin")';
1868 vrfy(tmp == "octal", '1620: tmp == "octal"');
1869 vrfy(base() == 2, '1621: base() == 2');
1871 tmp = config("mode", "real");
1872 print '1622: tmp = config("mode", "real")';
1873 vrfy(tmp == "binary", '1623: tmp == "binary"');
1876 print '1624: tmp = base(1/3)';
1877 vrfy(config("mode") == "fraction",
1878 '1625: config("mode") == "fraction"');
1881 print '1626: tmp = base(-10)';
1882 vrfy(config("mode") == "integer",
1883 '1627: config("mode") == "integer"');
1886 print '1628: tmp = base(10)';
1887 vrfy(config("mode") == "real", '1629: config("mode") == "real"');
1890 print '1630: tmp = base(1e20)';
1891 vrfy(config("mode") == "scientific",
1892 '1631: config("mode") == "scientific"');
1895 print '1632: tmp = base(16)';
1896 vrfy(config("mode") == "hexadecimal", \
1897 '1633: config("mode") == "hexadecimal"');
1900 print '1634: tmp = base(8)';
1901 vrfy(config("mode") == "octal", '1635: config("mode") == "octal"');
1904 print '1636: tmp = base(2)';
1905 vrfy(config("mode") == "binary",'1637: config("mode") == "binary"');
1908 print '1638: tmp = base(8)';
1909 vrfy(str(0x80000000) == "020000000000", \
1910 '1639: str(0x8000000) == \"020000000000\"');
1911 vrfy(str(0xffffffff) == "037777777777", \
1912 '1640: str(0xffffffff) == \"037777777777\"');
1913 vrfy(str(3e9) == "026264057000", \
1914 '1641: str(3e9) == \"026264057000\"');
1917 print '1642: tmp = base(16)';
1918 vrfy(str(0x80000000) == "0x80000000", \
1919 '1643: str(0x8000000) == \"0x80000000\"');
1920 vrfy(str(0xffffffff) == "0xffffffff", \
1921 '1644: str(0xffffffff) == \"0xffffffff\"');
1922 vrfy(str(3e9) == "0xb2d05e00", \
1923 '1645: str(3e9) == \"0xb2d05e00\"');
1926 print '1646: tmp = base(10)';
1927 vrfy(config("mode") == "real", \
1928 '1647: config("mode") == "real"');
1930 vrfy(str(0x80000000) == "2147483648", \
1931 '1648: str(0x80000000) == \"2147483648\"');
1932 vrfy(str(0xffffffff) == "4294967295", \
1933 '1649: str(0xffffffff) == \"4294967295\"');
1934 vrfy(str(3e9) == "3000000000", \
1935 '1650: str(3e9) == \"3000000000\"');
1937 /* test base2() functionality */
1938 vrfy(base2() == 0, '1651: base2() == 0');
1939 vrfy(base2(0) == 0, '1652: base2(0) == 0');
1940 vrfy(base2() == 0, '1653: base2() == 0');
1941 vrfy(base2(16) == 0, '1654: base2(16) == 0');
1942 vrfy(base2() == 16, '1655: base2() == 16');
1943 vrfy(str(3e9) == "3000000000 /* 0xb2d05e00 */",
1944 '1656: str(3e9) == "3000000000 /* 0xb2d05e00 */"');
1945 vrfy(base2(1/3) == 16, '1657: base2(16) == 16');
1946 vrfy(str(23209) == "23209 /* 23209 */",
1947 '1658: str(23209) == "23209 /* 23209 */"');
1948 vrfy(str(3/2) == "1.5 /* 3/2 */",
1949 '1659: str(3/2) == "1.5 /* 3/2 */"');
1950 vrfy(base() == 10, '1660: base() == 10');
1951 vrfy(base2(0) == 1/3, '1661: base2(0) == 1/3');
1953 print '1662: Ending mode/base test';
1955 print '026: parsed test_mode()';
1959 * The 1700's contain tests for reading resource files. These tests are
1960 * done inline near the bottom.
1968 print '027: read -once surd';
1976 print '1800: Beginning object test';
1979 vrfy(surd_type == -1, '1801: surd_type == -1');
1981 print '1802: a = surd(2,3)';
1982 vrfy(a == surd(2,3), '1803: a == surd(2,3)');
1983 vrfy(surd_value(a) == 2+3i, '1804: surd_value(a) == 2+3i');
1984 vrfy(conj(a) == surd(2,-3), '1805: conj(a) == surd(2,-3)');
1985 vrfy(norm(a) == 13, '1806: norm(a) == 13');
1986 vrfy(a+1 == surd(3,3), '1807: a+1 == surd(3,3)');
1988 print '1808: b = surd(3,4)';
1989 vrfy(a+b == surd(5,7), '1809: a+b == surd(5,7)');
1990 vrfy(a-b == surd(-1,-1), '1810: a-b == surd(-1,-1)');
1991 vrfy(++a == surd(3,3), '1811: ++a == surd(3,3)');
1992 vrfy(--a == surd(2,3), '1812: --a == surd(2,3)');
1993 vrfy(-a == surd(-2,-3), '1813: -a == surd(-2,-3)');
1994 vrfy(a*2 == surd(4,6), '1814: a*2 == surd(4,6)');
1995 vrfy(a*b == surd(-6,17), '1815: a*b == surd(-6,17)');
1996 vrfy(a^2 == surd(-5,12), '1816: a^2 == surd(-5,12)');
1997 vrfy(scale(a,2) == surd(8,12), '1817: scale(a,2) == surd(8,12)');
1998 vrfy(a<<3 == surd(16,24), '1818: a<<3 == surd(16,24)');
1999 vrfy(a/2 == surd(1,1.5), '1819: a/2 == surd(1,1.5)');
2000 vrfy(a/b == surd(0.72,0.04), '1820: a/b == surd(0.72,0.04)');
2001 vrfy(1/b == surd(0.12,-0.16), '1821: 1/b == surd(0.12,-0.16)');
2002 vrfy(inverse(b) == 1/b, '1822: inverse(b) == 1/b');
2003 vrfy(a != b, '1823: a != b');
2005 print '1824: surd_type = 2';
2006 vrfy(surd_type == 2, '1825: surd_type == 2');
2007 vrfy(sgn(a) == 1, '1826: sgn(a) == 1');
2008 vrfy(a < b, '1827: a < b');
2009 vrfy(a <= a, '1828: a < a');
2010 vrfy(isobj(a) == 1, '1829: isobj(a) == 1');
2012 obj pt {x,y}, PP = obj pair {A,B} = {obj pt, obj pt};
2013 print '1830: obj pt {x,y}, PP = obj pair {A,B} = {obj pt, obj pt}';
2015 print '1831: Ending object test';
2017 print '028: parsed test_obj()';
2021 * Prime builtin function testing
2025 print '1900: Beginning prime builtins test';
2027 vrfy(isprime(-3) == 1, '1901: isprime(-3) == 1');
2028 vrfy(isprime(-1) == 0, '1902: isprime(-1) == 0');
2029 vrfy(isprime(0) == 0, '1903: isprime(0) == 0');
2030 vrfy(isprime(1) == 0, '1904: isprime(1) == 0');
2031 vrfy(isprime(2) == 1, '1905: isprime(2) == 1');
2032 vrfy(isprime(3) == 1, '1906: isprime(3) == 1');
2033 vrfy(isprime(4) == 0, '1907: isprime(4) == 0');
2034 vrfy(isprime(5) == 1, '1908: isprime(5) == 1');
2035 vrfy(isprime(17) == 1, '1909: isprime(17) == 1');
2036 vrfy(isprime(100) == 0, '1910: isprime(100) == 0');
2037 vrfy(isprime(21701,-1) == 1, '1911: isprime(21701,-1) == 1');
2038 vrfy(isprime(65521,-1) == 1, '1912: isprime(65521,-1) == 1');
2039 vrfy(isprime(65535,-1) == 0, '1913: isprime(65535,-1) == 0');
2040 vrfy(isprime(65536,-1) == 0, '1914: isprime(65536,-1) == 0');
2041 vrfy(isprime(1234577) == 1, '1915: isprime(1234577) == 1');
2042 vrfy(isprime(1234579) == 0, '1916: isprime(1234579) == 0');
2043 vrfy(isprime(2^31-9) == 0, '1917: isprime(2^31-9) == 0');
2044 vrfy(isprime(2^31-1) == 1, '1918: isprime(2^31-1) == 1');
2045 vrfy(isprime(2^31+9) == 0, '1919: isprime(2^31+11) == 0');
2046 vrfy(isprime(2^31+11) == 1, '1920: isprime(2^31+11) == 1');
2047 vrfy(isprime(3e9) == 0, '1921: isprime(3e9) == 0');
2048 vrfy(isprime(3e9+19) == 1, '1922: isprime(3e9+19) == 1');
2049 vrfy(isprime(2^32-7) == 0, '1923: isprime(2^32-7) == 0');
2050 vrfy(isprime(2^32-5) == 1, '1924: isprime(2^32-5) == 1');
2051 vrfy(isprime(2^32,-1) == 0, '1925: isprime(2^32,-1) == 0');
2052 vrfy(isprime(2^32+1,-1) == -1, '1926: isprime(2^32+1,-1) == -1');
2053 vrfy(isprime(3^99,2) == 2, '1927: isprime(3^99,2) == 2');
2054 vrfy(isprime(4^99,2) == 0, '1928: isprime(3^99,2) == 0');
2055 vrfy(nextprime(-3) == 5, '1929: nextprime(-3) == 5');
2056 vrfy(nextprime(0) == 2, '1930: nextprime(0) == 2');
2057 vrfy(nextprime(1) == 2, '1931: nextprime(1) == 2');
2058 vrfy(nextprime(2) == 3, '1932: nextprime(2) == 3');
2059 vrfy(nextprime(3) == 5, '1933: nextprime(3) == 5');
2060 vrfy(nextprime(4) == 5, '1934: nextprime(4) == 5');
2061 vrfy(nextprime(5) == 7, '1935: nextprime(5) == 7');
2062 vrfy(nextprime(17) == 19, '1936: nextprime(17) == 19');
2063 vrfy(nextprime(100) == 101, '1937: nextprime(100) == 101');
2064 vrfy(nextprime(21701,-1) == 21713,
2065 '1938: nextprime(21701,-1) == 21713');
2066 vrfy(nextprime(65519) == 65521,
2067 '1939: nextprime(65519) == 65521');
2068 vrfy(nextprime(65520) == 65521,
2069 '1940: nextprime(65520) == 65521');
2070 vrfy(nextprime(65521,-1) == 65537,
2071 '1941: nextprime(65521,-1) == 65537');
2072 vrfy(nextprime(65531) == 65537,
2073 '1942: nextprime(65531) == 65537');
2074 vrfy(nextprime(65535,-1) == 65537,
2075 '1943: nextprime(65535,-1) == 65537');
2076 vrfy(nextprime(65536) == 65537,
2077 '1944: nextprime(65536) == 65537');
2078 vrfy(nextprime(1234576,2)==1234577,
2079 '1945: nextprime(1234576,2)==1234577');
2080 vrfy(nextprime(2^31-9) == 2^31-1,
2081 '1946: nextprime(2^31-9) == 2^31-1');
2082 vrfy(nextprime(2^31-1) == 2^31+11,
2083 '1947: nextprime(2^31-1) == 2^31+11');
2084 vrfy(nextprime(3e9) == 3e9+19,'1948: nextprime(3e9) == 3e9+19');
2085 vrfy(nextprime(2^32-7) == 2^32-5,
2086 '1949: nextprime(2^32-7) == 2^32-5');
2087 vrfy(nextprime(2^32,-1) == -1, '1950: nextprime(2^32,-1) == -1');
2088 vrfy(nextprime(2^32+5,-1) == -1,'1951: nextprime(2^32+5,-1) == -1');
2089 vrfy(nextprime(3^99,-1) == -1, '1952: nextprime(3^99,-1) == -1');
2090 vrfy(nextprime(3^99,2) == 2, '1953: nextprime(3^99,2) == 2');
2091 vrfy(prevprime(-3,-1) == 2, '1954: prevprime(-3,-1) == 2');
2092 vrfy(prevprime(0,-1) == 0, '1955: prevprime(0,-1) == 0');
2093 vrfy(prevprime(1,-1) == 0, '1956: prevprime(1,-1) == 0');
2094 vrfy(prevprime(2,-2) == 0, '1957: prevprime(2,-2) == 0');
2095 vrfy(prevprime(5) == 3, '1958: prevprime(5) == 3');
2096 vrfy(prevprime(4) == 3, '1959: prevprime(4) == 3');
2097 vrfy(prevprime(7) == 5, '1960: prevprime(7) == 5');
2098 vrfy(prevprime(19) == 17, '1961: prevprime(19) == 17');
2099 vrfy(prevprime(100) == 97, '1962: prevprime(100) == 97');
2100 vrfy(prevprime(21713,-1) == 21701,
2101 '1963: prevprime(21713,-1) == 21701');
2102 vrfy(prevprime(65520) == 65519,
2103 '1964: prevprime(65520) == 65519');
2104 vrfy(prevprime(65521) == 65519,
2105 '1965: prevprime(65521) == 65519');
2106 vrfy(prevprime(65522) == 65521,
2107 '1966: prevprime(65520) == 65521');
2108 vrfy(prevprime(65523) == 65521,
2109 '1967: prevprime(65523) == 65521');
2110 vrfy(prevprime(65531) == 65521,
2111 '1968: prevprime(65531) == 65521');
2112 vrfy(prevprime(65535) == 65521,
2113 '1969: prevprime(65535) == 65521');
2114 vrfy(prevprime(65536) == 65521,
2115 '1970: prevprime(65536) == 65521');
2116 vrfy(prevprime(65537) == 65521,
2117 '1971: prevprime(65537) == 65521');
2118 vrfy(prevprime(65539) == 65537,
2119 '1972: prevprime(65539) == 65537');
2120 vrfy(prevprime(1234578,2)==1234577,
2121 '1973: prevprime(1234578,2)==1234577');
2122 vrfy(prevprime(2^31-1) == 2^31-19,
2123 '1974: prevprime(2^31-1) == 2^31-19');
2124 vrfy(prevprime(2^31+11) == 2^31-1,
2125 '1975: prevprime(2^31+11) == 2^31-1');
2126 vrfy(prevprime(3e9) == 3e9-71,'1976: prevprime(3e9) == 3e9-17');
2127 vrfy(prevprime(2^32-3) == 2^32-5,
2128 '1977: prevprime(2^32-3) == 2^32-5');
2129 vrfy(prevprime(2^32-1) == 2^32-5,
2130 '1978: prevprime(2^32-1) == 2^32-5');
2131 vrfy(prevprime(2^32,-1) == -1, '1979: prevprime(2^32,-1) == -1');
2132 vrfy(prevprime(3^99,-1) == -1, '1980: prevprime(3^99,-1) == -1');
2133 vrfy(prevprime(3^99,2) == 2, '1981: prevprime(3^99,2) == 2');
2134 vrfy(pix(-1) == 0, '1982: pix(-1) == 0');
2135 vrfy(pix(1) == 0, '1983: pix(1) == 0');
2136 vrfy(pix(2) == 1, '1984: pix(2) == 1');
2137 vrfy(pix(3) == 2, '1985: pix(3) == 2');
2138 vrfy(pix(100) == 25, '1986: pix(100) == 25');
2139 vrfy(pix(1000) == 168, '1987: pix(1000) == 168');
2140 vrfy(pix(10000) == 1229, '1988: pix(10000) == 1229');
2141 vrfy(pix(100000) == 9592, '1989: pix(100000) == 9592');
2142 vrfy(pix(2^19+59) == 43393, '1990: pix(2^19+59) == 43393');
2143 vrfy(pix(1000000) == 78498, '1991: pix(1000000) == 78498');
2144 vrfy(pix(10000000) == 664579, '1992: pix(10000000) == 664579');
2145 vrfy(pix(2^32-6) == 203280220, '1993: pix(2^32-6) == 203280220');
2146 vrfy(pix(2^32-5) == 203280221, '1994: pix(2^32-5) == 203280221');
2147 vrfy(pix(2^32-1) == 203280221, '1995: pix(2^32-1) == 203280221');
2148 vrfy(pfact(40) == 7420738134810,'1996: pfact(40) == 7420738134810');
2149 vrfy(pfact(200)/pfact(198)==199,'1997: pfact(200)/pfact(198)==199');
2150 vrfy(nextprime(3e9)==nextcand(3e9),
2151 '1998: nextprime(3e9)==nextcand(3e9)');
2152 vrfy(prevprime(3e9)==prevcand(3e9),
2153 '1999: prevprime(3e9)==prevcand(3e9)');
2154 vrfy(nextcand(2^100,0)-2^100 == 3,
2155 '2000: nextcand(2^100,0)-2^100 == 3');
2156 vrfy(nextcand(2^100)-2^100 == 277,
2157 '2001: nextcand(2^100)-2^100 == 277');
2158 vrfy(2^100-prevcand(2^100,0) == 5,
2159 '2002: 2^100-prevcand(2^100,0) == 5');
2160 vrfy(2^100-prevcand(2^100) == 15,
2161 '2003: 2^100-prevcand(2^100) == 15');
2162 vrfy(nextcand(2^50,4,5)-2^50 == 55,
2163 '2004: nextcand(2^50,4,5)-2^50 == 55');
2164 vrfy(2^50-prevcand(2^50,4,5) == 27,
2165 '2005: 2^50-prevcand(2^50,4,5) == 27');
2166 vrfy(nextprime(2^32-6) == 2^32-5,
2167 '2006: nextprime(2^32-6) == 2^32-5');
2168 vrfy(nextprime(2^32-5) == 2^32+15,
2169 '2007: nextprime(2^32-5) == 2^32+15');
2170 vrfy(prevprime(2^32-1) == 2^32-5,
2171 '2008: prevprime(2^32-1) == 2^32-5');
2172 vrfy(prevcand(2^50,4,5,0,4) == 0,
2173 '2009: prevcand(2^50,4,5,0,4) == 0');
2174 vrfy(2^50-prevcand(2^50,4,5,1,4) == 27,
2175 '2010: 2^50-prevcand(2^50,4,5,1,4) == 27');
2176 vrfy(prevcand(2^50,4,5,2,4) == 2,
2177 '2011: prevcand(2^50,4,5,2,4) == 2');
2178 vrfy(2^50-prevcand(2^50,4,5,3,4) == 113,
2179 '2012: 2^50-prevcand(2^50,4,5,3,4) == 113');
2180 vrfy(2^50-prevcand(2^50,4,5,7,17) == 813,
2181 '2013: 2^50-prevcand(2^50,4,5,7,17) == 813');
2182 vrfy(nextcand(2^50,4,5,0,4) == 0,
2183 '2014: nextcand(2^50,4,5,0,4) == 0');
2184 vrfy(nextcand(2^50,4,5,1,4)-2^50 == 145,
2185 '2015: nextcand(2^50,4,5,1,4)-2^50 == 145');
2186 vrfy(nextcand(2^50,4,5,2,4) == 0,
2187 '2016: nextcand(2^50,4,5,2,4) == 0');
2188 vrfy(nextcand(2^50,4,5,3,4)-2^50 == 55,
2189 '2017: nextcand(2^50,4,5,3,4)-2^50 == 55');
2190 vrfy(nextcand(2^50,4,5,7,17)-2^50 == 853,
2191 '2018: nextcand(2^50,4,5,7,17)-2^50 == 853');
2192 vrfy(ptest(2^100+277) == 1, '2019: ptest(2^100+277) == 1');
2193 vrfy(ptest(2^50-27,4,5) == 1, '2020: ptest(2^50-27,4,5) == 1');
2194 vrfy(ptest(2^50+55,4,5) == 1, '2021: ptest(2^50+55,4,5) == 1');
2195 vrfy(ptest(2^32+1,10) == 0, '2022: ptest(2^32+1,10) == 0');
2196 vrfy(lfactor(1001,100) == 7, '2023: lfactor(1001,100) == 7');
2197 vrfy(lfactor(1001,4) == 7, '2024: lfactor(1001,4) == 7');
2198 vrfy(lfactor(1001,3) == 1, '2025: lfactor(1001,3) == 1');
2199 vrfy(lfactor(127,10000) == 1, '2026: lfactor(127,10000) == 1');
2200 vrfy(lfactor(2^19-1,10000) == 1,'2027: lfactor(2^19-1,10000) == 1');
2201 vrfy(lfactor(2^31-1,10000) == 1,'2028: lfactor(2^31-1,10000) == 1');
2202 vrfy(lfactor(2^32-5,10000) == 1,'2029: lfactor(2^32-5,10000) == 1');
2203 vrfy(lfactor(2^38+7,50000) == 1,'2030: lfactor(2^38+7,50000) == 1');
2204 vrfy(lfactor(1009^2,pix(1009)) == 1009,
2205 '2031: lfactor(1009^2,pix(1009)) == 1009');
2206 vrfy(lfactor(1009^2,pix(1009)-1) == 1,
2207 '2032: lfactor(1009^2,pix(1009)-1) == 1');
2208 vrfy(lfactor(65519*65521,7000) == 65519,
2209 '2033: lfactor(65519*65521,7000) == 65519');
2210 vrfy(lfactor(65521^2,pix(65521)) == 65521,
2211 '2034: lfactor(65521^2,pix(65521)) == 65521');
2212 vrfy(lfactor(65521^2,pix(65521)-1) == 1,
2213 '2035: lfactor(65521^2,pix(65521)-1) == 1');
2214 vrfy(lfactor(524309^6,100000) == 524309,
2215 '2036: lfactor(524309^6,100000) == 524309');
2217 print '2037: Ending prime builtins test';
2219 print '029: parsed test_prime()';
2223 * Test the Lucas primality test resource file
2225 read -once "lucas_chk"; /* obtain our needed Lucas resource file */
2226 print '030: read lucas_chk';
2230 print '2100: Beginning lucas check test';
2232 vrfy(lucas_chk(100,1) == 1, '2101: lucas_chk(100,1) == 1');
2234 print '2102: Ending lucas check test';
2236 print '031: parsed test_lucas()';
2240 * Test new operator functionality
2244 static mat A[3] = {1,2,3};
2245 static mat A2[3] = {1,2,3};
2251 print '2200: Beginning new operator functionality test';
2254 print '2201: (v = 3) = 4';
2255 vrfy(v == 4, '2202: v == 4');
2257 print '2203: (v += 3) *= 4';
2258 vrfy(v == 28, '2204: v == 28');
2259 vrfy(A == A2, '2205: A == A2');
2261 print '2206: matfill(B = A, 4)';
2262 vrfy(A == A2, '2207: A == A2');
2263 vrfy(size(B) == 3, '2208: size(B) == 3');
2264 vrfy(B[0] == 4, '2209: B[0] == 4');
2265 vrfy(B[1] == 4, '2210: B[1] == 4');
2266 vrfy(B[2] == 4, '2211: B[2] == 4');
2268 print '2212: a = 3';
2270 print '2213: ++(b = a)';
2271 vrfy(a == 3, '2214: a == 3');
2272 vrfy(b == 4, '2215: b == 4');
2274 print '2216: ++++a';
2275 vrfy(a == 5, '2217: a == 5');
2276 vrfy((++a)++ == 6, '2218: (++a)++ == 6');
2277 vrfy(a == 7, '2219: a == 7');
2279 print '2220: (++a) *= b';
2280 vrfy(a == 32, '2221: a == 32');
2281 vrfy(b == 4, '2222: b == 4');
2282 vrfy(++(a*=b) == 129, '2223: ++(a*=b) == 129');
2283 vrfy(a == 129, '2224: a == 129');
2284 vrfy(b == 4, '2225: b == 4');
2285 vrfy((a = (--a / b++))-- == 32,
2286 '2226: (a = (--a / b++))-- == 32');
2287 vrfy(a == 31, '2227: a == 31');
2288 vrfy(b == 5, '2228: b == 5');
2289 vrfy((++++a / ----b) == 11,
2290 '2229: (++++a / ----b) == 11');
2291 vrfy(a == 33, '2230: a == 33');
2292 vrfy(b == 3, '2231: b == 3');
2293 vrfy((a/=(--a/++b))-- == 4,
2294 '2232: (a/=(--a/++b))-- == 4');
2295 vrfy(a == 3, '2233: a == 3');
2296 vrfy(b == 4, '2234: b == 4');
2298 print '2235: v = a----';
2299 vrfy(v == 3, '2236: v == 3');
2300 vrfy(a == 1, '2237: a == 1');
2302 print '2238: a = ----v';
2303 vrfy(a == 1, '2239: a == 1');
2304 vrfy(v == 1, '2240: v == 1');
2306 print '2241: v = a++++';
2307 vrfy(a == 3, '2242: a == 3');
2308 vrfy(v == 1, '2243: v == 1');
2310 print '2244: a = ++++v';
2311 vrfy(a == 3, '2245: a == 3');
2312 vrfy(v == 3, '2246: v == 3');
2314 print '2247: a = ----v----';
2315 vrfy(a == 1, '2248: a == 1');
2316 vrfy(v == -1, '2249: v == -1');
2318 print '2250: v = ++++a++++';
2319 vrfy(a == 5, '2251: a == 5');
2320 vrfy(v == 3, '2252: v == 3');
2322 print '2253: a = ++++v----';
2323 vrfy(a == 5, '2254: a == 5');
2324 vrfy(v == 3, '2255: v == 3');
2326 print '2256: v = --++a--++';
2327 vrfy(a == 5, '2257: a == 5');
2328 vrfy(v == 5, '2258: v == 5');
2330 print '2259: a = -++v';
2331 vrfy(a == -6, '2260: a == -6');
2332 vrfy(v == 6, '2261: v == 6');
2334 print '2262: Ending new operator functionality test';
2336 print '032: parsed test_newop()';
2340 * Test object increment/decrement
2342 read -once "test2300";
2343 print '033: read -once test2300';
2345 define test_xx_incdec()
2350 print '2300: Beginning object increment/decrement test';
2353 print '2301: A = mkmat(1,2,3)';
2354 vrfy(ckmat(A,1,2,3) == 1,
2355 '2302: ckmat(A,1,2,3) == 1');
2357 print '2303: B = A++';
2358 vrfy(ckmat(B,1,2,3) == 1,
2359 '2304: ckmat(B,1,2,3) == 1');
2360 vrfy(ckmat(A,2,3,4) == 1,
2361 '2305: ckmat(A,2,3,4) == 1');
2363 print '2306: B = A--';
2364 vrfy(ckmat(A,1,2,3) == 1,
2365 '2307: ckmat(A,1,2,3) == 1');
2366 vrfy(ckmat(B,2,3,4) == 1,
2367 '2308: ckmat(B,2,3,4) == 1');
2369 print '2309: B = ++A';
2370 vrfy(ckmat(A,2,3,4) == 1,
2371 '2310: ckmat(A,2,3,4) == 1');
2372 vrfy(ckmat(B,2,3,4) == 1,
2373 '2311: ckmat(B,2,3,4) == 1');
2375 print '2312: B = --A';
2376 vrfy(ckmat(A,1,2,3) == 1,
2377 '2313: ckmat(A,1,2,3) == 1');
2378 vrfy(ckmat(B,1,2,3) == 1,
2379 '2314: ckmat(B,1,2,3) == 1');
2382 print '2315: n = 1';
2383 vrfy(n + n + n + n++ == 4,
2384 '2316: n + n + n + n++ == 4');
2385 vrfy(n == 2, '2317: n == 2');
2387 print '2318: n = 1';
2388 vrfy(n + n + n++ == 3, '2319: n + n + n++ == 3');
2389 vrfy(n == 2, '2320: n == 2');
2391 print '2321: n = 1';
2392 vrfy(n + n++ == 2, '2322: n + n++ == 3');
2393 vrfy(n == 2, '2323: n == 2');
2395 print '2315: Ending object increment/decrement test';
2397 print '034: parsed test_xx_incdec()';
2401 * testing rounding config modes
2407 print '2400: Beginning config rounding mode test';
2411 print '2401: mode = 0';
2412 vrfy(appr(-5.44,0.1,mode) == -5.5,
2413 '2402: appr(-5.44,0.1,mode) == -5.5');
2414 vrfy(appr(5.44,0.1,mode) == 5.4,
2415 '2403: appr(5.44,0.1,mode) == 5.4');
2416 vrfy(appr(5.7,1,mode) == 5,
2417 '2404: appr(5.7,1,mode) == 5');
2418 vrfy(appr(-5.7,1,mode) == -6,
2419 '2405: appr(-5.7,1,mode) == -6');
2420 vrfy(appr(-5.44,-0.1,mode) == -5.4,
2421 '2406: appr(-5.44,-0.1,mode) == -5.4');
2422 vrfy(appr(5.44,-0.1,mode) == 5.5,
2423 '2407: appr(5.44,-0.1,mode) == 5.5');
2424 vrfy(appr(5.7,-1,mode) == 6,
2425 '2408: appr(5.7,-1,mode) == 6');
2426 vrfy(appr(-5.7,-1,mode) == -5,
2427 '2409: appr(-5.7,-1,mode) == -5');
2431 print '2410: mode = 1';
2432 vrfy(appr(-5.44,0.1,mode) == -5.4,
2433 '2411: appr(-5.44,0.1,mode) == -5.4');
2434 vrfy(appr(5.44,0.1,mode) == 5.5,
2435 '2412: appr(5.44,0.1,mode) == 5.5');
2436 vrfy(appr(5.7,1,mode) == 6,
2437 '2413: appr(5.7,1,mode) == 6');
2438 vrfy(appr(-5.7,1,mode) == -5,
2439 '2414: appr(-5.7,1,mode) == -5');
2440 vrfy(appr(-5.44,-0.1,mode) == -5.5,
2441 '2415: appr(-5.44,-0.1,mode) == -5.5');
2442 vrfy(appr(5.44,-0.1,mode) == 5.4,
2443 '2416: appr(5.44,-0.1,mode) == 5.4');
2444 vrfy(appr(5.7,-1,mode) == 5,
2445 '2417: appr(5.7,-1,mode) == 5');
2446 vrfy(appr(-5.7,-1,mode) == -6,
2447 '2418: appr(-5.7,-1,mode) == -6');
2451 print '2419: mode = 2';
2452 vrfy(appr(-5.44,0.1,mode) == -5.4,
2453 '2420: appr(-5.44,0.1,mode) == -5.4');
2454 vrfy(appr(5.44,0.1,mode) == 5.4,
2455 '2421: appr(5.44,0.1,mode) == 5.4');
2456 vrfy(appr(5.7,1,mode) == 5,
2457 '2422: appr(5.7,1,mode) == 5');
2458 vrfy(appr(-5.7,1,mode) == -5,
2459 '2423: appr(-5.7,1,mode) == -5');
2463 print '2424: mode = 3';
2464 vrfy(appr(-5.44,0.1,mode) == -5.5,
2465 '2425: appr(-5.44,0.1,mode) == -5.5');
2466 vrfy(appr(5.44,0.1,mode) == 5.5,
2467 '2426: appr(5.44,0.1,mode) == 5.5');
2468 vrfy(appr(5.7,1,mode) == 6,
2469 '2427: appr(5.7,1,mode) == 6');
2470 vrfy(appr(-5.7,1,mode) == -6,
2471 '2428: appr(-5.7,1,mode) == -6');
2475 print '2429: mode = 4';
2476 vrfy(appr(-5.44,0.1,mode) == -5.5,
2477 '2430: appr(-5.44,0.1,mode) == -5.5');
2478 vrfy(appr(5.44,0.1,mode) == 5.4,
2479 '2431: appr(5.44,0.1,mode) == 5.4');
2480 vrfy(appr(5.7,1,mode) == 5,
2481 '2432: appr(5.7,1,mode) == 5');
2482 vrfy(appr(-5.7,1,mode) == -6,
2483 '2433: appr(-5.7,1,mode) == -6');
2487 print '2434: mode = 5';
2488 vrfy(appr(-5.44,0.1,mode) == -5.4,
2489 '2435: appr(-5.44,0.1,mode) == -5.4');
2490 vrfy(appr(5.44,0.1,mode) == 5.5,
2491 '2436: appr(5.44,0.1,mode) == 5.5');
2492 vrfy(appr(5.7,1,mode) == 6,
2493 '2437: appr(5.7,1,mode) == 6');
2494 vrfy(appr(-5.7,1,mode) == -5,
2495 '2438: appr(-5.7,1,mode) == -5');
2499 print '2439: mode = 6';
2500 vrfy(appr(-5.44,0.1,mode) == -5.4,
2501 '2440: appr(-5.44,0.1,mode) == -5.4');
2502 vrfy(appr(5.44,0.1,mode) == 5.4,
2503 '2441: appr(5.44,0.1,mode) == 5.4');
2504 vrfy(appr(5.7,1,mode) == 5,
2505 '2442: appr(5.7,1,mode) == 5');
2506 vrfy(appr(-5.7,1,mode) == -5,
2507 '2443: appr(-5.7,1,mode) == -5');
2508 vrfy(appr(-5.44,-0.1,mode) == -5.5,
2509 '2444: appr(-5.44,-0.1,mode) == -5.5');
2510 vrfy(appr(5.44,-0.1,mode) == 5.5,
2511 '2445: appr(5.44,-0.1,mode) == 5.5');
2512 vrfy(appr(5.7,-1,mode) == 6,
2513 '2446: appr(5.7,-1,mode) == 6');
2514 vrfy(appr(-5.7,-1,mode) == -6,
2515 '2447: appr(-5.7,-1,mode) == -6');
2519 print '2448: mode = 7';
2520 vrfy(appr(-5.44,0.1,mode) == -5.5,
2521 '2449: appr(-5.44,0.1,mode) == -5.5');
2522 vrfy(appr(5.44,0.1,mode) == 5.5,
2523 '2450: appr(5.44,0.1,mode) == 5.5');
2524 vrfy(appr(5.7,1,mode) == 6,
2525 '2451: appr(5.7,1,mode) == 6');
2526 vrfy(appr(-5.7,1,mode) == -6,
2527 '2452: appr(-5.7,1,mode) == -6');
2528 vrfy(appr(-5.44,-0.1,mode) == -5.4,
2529 '2453: appr(-5.44,-0.1,mode) == -5.4');
2530 vrfy(appr(5.44,-0.1,mode) == 5.4,
2531 '2454: appr(5.44,-0.1,mode) == 5.4');
2532 vrfy(appr(5.7,-1,mode) == 5,
2533 '2455: appr(5.7,-1,mode) == 5');
2534 vrfy(appr(-5.7,-1,mode) == -5,
2535 '2456: appr(-5.7,-1,mode) == -5');
2539 print '2457: mode = 8';
2540 vrfy(appr(-5.44,0.1,mode) == -5.4,
2541 '2458: appr(-5.44,0.1,mode) == -5.4');
2542 vrfy(appr(5.44,0.1,mode) == 5.4,
2543 '2459: appr(5.44,0.1,mode) == 5.4');
2544 vrfy(appr(5.7,1,mode) == 6,
2545 '2460: appr(5.7,1,mode) == 6');
2546 vrfy(appr(-5.7,1,mode) == -6,
2547 '2461: appr(-5.7,1,mode) == -6');
2551 print '2462: mode = 9';
2552 vrfy(appr(-5.44,0.1,mode) == -5.5,
2553 '2463: appr(-5.44,0.1,mode) == -5.5');
2554 vrfy(appr(5.44,0.1,mode) == 5.5,
2555 '2464: appr(5.44,0.1,mode) == 5.5');
2556 vrfy(appr(5.7,1,mode) == 5,
2557 '2465: appr(5.7,1,mode) == 5');
2558 vrfy(appr(-5.7,1,mode) == -5,
2559 '2466: appr(-5.7,1,mode) == -5');
2563 print '2467: mode = 10';
2564 vrfy(appr(-5.44,0.1,mode) == -5.5,
2565 '2468: appr(-5.44,0.1,mode) == -5.5');
2566 vrfy(appr(5.44,0.1,mode) == 5.4,
2567 '2469: appr(5.44,0.1,mode) == 5.4');
2568 vrfy(appr(5.7,1,mode) == 6,
2569 '2470: appr(5.7,1,mode) == 6');
2570 vrfy(appr(-5.7,1,mode) == -5,
2571 '2471: appr(-5.7,1,mode) == -5');
2572 vrfy(appr(-5.44,-0.1,mode) == -5.4,
2573 '2472: appr(-5.44,-0.1,mode) == -5.4');
2574 vrfy(appr(5.44,-0.1,mode) == 5.5,
2575 '2473: appr(5.44,-0.1,mode) == 5.5');
2576 vrfy(appr(5.7,-1,mode) == 5,
2577 '2474: appr(5.7,-1,mode) == 5');
2578 vrfy(appr(-5.7,-1,mode) == -6,
2579 '2475: appr(-5.7,-1,mode) == -6');
2583 print '2476: mode = 11';
2584 vrfy(appr(-5.44,0.1,mode) == -5.4,
2585 '2477: appr(-5.44,0.1,mode) == -5.4');
2586 vrfy(appr(5.44,0.1,mode) == 5.5,
2587 '2478: appr(5.44,0.1,mode) == 5.5');
2588 vrfy(appr(5.7,1,mode) == 5,
2589 '2479: appr(5.7,1,mode) == 5');
2590 vrfy(appr(-5.7,1,mode) == -6,
2591 '2480: appr(-5.7,1,mode) == -6');
2592 vrfy(appr(-5.44,-0.1,mode) == -5.5,
2593 '2481: appr(-5.44,-0.1,mode) == -5.5');
2594 vrfy(appr(5.44,-0.1,mode) == 5.4,
2595 '2482: appr(5.44,-0.1,mode) == 5.4');
2596 vrfy(appr(5.7,-1,mode) == 6,
2597 '2483: appr(5.7,-1,mode) == 6');
2598 vrfy(appr(-5.7,-1,mode) == -5,
2599 '2484: appr(-5.7,-1,mode) == -5');
2603 print '2485: mode = 12';
2604 vrfy(appr(-5.44,0.1,mode) == -5.4,
2605 '2486: appr(-5.44,0.1,mode) == -5.4');
2606 vrfy(appr(5.44,0.1,mode) == 5.4,
2607 '2487: appr(5.44,0.1,mode) == 5.4');
2608 vrfy(appr(5.7,1,mode) == 6,
2609 '2488: appr(5.7,1,mode) == 6');
2610 vrfy(appr(-5.7,1,mode) == -6,
2611 '2489: appr(-5.7,1,mode) == -6');
2612 vrfy(appr(-5.44,-0.1,mode) == -5.5,
2613 '2490: appr(-5.44,-0.1,mode) == -5.5');
2614 vrfy(appr(5.44,-0.1,mode) == 5.5,
2615 '2491: appr(5.44,-0.1,mode) == 5.5');
2616 vrfy(appr(5.7,-1,mode) == 5,
2617 '2492: appr(5.7,-1,mode) == 5');
2618 vrfy(appr(-5.7,-1,mode) == -5,
2619 '2493: appr(-5.7,-1,mode) == -5');
2623 print '2494: mode = 13';
2624 vrfy(appr(-5.44,0.1,mode) == -5.5,
2625 '2495: appr(-5.44,0.1,mode) == -5.5');
2626 vrfy(appr(5.44,0.1,mode) == 5.5,
2627 '2496: appr(5.44,0.1,mode) == 5.5');
2628 vrfy(appr(5.7,1,mode) == 5,
2629 '2497: appr(5.7,1,mode) == 5');
2630 vrfy(appr(-5.7,1,mode) == -5,
2631 '2498: appr(-5.7,1,mode) == -5');
2632 vrfy(appr(-5.44,-0.1,mode) == -5.4,
2633 '2499: appr(-5.44,-0.1,mode) == -5.4');
2634 vrfy(appr(5.44,-0.1,mode) == 5.4,
2635 '2500: appr(5.44,-0.1,mode) == 5.4');
2636 vrfy(appr(5.7,-1,mode) == 6,
2637 '2501: appr(5.7,-1,mode) == 6');
2638 vrfy(appr(-5.7,-1,mode) == -6,
2639 '2502: appr(-5.7,-1,mode) == -6');
2643 print '2503: mode = 14';
2644 vrfy(appr(-5.44,0.1,mode) == -5.5,
2645 '2504: appr(-5.44,0.1,mode) == -5.5');
2646 vrfy(appr(5.44,0.1,mode) == 5.4,
2647 '2505: appr(5.44,0.1,mode) == 5.4');
2648 vrfy(appr(5.7,1,mode) == 6,
2649 '2506: appr(5.7,1,mode) == 6');
2650 vrfy(appr(-5.7,1,mode) == -5,
2651 '2507: appr(-5.7,1,mode) == -5');
2652 vrfy(appr(-5.44,-0.1,mode) == -5.5,
2653 '2508: appr(-5.44,-0.1,mode) == -5.5');
2654 vrfy(appr(5.44,-0.1,mode) == 5.4,
2655 '2509: appr(5.44,-0.1,mode) == 5.4');
2656 vrfy(appr(5.7,-1,mode) == 6,
2657 '2510: appr(5.7,-1,mode) == 6');
2658 vrfy(appr(-5.7,-1,mode) == -5,
2659 '2511: appr(-5.7,-1,mode) == -5');
2663 print '2512: mode = 15';
2664 vrfy(appr(-5.44,0.1,mode) == -5.4,
2665 '2513: appr(-5.44,0.1,mode) == -5.4');
2666 vrfy(appr(5.44,0.1,mode) == 5.5,
2667 '2514: appr(5.44,0.1,mode) == 5.5');
2668 vrfy(appr(5.7,1,mode) == 5,
2669 '2515: appr(5.7,1,mode) == 5');
2670 vrfy(appr(-5.7,1,mode) == -6,
2671 '2516: appr(-5.7,1,mode) == -6');
2672 vrfy(appr(-5.44,-0.1,mode) == -5.4,
2673 '2517: appr(-5.44,-0.1,mode) == -5.4');
2674 vrfy(appr(5.44,-0.1,mode) == 5.5,
2675 '2518: appr(5.44,-0.1,mode) == 5.5');
2676 vrfy(appr(5.7,-1,mode) == 5,
2677 '2519: appr(5.7,-1,mode) == 5');
2678 vrfy(appr(-5.7,-1,mode) == -6,
2679 '2520: appr(-5.7,-1,mode) == -6');
2681 print '2521: Ending config rounding mode test';
2683 print '035: parsed test_round()';
2687 * Test certain numeric functions extensively
2689 * Test multiplication, sqrt(), exp(), ln(), power(), gcd(), complex
2690 * power, complex exp, complex log.
2692 read -once "test2600";
2693 print '036: read -once test2600';
2696 local tnum; /* test number */
2699 print '2600: Beginning extensive numeric function test';
2702 print '2601: i = config("sqrt")';
2704 tnum = test2600(1, 2602);
2706 i = config("sqrt", i);
2707 print tnum++: ': i = config("sqrt", i)';
2709 i = epsilon(1e-100),;
2710 print tnum++: ': i = epsilon(1e-100),;';
2711 vrfy(ln(exp(6)) == 6,
2712 strcat(str(tnum++), ': ln(exp(6)) == 6'));
2713 vrfy(ln(exp(4)^4) == 16,
2714 strcat(str(tnum++), ': ln(exp(4)^4) == 16'));
2715 vrfy(ln(exp(6.5)^8) == 52,
2716 strcat(str(tnum++), ': ln(exp(6.5)^8) == 52'));
2717 vrfy(ln(exp(5)^16) == 80,
2718 strcat(str(tnum++), ': ln(exp(5)^16) == 80'));
2719 vrfy(ln(exp(4.5)^4) == 18,
2720 strcat(str(tnum++), ': ln(exp(4.5)^4) == 18'));
2721 vrfy(ln(exp(4)^8) == 32,
2722 strcat(str(tnum++), ': ln(exp(4)^8) == 32'));
2723 vrfy(ln(exp(60/11)^11) == 60,
2724 strcat(str(tnum++), ': ln(exp(60/11)^11) == 60'));
2725 vrfy(ln(exp(6)^15) == 90,
2726 strcat(str(tnum++), ': ln(exp(6)^11) == 90'));
2727 vrfy(ln(exp(80/17)^17) == 80,
2728 strcat(str(tnum++), ': ln(exp(80/17)^17) == 80'));
2729 vrfy(ln(exp(6)^15) == 90,
2730 strcat(str(tnum++), ': ln(exp(6)^15) == 90'));
2731 vrfy(ln(exp(5)^18) == 90,
2732 strcat(str(tnum++), ': ln(exp(5)^18) == 90'));
2734 strcat(str(tnum++), ': log(1e6)) == 6'));
2736 strcat(str(tnum++), ': log(1)) == 0'));
2738 strcat(str(tnum++), ': log(100)) == 2'));
2739 vrfy(log(1e66) == 66,
2740 strcat(str(tnum++), ': log(1e66)) == 66'));
2741 vrfy(log(1e127) == 127,
2742 strcat(str(tnum++), ': log(1e127)) == 127'));
2743 vrfy(round(log(17^47),10) == 57.8310993048,
2745 ': round(log(17^47),10) == 57.8310993048'));
2746 vrfy(round(log(127),10) == 2.103803721,
2748 ': round(log(127),10) == 2.103803721'));
2749 vrfy(round(log(0.25,0.00001),5) == -0.60206,
2751 ': round(log(0.25,0.00001),5) == -0.60206'));
2752 vrfy(round(log(0.25,1e-10),10) == -0.6020599913,
2754 ': round(log(0.25,1e-10),10) == -0.6020599913'));
2755 vrfy(round( log(1.2+1.2i,1e-5),5) == 0.2297+0.34109i,
2757 ': round(log(1.2+1.2i,1e-5),5) == 0.2297+0.34109i'));
2758 vrfy(round( log(1.2+1.2i,1e-10),10) == 0.2296962439+0.3410940885i,
2760 ': round(log(1.2+1.2i,1e-10),10) == ',
2761 '0.2296962439+0.3410940885i'));
2763 print tnum++: ': epsilon(i),;';
2765 print tnum: ': Ending extensive numeric function test';
2767 print '037: parsed test_2600()';
2773 read -once "test2700";
2774 print '038: read -once test2700';
2777 local tnum; /* test number */
2779 print '2700: Beginning complex sqrt test';
2781 tnum = test2700(1, 2701);
2783 print tnum: ': Ending complex sqrt test';
2785 print '039: parsed test_2700()';
2789 * Test matrix operations
2791 mat mat_C[2] = {1,2};
2792 print '040: mat mat_C[2] = {1,2}';
2794 print '041: C[0] = mat_C';
2796 print '042: global mat_D';
2798 define test_matrix()
2801 static mat binv[4,4] = {
2802 0, 1, 0, 0, 2, -3/2, 2, -1/2, -3,
2803 0.5, -1.0, 0.5, 1.0, 0.0, 0.0, 0.0
2805 static mat c[] = { 1, 2+3i, -5+4i, 5i+6, -7i };
2806 static mat d[-1:1, -2:2, -3:3, -4:4];
2807 static mat A[2] = {1,2};
2808 static mat id0[2,2] = {1,0,0,1};
2809 static mat id1[0:2,-1:1] = {1,0,0,0,1,0,0,0,1};
2810 static mat noid0[2,2] = {1,2,0,1};
2811 static mat noid1[2,3] = {1,0,0,1,0,0};
2812 static mat noid2[4] = {1,0,0,1};
2813 static mat xp[3] = {2,3,4};
2814 static mat yp[3] = {3,4,5};
2815 static mat zp[3] = {-1,2,-1};
2816 static mat X[2,2] = {1,2,3,4};
2817 static mat Y[2,2] = {5,6,7,8};
2818 static mat Z[2,2] = {190,232,286,352};
2819 static mat x[] = {11,13,17,23,29};
2820 static mat y0[] = {1,3,7,3,9};
2821 static mat y1[] = {-9,-7,-3,-7,-1};
2822 static mat y2[] = {-9,-7,-3,3,9};
2823 static mat y3[] = {1,3,7,-7,-1};
2824 static mat y4[] = {1,3,-3,3,-1};
2830 print '2800: Beginning test_matrix';
2833 vrfy(b[0,0] == 0, '2801: b[0,0] == 0');
2835 vrfy(b[0,1] == 0, '2802: b[0,1] == 0');
2837 vrfy(b[0,2] == 0, '2803: b[0,2] == 0');
2839 vrfy(b[0,3] == 1, '2804: b[0,3] == 1');
2841 vrfy(b[1,0] == 1, '2805: b[1,0] == 1');
2843 vrfy(b[1,1] == 0, '2806: b[1,1] == 0');
2845 vrfy(b[1,2] == 0, '2807: b[1,2] == 0');
2847 vrfy(b[1,3] == 0, '2808: b[1,3] == 0');
2849 vrfy(b[2,0] == 1, '2809: b[2,0] == 1');
2851 vrfy(b[2,1] == 1, '2810: b[2,1] == 1');
2853 vrfy(b[2,2] == 1, '2811: b[2,2] == 1');
2855 vrfy(b[2,3] == 1, '2812: b[2,3] == 1');
2857 vrfy(b[3,0] == 1, '2813: b[3,0] == 1');
2859 vrfy(b[3,1] == 2, '2814: b[3,1] == 2');
2861 vrfy(b[3,2] == 4, '2815: b[3,2] == 4');
2863 vrfy(b[3,3] == 8, '2816: b[3,3] == 8');
2864 vrfy(det(b) == -2, '2817: det(b) == -2');
2865 vrfy(binv[0,0] == 0, '2818: binv[0,0] == 0');
2866 vrfy(binv[0,1] == 1, '2819: binv[0,1] == 1');
2867 vrfy(binv[0,2] == 0, '2820: binv[0,2] == 0');
2868 vrfy(binv[0,3] == 0, '2821: binv[0,3] == 0');
2869 vrfy(binv[1,0] == 2, '2822: binv[1,0] == 2');
2870 vrfy(binv[1,1] == -3/2, '2823: binv[1,1] == -3/2');
2871 vrfy(binv[1,2] == 2, '2824: binv[1,2] == 2');
2872 vrfy(binv[1,3] == -1/2, '2825: binv[1,3] == -1/2');
2873 vrfy(binv[2,0] == -3, '2826: binv[2,0] == -3');
2874 vrfy(binv[2,1] == 1/2, '2827: binv[2,1] == 1/2');
2875 vrfy(binv[2,2] == -1, '2828: binv[2,2] == -1');
2876 vrfy(binv[2,3] == 1/2, '2829: binv[2,3] == 1/2');
2877 vrfy(binv[3,0] == 1, '2830: binv[3,0] == 1');
2878 vrfy(binv[3,1] == 0, '2831: binv[3,1] == 0');
2879 vrfy(binv[3,2] == 0, '2832: binv[3,2] == 0');
2880 vrfy(binv[3,3] == 0, '2833: binv[3,3] == 0');
2881 vrfy(inverse(b) == binv, '2834: inverse(b) == binv');
2882 vrfy(avg(b) == b, '2835: avg(b) == b');
2883 vrfy(avg(binv) == binv, '2836: avg(binv) == binv');
2884 vrfy((b+binv)/2 == avg(b,binv), '2837: (b+binv)/2 == avg(b,binv)');
2885 vrfy(ismat(b) == 1, '2838: ismat(b) == 1');
2886 vrfy(matsum(b) == 21, '2839: matsum(b) == 21');
2887 vrfy(matsum(binv) == 1, '2840: matsum(binv) == 1');
2888 vrfy(c[0] == 1, '2841: c[0] == 1');
2889 vrfy(c[1] == 2+3i, '2842: c[1] == 2+3i');
2890 vrfy(c[2] == -5+4i, '2843: c[2] == -5+4i');
2891 vrfy(c[3] == 6+5i, '2844: c[3] == 6+5i');
2892 vrfy(c[4] == -7i, '2845: c[4] == -7i');
2893 vrfy(matsum(c) == 4+5i, '2846: matsum(c) == 4+5i');
2894 vrfy(matdim(b) == 2, '2847: matdim(b) == 2');
2895 vrfy(matdim(c) == 1, '2848: matdim(c) == 1');
2896 vrfy(matdim(d) == 4, '2849: matdim(c) == 4');
2897 vrfy(matmax(c,1) == 4, '2850: matmax(c,1) == 4');
2898 vrfy(matmin(c,1) == 0, '2851: matmin(c,1) == 0');
2899 vrfy(matmin(d,1) == -1, '2852: matmin(d,1) == -1');
2900 vrfy(matmin(d,3) == -3, '2853: matmin(d,3) == -3');
2901 vrfy(matmax(d,1) == 1, '2854: matmin(d,1) == 1');
2902 vrfy(matmax(d,3) == 3, '2855: matmin(d,3) == 3');
2903 vrfy(size(binv) == 16, '2856: size(binv) == 16');
2904 vrfy(size(c) == 5, '2857: size(c) == 5');
2905 vrfy(size(d) == 945, '2858: size(d) == 945');
2906 vrfy(size(e) == 25, '2859: size(e) == 25');
2908 print '2860: matfill(d,1)';
2909 vrfy(matsum(d) == 945, '2861: matsum(d) == 945');
2911 print '2862: matfill(e,1,0)';
2912 vrfy(matsum(d) == 945, '2863: matsum(d) == 945');
2913 vrfy(matsum(e) == 20, '2864: matsum(e) == 20');
2914 vrfy(search(binv,1) == 1, '2865: search(binv,1) == 1');
2915 vrfy(search(binv,2) == 4, '2866: search(binv,2) == 4');
2916 vrfy(search(binv,2,4) == 4, '2867: search(binv,2,4) == 4');
2917 vrfy(search(binv,2,5) == 6, '2868: search(binv,2,5) == 6');
2918 vrfy(rsearch(binv,2) == 6, '2869: rsearch(binv,2) == 6');
2919 vrfy(rsearch(binv,2,6) == 6, '2870: rsearch(binv,2,6) == 6');
2920 vrfy(rsearch(binv,2,5) == 4, '2871: rsearch(binv,2,5) == 4');
2921 vrfy(A[0] == 1, '2872: A[0] == 1');
2922 vrfy(A[1] == 2, '2873: A[1] == 2');
2924 print '2874: A[0] = A';
2926 print '2875: B = A[0]';
2927 vrfy(B[0] == 1, '2876: B[0] == 1');
2928 vrfy(B[1] == 2, '2877: B[1] == 2');
2930 print '2878: mat_D = mat_C[0]';
2931 vrfy(mat_D[0] == 1, '2879: mat_D[0] == 1');
2932 vrfy(mat_D[1] == 2, '2880: mat_D[1] == 2');
2933 vrfy(quomod(15.6,5.2,M[0],M[1]) == 0,
2934 '2881: quomod(15.6,5.2,M[0],M[1]) == 0');
2935 vrfy(M[0] == 3, '2882: M[0] == 3');
2936 vrfy(M[1] == 0, '2883: M[1] == 0');
2937 vrfy(isident(id0) == 1, '2884: isident(id0) == 1');
2938 vrfy(isident(id1) == 1, '2885: isident(id1) == 1');
2939 vrfy(isident(noid0) == 0, '2886: isident(noid0) == 0');
2940 vrfy(isident(noid1) == 0, '2887: isident(noid1) == 0');
2941 vrfy(isident(noid2) == 0, '2888: isident(noid2) == 0');
2942 vrfy(xp[0] == 2, '2889: xp[0] == 2');
2943 vrfy(xp[1] == 3, '2890: xp[1] == 3');
2944 vrfy(xp[2] == 4, '2891: xp[2] == 4');
2945 vrfy(yp[0] == 3, '2892: yp[0] == 3');
2946 vrfy(yp[1] == 4, '2893: yp[1] == 4');
2947 vrfy(yp[2] == 5, '2894: yp[2] == 5');
2948 vrfy(zp[0] == -1, '2895: zp[0] == -1');
2949 vrfy(zp[1] == 2, '2896: zp[1] == 2');
2950 vrfy(zp[2] == -1, '2897: zp[2] == -1');
2951 vrfy(cp(xp,yp) == zp, '2898: cp(xp,yp) == zp');
2952 vrfy(cp(yp,xp) == -zp, '2899: cp(yp,xp) == -zp');
2954 print '2900: matfill(zero3,0)';
2955 vrfy(cp(xp,xp) == zero3, '2901: cp(xp,xp) == zero3');
2956 vrfy(dp(xp,yp) == 38, '2902: dp(xp,yp) == 38');
2957 vrfy(dp(yp,xp) == 38, '2903: dp(yp,xp) == 38');
2958 vrfy(dp(zp,dp(xp,yp)*zp) == 228,'2904: dp(zp,dp(xp,yp)*zp) == 228');
2959 vrfy(ssq(X, Y, X + Y) == Z, '2905: ssq(X, Y, X + Y) == Z');
2960 vrfy(mod(x,10,0) == y0, '2906: mod(x,10,0) == y0');
2961 vrfy(mod(x,10,1) == y1, '2907: mod(x,10,1) == y1');
2962 vrfy(mod(x,10,2) == y0, '2908: mod(x,10,2) == y0');
2963 vrfy(mod(x,10,3) == y1, '2909: mod(x,10,3) == y1');
2964 vrfy(mod(x,10,4) == y0, '2910: mod(x,10,4) == y0');
2965 vrfy(mod(x,10,5) == y1, '2911: mod(x,10,5) == y1');
2966 vrfy(mod(x,10,6) == y0, '2912: mod(x,10,6) == y0');
2967 vrfy(mod(x,10,7) == y1, '2913: mod(x,10,7) == y1');
2968 vrfy(mod(x,10,8) == y2, '2914: mod(x,10,8) == y2');
2969 vrfy(mod(x,10,9) == y3, '2915: mod(x,10,9) == y3');
2970 vrfy(mod(x,10,10) == y2, '2916: mod(x,10,10) == y2');
2971 vrfy(mod(x,10,11) == y3, '2917: mod(x,10,11) == y3');
2972 vrfy(mod(x,10,12) == y2, '2918: mod(x,10,12) == y2');
2973 vrfy(mod(x,10,13) == y3, '2919: mod(x,10,13) == y3');
2974 vrfy(mod(x,10,14) == y2, '2920: mod(x,10,14) == y2');
2975 vrfy(mod(x,10,15) == y3, '2921: mod(x,10,15) == y3');
2976 vrfy(mod(x,10,16) == y4, '2922: mod(x,10,16) == y4');
2977 vrfy(mod(x,10,16) == y4, '2923: mod(x,10,16) == y4');
2978 vrfy(mod(x,10,18) == y4, '2924: mod(x,10,18) == y4');
2979 vrfy(mod(x,10,19) == y4, '2925: mod(x,10,18) == y4');
2980 vrfy(mod(x,10,20) == y4, '2926: mod(x,10,20) == y4');
2981 vrfy(mod(x,10,21) == y4, '2927: mod(x,10,21) == y4');
2982 vrfy(mod(x,10,22) == y4, '2928: mod(x,10,22) == y4');
2983 vrfy(mod(x,10,23) == y4, '2929: mod(x,10,23) == y4');
2984 vrfy(mod(x,10,24) == y4, '2930: mod(x,10,24) == y4');
2985 vrfy(mod(x,10,25) == y4, '2931: mod(x,10,25) == y4');
2986 vrfy(mod(x,10,26) == y4, '2932: mod(x,10,26) == y4');
2987 vrfy(mod(x,10,27) == y4, '2933: mod(x,10,27) == y4');
2988 vrfy(mod(x,10,28) == y4, '2934: mod(x,10,28) == y4');
2989 vrfy(mod(x,10,29) == y4, '2935: mod(x,10,29) == y4');
2990 vrfy(mod(x,10,30) == y4, '2936: mod(x,10,30) == y4');
2991 vrfy(mod(x,10,31) == y4, '2937: mod(x,10,31) == y4');
2993 print '2938: Ending mat_functions';
2995 print '043: parsed test_matrix()';
2999 * Test string constants and comparisons
3001 define test_strings()
3005 print '3000: Beginning test_strings';
3008 print "3001: x = 'string'";
3010 print '3002: y = "string"';
3012 print '3003: z = x';
3013 vrfy(z == "string", '3004: z == "string"');
3014 vrfy(z != "foo", '3005: z != "foo"');
3015 vrfy(z != 3, '3006: z != 3');
3016 vrfy('' == "", '3007: \'\' == ""');
3017 vrfy("a" == "a", '3008: "a" == "a"');
3018 vrfy("c" != "d", '3009: "c" != "d"');
3019 vrfy("" != "a", '3010: "" != "a"');
3020 vrfy("rs" < "rt", '3011: "rs" < "rt"');
3021 vrfy("rs" < "ss", '3012: "rs < "ss"');
3022 vrfy("rs" <= "rs", '3013: "rs" <= "rs"');
3023 vrfy("rs" <= "tu", '3014: "rs" <= "tu"');
3024 vrfy("rs" > "cd", '3015: "rs" > "cd"');
3025 vrfy("rs" >= "rs", '3016: "rs" >= "rs"');
3026 vrfy("rs" >= "cd", '3017: "rs" >= "cd"');
3027 vrfy("abc" > "ab", '3018: "abc" > "ab"');
3029 print '3019: Ending test_strings';
3031 print '044: parsed test_strings()';
3035 * test_matobj - test determinants of a matrix containing objects
3037 read -once "test3100";
3038 print '045: read -once test3100';
3040 define test_matobj()
3042 local mat A[3,3] = {2, 3, 5, 7, 11, 13, 17, 19, 23};
3045 print '3100: Beginning test_matobj';
3047 vrfy(det(A) == -78, '3101: det(A) == -78');
3048 vrfy(det(A^2) == 6084, '3102: det(A^2) == 6084');
3049 vrfy(det(A^3) == -474552, '3103: det(A^3) == -474552');
3050 vrfy(det(A^-1) == -1/78, '3104: det(A^-1) == -1/78');
3052 print '3105: md = 0';
3054 print '3106: B[0,0] = res(2)';
3056 print '3107: B[0,1] = res(3)';
3058 print '3108: B[1,0] = res(5)';
3060 print '3109: B[1,1] = res(7)';
3061 print '3110: md = 0';
3063 vrfy(det(B) == res(-1), '3111: det(B) == res(-1)');
3065 print '3112: md = 1';
3066 vrfy(det(B) == 0, '3113: det(B) == 0');
3068 print '3114: md = 2';
3069 vrfy(det(B) == res(1), '3115: det(B) == res(1)');
3071 print '3116: md = 3';
3072 vrfy(det(B) == res(2), '3117: det(B) == res(2)');
3074 print '3118: md = 4';
3075 vrfy(det(B) == res(3), '3119: det(B) == res(3)');
3077 print '3120: md = 5';
3078 vrfy(det(B) == res(4), '3121: det(B) == res(4)');
3080 print '3122: md = 6';
3081 vrfy(det(B) == res(5), '3123: det(B) == res(5)');
3083 print '3124: md = 7';
3084 vrfy(det(B) == res(6), '3125: det(B) == res(6)');
3086 print '3126: md = 8';
3087 vrfy(det(B) == res(7), '3127: det(B) == res(7)');
3089 print '3128: md = 9';
3090 vrfy(det(B) == res(8), '3129: det(B) == res(8)');
3092 print '3130: md = 10';
3093 vrfy(det(B) == res(9), '3131: det(B) == res(9)');
3095 print '3132: md = 11';
3096 vrfy(det(B) == res(10), '3133: det(B) == res(10)');
3098 print '3134: md = 12';
3099 vrfy(det(B) == res(11), '3135: det(B) == res(11)');
3101 print '3136: md = 13';
3102 vrfy(det(B) == res(12), '3137: det(B) == res(12)');
3104 print '3138: md = 14';
3105 vrfy(det(B) == res(13), '3139: det(B) == res(13)');
3107 print '3140: md = 15';
3108 vrfy(det(B) == res(14), '3141: det(B) == res(14)');
3110 print '3142: Ending test_matobj';
3112 print '046: parsed test_matobj()';
3116 * test_poly - test the polynomial function
3120 print '3200: Beginning test_matobj';
3122 vrfy(poly(2,3,5,2) == 19, '3201: poly(2,3,5,2) == 19');
3123 vrfy(poly(list(5,3,2),2) == 19,\
3124 '3202: poly(list(5,3,2),2) == 19');
3125 vrfy(poly(list(5,3,2)) == 5, '3203: poly(list(5,3,2)) == 5');
3126 vrfy(poly(2) == 2, '3204: poly(2) == 2');
3127 vrfy(poly(list(5,3,2),2,3) == 19,\
3128 '3205: poly(list(5,3,2),2,3) == 19');
3129 vrfy(poly(list()) == 0, '3206: poly(list()) == 0');
3130 vrfy(poly(list(),2,3) == 0, '3207: poly(list(),2,3) == 0');
3131 vrfy(poly(list(list(5,3,2)),7,2) == 19,\
3132 '3208: poly(list(list(5,3,2)),7,2) == 19');
3133 vrfy(poly(list(list(1,2,3),list(4,5),6),7) == 323,\
3134 '3209: poly(list(list(1,2,3),list(4,5),6),7) == 323');
3135 vrfy(poly(list(list(1,2,3),list(4,5),6),7,8) == 811,\
3136 '3210: poly(list(list(1,2,3),list(4,5),6),7,8) == 811');
3137 vrfy(poly(list(list(1,2,3),list(4,5),6),7,8,9) == 811,\
3138 '3211: poly(list(list(1,2,3),list(4,5),6),7,8,9)==811');
3139 vrfy(poly(list(5,3,2), list()) == 5,\
3140 '3212: poly(list(5,3,2), list() == 5');
3141 vrfy(poly(list(5,3,2), list(2)) == 19,\
3142 '3213: poly(list(5,3,2), list(2)) == 19');
3143 vrfy(poly(list(5,3,2), list(2,3)) == 19,\
3144 '3214: poly(list(5,3,2), list(2,3)) == 19');
3145 vrfy(poly(list(list(list(0,0,0,0,0,1))),2,3,4) == 4^5,\
3146 '3215: poly(list(list(list(0,0,0,0,0,1))),2,3,4)==4^5');
3147 vrfy(poly(list(list(list(0,0,0,0,0,1))),2,list(3,4)) == 4^5,\
3148 '3216: poly(list(list(list(0,0,0,0,0,1))),2,list(3,4))==4^5');
3150 print '3217: Ending test_poly';
3152 print '047: parsed test_poly()';
3156 * test_det - more determinent testing
3158 read -once "test3300";
3159 print '048: read -once test3300';
3163 local tnum; /* test number */
3166 print '3300: Beginning test_det';
3168 tnum = test3300(1, 3301);
3170 print tnum: ': Ending test_det';
3172 print '049: parsed test_det()';
3176 * test_trig - trig function testing
3178 read -once "test3400";
3179 print '050: read -once test3400';
3183 local tnum; /* test number */
3186 print '3400: Beginning test_trig';
3188 tnum = test3400(1, 3401);
3190 print tnum: ': Ending test_trig';
3192 print '051: parsed test_trig()';
3196 * test_frem - tests of the functions frem, fcnt, gcdrem
3198 read -once "test3500";
3199 print '052: read -once test3500';
3203 local tnum; /* test number */
3205 print '3500: Beginning test_frem';
3207 tnum = test3500(1, 3501, 200, 61);
3209 print tnum: ': Ending test_frem';
3211 print '053: parsed test_frem()';
3215 * test_error - test the error() builtin
3217 * This function is designed to trigger 148 errors, so we bump the
3218 * errmax by 148 during this call.
3222 local strx, e99, list1, e9999;
3223 local a, b, c, n, x; /* used by newerror() */
3225 print '3600: Beginning test_error';
3227 /* bump ecnt up by 148 */
3229 print '3601: ecnt += 148';
3232 print '3602: strx = "x"';
3234 print '3603: e99 = error(99)';
3235 vrfy(1/0 == error(10001), '3604: 1/0 == error(10001)');
3236 vrfy(0/0 == error(10002), '3605: 0/0 == error(10002)');
3237 vrfy(2 + "x" == error(10003), '3606: 2 + "x" == error(10003)');
3238 vrfy("x" - 2 == error(10004), '3607: "x" - 2 == error(10004)');
3239 vrfy("x" * "y" == error(10005), '3608: "x" * "y" == error(10005)');
3240 vrfy("x" / "y" == error(10006), '3609: "x" / "y" == error(10006)');
3241 vrfy(-list(1) == error(10007), '3610: -list(1) == error(10007)');
3242 vrfy("x"^2 == error(10008), '3611: "x"^2 == error(10008)');
3243 vrfy(inverse("x")==error(10009),'3612: inverse("x") == error(10009)');
3244 vrfy(++strx == error(10010), '3613: ++strx == error(10010)');
3245 vrfy(strx == error(10010), '3614: strx == error(10010)');
3247 print '3615: strx = "x"';
3248 vrfy(strx++ == "x", '3616: strx++ == "x"');
3249 vrfy(strx == error(10010), '3617: strx == error(10010)');
3251 print '3618: strx = "x"';
3252 vrfy(--strx == error(10011), '3619: strx == error(10011)');
3253 vrfy(int("x") == error(10012), '3620: int("x") == error(10012)');
3254 vrfy(frac("x") == error(10013), '3621: frac("x") == error(10013)');
3255 vrfy(conj("x") == error(10014), '3622: conj("x") == error(10014)');
3256 vrfy(appr("x",.1) == error(10015),
3257 '3623: appr("x",.1) == error(10015)');
3258 vrfy(appr(1.27,.1i) == error(10016),
3259 '3624: appr(1.27,.1i) == error(10016)');
3260 vrfy(appr(1.27,.1,.1) == error(10017),
3261 '3625: appr(1.27,.1,.1) == error(10017)');
3262 vrfy(round("x") == error(10018),
3263 '3626: round("x") == error(10018)');
3264 vrfy(round(1.25,.1) == error(10019),
3265 '3627: round(1.25,.1) == error(10019)');
3266 vrfy(round(1.25,"x") == error(10019),
3267 '3628: round(1.25,"x") == error(10019)');
3268 vrfy(round(1.25,1,.1) == error(10020),
3269 '3629: round(1.25,1,.1) == error(10020)');
3270 vrfy(bround("x") == error(10021),
3271 '3630: bround("x") == error(10021)');
3272 vrfy(bround(1.25,.1) == error(10022),
3273 '3631: bround(1.25,.1) == error(10022)');
3274 vrfy(bround(1.25,"x") == error(10022),
3275 '3632: bround(1.25,"x") == error(10022)');
3276 vrfy(bround(1.25,1,.1) == error(10023),
3277 '3633: bround(1.25,1,.1) == error(10023)');
3278 vrfy(sqrt("x") == error(10024),
3279 '3634: sqrt("x") == error(10024)');
3280 vrfy(sqrt(2,"x") == error(10025),
3281 '3635: sqrt(2,"x") == error(10025)');
3282 vrfy(sqrt(2,0) == error(10025),
3283 '3636: sqrt(2,0) == error(10025)');
3284 vrfy(sqrt(2,.1,.1) == error(10026),
3285 '3637: sqrt(2,.1,.1) == error(10026)');
3286 vrfy(root("x",3) == error(10027),
3287 '3638: root("x",3) == error(10027)');
3288 vrfy(root(3,"x") == error(10028),
3289 '3639: root(3,"x") == error(10028)');
3290 vrfy(root(3,-2) == error(10028),
3291 '3640: root(3,-2) == error(10028)');
3292 vrfy(root(3,0) == error(10028),
3293 '3641: root(3,0) == error(10028)');
3294 vrfy(root(3,.1) == error(10028),
3295 '3642: root(3,.1) == error(10028)');
3296 vrfy(root(3,2,"x") == error(10029),
3297 '3643: root(3,2,"x") == error(10029)');
3298 vrfy(root(3,2,0) == error(10029),
3299 '3644: root(3,2,0) == error(10029)');
3300 vrfy(norm("x") == error(10030), '3645: norm("x") == error(10030)');
3301 vrfy(list() << 2 == error(10031),'3646: list() << 2 == error(10031)');
3302 vrfy(1.5 << 2 == error(10031), '3647: 1.5 << 2 == error(10031)');
3303 vrfy(3 << "x" == error(10032), '3648: 3 << "x" == error(10032)');
3304 vrfy(3 << 1.5 == error(10032), '3649: 3 << 1.5 == error(10032)');
3305 vrfy(3 << 2^31 == error(10032), '3650: 3 << 2^31 == error(10032)');
3306 vrfy(scale("x",2) == error(10033),
3307 '3651: scale("x",2) == error(10033)');
3308 vrfy(scale(3,"x") == error(10034),
3309 '3652: scale(3,"x") == error(10034)');
3310 vrfy(scale(3,1.5) == error(10034),
3311 '3653: scale(3,1.5) == error(10034)');
3312 vrfy(scale(3,2^31) == error(10034),
3313 '3654: scale(3,2^31) == error(10034)');
3314 vrfy("x" ^ 3 == error(10035), '3655: "x" ^ 3 == error(10035)');
3315 vrfy(2 ^ "x" == error(10036), '3656: 2 ^ "x" == error(10036)');
3316 vrfy(2 ^ "2" == error(10036), '3657: 2 ^ "2" == error(10036)');
3317 vrfy(power("x",2.1) == error(10037),
3318 '3658: power("x",2.1) == error(10037)');
3319 vrfy(power(2,"x") == error(10038),
3320 '3659: power(2,"x") == error(10038)');
3321 vrfy(power(2,2.1,"x") == error(10039),
3322 '3660: power(2,2.1,"x") == error(10039)');
3323 vrfy(quo("x",3) == error(10040),
3324 '3661: quo("x",3) == error(10040)');
3325 vrfy(quo(8,"x") == error(10041),
3326 '3662: quo(8,"x") == error(10041)');
3327 vrfy(quo(8,3,"x") == error(10042),
3328 '3663: quo(8,3,"x") == error(10042)');
3329 vrfy(quo(8,3,2.1) == error(10042),
3330 '3664: quo(8,3,2.1) == error(10042)');
3331 vrfy(mod("x",3) == error(10043),
3332 '3665: mod("x",3) == error(10043)');
3333 vrfy(mod(8,"x") == error(10044),
3334 '3666: mod(8,"x") == error(10044)');
3335 vrfy(mod(8,3,"x") == error(10045),
3336 '3667: mod(8,3,"x") == error(10045)');
3337 vrfy(mod(8,3,2.1) == error(10045),
3338 '3668: mod(8,3,2.1) == error(10045)');
3339 vrfy(sgn("x") == error(10046),
3340 '3669: sgn("x") == error(10046)');
3341 vrfy(abs("x") == error(10047),
3342 '3670: abs("x") == error(10047)');
3343 vrfy(abs(2+3i,"x") == error(10048),
3344 '3671: abs(2+3i,"x") == error(10048)');
3345 vrfy(abs(2+3i,0) == error(10048),
3346 '3672: abs(2+3i,0) == error(10048)');
3347 list1 = list(2,3,"x",4,5);
3348 print '3673: list1 = list(2,3,"x",4,5)';
3349 vrfy(avg(list1) == error(10003),
3350 '3674: avg(list1) == error(10003)');
3352 vrfy(iserror(e99)==99, '3675: iserror(e99) == 99');
3353 vrfy(e99 + 2 == e99, '3676: e99 + 2 == e99');
3354 vrfy(e99 - 2 == e99, '3677: e99 - 2 == e99');
3355 vrfy(e99 * 2 == e99, '3678: e99 * 2 == e99');
3356 vrfy(e99 / 2 == e99, '3679: e99 / 2 == e99');
3357 vrfy(e99 // 2 == e99, '3680: e99 // 2 == e99');
3358 vrfy(e99 % 2 == e99, '3681: e99 % 2 == e99');
3359 vrfy(e99 ^ 2 == e99, '3682: e99 ^ 2 == e99');
3360 vrfy(2 + e99 == e99, '3683: 2 + e99 == e99');
3361 vrfy(2 - e99 == e99, '3684: 2 - e99 == e99');
3362 vrfy(2 * e99 == e99, '3685: 2 * e99 == e99');
3363 vrfy(2 / e99 == e99, '3686: 2 / e99 == e99');
3364 vrfy(2 // e99 == e99, '3687: 2 // e99 == e99');
3365 vrfy(2 % e99 == e99, '3688: 2 % e99 == e99');
3366 vrfy(2 ^ e99 == e99, '3689: 2 ^ e99 == e99');
3367 vrfy(- e99 == e99, '3690: -e99 == e99');
3368 vrfy(inverse(e99) == e99, '3691: inverse(e99) == e99');
3369 vrfy(++e99 == e99, '3692: ++e99 == e99');
3370 vrfy(--e99 == e99, '3693: --e99 == e99');
3371 vrfy(int(e99) == e99, '3694: int(e99) == e99');
3372 vrfy(frac(e99) == e99, '3695: frac(e99) == e99');
3373 vrfy(conj(e99) == e99, '3696: conj(e99) == e99');
3374 vrfy(norm(e99) == e99, '3697: norm(e99) == e99');
3375 vrfy(sgn(e99) == e99, '3698: sgn(e99) == e99');
3376 vrfy(appr(e99,1,0) == e99, '3699: appr(e99,1,0) == e99');
3377 vrfy(round(e99) == e99, '3700: round(e99) == e99');
3378 vrfy(bround(e99) == e99, '3701: bround(e99) == e99');
3379 vrfy(sqrt(e99) == e99, '3702: sqrt(e99) == e99');
3380 print '3703: a = newerror("alpha")';
3381 a = newerror("alpha");
3382 print '3704: b = newerror("beta")';
3383 b = newerror("beta");
3384 print '3705: c = newerror("alpha")';
3385 c = newerror("alpha");
3386 vrfy(a == c, '3706: a == c');
3387 vrfy(strerror(a) == "alpha", '3707: strerror(a) == "alpha"');
3388 print '3708: n = iserror(a)';
3390 vrfy(a == error(n), '3709: a == error(n)');
3391 vrfy(newerror() == newerror("???"),
3392 '3710: newerror() == newerror("???")');
3393 vrfy(newerror("") == newerror(),
3394 '3711: newerror("") == newerror()');
3395 e9999 = error(9999);
3396 print '3712: e9999 = error(9999)';
3397 vrfy(errno() == 9999, '3713: errno() == 9999');
3398 vrfy(error() == e9999, '3714: error() == e9999');
3399 /* test 3715 removed due to non-portable strerror() output */
3400 x = newerror("Alpha");
3401 print '3716: x = newerror("Alpha")';
3403 print '3717: n = iserror(x)';
3404 vrfy(errno() == n, '3718: errno() == n');
3405 vrfy(error() == x, '3719: error() == x');
3406 vrfy(strerror() == "Alpha", '3720: strerror() == "Alpha"');
3407 vrfy(errno(9999) == n, '3721: errno() == n');
3408 vrfy(errno() == 9999, '3722: errno() == 9999');
3409 vrfy(error() == e9999, '3723: error() == e9999');
3410 /* test 3724 removed due to non-portable strerror() output */
3412 print '3725: a = 1/0';
3413 vrfy(strerror() == "Division by zero",
3414 '3726: strerror() == "Division by zero"');
3416 print '3727: n = 8191';
3417 /* test 3728 removed due to non-portable strerror() output */
3419 /* errmax and errcount should be bumped up the 148 errors above */
3420 vrfy(errcount() == ecnt, '3729: errcount() == ecnt');
3422 print '3730: Ending test_error';
3424 print '054: parsed test_error()';
3428 * test_param - test new param() functionality.
3430 define g_param() = (param(2) = param(1));
3431 print '055: define g_param() = (param(2) = param(1))';
3432 define h_param() = (param(1)++, param(2)--);
3433 print '056: define h_param() = (param(1)++, param(2)--)';
3436 print '057: global u_glob = 5';
3438 print '058: global v_glob = 10';
3439 vrfy(g_param(u_glob, `v_glob) == 5, '059: g_param(u_glob, `v_glob) == 5');
3440 vrfy(u_glob == 5, '060: u_glob == 5');
3441 vrfy(v_glob == 5, '061: v_glob == 5');
3442 vrfy(h_param(`u_glob, `v_glob) == 5, '062: h_param(`u_glob, `v_glob) == 5');
3443 vrfy(u_glob == 6, '063: u_glob == 6');
3444 vrfy(v_glob == 4, '064: v_glob == 4');
3450 print '3800: Beginning test_param';
3453 print '3801: u = 5';
3455 print '3802: v = 10';
3456 vrfy(g_param(u, `v) == 5, '3803: g_param(u, `v) == 5');
3457 vrfy(u == 5, '3804: u == 5');
3458 vrfy(v == 5, '3805: v == 5');
3459 vrfy(h_param(`u, `v) == 5, '3806: h_param(`u, `v) == 5');
3460 vrfy(u == 6, '3807: u == 6');
3461 vrfy(v == 4, '3808: v == 4');
3463 print '3809: Ending test_param';
3465 print '065: parsed test_param()';
3469 * test_noarg - test missing argment functionality
3475 print '3900: Beginning test_noarg';
3478 print '3901: A = list(1,,3)';
3479 vrfy(A[[0]] == 1, '3902: A[[0]] == 1');
3480 vrfy(isnull(A[[1]]), '3903: isnull(A[[1]])');
3481 vrfy(A[[2]] == 3, '3904: A[[2]] == 3');
3482 vrfy(size(A) == 3, '3905: size(A) == 3');
3485 print '3906: B = list(,,)';
3486 vrfy(isnull(B[[0]]), '3907: isnull(B[[0]])');
3487 vrfy(isnull(B[[1]]), '3908: isnull(B[[1]])');
3488 vrfy(isnull(B[[2]]), '3909: isnull(B[[2]])');
3489 vrfy(size(B) == 3, '3910: size(B) == 3');
3492 print '3911: mat C[] = {,,}';
3493 vrfy(C[0] == 0, '3912: C[0] == 0');
3494 vrfy(C[1] == 0, '3913: C[1] == 0');
3495 vrfy(C[2] == 0, '3914: C[2] == 0');
3496 vrfy(size(C) == 3, '3915: size(C) == 3');
3499 print '3916: mat D[] = { }';
3500 vrfy(D[0] == 0, '3917: D[0] == 0');
3501 vrfy(size(D) == 1, '3918: size(D) == 1');
3502 print '3919: Ending test_noarg';
3504 print '066: parsed test_noarg';
3508 * test_ptest - more tests of the functions ptest, nextcand, prevcand
3510 read -once "test4000";
3511 print '067: read -once test4000';
3515 local tnum; /* test number */
3517 print '4000: Beginning test_ptest';
3519 tnum = test4000(1, 4001);
3521 print tnum: ': Ending test_ptest';
3523 print '068: parsed test_ptest()';
3527 * test_redc - REDC operation tests
3529 read -once "test4100";
3530 print '069: read -once test4100';
3534 local tnum; /* test number */
3536 print '4100: Beginning test_redc';
3538 tnum = test4100(1, 4101);
3540 print tnum: ': Ending test_redc';
3542 print '070: parsed test_redc()';
3546 * test_fileops - test various file operations
3548 define test_fileops()
3550 local a, b, c, f, m, n, p, r, s, x, y, z;
3554 local LCN = "Landon\nCurt\nNoll\n";
3555 local long = "0123456789abcdef0123456789abcdef";
3557 print '4200: Beginning test_fileops';
3562 x = rm("-f", "junk4200");
3563 print '4201: x = rm("-f", "junk4200")';
3564 vrfy(!iserror(f = fopen("junk4200", "w+")),
3565 '4202: !iserror(f = fopen("junk4200", "w+"))');
3566 vrfy(!iserror(fputs(f, LCN)), '4203: !iserror(fputs(f, LCN))');
3567 vrfy(isnull(rewind(f)), '4204: isnull(rewind(f))');
3568 vrfy(fgetfield(f) == L, '4205: fgetfield(f) == L');
3569 vrfy(fgetfield(f) == C, '4206: fgetfield(f) == C');
3570 vrfy(fgetfield(f) == N, '4207: fgetfield(f) == N');
3571 vrfy(isnull(fgetfield(f)), '4208: isnull(fgetfield(f))');
3572 vrfy(isnull(rewind(f)), '4209: isnull(rewind(f))');
3573 vrfy(fgetline(f) == L, '4210: fgetline(f) == L');
3574 vrfy(fgetline(f) == C, '4211: fgetline(f) == C');
3575 vrfy(fgetline(f) == N, '4212: fgetline(f) == N');
3576 vrfy(isnull(fgetline(f)), '4213: isnull(fgetline(f))');
3577 vrfy(isnull(rewind(f)), '4214: isnull(rewind(f))');
3578 vrfy(fgets(f) == strcat(L,"\n"), '4215: fgets(f) == strcat(L,"\\n")');
3579 vrfy(fgets(f) == strcat(C,"\n"), '4216: fgets(f) == strcat(C,"\\n")');
3580 vrfy(fgets(f) == strcat(N,"\n"), '4217: fgets(f) == strcat(N,"\\n")');
3581 vrfy(isnull(fgets(f)), '4218: isnull(fgets(f))');
3582 vrfy(isnull(rewind(f)), '4219: isnull(rewind(f))');
3583 vrfy(fgetstr(f) == LCN, '4220: fgetstr(f) == LCN');
3584 vrfy(isnull(fclose(f)), '4221: isnull(fclose(f))');
3585 vrfy(isnull(fclose(f)), '4222: isnull(fclose(f))');
3590 vrfy(!iserror(f = fopen("junk4200", "w+")),
3591 '4223: !iserror(f)');
3593 vrfy(isnull(fputstr(f, L, C, N)),
3594 '4224: isnulll(fputstr(f, L, C, N))');
3595 vrfy(isnull(rewind(f)), '4225: isnull(rewind(f))');
3596 vrfy(fgetstr(f) == L, '4226: fgetstr(f) == L');
3597 vrfy(fgetstr(f) == C, '4227: fgetstr(f) == C');
3598 vrfy(fgetstr(f) == N, '4228: fgetstr(f) == N');
3599 vrfy(isnull(fgetstr(f)), '4229: isnull(fgetstr(f))');
3601 print '4230: n = ftell(f)';
3602 vrfy(isnull(fputs(f,L,"\n",C,"\n",N,"\n")),
3603 '4231: isnull(fputs(f,L,"\\n",C,"\\n",N,"\\n"))');
3605 print '4232: fseek(f, n)';
3606 vrfy(fgetstr(f) == LCN, '4233: fgetstr(f) == LCN');
3607 vrfy(isnull(fclose(f)), '4234: isnull(fclose(f))');
3612 a = exp(27, 1e-1000);
3613 print '4235: a = exp(27, 1e-1000)';
3614 b = sqrt(7 + 5i, 1e-2000);
3615 print '4236: b = sqrt(7 + 5i, 1e-2000)';
3616 c = config("display", 1000);
3617 print '4237: c = config("display", 1000)';
3618 vrfy(!iserror(f=fopen("junk4200","w+")),
3619 '4238: !iserror(f=fopen("junk4200","w+"))');
3620 vrfy(!iserror(fprintf(f, "%f\n\tand\n\t%r",a,b)),
3621 '4239: !iserror(fprintf(f, "%f\\n\\tand\\n\\t%r",a,b))');
3622 vrfy(isnull(rewind(f)), '4240: isnull(rewind(f))');
3623 vrfy(fscanf(f,"%f and %r",x,y)==2,
3624 '4241: fscanf(f,"%f and %r",x,y)==2');
3625 vrfy(x == a && y == b, '4242: x == a && y == b');
3626 vrfy(!iserror(freopen(f, "w+")), '4243: !iserror(freopen(f, "w+"))');
3628 print '4244: L = "Landon\\n"';
3630 print '4245: C = "\tCurt\\n"';
3632 print '4246: N = "\\t\\tNoll\\n"';
3633 vrfy(isnull(fputs(f, L, "|", C, "[", N, "]" )),
3634 '4247: isnull(fputs(f, L, "|", C, "[", N, "]" ))');
3635 vrfy(isnull(rewind(f)), '4248: isnull(rewind(f))');
3636 vrfy(fscanf(f, "%[^|]%*c%[^[]%*c%[^]]", x,y,z) == 3,
3637 '4249: fscanf(f, "%[^|]%*c%[^[]%*c%[^]]", x,y,z) == 3');
3638 vrfy(x == L && y == C && z == N,
3639 '4250: x == L && y == C && z == N');
3640 vrfy(isnull(rewind(f)), '4251: isnull(rewind(f))');
3641 vrfy(fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2,
3642 '4252: fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2');
3644 print '4253: fseek(f, m)';
3645 vrfy(fscanf(f, "%3c", x) == 1, '4254: fscanf(f, "%3c", x) == 1');
3646 vrfy(x == "\tCu", '4255: x == "\tCu"');
3648 print '4256: fseek(f, n)';
3649 vrfy(fscanf(f, "%s", y) == 1, '4257: fscanf(f, "%s", y) == 1');
3650 vrfy(y == "Noll", '4258: y == "Noll"');
3651 vrfy(isnull(fclose(f)), '4259: isnull(fclose(f))');
3656 vrfy(!iserror(p=fpathopen("junk4200","r",".")),
3657 '4260: !iserror(p=fparhopen("junk4200","r","."))');
3658 vrfy(!iserror(fclose(p)), '4261: !iserror(fclose(p))');
3659 vrfy(!iserror(r=fpathopen("regress.cal","r")),
3660 '4262: !iserror(r=fparhopen("regress.cal","r","."))');
3661 vrfy(!iserror(fclose(r)), '4263: !iserror(fclose(r))');
3664 * verify non-stack overflow on long filenames
3666 long = long + long + long + long;
3667 print '4264: long = long + long + long + long;';
3668 long = long + long + long + long;
3669 print '4265: long = long + long + long + long;';
3670 vrfy(strlen(long) == 512, '4266: strlen(long) == 512');
3671 /* bump ecnt up by 1 */
3673 print '4267: ++ecnt;';
3674 vrfy(isfile(p=fopen(long,"r")) == 0,
3675 '4268: isfile(p=fopen(long,"r")) == 0');
3678 * test fgetfile() and fgetline()
3680 vrfy(!iserror(p=fopen("tmp4200","w")),
3681 '4269: !iserror(p=fopen("tmp4200","w"))');
3682 vrfy(!iserror(fputs(p,"chongo\n")),
3683 '4270: !iserror(fputs(p,"chongo\n"))');
3684 vrfy(!iserror(fputs(p,"w\0a\0s\n")),
3685 '4271: !iserror(fputs(p,"w\0a\0s\n"))');
3686 vrfy(!iserror(fputs(p,"here\n")),
3687 '4272: !iserror(fputs(p,"here\n"))');
3688 vrfy(!iserror(fclose(p)), '4273: !iserror(fclose(p))');
3689 vrfy(!iserror(p=fopen("tmp4200","r")),
3690 '4274: !iserror(p=fopen("tmp4200","r"))');
3691 vrfy(!iserror(s=fgetline(p)), '4275: !iserror(s=fgetline(p))');
3692 vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0');
3693 vrfy(!iserror(s=fgetfile(p)), '4277: !iserror(s=fgetfile(p))');
3694 vrfy(strcmp(s,"w\0a\0s\nhere\n") == 0,
3695 '4278: strcmp(s,"w\0a\0s\nhere\n") == 0');
3696 vrfy(!iserror(fclose(p)), '4279: !iserror(fclose(p))');
3702 print '4280: x = rm("junk4200")';
3704 print '4281: x = rm("tmp4200")';
3706 print '4282: Ending test_fileops';
3708 print '071: parsed test_fileops()';
3712 * test_matdcl - test new matrix declaration syntax
3715 print '072: mat_X = mat[4]';
3716 mat mat_X1, mat_X2[2]; mat mat_X3[3];
3717 print '073: mat mat_X1, mat_X2[2]; mat mat_X3[3]';
3718 mat mat_Z0, mat_Z1 [2] = {1,2};
3719 print '074: mat mat_Z0, mat_Z1 [2] = {1,2}';
3720 define test_matdcl()
3723 local mat mat_Y1, mat_Y2[2], mat_Y3[3];
3724 local mat M0, M1, M2[2,2];
3727 print '4300: Beginning test_matdcl';
3729 vrfy(size(mat_X0) == 4, '4301: size(mat_X0) == 4');
3730 vrfy(size(mat_X1) == 2, '4302: size(mat_X1) == 2');
3731 vrfy(size(mat_X2) == 2, '4303: size(mat_X2) == 2');
3732 vrfy(size(mat_X3) == 3, '4304: size(mat_X3) == 3');
3733 vrfy(ismat(mat_X0), '4305: ismat(mat_X0)');
3734 vrfy(ismat(mat_X1), '4306: ismat(mat_X1)');
3735 vrfy(ismat(mat_X2), '4307: ismat(mat_X2)');
3736 vrfy(ismat(mat_X3), '4308: ismat(mat_X3)');
3738 print '4309: mat_Y0 = mat[4]';
3739 vrfy(size(mat_Y0) == 4, '4310: size(mat_Y0) == 4');
3740 vrfy(size(mat_Y1) == 2, '4311: size(mat_Y1) == 2');
3741 vrfy(size(mat_Y2) == 2, '4312: size(mat_Y2) == 2');
3742 vrfy(size(mat_Y3) == 3, '4313: size(mat_Y3) == 3');
3743 vrfy(ismat(mat_Y0), '4314: ismat(mat_Y0)');
3744 vrfy(ismat(mat_Y1), '4315: ismat(mat_Y1)');
3745 vrfy(ismat(mat_Y2), '4316: ismat(mat_Y2)');
3746 vrfy(ismat(mat_Y3), '4317: ismat(mat_Y3)');
3747 vrfy(size(mat_Z0) == 2, '4318: size(mat_Z0) == 2');
3748 vrfy(size(mat_Z1) == 2, '4319: size(mat_Z1) == 2');
3749 vrfy(ismat(mat_Z0), '4320: ismat(mat_Z0)');
3750 vrfy(ismat(mat_Z1), '4321: ismat(mat_Z1)');
3751 vrfy(mat_Z0 == mat_Z1, '4322: mat_Z0 == mat_Z1');
3752 vrfy(mat_Z0 == (mat[2] = {1,2}), '4323: mat_Z0 == (mat[2] = {1,2})');
3753 vrfy(mat_Z0[0] == 1, '4324: mat_Z0[0] == 1');
3754 vrfy(mat_Z0[1] == 2, '4325: mat_Z0[1] == 2');
3756 print '4326: mat_Z1 = {,3}';
3757 vrfy(mat_Z0 != mat_Z1, '4327: mat_Z0 != mat_Z1');
3758 vrfy(mat_Z1[0] == 1, '4328: mat_Z1[0] == 1');
3759 vrfy(mat_Z1[1] == 3, '4329: mat_Z1[1] == 3');
3761 print '4330: mat_X3 = {2,3,5}';
3763 print '4331: mat_X3 += {3,4,5}';
3764 vrfy(mat_X3[0] == 5, '4332: mat_X3[0] == 5');
3765 vrfy(mat_X3[1] == 7, '4333: mat_X3[1] == 7');
3766 vrfy(mat_X3[2] == 10, '4334: mat_X3[2] == 10');
3768 print '4335: mat_Y3 = mat_X3';
3770 print '4336: mat_Y3 -= {0,1,}';
3771 vrfy(mat_Y3[0] == 0, '4337: mat_Y3[0] == 0');
3772 vrfy(mat_Y3[1] == 6, '4338: mat_Y3[1] == 6');
3773 vrfy(mat_Y3[2] == 8, '4339: mat_Y3[2] == 8');
3775 print '4340: ecnt += 2';
3777 print '4341: mat_Y3 += 2';
3778 vrfy(mat_Y3 == error(10003), '4342: mat_Y3 == error(10003)');
3779 vrfy(errcount() == ecnt, '4343: errcount() == ecnt');
3781 print '4344: mat_Z0 += { }';
3782 vrfy(mat_Z0[0] == 2, '4345: mat_Z0[0] == 2');
3783 vrfy(mat_Z0[1] == 4, '4346: mat_Z0[1] == 4');
3784 mat_Y0 = {mat_Z0, ,mat_Z1, mat_X3};
3785 print '4347: mat_Y0 = {mat_Z0, ,mat_Z1, mat_X3}';
3786 vrfy(size(mat_Y0) == 4, '4348: size(mat_Y0) == 4');
3787 for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i]);
3788 print '4349: for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i])';
3789 mat_X0==(mat[4]={2,1,2,3});
3790 print '4350: mat_X0==(mat[4]={2,1,2,3})';
3791 vrfy(mat_Y0[0] == mat_Z0, '4351: mat_Y0[0] == mat_Z0');
3792 vrfy(mat_Y0[1] == 0, '4352: mat_Y0[1] == 0');
3793 vrfy(mat_Y0[2] == mat_Z1, '4353: mat_Y0[2] == mat_Z1');
3794 vrfy(mat_Y0[3] == mat_X3, '4354: mat_Y0[3] == mat_X3');
3795 vrfy(mat_Y0[0][0] == 2, '4355: mat_Y0[0][0] == 2');
3796 vrfy(mat_Y0[0][1] == 4, '4356: mat_Y0[0][1] == 4');
3797 vrfy(mat_Y0[2][0] == 1, '4357: mat_Y0[2][0] == 1');
3798 vrfy(mat_Y0[2][1] == 3, '4358: mat_Y0[2][1] == 3');
3799 vrfy(mat_Y0[3][0] == 5, '4359: mat_Y0[3][0] == 5');
3800 vrfy(mat_Y0[3][1] == 7, '4360: mat_Y0[3][1] == 7');
3801 vrfy(mat_Y0[3][2] == 10, '4361: mat_Y0[3][2] == 10');
3803 M0 = {(mat[2]={5,17}),(mat[2]={3,4}),(mat[2]={2,3}),(mat[2]={1,2})};
3804 print '4362: M0 = {(mat[2]={5,17}), ...}';
3805 M1 = {(mat[2]={5,3}),(mat[2]={2,5}),(mat[2]={1,5}),(mat[2]={3,2})};
3806 print '4363: M1 = {(mat[2]={5,3}), ...}';
3808 print '4364: M2 = M0+M1';
3809 vrfy(M2[0,0]==(mat[2]={10,20}), '4365: M2[0,0]==(mat[2]={10,20})');
3810 vrfy(M2[0,1]==(mat[2]={5,9}), '4366: M2[0,1]==(mat[2]={5,9})');
3811 vrfy(M2[1,0]==(mat[2]={3,8}), '4367: M2[1,0]==(mat[2]={3,20})');
3812 vrfy(M2[1,1]==(mat[2]={4,4}), '4368: M2[1,1]==(mat[2]={4,4})');
3814 print '4369: Ending test_matdcl';
3816 print '075: parsed test_matdcl()';
3820 * test_objmat - test combined obj and mat operations
3822 define test_objmat()
3824 static obj surd P, R, S, T, U;
3825 local mat M0[2] = {5,17};
3826 local mat M1[2] = {3,4};
3827 local mat M2[2,2] = {1,2,3,5};
3828 local mat M3[2,2] = {3,5,7,11};
3829 local mat M4[2,2] = {51,82,116,187};
3834 print '4400: Beginning test_objmat';
3837 print '4401: surd_type == -1';
3839 print '4402: P = {M0,M1}';
3840 vrfy(P == surd(M0,M1), '4403: P == surd(M0,M1)');
3841 vrfy(P != surd(M1,M0), '4404: P != surd(M1,M0)');
3842 vrfy(conj(P)==surd(M0,-M1), '4405: conj(P)==surd(M0,-M1)');
3844 print '4406: Q = surd_value(P)';
3845 vrfy(ismat(Q), '4407: ismat(Q)');
3846 vrfy(Q == (mat[2]={5+3i,17+4i}), '4408: Q == (mat[2]={5+3i,17+4i})');
3848 print '4409: R = {M2,M3}';
3849 vrfy(norm(R) == M4, '4410: norm(R) == M4');
3850 vrfy(det(surd_value(R^2)) == -23-6i, \
3851 '4411: det(surd_value(R^2)) == -23-6i');
3852 vrfy(det(norm(R^5))==268107761663283843865, \
3853 '4412: det(norm(R^5))==268107761663283843865');
3855 print '4413: S = {M2+M3, M2-M3}';
3856 T = {M2+3*M3, 5*M2-M3};
3857 print '4414: T = {M2+3*M3, 5*M2-M3}';
3858 U = {(M4 -= {50,80,110,180}), M4+M2};
3859 print '4415: U = {(M4 -= {50,80,110,180}), M4+M2}';
3860 vrfy(det(surd_value(R*S*T*U)) == 480-15040i,
3861 '4416: det(surd_value(R*S*T*U)) == 480-15040i');
3862 vrfy(det(surd_value(R*S+T*U)) == 78+514i,
3863 '4417: det(surd_value(R*S+T*U)) == 78+514i');
3864 V = norm(det(surd_value(R^5+S^5+T^5+U^5)));
3865 print '4418: V = norm(det(surd_value(R^5+S^5+T^5+U^5)))';
3866 vrfy(V == 41952632964892462488299378, \
3867 '4419: V == 41952632964892462488299378');
3868 V = norm(det(surd_value(R^5-S^5+T^5-U^5)));
3869 print '4420: V = norm(det(surd_value(R^5-S^5+T^5-U^5)))';
3870 vrfy(V == 40891924356202870926321650, \
3871 '4421: V == 40891924356202870926321650');
3874 vrfy((mat [3] = {2,3,5})+(mat[3] = {7,11,13}) == (mat[3]={9,14,18}),\
3875 '4422: (mat [3] = {2,3,5})+(mat[3] = {7,11,13}) == (mat[3]={9,14,18})');
3877 vrfy((mat [2,2] = {2,3,5,7})^2 == (mat[2,2] = {19, 27, 45, 64}),\
3878 '4423: (mat [2,2] = {2,3,5,7})^2 == (mat[2,2] = {19, 27, 45, 64})');
3880 vrfy((mat [] = {1,2,3}) == (mat[3] = {1,2,3}),
3881 '4424: (mat [] = {1,2,3}) == (mat[3] = {1,2,3})');
3884 print '4425: mat A[3] = {2,3,5}';
3885 mat A[3] = {A[0], A[2], A[1]};
3886 print '4426: mat A[3] = {A[0], A[2], A[1]}';
3887 vrfy(A == (mat[3] = {2, 5, 3}), '4427: A == (mat[3] = {2, 5, 3})');
3889 B = mat[3] = {2,5,3};
3890 print '4428: B = mat[3] = {2,5,3}';
3891 vrfy(A == B, '4429: A == B');
3893 mat A[2] = {A[1], A[2]};
3894 print '4430: mat A[2] = {A[1], A[2]}';
3895 vrfy(A == (mat[2] = {5, 3}), '4431: A == (mat[2] = {5, 3})');
3898 print '4432: A = B';
3899 A = {A[0], A[2], A[1]};
3900 print '4433: A = {A[0], A[2], A[1]}';
3901 vrfy(A == (mat[3] = {2, 3, 3}), '4434: A == (mat[3] = {2, 3, 3})');
3903 A = mat[3] = {1,2} = {,3,4};
3904 print '4435: A = mat[3] = {1,2} = {,3,4}';
3905 vrfy(A == (mat[3] = {1,3,4}), '4436: A == (mat[3] = {1,3,4})');
3907 mat A[4] = {1,2,3,4};
3908 print '4437: mat A[4] = {1,2,3,4}';
3910 print '4438: A = {,5,,6}';
3911 vrfy(A == (mat[4] = {1,5,3,6}), '4439: A == (mat[4] = {1,5,3,6})');
3914 print '4440: A = {7}';
3915 vrfy(A == (mat[4] = {7,5,3,6}), '4441: A == (mat[4] = {7,5,3,6})');
3918 print '4442: mat M[2]';
3919 mat A, B, C [3] = {M, M, M};
3920 print '4443: mat A, B, C [3] = {M, M, M}';
3922 A = {{2, 3}, {5, 7}, {11, 13}};
3923 print '4444: A = {{2, 3}, {5, 7}, {11, 13}}';
3924 B = {{1, 2}, {3, 4}, {5, 6}};
3925 print '4445: B = {{1, 2}, {3, 4}, {5, 6}}';
3926 C = {{3, 5}, {8, 11}, {16, 19}};
3927 print '4446: C = {{3, 5}, {8, 11}, {16, 19}}';
3929 vrfy(A + B == C, '4447: A + B == C');
3932 print '4448: mat A[2][3]';
3933 A = {{1, 2, 3}, {4, 5, 6}};
3934 print '4449: A = {{1, 2, 3}, {4, 5, 6}}';
3935 vrfy(A[0][1] == 2, '4450: A[0][1] == 2');
3937 vrfy(A[1,0] == 4, '4451: A[1,0] == 4');
3939 B = mat[2][3] = {{1, 2, 3}, {4, 5, 6}};
3940 print '4452: B = mat[2][3] = {{1, 2, 3}, {4, 5, 6}}';
3941 vrfy(A == B, '4453: A == B');
3943 mat A[2][3] = {{1, 2, 3}, {4, 5, 6}};
3944 print '4454: mat A[2][3] = {{1, 2, 3}, {4, 5, 6}}';
3945 vrfy(A == B, '4455: A == B');
3947 mat A[2][3] = {{1,2,3},4};
3948 print '4456: mat A[2][3] = {{1,2,3},4}';
3949 vrfy(A[0] == (mat[3] = {1,2,3}), '4457: A[0] == (mat[3] = {1,2,3})');
3951 vrfy(A[1] == 4, '4458: A[1] == 4');
3954 print '4459: A += {{3,5,7}, 11}';
3956 vrfy(A[0] == (mat[3]={4,7,10}), '4460: A[0] == (mat[3]={4,7,10})');
3958 vrfy(A[1] == 15, '4461: A[1] == 15');
3960 mat A[2,2][2,2]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
3961 print '4462: mat A[2,2][2,2]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}';
3963 print '4463: B = A^2';
3965 vrfy(B[0,0] == (mat[2,2] = {118, 132, 166, 188}), \
3966 '4464: B[0,0] == (mat[2,2] = {118, 132, 166, 188})');
3968 print '4465: Ending test_objmat';
3970 print '4500: reserved for future expansion of test_objmat';
3972 print '076: parsed test_objmat()';
3976 * test_fileop - test file operations
3978 read -once "test4600";
3979 print '077: read -once test4600';
3981 define test_fileop()
3983 local tnum; /* test number */
3985 print '4600: Beginning test_fileop';
3987 tnum = test4600(1, 4601);
3989 print tnum: ': Ending test_fileop';
3991 print '078: parsed test_fileop()';
3997 x_081 = isqrt(2e5000);
3998 print '079: x_081 = isqrt(2e5000)'
3999 s_x_081 = str(x_081);
4000 print '080: s_x_081 = str(x_081)';
4001 d_081 = rm("-f", "test082.cal");
4002 print '081: d_081 = rm("-f", "test082.cal")';
4004 print '082: write test082.cal';
4005 read "./test082.cal";
4006 print '083: read "./test082.cal"';
4007 d_081 = rm("test082.cal");
4008 print '084: d081 = rm("test082.cal")';
4009 vrfy(__ == 63, '085: __ == 63');
4010 vrfy(x_081 == isqrt(2e5000), '086: x_081 == isqrt(2e5000)');
4014 * test_charset - test the ASCII character set and \'s
4016 define test_charset()
4018 print '4700: Beginning test_charset';
4020 vrfy("\a" == char(7), '4701: "\\a" == char(7)');
4021 vrfy("\v" == char(11), '4702: "\\v" == char(11)');
4022 vrfy("\e" == char(27), '4703: "\\e" == char(27)');
4023 vrfy("\\" == char(92), '4704: "\\\\" == char(92)');
4024 vrfy("\101" == "A", '4705: "\\101" == "A"');
4025 vrfy("\123" == char(0123), '4706: "\\123" == char(0123)');
4026 vrfy("\123\124" == "ST", '4707: "\\123\\124" == "ST"');
4027 vrfy("\311" == char(201), '4708: "\\311" == char(201)');
4028 vrfy("\119" == "\t9", '4709: "\\119" == "\t9"');
4029 vrfy("\765" == "\365", '4710: "\\765" == "\365"');
4030 vrfy("\x61" == "a", '4711: "\\x61" == "a"');
4031 vrfy("\x73" == "s", '4712: "\\x73" == "s"');
4032 vrfy("\xea" == char(234), '4713: "\\xea" == char(234)');
4033 vrfy("\x61\x62\x63" == "abc", '4714: "\\x61\\x62\\x63" == "abc"');
4034 vrfy("\x8g" == "\bg", '4715: "\\x8g" == "\bg"');
4035 vrfy(eval('"\\\\"') == "\\",
4036 '4716: eval(\'"\\\\\\\\"\') == "\\\\"');
4038 print '4717: Ending test_charset';
4040 print '087: parsed test_fileop()';
4044 * test_strprintf - test strprintf calls
4046 define test_strprintf()
4048 local callcfg; /* caller configuration value */
4049 local c; /* modified configuration */
4051 print '4800: Beginning test_strprintf';
4054 callcfg = config("all");
4055 print '4801: callcfg = config("all")';
4056 c = config("mode", "frac");
4057 print '4802: c = config("mode", "frac")';
4058 c = config("outround", 24);
4059 print '4803: c = config("outround", 24)';
4060 c = config("display", 2);
4061 print '4804: c = config("display", 2)';
4062 c = config("tilde", 0);
4063 print '4805: c = config("tilde", 0)';
4064 c = config("leadzero", 0);
4065 print '4806: c = config("leadzero", 0)';
4066 c = config("fullzero", 0);
4067 print '4807: c = config("fullzero", 0)';
4069 /* tests with tilde == 0 */
4070 vrfy(strprintf("%d%d", 27, 29) == "2729",
4071 '4808: strprintf("%d%d", 27, 29) == "2729"');
4072 vrfy(strprintf("%5d%3d", 27, 29) == " 27 29",
4073 '4809: strprintf("%5d%3d", 27, 29) == " 27 29"; ');
4074 vrfy(strprintf("%-5d%-3d", 27, 29) == "27 29 ",
4075 '4810: strprintf("%-5d%-3d", 27, 29) == "27 29 "');
4076 vrfy(strprintf("%f", 1.375) == "1.38",
4077 '4811: strprintf("%f", 1.375) == "1.38"');
4078 vrfy(strprintf("%f", 1.385) == "1.38",
4079 '4812: strprintf("%f", 1.385) == "1.38"');
4080 vrfy(strprintf("%f", .375) == ".38",
4081 '4813: strprintf("%f", .375) == ".38"');
4082 vrfy(strprintf("%f", .385) == ".38",
4083 '4814: strprintf("%f", .385) == ".38"');
4085 /* tests with tilde == 1 */
4086 c = config("tilde", 1);
4087 print '4815: c = config("tilde", 1)';
4088 vrfy(strprintf("%f", 1.375) == "~1.38",
4089 '4816: strprintf("%f", 1.375) == "~1.38"');
4090 vrfy(strprintf("%f", 27/29) == "~.93",
4091 '4817: strprintf("%f", 27/29) == "~.93"');
4092 vrfy(strprintf("%r", 27/29) == "27/29",
4093 '4818: strprintf("%r", 27/29) == "27/29"');
4094 vrfy(strprintf("%o", 27/29) == "033/035",
4095 '4819: strprintf("%o", 27/29) == "033/035"');
4096 vrfy(strprintf("%x", 27/29) == "0x1b/0x1d",
4097 '4820: strprintf("%x", 27/29) == "0x1b/0x1d"');
4098 vrfy(strprintf("%b", 27/29) == "0b11011/0b11101",
4099 '4821: strprintf("%b", 27/29) == "0b11011/0b11101"');
4100 vrfy(strprintf("%e", 12345) == "~1.23e4",
4101 '4822: strprintf("%e", 12345) == "~1.23e4"');
4103 /* mode tests with tilde == 0 */
4104 c = config("tilde", 0);
4105 print '4823: c = config("tilde", 0)';
4106 vrfy(strprintf("%e", 12345) == "1.23e4",
4107 '4824: strprintf("%e", 12345) == "1.23e4"');
4108 vrfy(strprintf("%.3e", 12345) == "1.234e4",
4109 '4825: strprintf("%.3e", 12345) == "1.234e4"');
4110 vrfy(strprintf("%e", .00012345) == "1.23e-4",
4111 '4826: strprintf("%e", .00012345) == "1.23e-4"');
4112 vrfy(strprintf("%d %d", 27) == "27 ",
4113 '4827: strprintf("%d %d", 27) == "27 "');
4114 vrfy(strprintf("%d", 27, 29) == "27",
4115 '4828: strprintf("%d", 27, 29) == "27"');
4116 vrfy(strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93",
4117 '4829: strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93"');
4118 vrfy(strprintf("%s", "abc") == "abc",
4119 '4830: strprintf("%s", "abc") == "abc"');
4120 vrfy(strprintf("%f", "abc") == "abc",
4121 '4831: strprintf("%f", "abc") == "abc"');
4122 vrfy(strprintf("%e", "abc") == "abc",
4123 '4832: strprintf("%e", "abc") == "abc"');
4124 vrfy(strprintf("%5s", "abc") == " abc",
4125 '4833: strprintf("%5s", "abc") == " abc"');
4126 vrfy(strprintf("%-5s", "abc") == "abc ",
4127 '4834: strprintf("%-5s", "abc") == "abc "');
4129 /* restore config */
4130 c = config("all", callcfg);
4131 print '4835: c = config("all", callcfg)';
4133 print '4836: Ending test_strprintf';
4135 print '088: parsed test_fileop()';
4139 * global and static assignment tests
4141 global a = 10, b, c d = 20, e;
4142 print '089: global a = 10, b, c d = 20, e, f';
4143 vrfy(a == 10, '090: a == 10');
4144 vrfy(b == 0, '091: b == 0');
4145 vrfy(c == 20, '092: c == 20');
4146 vrfy(d == 20, '093: d == 20');
4147 vrfy(e == 0, '094: e == 0');
4148 vrfy(f == 0, '095: f == 0');
4149 static a b = 30, c, e = 30;
4150 print '096: static a b = 30, c, e = 30';
4151 vrfy(a == 30, '097: a == 30');
4152 vrfy(b == 30, '098: b == 30');
4153 vrfy(c == 0, '099: c == 0');
4154 vrfy(e == 30, '100: e == 30');
4156 print '101: global a, b';
4157 vrfy(a == 10, '102: a == 10');
4158 vrfy(b == 0, '103: b == 0');
4159 static mat A, B[2,2] = {1,2,3,4};
4160 print '104: static mat A, B[2,2] = {1,2,3,4}';
4161 define f100(x,y) = (mat [2,2] = {x,0,0,y}) * A;
4162 print '105: define f100(x,y) = (mat [2,2] = {x,0,0,y}) * A';
4163 define g100(x) = (mat[2,2] = {x,x,x,x}) + B;
4164 print '106: define g100(x) = (mat[2,2] = {x,x,x,x}) + B';
4165 define h100(a,b,c,d) = ((B = {a,b,c,d}), null());
4166 print '107: define h100(a,b,c,d) = ((B = {a,b,c,d}), null())';
4168 print '108: global A, B';
4169 vrfy(A == 0, '109: A == 0');
4170 vrfy(B == 0, '110: B == 0');
4171 x = test(f100(2,3) == (mat[2,2] = {2, 4, 9, 12}));
4172 vrfy(x, '111: test(f100(2,3) == (mat[2,2] = {2, 4, 9, 12}))');
4173 x = test(g100(4) == (mat[2,2] = {5,6,7,8}));
4174 vrfy(x, '112: test(g100(4) == (mat[2,2] = {5,6,7,8}))');
4175 x = test(h100(2,3,5,7) == null());
4176 vrfy(x, '113: test(h100(2,3,5,7) == null())');
4177 x = test(g100(4) == (mat[2,2] = {6,7,9,11}));
4178 vrfy(x, '114: test(g100(4) == (mat[2,2] = {6,7,9,11}))');
4179 global obj point {x,y} P Q = {1,2}, R={3,4}, S;
4180 print '115: global obj point {x,y} P, Q = {1,2}, R={3,4}, S';
4181 vrfy(P.x == 1, '116: P.x == 1');
4182 vrfy(P.y == 2, '117: P.y == 2');
4183 vrfy(Q.x == 1, '118: Q.x == 1');
4184 vrfy(Q.y == 2, '119: Q.y == 2');
4185 vrfy(R.x == 3, '120: R.x == 3');
4186 vrfy(R.y == 4, '121: R.y == 4');
4187 vrfy(S.x == 0, '122: S.x == 0');
4188 vrfy(S.y == 0, '123: S.y == 0');
4192 * test_listsearch - test searching in lists
4194 define test_listsearch()
4198 print '4900: Beginning test_listsearch';
4201 print '4901: L = list()';
4202 vrfy(isnull(search(L,1)), '4902: isnull(search(L,1))');
4203 vrfy(isnull(rsearch(L,1)), '4903: isnull(search(L,1))');
4204 L = list(0,1,2,3,0,1,2,3,0,1);
4205 print '4904: L = list(0,1,2,3,0,1,2,3,0,1)';
4206 vrfy(search(L,0) == 0, '4905: search(L,0) == 0');
4207 vrfy(rsearch(L,0) == 8, '4906: rsearch(L,0) == 8');
4208 vrfy(search(L,0,2) == 4, '4907: search(L,0,2) == 4');
4209 vrfy(rsearch(L,0,7) == 4, '4908: rsearch(L,0,7) == 4');
4210 vrfy(isnull(search(L,2,7)), '4909: isnull(search(L,2,7))');
4211 vrfy(isnull(rsearch(L,3,2)), '4910: isnull(rsearch(L,3,2))');
4212 vrfy(isnull(search(L,0,1,4)), '4911: isnull(search(L,0,1,4)');
4213 vrfy(isnull(rsearch(L,0,1,4)), '4912: isnull(rsearch(L,0,1,4)');
4214 vrfy(search(L,0,-5) == 8, '4913: search(L,0,-5) == 8');
4215 vrfy(rsearch(L,0,-9,-2) == 4, '4914: rsearch(L,0,-9,-2) == 4');
4216 vrfy(isnull(search(L,3,20)), '4915: isnull(search(L,3,20)');
4217 vrfy(isnull(search(L,3,0,-20)), '4916: isnull(search(L,3,0,-20)');
4218 vrfy(isnull(rsearch(L,3,20,2)), '4917: isnull(rsearch(L,3,20,2)');
4219 vrfy(rsearch(L,3,-20,20) == 7, '4918: rsearch(L,3,-20,20) == 7');
4221 print '4919: Ending test_strprintf';
4223 print '124: parsed test_listsearch()';
4227 * test_filesearch - test searching in files
4229 * This function is designed to trigger 22 errors, so we bump the
4230 * errmax by 22 during this call.
4232 define test_filesearch()
4234 local f, g; /* open files */
4235 local s; /* local string */
4236 local a, b, c, d; /* new error values */
4239 print '5000: Beginning test_filesearch';
4244 print '5001: x = rm("-f", "junk5000")';
4245 x = rm("-f", "junk5000");
4246 f = fopen("junk5000", "w");
4247 print '5002: f = fopen("junk5000", "w")';
4249 prob("Unable to open \"junk5000\" for writing");
4252 print '5003: if (iserror(f)) { ... }';
4253 s = "alpha beta gamma ";
4254 print '5004: s = "alpha beta gamma "';
4257 print '5005: fputs(f, s)';
4259 print '5006: fflush(f)';
4260 print '5007: test unused';
4262 /* bump errmax up by 16 */
4264 print '5008: ecnt += 16';
4266 vrfy(search(f, 45) == error(10122),
4267 '5009: search(f, 45) == error(10122)');
4268 vrfy(search(f, "a", 1/2) == error(10123),
4269 '5010: search(f, "a", 1/2) == error(10123)');
4270 vrfy(search(f, "a", 0, "b") == error(10124),
4271 '5011: search(f, "a", 0, "b") == error(10124)');
4272 vrfy(search(f, "a", 0) == error(10126),
4273 '5012: search(f, "a") == error(10126)');
4274 vrfy(rsearch(f, 45) == error(10128),
4275 '5013: rsearch(f, 45) == error(10128)');
4276 vrfy(rsearch(f, "a", "b") == error(10129),
4277 '5014: rsearch(f, "a", "b") == error(10129)');
4278 vrfy(rsearch(f, "a", 0, "b") == error(10130),
4279 '5015: rsearch(f, "a", 0, "b") == error(10130)');
4280 vrfy(rsearch(f, "a", 0) == error(10132),
4281 '5016: rsearch(f,"a",0) == error(10132)');
4283 /* errmax and errcount should be bumped up the 16 errors above */
4284 vrfy(errcount() == ecnt, '5017: errcount() == ecnt');
4286 if (freopen(f, "r")) {
4287 prob("Unable to reopen \"junk5000\" for reading");
4290 print '5018: if (freopen(f, "r")) { ... }';
4291 vrfy(fsize(f) == 17, '5019: fsize(f) == 17');
4292 vrfy(search(f, s, 0) == 0, '5020: search(f, s, 0) == 0');
4293 vrfy(ftell(f) == 17, '5021: ftell(f) == 17');
4294 vrfy(rsearch(f, s, 0) == 0, '5022: rsearch(f, s, 0) == 0');
4295 vrfy(ftell(f) == 16, '5023: ftell(f) == 16');
4296 vrfy(search(f, "", 2) == 2, '5024: search(f, "", 2) == 2');
4297 vrfy(ftell(f) == 2, '5025: ftell(f) == 2');
4298 vrfy(search(f, "", 17) == 17, '5026: search(f, "", 17) == 17');
4299 vrfy(ftell(f) == 17, '5027: ftell(f) == 17');
4300 vrfy(isnull(search(f, "", 100)),
4301 '5028: isnull(search(f, "", 100))');
4302 vrfy(ftell(f) == 17, '5029: ftell(f) == 17');
4303 vrfy(rsearch(f, "", 5) == 5, '5030: rsearch(f, "", 5) == 5');
4304 vrfy(ftell(f) == 5, '5031: ftell(f) == 5');
4305 vrfy(search(f, "beta", 0) == 6, '5032: search(f, "beta", 0) == 6');
4306 vrfy(ftell(f) == 10, '5033: ftell(f) == 10');
4307 vrfy(rsearch(f, "beta", 100) == 6,
4308 '5034: rsearch(f, "beta", 100) == 6');
4309 vrfy(ftell(f) == 9, '5035: ftell(f) == 9');
4310 vrfy(search(f, "a", 2) == 4, '5036: search(f, "a", 2) == 4');
4311 vrfy(ftell(f) == 5, '5037: ftell(f) == 5');
4312 vrfy(search(f, "a", 4) == 4, '5038: search(f, "a", 4) == 4');
4313 vrfy(search(f, "m") == 13, '5039: search(f, "m") == 13');
4314 vrfy(search(f, "m") == 14, '5040: search(f, "m") == 14');
4315 vrfy(isnull(search(f, "m")), '5041: isnull(search(f, "m"))');
4316 vrfy(rsearch(f, "m", 15) == 14, '5042: rsearch(f, "m", 14) == 14');
4317 vrfy(isnull(search(f, "beta", 7)),
4318 '5043: isnull(search(f, "beta", 7))');
4319 vrfy(ftell(f) == 14, '5044: ftell(f) == 14');
4320 vrfy(search(f,"a",2,15) == 4, '5045: search(f,"a",2,15) == 4');
4321 vrfy(ftell(f) == 5, '5046: ftell(f) == 5');
4322 vrfy(isnull(search(f,"a",2,4)), '5047: isnull(search(f,"a",2,4))');
4323 vrfy(ftell(f) == 4, '5048: ftell(f) == 4');
4324 vrfy(search(f,"a",,5) == 4, '5049: search(f,"a",,5) == 4');
4325 vrfy(rsearch(f,"a",2,15) == 12, '5050: rsearch(f,"a",2,15) == 12');
4326 vrfy(ftell(f) == 12, '5051: ftell(f) == 12');
4327 vrfy(rsearch(f,"a",2,12) == 9, '5052: rsearch(f,"a",2,12) == 9');
4329 /* generate 2 more errors */
4331 print '5053: ecnt += 2';
4333 print '5054: a = 2 + ""';
4335 print '5055: g = fopen(3, "r")';
4337 print '5056: c = 5^2';
4338 vrfy(errcount() == ecnt, '5057: errcount() == ecnt');
4340 /* generate 4 more errors by testing newerror */
4342 print '5058: ecnt += 4';
4343 a = newerror("alpha");
4344 print '5059: a = newerror("alpha")';
4345 b = newerror("beta");
4346 print '5060: b = newerror("beta")';
4347 c = newerror("alpha");
4348 print '5061: c = newerror("alpha")';
4349 d = newerror("beta");
4350 print '5062: d = newerror("beta")';
4351 vrfy(errcount() == ecnt, '5063: errcount() == ecnt');
4352 vrfy(a == c, '5064: a == c');
4353 vrfy(b == d, '5065: b == d');
4357 print '5066: error(0)';
4358 vrfy(strerror() == "No error", '5067: strerror() == "No error"');
4364 print '5068: fclose(f)';
4366 print '5069: rm("junk5000")';
4368 print '5070: Ending test_filesearch';
4370 print '125: parsed test_filesearch()';
4374 * test_newdecl - test the new code generator declaration scope and order
4376 read -once "test5100";
4377 print '126: read -once test5100';
4379 define test_newdecl()
4382 print '5100: Beginning test_newdecl';
4388 print '5101: test5100(1)';
4389 vrfy(a5100 == 0, '5102: a5100 == 0');
4390 vrfy(b5100 == 2, '5103: b5100 == 2');
4392 print '5104: test5100(1)';
4393 vrfy(a5100 == 0, '5105: a5100 == 0');
4394 vrfy(b5100 == 3, '5106: b5100 == 3');
4396 print '5107: test5100(1)';
4397 vrfy(a5100 == 0, '5108: a5100 == 0');
4398 vrfy(b5100 == 4, '5109: b5100 == 4');
4400 print '5110: test5100(2)';
4401 vrfy(a5100 == 3, '5111: a5100 == 3');
4402 vrfy(b5100 == 4, '5112: b5100 == 4');
4404 print '5113: test5100(2)';
4405 vrfy(a5100 == 4, '5114: a5100 == 4');
4406 vrfy(b5100 == 4, '5115: b5100 == 4');
4408 print '5116: test5100(2)';
4409 vrfy(a5100 == 5, '5117: a5100 == 5');
4410 vrfy(b5100 == 4, '5118: b5100 == 4');
4412 print '5119: test5100(3)';
4413 vrfy(a5100 == 5, '5120: a5100 == 5');
4414 vrfy(b5100 == 5, '5121: b5100 == 5');
4416 print '5122: test5100(9)';
4417 vrfy(a5100 == 5, '5123: a5100 == 5');
4418 vrfy(b5100 == 6, '5124: b5100 == 6');
4420 print '5125: test5100(0)';
4421 vrfy(a5100 == 5, '5126: a5100 == 5');
4422 vrfy(b5100 == 6, '5127: b5100 == 6');
4424 print '5128: test5100(-1)';
4425 vrfy(a5100 == 5, '5129: a5100 == 5');
4426 vrfy(b5100 == 6, '5130: b5100 == 6');
4428 print '5131: Ending test_newdecl';
4431 print '127: parsed test_newdecl()';
4435 * test_globstat - test the fix of a global/static bug
4437 read -once "test5200";
4438 print '128: read -once test5200';
4440 define test_globstat()
4442 print '5200: Beginning test_globstat';
4445 * test {f,g,h}5200 calls
4447 vrfy(a5200 == 10, '5201: a5200 == 10');
4448 vrfy(eval("a5200") == 10, '5202: eval("a5200") == 10');
4449 vrfy(f5200(1) == 21, '5203: f5200(1) == 21');
4450 vrfy(a5200 == 10, '5204: a5200 == 10');
4451 vrfy(eval("a5200") == 10, '5205: eval("a5200") == 10');
4452 vrfy(h5200(2) == 12, '5206: h5200(2) == 12');
4453 vrfy(a5200 == 10, '5207: a5200 == 10');
4454 vrfy(eval("a5200") == 10, '5208: eval("a5200") == 10');
4455 vrfy(g5200(3) == 33, '5209: g5200(3) == 33');
4456 vrfy(a5200 == 30, '5210: a5200 == 30');
4457 vrfy(eval("a5200") == 30, '5211: eval("a5200") == 30');
4458 vrfy(h5200(4) == 34, '5212: h5200(4) == 34');
4459 vrfy(f5200(5) == 25, '5213: f5200(5) == 25');
4460 vrfy(h5200(6) == 36, '5214: h5200(6) == 36');
4461 vrfy(g5200(7) == 37, '5215: g5200(7) == 37');
4462 vrfy(f5200(8) == 28, '5216: f5200(8) == 28');
4463 vrfy(g5200(9) == 39, '5217: g5200(9) == 39');
4464 vrfy(a5200 == 30, '5218: a5200 == 30');
4465 vrfy(eval("a5200") == 30, '5219: eval("a5200") == 30');
4467 print '5220: Ending test_globstat';
4469 print '129: parsed test_globstat()';
4473 * test_newop2 - test new label stuff
4475 define test_newop2(x) {if (x < 0) goto l130; ++x; l130: return x;}
4476 print '130: define test_newop3(x) {if (x < 0) goto l130; ++x; l130: return x;}'
4477 vrfy(test_newop2(100) == 101, '131: test_newop2(100) == 101');
4478 vrfy(test_newop2(-100) == -100, '132: test_newop2(-100) == -100');
4482 * test_newop3 - test new label stuff
4484 define test_newop3(x) {
4494 print '133: define test_newop3(x) ...';
4495 vrfy(test_newop3(2) == 1, '134: test_newop3(2) == 1');
4496 vrfy(test_newop3(3) == 2, '135: test_newop3(3) == 2');
4497 vrfy(test_newop3(4) == 3, '136: test_newop3(4) == 3');
4501 * Test random - Blum-Blum-Shub pseudo-random number generator
4503 define test_random()
4505 local init; /* initial generator state */
4506 local state0; /* a generator state */
4507 local state1; /* a generator state */
4511 print '5300: Beginning random test';
4513 /* test save and restore of the initial state */
4515 print '5301: tmp = srandom(0)';
4517 print '5302: init = srandom()';
4518 state0 = srandom(0);
4519 print '5303: state0 = srandom(0)';
4520 vrfy(state0 == init, '5304: state0 == init');
4522 /* test the additive 55 shuffle generator */
4524 print '5305: tmp = srandom(0)';
4525 vrfy(random() == 0x7fb838a8a0a95046, \
4526 '5306: random() == 0x7fb838a8a0a95046');
4527 vrfy(random() == 0xb9d9d9fb4440f7bb, \
4528 '5307: random() == 0xb9d9d9fb4440f7bb');
4529 tmp = srandom(init);
4530 print '5308: tmp = srandom(init)';
4531 vrfy(random() == 0x7fb838a8a0a95046, \
4532 '5309: random() == 0x7fb838a8a0a95046');
4533 vrfy(random() == 0xb9d9d9fb4440f7bb, \
4534 '5310: random() == 0xb9d9d9fb4440f7bb');
4536 /* test range interface */
4538 print '5311: tmp = srandom(0)';
4539 vrfy(random(12345678901234567890) == 0x7fb838a8a0a95046, \
4540 '5312: random(12345678901234567890) == 0x7fb838a8a0a95046');
4541 vrfy(random(216091) == 0x2e767, '5313: random(216091) == 0x2e767');
4542 vrfy(random(100) == 0x33, '5314: random(100) == 0x33');
4543 vrfy(random(-46,46) == -0xc, '5315: random(-46,46) == -0xc');
4545 print '5316: tmp = srandom(0)';
4546 vrfy(random(2^64) == 0x7fb838a8a0a95046, \
4547 '5317: random(2^64) == 0x7fb838a8a0a95046');
4548 vrfy(random(0,2^64) == 0xb9d9d9fb4440f7bb, \
4549 '5318: random(0,2^64) == 0xb9d9d9fb4440f7bb');
4551 /* test different forms of seeding the initial state */
4553 print '5319: tmp = srandom(0)';
4554 vrfy(srandom() == init, '5320: srandom() == init');
4555 tmp = srandom(0x87e6ec938ff55aa5<<64);
4556 print '5321: tmp = srandom(0x87e6ec938ff55aa5<<64)';
4557 vrfy(srandom() == init, '5322: srandom() == init');
4558 tmp = srandom(state0);
4559 print '5323: tmp = srandom(state0)';
4560 vrfy(srandom() == init, '5324: srandom() == init');
4561 tmp = srandom(init);
4562 print '5325: tmp = srandom(init)';
4563 vrfy(srandom() == init, '5326: srandom() == init');
4564 vrfy(tmp == init, '5327: tmp == init');
4566 /* test the bit length interface */
4568 print '5328: tmp = srandomom(0)';
4569 vrfy(randombit(64) == 0x7fb838a8a0a95046, \
4570 '5329: randombit(64) == 0x7fb838a8a0a95046');
4571 vrfy(randombit(128) == 0xb9d9d9fb4440f7bbc1a7bd3b4e853fc9, \
4572 '5330: randombit(128) == 0xb9d9d9fb4440f7bbc1a7bd3b4e853fc9');
4573 vrfy(randombit(64) == 0x2d4e1588719986aa, \
4574 '5331: randombit(64) == 0x2d4e1588719986aa');
4575 vrfy(randombit(128) == 0x8d68905434b020ccb849e17a03a5c441, \
4576 '5332: randombit(128) == 0x8d68905434b020ccb849e17a03a5c441');
4578 print '5333: tmp = srandom(0)';
4579 vrfy(randombit(32) == 0x7fb838a8, '5334: randombit(32) == 0x7fb838a8');
4580 vrfy(randombit(32) == 0xa0a95046, '5335: randombit(32) == 0xa0a95046');
4581 vrfy(randombit(1) == 0x1, '5336: randombit(1) == 0x1');
4582 vrfy(randombit(5) == 0xe, '5337: randombit(5) == 0xe');
4583 vrfy(randombit(33) == 0xececfda2, '5338: randombit(33) == 0xececfda2');
4584 vrfy(randombit(25) == 0x40f7bb, '5339: randombit(25) == 0x40f7bb');
4585 vrfy(randombit(2) == 0x3, '5340: randombit(2) == 0x3');
4586 vrfy(randombit(13) == 0xd3, '5341: randombit(13) == 0xd3');
4587 vrfy(randombit(18) == 0x37a76, '5342: randombit(18) == 0x37a76');
4588 vrfy(randombit(8) == 0x9d, '5343: randombit(8) == 0x9d');
4589 vrfy(randombit(9) == 0x14, '5344: randombit(9) == 0x14');
4590 vrfy(randombit(70) == 0x3fc92d4e1588719986, \
4591 '5345: randombit(70) == 0x3fc92d4e1588719986');
4592 vrfy(randombit(123) == 0x5546b4482a1a5810665c24f0bd01d2e, \
4593 '5346: randombit(123) == 0x5546b4482a1a5810665c24f0bd01d2e');
4594 vrfy(randombit(8) == 0x22, '5347: randombit(8) == 0x22');
4595 vrfy(randombit(65) == 0x1d2a104aaf523699, \
4596 '5348: randombit(65) == 0x1d2a104aaf523699');
4597 vrfy(randombit(63) == 0x60e63d498ba690ec, \
4598 '5349: randombit(63) == 0x60e63d498ba690ec');
4599 vrfy(randombit(1) == 0x1, '5350: randombit(1) == 0x1');
4600 vrfy(randombit(2) == 0x3, '5351: randombit(2) == 0x3');
4601 vrfy(randombit(4) == 0x0, '5352: randombit(4) == 0x0');
4602 vrfy(randombit(3) == 0x0, '5353: randombit(3) == 0x0');
4604 print '5354: state1 = srandom()';
4606 /* test randombit skip interface */
4608 print '5355: tmp = srandom(0)';
4609 vrfy(randombit(20) == 523139, '5356: randombit(20) == 523139');
4610 vrfy(randombit(20) == 567456, '5357: randombit(20) == 567456');
4611 vrfy(randombit(20) == 693508, '5358: randombit(20) == 693508');
4612 vrfy(randombit(20) == 440793, '5359: randombit(20) == 440793');
4614 print '5360: tmp = srandom(0)';
4615 vrfy(randombit(-20) == 20, '5361: randombit(-20) == 20');
4616 vrfy(randombit(20) == 567456, '5362: randombit(20) == 567456');
4617 vrfy(randombit(-20) == 20, '5363: randombit(-20) == 20');
4618 vrfy(randombit(20) == 440793, '5364: randombit(20) == 440793');
4620 /* test randombit without and arg */
4622 print '5365: tmp = srandom(0)';
4623 vrfy(randombit() == 0, '5366: randombit() == 0');
4624 vrfy(randombit() == 1, '5367: randombit() == 1');
4625 vrfy(randombit() == 1, '5368: randombit() == 1');
4627 /* test range interface some more */
4628 tmp = srandom(state1);
4629 print '5369: tmp = srandom(state1)';
4630 vrfy(random(-46,46) == -0x7, '5370: random(-46,46) == -0x7');
4631 vrfy(random(21701,23209) == 23061,
4632 '5371: random(21701,23209) == 23061');
4633 vrfy(random(0x22,0x1d2a104aaf523699) == 0x17c97dfa80bbdf1b,
4634 '5372: random(0x22,0x1d2a104aaf523699) == 0x17c97dfa80bbdf1b');
4635 vrfy(random(0x2d4e16aa,0x7fb83046) == 0x48e98d92,
4636 '5373: random(0x2d4e16aa,0x7fb83046) == 0x48e98d92');
4637 vrfy(random(-0x2d4986aa,0x7fb83846) == 0x3b3f6c0c,
4638 '5374: random(-0x2d4986aa,0x7fb83846) == 0x3b3f6c0c');
4639 vrfy(random(-0x2d9986aa,-0x7fb9504) == -0x235f9ce1,
4640 '5375: random(-0x2d9986aa,-0x7fb9504) == -0x235f9ce1');
4643 /* test pre-compiled random states */
4644 tmp = srandom(init);
4645 print '5376: tmp = srandom(init)';
4646 state0 = srandom(0,1);
4647 print '5377: state0 = srandom(0,1)';
4648 vrfy(randombit(123) == 0x4cf8834399f8832d5c1ec35f20095f0, \
4649 '5378: randombit(123) == 0x4cf8834399f8832d5c1ec35f20095f0');
4650 state1 = srandom(123455432112345,1);
4651 print '5379: state1 = srandom(123455432112345,1)';
4652 vrfy(randombit(123) == 0x437c9618d5a9c07d935b0ff7cef7346, \
4653 '5380: randombit(123) == 0x437c9618d5a9c07d935b0ff7cef7346');
4655 print '5381: tmp = srandom(0,1)';
4656 vrfy(randombit(-123) == 123, '5382: randombit(-123) == 123');
4657 vrfy(srandom() == state1, '5383: srandom() == state1');
4659 print '5384: tmp = srandom(0,2)';
4660 vrfy(randombit(123) == 0x7d53b2dbfe1edcb07df84f7fe96d5e9, \
4661 '5385: randombit(123) == 0x7d53b2dbfe1edcb07df84f7fe96d5e9');
4663 print '5386: tmp = srandom(0,3)';
4664 vrfy(randombit(123) == 0x365cbae1adb9a706816abe3b64c1f2a, \
4665 '5387: randombit(123) == 0x365cbae1adb9a706816abe3b64c1f2a');
4667 print '5388: tmp = srandom(0,4)';
4668 vrfy(randombit(123) == 0x63d9621736e59a3a5a8311117a1ef01, \
4669 '5389: randombit(123) == 0x63d9621736e59a3a5a8311117a1ef01');
4671 print '5390: tmp = srandom(0,5)';
4672 vrfy(randombit(123) == 0x38d90517d6d532d1efb6eaf26bf927, \
4673 '5391: randombit(123) == 0x38d90517d6d532d1efb6eaf26bf927');
4675 print '5392: tmp = srandom(0,6)';
4676 vrfy(randombit(123) == 0x146f2a1ce8cabcc313ab24f73747fbc, \
4677 '5393: randombit(123) == 0x146f2a1ce8cabcc313ab24f73747fbc');
4679 print '5394: tmp = srandom(0,7)';
4680 vrfy(randombit(123) == 0x7a4a2b4ed817e5267358ea2979155d8, \
4681 '5395: randombit(123) == 0x7a4a2b4ed817e5267358ea2979155d8');
4683 print '5396: tmp = srandom(0,8)';
4684 vrfy(randombit(123) == 0x5f30f211464854a37989cca3a8ecd0a, \
4685 '5397: randombit(123) == 0x5f30f211464854a37989cca3a8ecd0a');
4687 print '5398: tmp = srandom(0,9)';
4688 vrfy(randombit(123) == 0x73aa8e572ee77682ae317804ed8d6e5, \
4689 '5399: randombit(123) == 0x73aa8e572ee77682ae317804ed8d6e5');
4690 tmp = srandom(0,10);
4691 print '5400: tmp = srandom(0,10)';
4692 vrfy(randombit(123) == 0x49c7acca8f461ad2edf4cb7651f18d3, \
4693 '5401: randombit(123) == 0x49c7acca8f461ad2edf4cb7651f18d3');
4694 tmp = srandom(0,11);
4695 print '5402: tmp = srandom(0,11)';
4696 vrfy(randombit(123) == 0x6042e2169a73140ffab1881df99a0ee, \
4697 '5403: randombit(123) == 0x6042e2169a73140ffab1881df99a0ee');
4698 tmp = srandom(0,12);
4699 print '5404: tmp = srandom(0,12)';
4700 vrfy(randombit(123) == 0x7b98097947d478611d96f4d7a1cd2af, \
4701 '5405: randombit(123) == 0x7b98097947d478611d96f4d7a1cd2af');
4702 tmp = srandom(0,13);
4703 print '5406: tmp = srandom(0,13)';
4704 vrfy(randombit(123) == 0x12324fd76d7a4a5a979765be2d57cfa, \
4705 '5407: randombit(123) == 0x12324fd76d7a4a5a979765be2d57cfa');
4706 tmp = srandom(0,14);
4707 print '5408: tmp = srandom(0,14)';
4708 vrfy(randombit(123) == 0x377ff9ef04ee24887984995f91489a3, \
4709 '5409: randombit(123) == 0x377ff9ef04ee24887984995f91489a3');
4710 tmp = srandom(0,15);
4711 print '5410: tmp = srandom(0,15)';
4712 vrfy(randombit(123) == 0x7db2b6245c5a24a1a52f74c8f828c6f, \
4713 '5411: randombit(123) == 0x7db2b6245c5a24a1a52f74c8f828c6f');
4714 tmp = srandom(0,16);
4715 print '5412: tmp = srandom(0,16)';
4716 vrfy(randombit(123) == 0x5958e6cc460c28a5e741706fd442f12, \
4717 '5413: randombit(123) == 0x5958e6cc460c28a5e741706fd442f12');
4718 tmp = srandom(0,17);
4719 print '5414: tmp = srandom(0,17)';
4720 vrfy(randombit(123) == 0x68c40ccf3805b2734d0d2881ca268d, \
4721 '5415: randombit(123) == 0x68c40ccf3805b2734d0d2881ca268d');
4722 tmp = srandom(0,18);
4723 print '5416: tmp = srandom(0,18)';
4724 vrfy(randombit(123) == 0x4afc6cd3b9e14dadc5b75c6a81602e5, \
4725 '5417: randombit(123) == 0x4afc6cd3b9e14dadc5b75c6a81602e5');
4726 tmp = srandom(0,19);
4727 print '5418: tmp = srandom(0,19)';
4728 vrfy(randombit(123) == 0x3ea4d30abf7da6596d2425e0a9a6348, \
4729 '5419: randombit(123) == 0x3ea4d30abf7da6596d2425e0a9a6348');
4730 tmp = srandom(0,20);
4731 print '5420: tmp = srandom(0,20)';
4732 vrfy(randombit(123) == 0x77f848c70d4622ed41956eceb3f15f6, \
4733 '5421: randombit(123) == 0x77f848c70d4622ed41956eceb3f15f6');
4734 vrfy(randombit(123) == 0x5bfa034925acaf7ad5ba5d8f7f32369, \
4735 '5422: randombit(123) == 0x5bfa034925acaf7ad5ba5d8f7f32369');
4736 vrfy(randombit(123) == 0x761100a4cecbdac8c8d539dee0e278e, \
4737 '5423: randombit(123) == 0x761100a4cecbdac8c8d539dee0e278e');
4740 tmp = srandom(7^23+19,2);
4741 print '5424: tmp = srandom(7^23+19,2)';
4742 vrfy(randombit(123) == 0x89b7ec9413e8af84a0c64ffc64d5a8, \
4743 '5425: randombit(123) == 0x89b7ec9413e8af84a0c64ffc64d5a8');
4744 tmp = srandom(7^23+19,3);
4745 print '5426: tmp = srandom(7^23+19,3)';
4746 vrfy(randombit(123) == 0x7a2b8a6ca93a29deb1c3a674a30bf26, \
4747 '5427: randombit(123) == 0x7a2b8a6ca93a29deb1c3a674a30bf26');
4748 tmp = srandom(7^23+19,4);
4749 print '5428: tmp = srandom(7^23+19,4)';
4750 vrfy(randombit(123) == 0x5425c6614dffcc0f376de4e9355c7df, \
4751 '5429: randombit(123) == 0x5425c6614dffcc0f376de4e9355c7df');
4752 tmp = srandom(7^23+19,5);
4753 print '5430: tmp = srandom(7^23+19,5)';
4754 vrfy(randombit(123) == 0x70fca502499fa3717e346df5438886d, \
4755 '5431: randombit(123) == 0x70fca502499fa3717e346df5438886d');
4756 tmp = srandom(7^23+19,6);
4757 print '5432: tmp = srandom(7^23+19,6)';
4758 vrfy(randombit(123) == 0x6ff886ac0918ad503290544af2cbd03, \
4759 '5433: randombit(123) == 0x6ff886ac0918ad503290544af2cbd03');
4760 tmp = srandom(7^23+19,7);
4761 print '5434: tmp = srandom(7^23+19,7)';
4762 vrfy(randombit(123) == 0x5747d8c33d6d6dc53357779dffcc430, \
4763 '5435: randombit(123) == 0x5747d8c33d6d6dc53357779dffcc430');
4764 tmp = srandom(7^23+19,8);
4765 print '5436: tmp = srandom(7^23+19,8)';
4766 vrfy(randombit(123) == 0x12769f65324d5e7986120b0caf071ad, \
4767 '5437: randombit(123) == 0x12769f65324d5e7986120b0caf071ad');
4768 tmp = srandom(7^23+19,9);
4769 print '5438: tmp = srandom(7^23+19,9)';
4770 vrfy(randombit(123) == 0x3f94d3585b986539158f6ccd97d261e, \
4771 '5439: randombit(123) == 0x3f94d3585b986539158f6ccd97d261e');
4772 tmp = srandom(7^23+19,10);
4773 print '5440: tmp = srandom(7^23+19,10)';
4774 vrfy(randombit(123) == 0x12874c359fffc6c0eda2aebfea97c71, \
4775 '5441: randombit(123) == 0x12874c359fffc6c0eda2aebfea97c71');
4776 tmp = srandom(7^23+19,11);
4777 print '5442: tmp = srandom(7^23+19,11)';
4778 vrfy(randombit(123) == 0x7e0480a70c6f32f6594db8fd58ada7, \
4779 '5443: randombit(123) == 0x7e0480a70c6f32f6594db8fd58ada7');
4780 tmp = srandom(7^23+19,12);
4781 print '5444: tmp = srandom(7^23+19,12)';
4782 vrfy(randombit(123) == 0x7f900aa8c7b9dacb6bf4ca0f5f81cb8, \
4783 '5445: randombit(123) == 0x7f900aa8c7b9dacb6bf4ca0f5f81cb8');
4784 tmp = srandom(7^23+19,13);
4785 print '5446: tmp = srandom(7^23+19,13)';
4786 vrfy(randombit(123) == 0x39311c5aa41e42bb5d7807bdb60aecc, \
4787 '5447: randombit(123) == 0x39311c5aa41e42bb5d7807bdb60aecc');
4788 tmp = srandom(7^23+19,14);
4789 print '5448: tmp = srandom(7^23+19,14)';
4790 vrfy(randombit(123) == 0x508bc8c5bd4555262b7ecd32a1ecd8e, \
4791 '5449: randombit(123) == 0x508bc8c5bd4555262b7ecd32a1ecd8e');
4792 tmp = srandom(7^23+19,15);
4793 print '5450: tmp = srandom(7^23+19,15)';
4794 vrfy(randombit(123) == 0x442d2076b8d58d3815841180e8401b6, \
4795 '5451: randombit(123) == 0x442d2076b8d58d3815841180e8401b6');
4796 tmp = srandom(7^23+19,16);
4797 print '5452: tmp = srandom(7^23+19,16)';
4798 vrfy(randombit(123) == 0x38db53974de9d3eea82a6ba35d2dc53, \
4799 '5453: randombit(123) == 0x38db53974de9d3eea82a6ba35d2dc53');
4800 tmp = srandom(7^23+19,17);
4801 print '5454: tmp = srandom(7^23+19,17)';
4802 vrfy(randombit(123) == 0x42c1d9d86c9c67acb518ee008ce8f38, \
4803 '5455: randombit(123) == 0x42c1d9d86c9c67acb518ee008ce8f38');
4804 tmp = srandom(7^23+19,18);
4805 print '5456: tmp = srandom(7^23+19,18)';
4806 vrfy(randombit(123) == 0x10dc81d7ef0a7aeb4aea1d4ac1fac2a, \
4807 '5457: randombit(123) == 0x10dc81d7ef0a7aeb4aea1d4ac1fac2a');
4808 tmp = srandom(7^23+19,19);
4809 print '5458: tmp = srandom(7^23+19,19)';
4810 vrfy(randombit(123) == 0x469f8d91b643e0bcc4b5d5c2fe61cfb, \
4811 '5459: randombit(123) == 0x469f8d91b643e0bcc4b5d5c2fe61cfb');
4812 tmp = srandom(7^23+19,20);
4813 print '5460: tmp = srandom(7^23+19,20)';
4814 vrfy(randombit(123) == 0x7f056e87cfcbe04a072e17502ef38f5, \
4815 '5461: randombit(123) == 0x7f056e87cfcbe04a072e17502ef38f5');
4816 vrfy(randombit(123) == 0x5d10d7665e56dee0ec5ea7d918ba073, \
4817 '5462: randombit(123) == 0x5d10d7665e56dee0ec5ea7d918ba073');
4818 vrfy(randombit(123) == 0x2058f802dd42b3aee4e734eacc13057, \
4819 '5463: randombit(123) == 0x2058f802dd42b3aee4e734eacc13057');
4821 /* test seed() as best as we can */
4822 vrfy(seed() >= 0, '5464: seed() >= 0');
4823 vrfy(seed() < 2^64, '5465: seed() < 2^64');
4824 vrfy(israndom(srandom(seed())), '5466: israndom(srandom(seed()))');
4826 /* verify random(10,11) double bug fix */
4827 vrfy(random(10,11) == 10, '5467: random(10,11) == 10');
4828 vrfy(random(10,11) == 10, '5468: random(10,11) == 10');
4829 vrfy(random(10,11) == 10, '5469: random(10,11) == 10');
4830 vrfy(random(0,1) == 0, '5470: random(0,1) == 0');
4831 vrfy(random(0,1) == 0, '5471: random(0,1) == 0');
4833 print '5472: Ending test_random';
4835 print '137: parsed test_random()';
4839 * test_newsyn - test new command completion syntax and scope rules
4841 for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;
4842 print "138: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;";
4843 vrfy(s5500 == 10, '139: s5500 == 10');
4844 vrfy(i == 5, '140: i == 5');
4845 for (s5500 = 0, i = 0; i < 9; i++) {
4848 print "141: for (s5500 = 0, i = 0; i < 9; i++) { s5500 += i; }";
4849 vrfy(s5500 == 36, '142: s5500 == 36');
4850 vrfy(i == 9, '143: i == 9');
4853 for (s5500 = 0, i = 0; i < 10; i++)
4855 vrfy(s5500 == 45, '144: s5500 == 45');
4856 vrfy(i == 10, '145: i == 10');
4858 print "146: { local i; for (s5500 = 0, i = 0; i < 10; i++) s5500 += i; ... }";
4859 vrfy(s5500 == 45, '147: s5500 == 45');
4860 vrfy(i == 9, '148: i == 9');
4862 define test_newsyn()
4864 local i; /* loop counter */
4866 print '5500: Beginning test_newsyn';
4869 * check basic for loop completion and scoping
4871 for (s5500 = 0, i = 0; i < 5; i++)
4873 print "5501: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;";
4874 vrfy(s5500 == 10, '5502: s5500 == 10');
4875 vrfy(i == 5, '5503: i == 5');
4877 for (s5500 = 0, i = 0; i < 6; i++)
4881 print "5504: for (s5500 = 0, i = 0; i < 6; i++) { s5500 += i; }";
4882 vrfy(s5500 == 15, '5505: s5500 == 15');
4883 vrfy(i == 6, '5506: i == 6');
4885 for (s5500 = 0, i = 0; i < 3; i++) {
4888 print "5507: for (s5500 = 0, i = 0; i < 3; i++) { s5500 += i; }";
4889 vrfy(s5500 == 3, '5508: s5500 == 3');
4890 vrfy(i == 3, '5509: i == 3');
4893 for (s5500 = 0, i = 0; i < 11; i++)
4895 vrfy(s5500 == 55, '5510: s5500 == 45');
4896 vrfy(i == 11, '5511: i == 11');
4898 print "5512: { local i; for (s5500 = 0, i = 0; i < 10; i++) ":
4899 "s5500 += i; ... }";
4900 vrfy(s5500 == 55, '5513: s5500 == 55');
4901 vrfy(i == 11, '5514: i == 11');
4904 * test completion of while loops
4907 print '5515: i = 0';
4909 print '5516: s5500 = 0';
4912 print "5517: while (++i < 4) s5500 += i;";
4913 vrfy(s5500 == 6, '5518: s5500 == 6');
4914 vrfy(i == 4, '5519: i == 4');
4917 print '5520: i = 0';
4919 print '5521: s5500 = 0';
4924 print "5522: while (++i < 7) { s5500 += i; }";
4925 vrfy(s5500 == 21, '5523: s5500 == 21');
4926 vrfy(i == 7, '5524: i == 7');
4929 print '5525: i = 0';
4931 print '5526: s5500 = 0';
4935 print "5527: while (++i < 8) { s5500 += i; }";
4936 vrfy(s5500 == 28, '5528: s5500 == 28');
4937 vrfy(i == 8, '5529: i == 8');
4940 * test completion of do-while loops
4943 print '5530: i = 0';
4945 print '5531: s5500 = 0';
4949 print "5532: do s5500 += i; while (++i < 12);";
4950 vrfy(s5500 == 66, '5533: s5500 == 66');
4951 vrfy(i == 12, '5534: i == 12');
4954 print '5535: i = 0';
4956 print '5536: s5500 = 0';
4960 print "5537: do { s5500 += i; } while (++i < 14);";
4961 vrfy(s5500 == 91, '5538: s5500 == 91');
4962 vrfy(i == 14, '5539: i == 14');
4965 print '5540: i = 0';
4967 print '5541: s5500 = 0';
4974 print "5542: do { s5500 += i; } while (++i < 13);";
4975 vrfy(s5500 == 78, '5543: s5500 == 78');
4976 vrfy(i == 13, '5544: i == 13');
4979 * test the completion of switch
4982 case 12: prob("switch showed i was 12 instead of 13"); break;
4984 vrfy(i == 13, '5545: i == 13');
4987 prob("switch showed i was something other than 13");
4999 "switch showed i was 1 instead of 13"
5008 "switch showed i was 2 instead of 13"
5026 print '5547: Ending test_newsyn';
5028 print '149: parsed test_newsyn()';
5029 vrfy(s5500 == 45, '150: s5500 == 45');
5030 vrfy(i == 9, '151: i == 9');
5034 * test_commaeq - test changes to , and =
5036 obj xx5600 {} xx5600;
5037 print '152: obj xx5600 {} xx5600';
5038 define xx5600_print() = printf("xx");
5039 print '153: xx5600_print() = printf("xx")';
5041 define test_commaeq()
5045 local a5600 = 0, b5600 = 0;
5049 * Calculations with i
5051 print '5600: Beginning test_commaeq';
5053 print '5601: i = 5';
5054 vrfy(i == 5, '5602: i == 5');
5056 print '5603: i += 2 *= 3 -= 1';
5057 vrfy(i == 20, '5604: i == 20');
5059 print '5607: ++i /= 7';
5060 vrfy(i == 3, '5608: i == 3');
5063 * xx5600 object type
5065 mat A[3] = {1,2,xx5600};
5066 print '5609: mat A[3] = {1,2,xx5600}';
5067 vrfy(A[2] == xx5600, '5610: A[2] == xx5600');
5068 vrfy(strprintf("%d", xx5600) == "xx",
5069 '5611: strprintf("%d", xx5600) == "xx"');
5072 * xy5600 object type
5074 obj xy5600 A = {1, 2} = {3, 4};
5075 print '5612: obj xy5600 A = {1, 2} = {3, 4}';
5076 vrfy(A.x == 3, '5613: A.x == 3');
5077 vrfy(A.y == 4, '5614: A.y == 4');
5078 obj xy5600 B = {A,A};
5079 print '5613: obj xy5600 B = {A,A}';
5080 vrfy(B.x.x == 3, '5615: B.x.x == 3');
5081 vrfy(B.y.y == 4, '5616: B.y.y == 4');
5083 print '5617: obj xy5600 C';
5084 C = {1, 2} = {C, C};
5085 print '5618: C = {1, 2} = {C, C}';
5086 vrfy(C.x.x == 1, '5619: C.x.x == 1');
5087 vrfy(C.y.x.y == 2, '5620: C.y.x.y == 2');
5089 print '5621: D = 7';
5090 obj xy5600 D = {1,2} = {D,D};
5091 print '5622: obj xy5600 D = {1,2} = {D,D}';
5092 vrfy(D.x == 7, '5623: D.x == 7');
5093 vrfy(D.y == 7, '5624: D.y == 7');
5098 mat A[3] = {1,2,3}, mat B[2] = {1,2};
5099 print '5625: mat A[3] = {1,2,3}, mat B[2] = {1,2}';
5100 vrfy(A[0] == 1, '5626: A[0] == 1');
5101 vrfy(B[1] == 2, '5627: B[1] == 2');
5104 * misc = and , expressions
5106 vrfy(((a5600 = 2, b5600) = 3) && a5600 + b5600 == 5,
5107 '5628: ((a5600 = 2, b5600) = 3) && a5600 + b5600 == 5');
5108 vrfy((2 ? a5600 : b5600 = 4) && a5600 == 4,
5109 '5629: (2 ? a5600 : b5600 = 4) && a5600 == 4');
5110 vrfy((0 ? a5600 : b5600 = 5) && b5600 == 5,
5111 '5630: (0 ? a5600 : b5600 = 5) && b5600 == 5');
5112 vrfy((a5600 || b5600 = 6) && a5600 == 6 && b5600 == 5,
5113 '5631: (a5600 || b5600 = 6) && a5600 == 6 && b5600 == 5');
5114 vrfy((a5600 && b5600 = 7) && a5600 == 6 && b5600 == 7,
5115 '5632: (a5600 && b5600 = 7) && a5600 == 6 && b5600 == 7');
5117 print '5633: Ending test_commaeq';
5119 print '155: parsed test_commaeq()';
5123 * test_size - test what we can about sizes
5125 * Since sizeof() and memsize() deal with machine specific sizes and
5126 * compiler structure layout issues, we cannot just determine if
5127 * these builtin values return a specific value.
5131 local z; /* test integer values */
5132 local q; /* test rational values */
5133 local c; /* test complex values */
5134 local m; /* test matrix */
5135 local l; /* test list */
5136 local a; /* test association */
5138 print '5700: Beginning test_size';
5141 * 0, -1 and 1 values are reported as 0 sizeof
5143 vrfy(sizeof(0) == 0, '5701: sizeof(0) == 0');
5144 vrfy(sizeof(1) == 0, '5702: sizeof(1) == 0');
5145 vrfy(sizeof(-1) == 0, '5703: sizeof(-1) == 0');
5147 print '5704: z = 0';
5148 vrfy(sizeof(z) == 0, '5705: sizeof(z) == 0');
5150 print '5706: z = 1';
5151 vrfy(sizeof(z) == 0, '5707: sizeof(z) == 0');
5153 print '5708: z = -1';
5154 vrfy(sizeof(z) == 0, '5709: sizeof(z) == 0');
5157 * non-integer rationals are larger than integers
5160 print '5710: q = 13/2';
5161 vrfy(sizeof(13)*2 == sizeof(q), '5711: sizeof(13)*2 == sizeof(q)');
5163 print '5712: q = 13';
5164 vrfy(sizeof(13) == sizeof(q), '5713: sizeof(13) == sizeof(q)');
5165 q = (17^139 + 674) / (17^139 + 686);
5166 print '5714: q = (17^139 + 674) / (17^139 + 686)';
5167 vrfy(sizeof(17^139 + 674)*2 == sizeof(q),
5168 '5715: sizeof(17^139 + 674)*2 == sizeof(q)');
5171 * recipricals are the same size of their integer inverses
5174 print '5716: q = 1/13';
5175 vrfy(sizeof(13) == sizeof(q), '5717: sizeof(13) == sizeof(q)');
5176 q = 1/(17^139 + 674);
5177 print '5718: q = 1/(17^139 + 674)';
5178 vrfy(sizeof(17^139 + 674) == sizeof(q),
5179 '5717: sizeof(17^139 + 674) == sizeof(q)');
5182 * negative values are the same size as positive values
5184 vrfy(sizeof(17^139 + 674) == sizeof(-q),
5185 '5718: sizeof(17^139 + 674) == sizeof(-q)');
5186 vrfy(sizeof(-(17^139 + 674)) == sizeof(-q),
5187 '5719: sizeof(-(17^139 + 674)) == sizeof(-q)');
5189 print '5720: q = 1/-13';
5190 vrfy(sizeof(13) == sizeof(q), '5721: sizeof(13) == sizeof(q)');
5193 * complex values with a real or imaginary part of 0, 1 or -1
5194 * are the same size as rationals
5197 print '5722: c = 0 + 4i';
5198 vrfy(sizeof(3) == sizeof(c), '5723: sizeof(3) == sizeof(c)');
5200 print '5724: c = 3 + 0i';
5201 vrfy(sizeof(3) == sizeof(c), '5725: sizeof(3) == sizeof(c)');
5203 print '5726: c = 1 + 4i';
5204 vrfy(sizeof(3) == sizeof(c), '5727: sizeof(3) == sizeof(c)');
5206 print '5728: c = 3 + 1i';
5207 vrfy(sizeof(3) == sizeof(c), '5729: sizeof(3) == sizeof(c)');
5209 print '5730: c = -1 + 4i';
5210 vrfy(sizeof(3) == sizeof(c), '5731: sizeof(3) == sizeof(c)');
5212 print '5732: c = 3 + -1i';
5213 vrfy(sizeof(3) == sizeof(c), '5733: sizeof(3) == sizeof(c)');
5216 * general complex values are twice the size as rationals
5219 print '5734: c = 3 + 4i';
5220 vrfy(sizeof(3)*2 == sizeof(c), '5735: sizeof(3)*2 == sizeof(c)');
5222 print '5736: z = 17^139 + 686';
5224 print '5737: c = z + z*1i';
5225 vrfy(sizeof(z)*2 == sizeof(c), '5738: sizeof(z)*2 == sizeof(c)');
5226 q = 1/(17^139 + 674);
5227 print '5739: q = 1/(17^139 + 674)';
5229 print '5740: c = q + q*1i';
5230 vrfy(sizeof(q)*2 == sizeof(c), '5741: sizeof(q)*2 == sizeof(c)');
5231 c = (z*q) + (1/(z*q))*1i;
5232 print '5742: c = (z*q) + (1/(z*q))*1i';
5233 vrfy(sizeof(z*q)*2 == sizeof(c), '5743: sizeof(z*q)*2 == sizeof(c)');
5234 vrfy(sizeof(z)*4 == sizeof(c), '5744: sizeof(z)*4 == sizeof(c)');
5235 vrfy(sizeof(q)*4 == sizeof(c), '5745: sizeof(q)*4 == sizeof(c)');
5238 * size of numeric values is always 1
5240 vrfy(size(0) == 1, '5746: size(0) == 1');
5241 vrfy(size(1) == 1, '5747: size(1) == 1');
5242 vrfy(size(13^10) == 1, '5748: size(13^10) == 1');
5243 vrfy(size(z) == 1, '5749: size(z) == 1');
5244 vrfy(size(q) == 1, '5750: size(q) == 1');
5245 vrfy(size(c) == 1, '5751: size(c) == 1');
5248 * size of a matrix is the sum of the sizes of the elements
5249 * sizeof of a matrix is the sum of the sizeofs of the elements
5252 print '5752: mat m[] = {z,q,c}';
5253 vrfy(size(m) == size(z)+size(q)+size(c),
5254 '5753: size(m) == size(z)+size(q)+size(c)');
5255 vrfy(sizeof(m) == sizeof(z)+sizeof(q)+sizeof(c),
5256 '5754: sizeof(m) == sizeof(z)+sizeof(q)+sizeof(c)');
5259 * size of a list is the number of elements
5260 * sizeof of a list is the sum of the sizeof's of the elements
5263 print '5755: list(z,q,c,m)';
5264 vrfy(size(l) == 4, '5756: size(l) == 4');
5265 vrfy(sizeof(l) == 2*sizeof(m), '5757: sizeof(l) == 2*sizeof(m)');
5268 * size of an assoc is the number of elements
5269 * sizeof of an assoc is the sum of the sizeof's of the elements
5272 print '5758: a = assoc()';
5274 print '5759: a["z"] = z+1';
5276 print '5760: a["q"] = q+2';
5278 print '5761: a["c"] = c+3';
5280 print '5762: a[m] = m';
5282 print '5763: a[l] = l';
5283 vrfy(size(a) == 5, '5764: size(a) == 5');
5284 vrfy(sizeof(a) == 25*sizeof(z), '5765: sizeof(a) == 25*sizeof(z)');
5287 * about all we can say about memsize is that it will always be
5288 * larger than sizeof
5290 vrfy(sizeof(z) < memsize(z), '5766: sizeof(z) < memsize(z)');
5291 vrfy(sizeof(q) < memsize(q), '5767: sizeof(q) < memsize(q)');
5292 vrfy(sizeof(c) < memsize(c), '5768: sizeof(c) < memsize(c)');
5293 vrfy(sizeof(m) < memsize(m), '5769: sizeof(m) < memsize(m)');
5294 vrfy(sizeof(l) < memsize(l), '5770: sizeof(l) < memsize(l)');
5295 vrfy(sizeof(a) < memsize(a), '5771: sizeof(a) < memsize(a)');
5297 print '5772: Ending test_size';
5299 print '156: parsed test_size()';
5303 * test_assign - test assignment of constants and variables
5305 global X5800, Y5800; /* X5800, Y5800 for "variables" */
5306 print '158: global X5800, Y5800';
5308 print '159: obj xy5800 {x, y}';
5310 define test_assign(base, work)
5312 print base: ': Beginning test_assign';
5318 print base+1: ': A = base+1';
5320 print base+2: ': B = base+2';
5322 print base+3: ': X5800 = base+3';
5324 print base+4: ': Y5800 = base+4';
5325 obj xy5800 A={1,2}, obj xy5800 B={3,4};
5326 print base+5: ': obj xy5800 A={1,2}, obj xy5800 B={3,4}';
5332 print base+6: ': X5800 = A';
5334 vrfy(X5800 == A, strprintf('%d: X5800 == A', base+7));
5336 print base+8: ': X5800 = Y5800 = B';
5338 vrfy(X5800 == B, strprintf('%d: X5800 == B', base+7));
5340 print base+8: ': X5800 = Y5800 = A';
5342 vrfy(X5800 == B, strprintf('%d: X5800 == B', base+9));
5343 vrfy(Y5800 == B, strprintf('%d: Y5800 == B', base+10));
5345 print base+11: ': Ending test_assign';
5347 print '160: test_assign()';
5351 * test_is - test is functions
5353 vrfy(isobjtype("xy5900") == 0, '161: isobjtype("xy5900") == 0');
5355 print '162: obj xy5900 {x, y}';
5356 vrfy(isobjtype("xy5900") == 1, '163: isobjtype("xy5900") == 1');
5358 vrfy(isdefined("fun5900") == 0, '164: isdefined("fun5900") == 0');
5359 define fun5900() { return 1; };
5360 print '165: define fun5900() { return 1; }';
5361 vrfy(isdefined("fun5900") == 2, '166: isdefined("fun5900") == 2');
5363 vrfy(isdefined("fun5900") == 0, '167: isdefined("fun5900") == 0');
5367 local loc; /* unassigned local variable */
5368 local a; /* assoc */
5369 local ofd; /* open file desriptor */
5370 local cfd; /* closed file descriptor */
5371 local blk; /* unnamed block */
5372 local nblk; /* named block */
5373 local cfg; /* config state */
5374 local serr; /* system value */
5375 local nerr; /* new error value */
5376 local odd; /* odd integer */
5377 local even; /* even integer that is 10 times odd */
5378 local hash; /* sha1 hash value */
5379 local id; /* identity matrix */
5380 local list; /* list value */
5381 local matrix; /* non-identity matrix */
5382 local nul; /* null value */
5383 local object; /* object */
5384 local rand; /* rand seed */
5385 local random; /* random seed */
5386 local real; /* real non-intger value */
5387 local prime; /* odd prime */
5388 local square; /* square of an odd prime */
5389 local string; /* string */
5390 local com; /* complex value */
5391 local rndint; /* a random integer */
5392 local rndexp; /* a random exponent */
5393 local rndval; /* rndint ^ rndexp */
5394 local i; /* integer value */
5395 local ok; /* 1 ==> issq() tests were OK, 0 ==> failure */
5397 print '5900: Beginning test_is';
5403 print '5901: a = assoc()';
5404 if (config("windows")) {
5405 ofd = fopen("NUL:", "rb");
5406 print '5902: ofd = fopen("NUL:", "rb")';
5407 cfd = fopen("NUL:", "rb");
5408 print '5903: cfd = fopen("NUL:", "rb")';
5410 ofd = fopen("/dev/null","rb");
5411 print '5902: ofd = fopen("/dev/null","rb")';
5412 cfd = fopen("/dev/null","rb");
5413 print '5903: cfd = fopen("/dev/null","rb")';
5416 print '5904: fclose(cfd)';
5418 print '5905: blk = blk()';
5419 nblk = blk("blk5900");
5420 print '5906: nblk = blk("blk5900")';
5421 cfg = config("all");
5422 print '5907: cfg = config("all")';
5424 print '5908: ecnt += 2';
5426 print '5909: serr = error(1)';
5427 nerr = newerror("curds");
5428 print '5910: nerr = newerror("curds")';
5430 print '5911: odd = 23209';
5432 print '5912: even = odd*10';
5434 print '5913: hash = sha1()';
5435 mat id[3,3] = {1,0,0,0,1,0,0,0,1};
5436 print '5914: id[3,3] = {1,0,0,0,1,0,0,0,1}';
5438 print '5915: list = list(2,3,4)';
5440 print '5916: mat matrix[2]';
5442 print '5917: nul = null()';
5444 print '5918: obj xy5900 object';
5446 print '5919: rand = srand(0)';
5447 random = srandom(0);
5448 print '5920: random = srandom(0)';
5449 real = 345.23045897;
5450 print '5921: real = 345.23045897';
5452 print '5922: prime = 3217';
5454 print '5923: square = prime^2';
5455 string = "a string";
5456 print '5924: string = "a string"';
5458 print '5925: com = 3+4i';
5460 print '5926: test unused';
5461 print '5927: test unused';
5462 print '5928: test unused';
5463 print '5929: test unused';
5468 vrfy(isassoc(loc) == 0, '5930: isassoc(loc) == 0');
5469 vrfy(isassoc(a) == 1, '5931: isassoc(a) == 1');
5470 vrfy(isassoc(ofd) == 0, '5932: isassoc(ofd) == 0');
5471 vrfy(isassoc(cfd) == 0, '5933: isassoc(cfd) == 0');
5472 vrfy(isassoc(blk) == 0, '5934: isassoc(blk) == 0');
5473 vrfy(isassoc(nblk) == 0, '5935: isassoc(nblk) == 0');
5474 vrfy(isassoc(cfg) == 0, '5936: isassoc(cfg) == 0');
5475 vrfy(isassoc(serr) == 0, '5937: isassoc(serr) == 0');
5476 vrfy(isassoc(nerr) == 0, '5938: isassoc(nerr) == 0');
5477 vrfy(isassoc(odd) == 0, '5939: isassoc(odd) == 0');
5478 vrfy(isassoc(even) == 0, '5940: isassoc(even) == 0');
5479 vrfy(isassoc(hash) == 0, '5941: isassoc(hash) == 0');
5480 vrfy(isassoc(id) == 0, '5942: isassoc(id) == 0');
5481 vrfy(isassoc(list) == 0, '5943: isassoc(list) == 0');
5482 vrfy(isassoc(matrix) == 0, '5944: isassoc(matrix) == 0');
5483 vrfy(isassoc(nul) == 0, '5945: isassoc(nul) == 0');
5484 vrfy(isassoc(object) == 0, '5946: isassoc(object) == 0');
5485 vrfy(isassoc(rand) == 0, '5947: isassoc(rand) == 0');
5486 vrfy(isassoc(random) == 0, '5948: isassoc(random) == 0');
5487 vrfy(isassoc(real) == 0, '5949: isassoc(real) == 0');
5488 vrfy(isassoc(prime) == 0, '5950: isassoc(prime) == 0');
5489 vrfy(isassoc(square) == 0, '5951: isassoc(square) == 0');
5490 vrfy(isassoc(string) == 0, '5952: isassoc(string) == 0');
5491 vrfy(isassoc(com) == 0, '5953: isassoc(com) == 0');
5492 print '5954: test unused';
5493 print '5955: test unused';
5494 print '5955: test unused';
5495 print '5956: test unused';
5496 print '5957: test unused';
5497 print '5958: test unused';
5498 print '5959: test unused';
5503 vrfy(isatty(loc) == 0, '5960: isatty(loc) == 0');
5504 vrfy(isatty(a) == 0, '5961: isatty(a) == 0');
5505 vrfy(isatty(ofd) == 0, '5962: isatty(ofd) == 0');
5506 vrfy(isatty(cfd) == 0, '5963: isatty(cfd) == 0');
5507 vrfy(isatty(blk) == 0, '5964: isatty(blk) == 0');
5508 vrfy(isatty(nblk) == 0, '5965: isatty(nblk) == 0');
5509 vrfy(isatty(cfg) == 0, '5966: isatty(cfg) == 0');
5510 vrfy(isatty(serr) == 0, '5967: isatty(serr) == 0');
5511 vrfy(isatty(nerr) == 0, '5968: isatty(nerr) == 0');
5512 vrfy(isatty(odd) == 0, '5969: isatty(odd) == 0');
5513 vrfy(isatty(even) == 0, '5970: isatty(even) == 0');
5514 vrfy(isatty(hash) == 0, '5971: isatty(hash) == 0');
5515 vrfy(isatty(id) == 0, '5972: isatty(id) == 0');
5516 vrfy(isatty(list) == 0, '5973: isatty(list) == 0');
5517 vrfy(isatty(matrix) == 0, '5974: isatty(matrix) == 0');
5518 vrfy(isatty(nul) == 0, '5975: isatty(nul) == 0');
5519 vrfy(isatty(object) == 0, '5976: isatty(object) == 0');
5520 vrfy(isatty(rand) == 0, '5977: isatty(rand) == 0');
5521 vrfy(isatty(random) == 0, '5978: isatty(random) == 0');
5522 vrfy(isatty(real) == 0, '5979: isatty(real) == 0');
5523 vrfy(isatty(prime) == 0, '5980: isatty(prime) == 0');
5524 vrfy(isatty(square) == 0, '5981: isatty(square) == 0');
5525 vrfy(isatty(string) == 0, '5982: isatty(string) == 0');
5526 vrfy(isatty(com) == 0, '5983: isatty(com) == 0');
5527 print '5984: test disabled due to stdin dependency';
5528 /* if we pipe to awk (for make chk), stdout and stderr are not ttys */
5529 print '5985: test unused';
5530 print '5986: test unused';
5531 vrfy(isatty(files(3)) == 0, '5987: isatty(files(3)) == 0');
5532 print '5988: test unused';
5533 print '5989: test unused';
5538 vrfy(isblk(loc) == 0, '5990: isblk(loc) == 0');
5539 vrfy(isblk(a) == 0, '5991: isblk(a) == 0');
5540 vrfy(isblk(ofd) == 0, '5992: isblk(ofd) == 0');
5541 vrfy(isblk(cfd) == 0, '5993: isblk(cfd) == 0');
5542 vrfy(isblk(blk) == 1, '5994: isblk(blk) == 1');
5543 vrfy(isblk(nblk) == 2, '5995: isblk(nblk) == 2');
5544 vrfy(isblk(cfg) == 0, '5996: isblk(cfg) == 0');
5545 vrfy(isblk(serr) == 0, '5997: isblk(serr) == 0');
5546 vrfy(isblk(nerr) == 0, '5998: isblk(nerr) == 0');
5547 vrfy(isblk(odd) == 0, '5999: isblk(odd) == 0');
5548 vrfy(isblk(even) == 0, '6000: isblk(even) == 0');
5549 vrfy(isblk(hash) == 0, '6001: isblk(hash) == 0');
5550 vrfy(isblk(id) == 0, '6002: isblk(id) == 0');
5551 vrfy(isblk(list) == 0, '6003: isblk(list) == 0');
5552 vrfy(isblk(matrix) == 0, '6004: isblk(matrix) == 0');
5553 vrfy(isblk(nul) == 0, '6005: isblk(nul) == 0');
5554 vrfy(isblk(object) == 0, '6006: isblk(object) == 0');
5555 vrfy(isblk(rand) == 0, '6007: isblk(rand) == 0');
5556 vrfy(isblk(random) == 0, '6008: isblk(random) == 0');
5557 vrfy(isblk(real) == 0, '6009: isblk(real) == 0');
5558 vrfy(isblk(prime) == 0, '6010: isblk(prime) == 0');
5559 vrfy(isblk(square) == 0, '6011: isblk(square) == 0');
5560 vrfy(isblk(string) == 0, '6012: isblk(string) == 0');
5561 vrfy(isblk(com) == 0, '6013: isblk(com) == 0');
5562 print '6014: test unused';
5563 print '6015: test unused';
5564 print '6015: test unused';
5565 print '6016: test unused';
5566 print '6017: test unused';
5567 print '6018: test unused';
5568 print '6019: test unused';
5573 vrfy(isconfig(loc) == 0, '6020: isconfig(loc) == 0');
5574 vrfy(isconfig(a) == 0, '6021: isconfig(a) == 0');
5575 vrfy(isconfig(ofd) == 0, '6022: isconfig(ofd) == 0');
5576 vrfy(isconfig(cfd) == 0, '6023: isconfig(cfd) == 0');
5577 vrfy(isconfig(blk) == 0, '6024: isconfig(blk) == 0');
5578 vrfy(isconfig(nblk) == 0, '6025: isconfig(nblk) == 0');
5579 vrfy(isconfig(cfg) == 1, '6026: isconfig(cfg) == 1');
5580 vrfy(isconfig(serr) == 0, '6027: isconfig(serr) == 0');
5581 vrfy(isconfig(nerr) == 0, '6028: isconfig(nerr) == 0');
5582 vrfy(isconfig(odd) == 0, '6029: isconfig(odd) == 0');
5583 vrfy(isconfig(even) == 0, '6030: isconfig(even) == 0');
5584 vrfy(isconfig(hash) == 0, '6031: isconfig(hash) == 0');
5585 vrfy(isconfig(id) == 0, '6032: isconfig(id) == 0');
5586 vrfy(isconfig(list) == 0, '6033: isconfig(list) == 0');
5587 vrfy(isconfig(matrix) == 0, '6034: isconfig(matrix) == 0');
5588 vrfy(isconfig(nul) == 0, '6035: isconfig(nul) == 0');
5589 vrfy(isconfig(object) == 0, '6036: isconfig(object) == 0');
5590 vrfy(isconfig(rand) == 0, '6037: isconfig(rand) == 0');
5591 vrfy(isconfig(random) == 0, '6038: isconfig(random) == 0');
5592 vrfy(isconfig(real) == 0, '6039: isconfig(real) == 0');
5593 vrfy(isconfig(prime) == 0, '6040: isconfig(prime) == 0');
5594 vrfy(isconfig(square) == 0, '6041: isconfig(square) == 0');
5595 vrfy(isconfig(string) == 0, '6042: isconfig(string) == 0');
5596 vrfy(isconfig(com) == 0, '6043: isconfig(com) == 0');
5597 print '6044: test unused';
5598 print '6045: test unused';
5599 print '6045: test unused';
5600 print '6046: test unused';
5601 print '6047: test unused';
5602 print '6048: test unused';
5603 print '6049: test unused';
5608 vrfy(isdefined("loc") == 0, '6050: isdefined("loc") == 0');
5609 vrfy(isdefined("a") == 0, '6051: isdefined("a") == 0');
5610 vrfy(isdefined("ofd") == 0, '6052: isdefined("ofd") == 0');
5611 vrfy(isdefined("cfd") == 0, '6053: isdefined("cfd") == 0');
5612 vrfy(isdefined("blk") == 1, '6054: isdefined("blk") == 1');
5613 vrfy(isdefined("nblk") == 0, '6055: isdefined("nblk") == 0');
5614 vrfy(isdefined("cfg") == 0, '6056: isdefined("cfg") == 0');
5615 vrfy(isdefined("serr") == 0, '6057: isdefined("serr") == 0');
5616 vrfy(isdefined("nerr") == 0, '6058: isdefined("nerr") == 0');
5617 vrfy(isdefined("odd") == 0, '6059: isdefined("odd") == 0');
5618 vrfy(isdefined("even") == 0, '6060: isdefined("even") == 0');
5619 vrfy(isdefined("hash") == 1, '6061: isdefined("hash") == 1');
5620 vrfy(isdefined("id") == 0, '6062: isdefined("id") == 0');
5621 vrfy(isdefined("list") == 1, '6063: isdefined("list") == 1');
5622 vrfy(isdefined("matrix") == 0, '6064: isdefined("matrix") == 0');
5623 vrfy(isdefined("nul") == 0, '6065: isdefined("nul") == 0');
5624 vrfy(isdefined("object") == 0, '6066: isdefined("object") == 0');
5625 vrfy(isdefined("rand") == 1, '6067: isdefined("rand") == 1');
5626 vrfy(isdefined("random") == 1, '6068: isdefined("random") == 1');
5627 vrfy(isdefined("real") == 0, '6069: isdefined("real") == 0');
5628 vrfy(isdefined("prime") == 0, '6070: isdefined("prime") == 0');
5629 vrfy(isdefined("square") == 0, '6071: isdefined("square") == 0');
5630 vrfy(isdefined("string") == 0, '6072: isdefined("string") == 0');
5631 vrfy(isdefined("abs") == 1, '6073: isdefined("abs") == 1');
5632 vrfy(isdefined("notafunc") == 0, '6074: isdefined("notafunc") == 0');
5633 vrfy(isdefined("com") == 0, '6075: isdefined("com") == 0');
5634 print '6076: test unused';
5635 print '6077: test unused';
5636 print '6078: test unused';
5637 print '6079: test unused';
5642 vrfy(iserror(loc) == 0, '6080: iserror(loc) == 0');
5643 vrfy(iserror(a) == 0, '6081: iserror(a) == 0');
5644 vrfy(iserror(ofd) == 0, '6082: iserror(ofd) == 0');
5645 vrfy(iserror(cfd) == 0, '6083: iserror(cfd) == 0');
5646 vrfy(iserror(blk) == 0, '6084: iserror(blk) == 0');
5647 vrfy(iserror(nblk) == 0, '6085: iserror(nblk) == 0');
5648 vrfy(iserror(cfg) == 0, '6086: iserror(cfg) == 0');
5649 vrfy(iserror(serr) == 1, '6087: iserror(serr) == 1');
5650 vrfy(iserror(nerr) > 0, '6088: iserror(nerr) > 0');
5651 vrfy(iserror(odd) == 0, '6089: iserror(odd) == 0');
5652 vrfy(iserror(even) == 0, '6090: iserror(even) == 0');
5653 vrfy(iserror(hash) == 0, '6091: iserror(hash) == 0');
5654 vrfy(iserror(id) == 0, '6092: iserror(id) == 0');
5655 vrfy(iserror(list) == 0, '6093: iserror(list) == 0');
5656 vrfy(iserror(matrix) == 0, '6094: iserror(matrix) == 0');
5657 vrfy(iserror(nul) == 0, '6095: iserror(nul) == 0');
5658 vrfy(iserror(object) == 0, '6096: iserror(object) == 0');
5659 vrfy(iserror(rand) == 0, '6097: iserror(rand) == 0');
5660 vrfy(iserror(random) == 0, '6098: iserror(random) == 0');
5661 vrfy(iserror(real) == 0, '6099: iserror(real) == 0');
5662 vrfy(iserror(prime) == 0, '6100: iserror(prime) == 0');
5663 vrfy(iserror(square) == 0, '6101: iserror(square) == 0');
5664 vrfy(iserror(string) == 0, '6102: iserror(string) == 0');
5665 vrfy(iserror(com) == 0, '6103: iserror(com) == 0');
5666 print '6104: test unused';
5667 print '6105: test unused';
5668 print '6105: test unused';
5669 print '6106: test unused';
5670 print '6107: test unused';
5671 print '6108: test unused';
5672 print '6109: test unused';
5677 vrfy(iseven(loc) == 1, '6110: iseven(loc) == 1');
5678 vrfy(iseven(a) == 0, '6111: iseven(a) == 0');
5679 vrfy(iseven(ofd) == 0, '6112: iseven(ofd) == 0');
5680 vrfy(iseven(cfd) == 0, '6113: iseven(cfd) == 0');
5681 vrfy(iseven(blk) == 0, '6114: iseven(blk) == 0');
5682 vrfy(iseven(nblk) == 0, '6115: iseven(nblk) == 0');
5683 vrfy(iseven(cfg) == 0, '6116: iseven(cfg) == 0');
5684 vrfy(iseven(serr) == 0, '6117: iseven(serr) == 0');
5685 vrfy(iseven(nerr) == 0, '6118: iseven(nerr) == 0');
5686 vrfy(iseven(odd) == 0, '6119: iseven(odd) == 0');
5687 vrfy(iseven(even) == 1, '6120: iseven(even) == 1');
5688 vrfy(iseven(hash) == 0, '6121: iseven(hash) == 0');
5689 vrfy(iseven(id) == 0, '6122: iseven(id) == 0');
5690 vrfy(iseven(list) == 0, '6123: iseven(list) == 0');
5691 vrfy(iseven(matrix) == 0, '6124: iseven(matrix) == 0');
5692 vrfy(iseven(nul) == 0, '6125: iseven(nul) == 0');
5693 vrfy(iseven(object) == 0, '6126: iseven(object) == 0');
5694 vrfy(iseven(rand) == 0, '6127: iseven(rand) == 0');
5695 vrfy(iseven(random) == 0, '6128: iseven(random) == 0');
5696 vrfy(iseven(real) == 0, '6129: iseven(real) == 0');
5697 vrfy(iseven(prime) == 0, '6130: iseven(prime) == 0');
5698 vrfy(iseven(square) == 0, '6131: iseven(square) == 0');
5699 vrfy(iseven(string) == 0, '6132: iseven(string) == 0');
5700 vrfy(iseven(com) == 0, '6133: iseven(com) == 0');
5701 print '6134: test unused';
5702 print '6135: test unused';
5703 print '6135: test unused';
5704 print '6136: test unused';
5705 print '6137: test unused';
5706 print '6138: test unused';
5707 print '6139: test unused';
5712 vrfy(isfile(loc) == 0, '6140: isfile(loc) == 0');
5713 vrfy(isfile(a) == 0, '6141: isfile(a) == 0');
5714 vrfy(isfile(ofd) == 1, '6142: isfile(ofd) == 1');
5715 vrfy(isfile(cfd) == 1, '6143: isfile(cfd) == 1');
5716 vrfy(isfile(blk) == 0, '6144: isfile(blk) == 0');
5717 vrfy(isfile(nblk) == 0, '6145: isfile(nblk) == 0');
5718 vrfy(isfile(cfg) == 0, '6146: isfile(cfg) == 0');
5719 vrfy(isfile(serr) == 0, '6147: isfile(serr) == 0');
5720 vrfy(isfile(nerr) == 0, '6148: isfile(nerr) == 0');
5721 vrfy(isfile(odd) == 0, '6149: isfile(odd) == 0');
5722 vrfy(isfile(even) == 0, '6150: isfile(even) == 0');
5723 vrfy(isfile(hash) == 0, '6151: isfile(hash) == 0');
5724 vrfy(isfile(id) == 0, '6152: isfile(id) == 0');
5725 vrfy(isfile(list) == 0, '6153: isfile(list) == 0');
5726 vrfy(isfile(matrix) == 0, '6154: isfile(matrix) == 0');
5727 vrfy(isfile(nul) == 0, '6155: isfile(nul) == 0');
5728 vrfy(isfile(object) == 0, '6156: isfile(object) == 0');
5729 vrfy(isfile(rand) == 0, '6157: isfile(rand) == 0');
5730 vrfy(isfile(random) == 0, '6158: isfile(random) == 0');
5731 vrfy(isfile(real) == 0, '6159: isfile(real) == 0');
5732 vrfy(isfile(prime) == 0, '6160: isfile(prime) == 0');
5733 vrfy(isfile(square) == 0, '6161: isfile(square) == 0');
5734 vrfy(isfile(string) == 0, '6162: isfile(string) == 0');
5735 vrfy(isfile(com) == 0, '6163: isfile(com) == 0');
5736 vrfy(isfile(files(0)) == 1, '6164: isfile(files(0)) == 1');
5737 vrfy(isfile(files(1)) == 1, '6165: isfile(files(1)) == 1');
5738 vrfy(isfile(files(2)) == 1, '6166: isfile(files(2)) == 1');
5739 vrfy(isfile(files(3)) == 1, '6167: isfile(files(3)) == 1');
5740 print '6168: test unused';
5741 print '6169: test unused';
5746 vrfy(ishash(loc) == 0, '6170: ishash(loc) == 0');
5747 vrfy(ishash(a) == 0, '6171: ishash(a) == 0');
5748 vrfy(ishash(ofd) == 0, '6172: ishash(ofd) == 0');
5749 vrfy(ishash(cfd) == 0, '6173: ishash(cfd) == 0');
5750 vrfy(ishash(blk) == 0, '6174: ishash(blk) == 0');
5751 vrfy(ishash(nblk) == 0, '6175: ishash(nblk) == 0');
5752 vrfy(ishash(cfg) == 0, '6176: ishash(cfg) == 0');
5753 vrfy(ishash(serr) == 0, '6177: ishash(serr) == 0');
5754 vrfy(ishash(nerr) == 0, '6178: ishash(nerr) == 0');
5755 vrfy(ishash(odd) == 0, '6179: ishash(odd) == 0');
5756 vrfy(ishash(even) == 0, '6180: ishash(even) == 0');
5757 vrfy(ishash(hash) == 2, '6181: ishash(hash) == 2');
5758 vrfy(ishash(id) == 0, '6182: ishash(id) == 0');
5759 vrfy(ishash(list) == 0, '6183: ishash(list) == 0');
5760 vrfy(ishash(matrix) == 0, '6184: ishash(matrix) == 0');
5761 vrfy(ishash(nul) == 0, '6185: ishash(nul) == 0');
5762 vrfy(ishash(object) == 0, '6186: ishash(object) == 0');
5763 vrfy(ishash(rand) == 0, '6187: ishash(rand) == 0');
5764 vrfy(ishash(random) == 0, '6188: ishash(random) == 0');
5765 vrfy(ishash(real) == 0, '6189: ishash(real) == 0');
5766 vrfy(ishash(prime) == 0, '6190: ishash(prime) == 0');
5767 vrfy(ishash(square) == 0, '6191: ishash(square) == 0');
5768 vrfy(ishash(string) == 0, '6192: ishash(string) == 0');
5769 vrfy(ishash(com) == 0, '6193: ishash(com) == 0');
5770 print '6194: test unused';
5771 print '6195: test unused';
5772 print '6196: test unused';
5773 print '6197: test unused';
5774 print '6198: test unused';
5775 print '6199: test unused';
5780 vrfy(isident(loc) == 0, '6200: isident(loc) == 0');
5781 vrfy(isident(a) == 0, '6201: isident(a) == 0');
5782 vrfy(isident(ofd) == 0, '6202: isident(ofd) == 0');
5783 vrfy(isident(cfd) == 0, '6203: isident(cfd) == 0');
5784 vrfy(isident(blk) == 0, '6204: isident(blk) == 0');
5785 vrfy(isident(nblk) == 0, '6205: isident(nblk) == 0');
5786 vrfy(isident(cfg) == 0, '6206: isident(cfg) == 0');
5787 vrfy(isident(serr) == 0, '6207: isident(serr) == 0');
5788 vrfy(isident(nerr) == 0, '6208: isident(nerr) == 0');
5789 vrfy(isident(odd) == 0, '6209: isident(odd) == 0');
5790 vrfy(isident(even) == 0, '6210: isident(even) == 0');
5791 vrfy(isident(hash) == 0, '6211: isident(hash) == 0');
5792 vrfy(isident(id) == 1, '6212: isident(id) == 1');
5793 vrfy(isident(list) == 0, '6213: isident(list) == 0');
5794 vrfy(isident(matrix) == 0, '6214: isident(matrix) == 0');
5795 vrfy(isident(nul) == 0, '6215: isident(nul) == 0');
5796 vrfy(isident(object) == 0, '6216: isident(object) == 0');
5797 vrfy(isident(rand) == 0, '6217: isident(rand) == 0');
5798 vrfy(isident(random) == 0, '6218: isident(random) == 0');
5799 vrfy(isident(real) == 0, '6219: isident(real) == 0');
5800 vrfy(isident(prime) == 0, '6220: isident(prime) == 0');
5801 vrfy(isident(square) == 0, '6221: isident(square) == 0');
5802 vrfy(isident(string) == 0, '6222: isident(string) == 0');
5803 vrfy(isident(com) == 0, '6223: isident(com) == 0');
5804 print '6224: test unused';
5805 print '6225: test unused';
5806 print '6226: test unused';
5807 print '6227: test unused';
5808 print '6228: test unused';
5809 print '6229: test unused';
5814 vrfy(isint(loc) == 1, '6230: isint(loc) == 1');
5815 vrfy(isint(a) == 0, '6231: isint(a) == 0');
5816 vrfy(isint(ofd) == 0, '6232: isint(ofd) == 0');
5817 vrfy(isint(cfd) == 0, '6233: isint(cfd) == 0');
5818 vrfy(isint(blk) == 0, '6234: isint(blk) == 0');
5819 vrfy(isint(nblk) == 0, '6235: isint(nblk) == 0');
5820 vrfy(isint(cfg) == 0, '6236: isint(cfg) == 0');
5821 vrfy(isint(serr) == 0, '6237: isint(serr) == 0');
5822 vrfy(isint(nerr) == 0, '6238: isint(nerr) == 0');
5823 vrfy(isint(odd) == 1, '6239: isint(odd) == 1');
5824 vrfy(isint(even) == 1, '6240: isint(even) == 1');
5825 vrfy(isint(hash) == 0, '6241: isint(hash) == 0');
5826 vrfy(isint(id) == 0, '6242: isint(id) == 0');
5827 vrfy(isint(list) == 0, '6243: isint(list) == 0');
5828 vrfy(isint(matrix) == 0, '6244: isint(matrix) == 0');
5829 vrfy(isint(nul) == 0, '6245: isint(nul) == 0');
5830 vrfy(isint(object) == 0, '6246: isint(object) == 0');
5831 vrfy(isint(rand) == 0, '6247: isint(rand) == 0');
5832 vrfy(isint(random) == 0, '6248: isint(random) == 0');
5833 vrfy(isint(real) == 0, '6249: isint(real) == 0');
5834 vrfy(isint(prime) == 1, '6250: isint(prime) == 1');
5835 vrfy(isint(square) == 1, '6251: isint(square) == 1');
5836 vrfy(isint(string) == 0, '6252: isint(string) == 0');
5837 vrfy(isint(com) == 0, '6253: isint(com) == 0');
5838 print '6254: test unused';
5839 print '6255: test unused';
5840 print '6255: test unused';
5841 print '6256: test unused';
5842 print '6257: test unused';
5843 print '6258: test unused';
5844 print '6259: test unused';
5849 vrfy(islist(loc) == 0, '6260: islist(loc) == 0');
5850 vrfy(islist(a) == 0, '6261: islist(a) == 0');
5851 vrfy(islist(ofd) == 0, '6262: islist(ofd) == 0');
5852 vrfy(islist(cfd) == 0, '6263: islist(cfd) == 0');
5853 vrfy(islist(blk) == 0, '6264: islist(blk) == 0');
5854 vrfy(islist(nblk) == 0, '6265: islist(nblk) == 0');
5855 vrfy(islist(cfg) == 0, '6266: islist(cfg) == 0');
5856 vrfy(islist(serr) == 0, '6267: islist(serr) == 0');
5857 vrfy(islist(nerr) == 0, '6268: islist(nerr) == 0');
5858 vrfy(islist(odd) == 0, '6269: islist(odd) == 0');
5859 vrfy(islist(even) == 0, '6270: islist(even) == 0');
5860 vrfy(islist(hash) == 0, '6271: islist(hash) == 0');
5861 vrfy(islist(id) == 0, '6272: islist(id) == 0');
5862 vrfy(islist(list) == 1, '6273: islist(list) == 1');
5863 vrfy(islist(matrix) == 0, '6274: islist(matrix) == 0');
5864 vrfy(islist(nul) == 0, '6275: islist(nul) == 0');
5865 vrfy(islist(object) == 0, '6276: islist(object) == 0');
5866 vrfy(islist(rand) == 0, '6277: islist(rand) == 0');
5867 vrfy(islist(random) == 0, '6278: islist(random) == 0');
5868 vrfy(islist(real) == 0, '6279: islist(real) == 0');
5869 vrfy(islist(prime) == 0, '6280: islist(prime) == 0');
5870 vrfy(islist(square) == 0, '6281: islist(square) == 0');
5871 vrfy(islist(string) == 0, '6282: islist(string) == 0');
5872 vrfy(islist(com) == 0, '6283: islist(com) == 0');
5873 print '6284: test unused';
5874 print '6255: test unused';
5875 print '6285: test unused';
5876 print '6286: test unused';
5877 print '6287: test unused';
5878 print '6288: test unused';
5879 print '6289: test unused';
5884 vrfy(ismat(loc) == 0, '6290: ismat(loc) == 0');
5885 vrfy(ismat(a) == 0, '6291: ismat(a) == 0');
5886 vrfy(ismat(ofd) == 0, '6292: ismat(ofd) == 0');
5887 vrfy(ismat(cfd) == 0, '6293: ismat(cfd) == 0');
5888 vrfy(ismat(blk) == 0, '6294: ismat(blk) == 0');
5889 vrfy(ismat(nblk) == 0, '6295: ismat(nblk) == 0');
5890 vrfy(ismat(cfg) == 0, '6296: ismat(cfg) == 0');
5891 vrfy(ismat(serr) == 0, '6297: ismat(serr) == 0');
5892 vrfy(ismat(nerr) == 0, '6298: ismat(nerr) == 0');
5893 vrfy(ismat(odd) == 0, '6299: ismat(odd) == 0');
5894 vrfy(ismat(even) == 0, '6300: ismat(even) == 0');
5895 vrfy(ismat(hash) == 0, '6301: ismat(hash) == 0');
5896 vrfy(ismat(id) == 1, '6302: ismat(id) == 1');
5897 vrfy(ismat(list) == 0, '6303: ismat(list) == 0');
5898 vrfy(ismat(matrix) == 1, '6304: ismat(matrix) == 1');
5899 vrfy(ismat(nul) == 0, '6305: ismat(nul) == 0');
5900 vrfy(ismat(object) == 0, '6306: ismat(object) == 0');
5901 vrfy(ismat(rand) == 0, '6307: ismat(rand) == 0');
5902 vrfy(ismat(random) == 0, '6308: ismat(random) == 0');
5903 vrfy(ismat(real) == 0, '6309: ismat(real) == 0');
5904 vrfy(ismat(prime) == 0, '6310: ismat(prime) == 0');
5905 vrfy(ismat(square) == 0, '6311: ismat(square) == 0');
5906 vrfy(ismat(string) == 0, '6312: ismat(string) == 0');
5907 vrfy(ismat(com) == 0, '6313: ismat(com) == 0');
5908 print '6314: test unused';
5909 print '6215: test unused';
5910 print '6315: test unused';
5911 print '6316: test unused';
5912 print '6317: test unused';
5913 print '6318: test unused';
5914 print '6319: test unused';
5919 vrfy(ismult(odd,even) == 0, '6320: ismult(odd,even) == 0');
5920 vrfy(ismult(even,odd) == 1, '6321: ismult(even,odd) == 1');
5921 vrfy(ismult(odd,odd) == 1, '6322: ismult(odd,odd) == 1');
5922 vrfy(ismult(even,prime) == 0, '6323: ismult(even,prime) == 0');
5923 vrfy(ismult(square,prime) == 1, '6324: ismult(square,prime) == 1');
5924 vrfy(ismult(real,prime) == 0, '6325: ismult(real,prime) == 0');
5925 vrfy(ismult(real,real*34) == 0, '6326: ismult(real,real*34) == 0');
5926 vrfy(ismult(real*34,real) == 1, '6327: ismult(real*34,real) == 1');
5927 print '6328: test unused';
5928 print '6329: test unused';
5933 vrfy(isnull(loc) == 0, '6330: isnull(loc) == 0');
5934 vrfy(isnull(a) == 0, '6331: isnull(a) == 0');
5935 vrfy(isnull(ofd) == 0, '6332: isnull(ofd) == 0');
5936 vrfy(isnull(cfd) == 0, '6333: isnull(cfd) == 0');
5937 vrfy(isnull(blk) == 0, '6334: isnull(blk) == 0');
5938 vrfy(isnull(nblk) == 0, '6335: isnull(nblk) == 0');
5939 vrfy(isnull(cfg) == 0, '6336: isnull(cfg) == 0');
5940 vrfy(isnull(serr) == 0, '6337: isnull(serr) == 0');
5941 vrfy(isnull(nerr) == 0, '6338: isnull(nerr) == 0');
5942 vrfy(isnull(odd) == 0, '6339: isnull(odd) == 0');
5943 vrfy(isnull(even) == 0, '6340: isnull(even) == 0');
5944 vrfy(isnull(hash) == 0, '6341: isnull(hash) == 0');
5945 vrfy(isnull(id) == 0, '6342: isnull(id) == 0');
5946 vrfy(isnull(list) == 0, '6343: isnull(list) == 0');
5947 vrfy(isnull(matrix) == 0, '6344: isnull(matrix) == 0');
5948 vrfy(isnull(nul) == 1, '6345: isnull(nul) == 1');
5949 vrfy(isnull(object) == 0, '6346: isnull(object) == 0');
5950 vrfy(isnull(rand) == 0, '6347: isnull(rand) == 0');
5951 vrfy(isnull(random) == 0, '6348: isnull(random) == 0');
5952 vrfy(isnull(real) == 0, '6349: isnull(real) == 0');
5953 vrfy(isnull(prime) == 0, '6350: isnull(prime) == 0');
5954 vrfy(isnull(square) == 0, '6351: isnull(square) == 0');
5955 vrfy(isnull(string) == 0, '6352: isnull(string) == 0');
5956 vrfy(isnull(com) == 0, '6353: isnull(com) == 0');
5957 print '6354: test unused';
5958 print '6355: test unused';
5959 print '6355: test unused';
5960 print '6356: test unused';
5961 print '6357: test unused';
5962 print '6358: test unused';
5963 print '6359: test unused';
5968 vrfy(isnum(loc) == 1, '6360: isnum(loc) == 1');
5969 vrfy(isnum(a) == 0, '6361: isnum(a) == 0');
5970 vrfy(isnum(ofd) == 0, '6362: isnum(ofd) == 0');
5971 vrfy(isnum(cfd) == 0, '6363: isnum(cfd) == 0');
5972 vrfy(isnum(blk) == 0, '6364: isnum(blk) == 0');
5973 vrfy(isnum(nblk) == 0, '6365: isnum(nblk) == 0');
5974 vrfy(isnum(cfg) == 0, '6366: isnum(cfg) == 0');
5975 vrfy(isnum(serr) == 0, '6367: isnum(serr) == 0');
5976 vrfy(isnum(nerr) == 0, '6368: isnum(nerr) == 0');
5977 vrfy(isnum(odd) == 1, '6369: isnum(odd) == 1');
5978 vrfy(isnum(even) == 1, '6370: isnum(even) == 1');
5979 vrfy(isnum(hash) == 0, '6371: isnum(hash) == 0');
5980 vrfy(isnum(id) == 0, '6372: isnum(id) == 0');
5981 vrfy(isnum(list) == 0, '6373: isnum(list) == 0');
5982 vrfy(isnum(matrix) == 0, '6374: isnum(matrix) == 0');
5983 vrfy(isnum(nul) == 0, '6375: isnum(nul) == 0');
5984 vrfy(isnum(object) == 0, '6376: isnum(object) == 0');
5985 vrfy(isnum(rand) == 0, '6377: isnum(rand) == 0');
5986 vrfy(isnum(random) == 0, '6378: isnum(random) == 0');
5987 vrfy(isnum(real) == 1, '6379: isnum(real) == 1');
5988 vrfy(isnum(prime) == 1, '6380: isnum(prime) == 1');
5989 vrfy(isnum(square) == 1, '6381: isnum(square) == 1');
5990 vrfy(isnum(string) == 0, '6382: isnum(string) == 0');
5991 vrfy(isnum(com) == 1, '6379: isnum(com) == 1');
5992 print '6384: test unused';
5993 print '6385: test unused';
5994 print '6385: test unused';
5995 print '6386: test unused';
5996 print '6387: test unused';
5997 print '6388: test unused';
5998 print '6389: test unused';
6003 vrfy(isobj(loc) == 0, '6390: isobj(loc) == 0');
6004 vrfy(isobj(a) == 0, '6391: isobj(a) == 0');
6005 vrfy(isobj(ofd) == 0, '6392: isobj(ofd) == 0');
6006 vrfy(isobj(cfd) == 0, '6393: isobj(cfd) == 0');
6007 vrfy(isobj(blk) == 0, '6394: isobj(blk) == 0');
6008 vrfy(isobj(nblk) == 0, '6395: isobj(nblk) == 0');
6009 vrfy(isobj(cfg) == 0, '6396: isobj(cfg) == 0');
6010 vrfy(isobj(serr) == 0, '6397: isobj(serr) == 0');
6011 vrfy(isobj(nerr) == 0, '6398: isobj(nerr) == 0');
6012 vrfy(isobj(odd) == 0, '6399: isobj(odd) == 0');
6013 vrfy(isobj(even) == 0, '6400: isobj(even) == 0');
6014 vrfy(isobj(hash) == 0, '6401: isobj(hash) == 0');
6015 vrfy(isobj(id) == 0, '6402: isobj(id) == 0');
6016 vrfy(isobj(list) == 0, '6403: isobj(list) == 0');
6017 vrfy(isobj(matrix) == 0, '6404: isobj(matrix) == 0');
6018 vrfy(isobj(nul) == 0, '6405: isobj(nul) == 0');
6019 vrfy(isobj(object) == 1, '6406: isobj(object) == 1');
6020 vrfy(isobj(rand) == 0, '6407: isobj(rand) == 0');
6021 vrfy(isobj(random) == 0, '6408: isobj(random) == 0');
6022 vrfy(isobj(real) == 0, '6409: isobj(real) == 0');
6023 vrfy(isobj(prime) == 0, '6410: isobj(prime) == 0');
6024 vrfy(isobj(square) == 0, '6411: isobj(square) == 0');
6025 vrfy(isobj(string) == 0, '6412: isobj(string) == 0');
6026 vrfy(isobj(com) == 0, '6413: isobj(com) == 0');
6027 print '6414: test unused';
6028 print '6415: test unused';
6029 print '6415: test unused';
6030 print '6416: test unused';
6031 print '6417: test unused';
6032 print '6418: test unused';
6033 print '6419: test unused';
6038 vrfy(isobjtype("loc") == 0, '6420: isobjtype("loc") == 0');
6039 vrfy(isobjtype("a") == 0, '6421: isobjtype("a") == 0');
6040 vrfy(isobjtype("ofd") == 0, '6422: isobjtype("ofd") == 0');
6041 vrfy(isobjtype("xy5800") == 1, '6423: isobjtype("xy5800") == 1');
6042 vrfy(isobjtype("xy5900") == 1, '6424: isobjtype("xy5900") == 1');
6043 print '6425: test unused';
6044 print '6426: test unused';
6045 print '6427: test unused';
6046 print '6428: test unused';
6047 print '6429: test unused';
6052 vrfy(isodd(loc) == 0, '6430: isodd(loc) == 0');
6053 vrfy(isodd(a) == 0, '6431: isodd(a) == 0');
6054 vrfy(isodd(ofd) == 0, '6432: isodd(ofd) == 0');
6055 vrfy(isodd(cfd) == 0, '6433: isodd(cfd) == 0');
6056 vrfy(isodd(blk) == 0, '6434: isodd(blk) == 0');
6057 vrfy(isodd(nblk) == 0, '6435: isodd(nblk) == 0');
6058 vrfy(isodd(cfg) == 0, '6436: isodd(cfg) == 0');
6059 vrfy(isodd(serr) == 0, '6437: isodd(serr) == 0');
6060 vrfy(isodd(nerr) == 0, '6438: isodd(nerr) == 0');
6061 vrfy(isodd(odd) == 1, '6439: isodd(odd) == 1');
6062 vrfy(isodd(even) == 0, '6440: isodd(even) == 0');
6063 vrfy(isodd(hash) == 0, '6441: isodd(hash) == 0');
6064 vrfy(isodd(id) == 0, '6442: isodd(id) == 0');
6065 vrfy(isodd(list) == 0, '6443: isodd(list) == 0');
6066 vrfy(isodd(matrix) == 0, '6444: isodd(matrix) == 0');
6067 vrfy(isodd(nul) == 0, '6445: isodd(nul) == 0');
6068 vrfy(isodd(object) == 0, '6446: isodd(object) == 0');
6069 vrfy(isodd(rand) == 0, '6447: isodd(rand) == 0');
6070 vrfy(isodd(random) == 0, '6448: isodd(random) == 0');
6071 vrfy(isodd(real) == 0, '6449: isodd(real) == 0');
6072 vrfy(isodd(prime) == 1, '6450: isodd(prime) == 1');
6073 vrfy(isodd(square) == 1, '6451: isodd(square) == 1');
6074 vrfy(isodd(string) == 0, '6452: isodd(string) == 0');
6075 vrfy(isodd(com) == 0, '6453: isodd(com) == 0');
6076 print '6454: test unused';
6077 print '6455: test unused';
6078 print '6455: test unused';
6079 print '6456: test unused';
6080 print '6457: test unused';
6081 print '6458: test unused';
6082 print '6459: test unused';
6087 vrfy(isprime(loc) == 0, '6460: isprime(loc) == 0');
6088 vrfy(isprime(odd) == 1, '6461: isprime(odd) == 1');
6089 vrfy(isprime(even) == 0, '6462: isprime(even) == 0');
6090 vrfy(isprime(prime) == 1, '6463: isprime(prime) == 1');
6091 vrfy(isprime(square) == 0, '6464: isprime(square) == 0');
6092 print '6465: test unused';
6093 print '6466: test unused';
6094 print '6468: test unused';
6095 print '6468: test unused';
6096 print '6469: test unused';
6101 vrfy(isrand(loc) == 0, '6470: isrand(loc) == 0');
6102 vrfy(isrand(a) == 0, '6471: isrand(a) == 0');
6103 vrfy(isrand(ofd) == 0, '6472: isrand(ofd) == 0');
6104 vrfy(isrand(cfd) == 0, '6473: isrand(cfd) == 0');
6105 vrfy(isrand(blk) == 0, '6474: isrand(blk) == 0');
6106 vrfy(isrand(nblk) == 0, '6475: isrand(nblk) == 0');
6107 vrfy(isrand(cfg) == 0, '6476: isrand(cfg) == 0');
6108 vrfy(isrand(serr) == 0, '6477: isrand(serr) == 0');
6109 vrfy(isrand(nerr) == 0, '6478: isrand(nerr) == 0');
6110 vrfy(isrand(odd) == 0, '6479: isrand(odd) == 0');
6111 vrfy(isrand(even) == 0, '6480: isrand(even) == 0');
6112 vrfy(isrand(hash) == 0, '6481: isrand(hash) == 0');
6113 vrfy(isrand(id) == 0, '6482: isrand(id) == 0');
6114 vrfy(isrand(list) == 0, '6483: isrand(list) == 0');
6115 vrfy(isrand(matrix) == 0, '6484: isrand(matrix) == 0');
6116 vrfy(isrand(nul) == 0, '6485: isrand(nul) == 0');
6117 vrfy(isrand(object) == 0, '6486: isrand(object) == 0');
6118 vrfy(isrand(rand) == 1, '6487: isrand(rand) == 1');
6119 vrfy(isrand(random) == 0, '6488: isrand(random) == 0');
6120 vrfy(isrand(real) == 0, '6489: isrand(real) == 0');
6121 vrfy(isrand(prime) == 0, '6490: isrand(prime) == 0');
6122 vrfy(isrand(square) == 0, '6491: isrand(square) == 0');
6123 vrfy(isrand(string) == 0, '6492: isrand(string) == 0');
6124 vrfy(isrand(com) == 0, '6493: isrand(com) == 0');
6125 print '6494: test unused';
6126 print '6495: test unused';
6127 print '6495: test unused';
6128 print '6496: test unused';
6129 print '6497: test unused';
6130 print '6498: test unused';
6131 print '6499: test unused';
6136 vrfy(israndom(loc) == 0, '6500: israndom(loc) == 0');
6137 vrfy(israndom(a) == 0, '6501: israndom(a) == 0');
6138 vrfy(israndom(ofd) == 0, '6502: israndom(ofd) == 0');
6139 vrfy(israndom(cfd) == 0, '6503: israndom(cfd) == 0');
6140 vrfy(israndom(blk) == 0, '6504: israndom(blk) == 0');
6141 vrfy(israndom(nblk) == 0, '6505: israndom(nblk) == 0');
6142 vrfy(israndom(cfg) == 0, '6506: israndom(cfg) == 0');
6143 vrfy(israndom(serr) == 0, '6507: israndom(serr) == 0');
6144 vrfy(israndom(nerr) == 0, '6508: israndom(nerr) == 0');
6145 vrfy(israndom(odd) == 0, '6509: israndom(odd) == 0');
6146 vrfy(israndom(even) == 0, '6510: israndom(even) == 0');
6147 vrfy(israndom(hash) == 0, '6511: israndom(hash) == 0');
6148 vrfy(israndom(id) == 0, '6512: israndom(id) == 0');
6149 vrfy(israndom(list) == 0, '6513: israndom(list) == 0');
6150 vrfy(israndom(matrix) == 0, '6514: israndom(matrix) == 0');
6151 vrfy(israndom(nul) == 0, '6515: israndom(nul) == 0');
6152 vrfy(israndom(object) == 0, '6516: israndom(object) == 0');
6153 vrfy(israndom(rand) == 0, '6517: israndom(rand) == 0');
6154 vrfy(israndom(random) == 1, '6518: israndom(random) == 1');
6155 vrfy(israndom(real) == 0, '6519: israndom(real) == 0');
6156 vrfy(israndom(prime) == 0, '6520: israndom(prime) == 0');
6157 vrfy(israndom(square) == 0, '6521: israndom(square) == 0');
6158 vrfy(israndom(string) == 0, '6522: israndom(string) == 0');
6159 vrfy(israndom(com) == 0, '6523: israndom(com) == 0');
6160 print '6524: test unused';
6161 print '6525: test unused';
6162 print '6526: test unused';
6163 print '6527: test unused';
6164 print '6528: test unused';
6165 print '6529: test unused';
6170 vrfy(isreal(loc) == 1, '6530: isreal(loc) == 1');
6171 vrfy(isreal(a) == 0, '6531: isreal(a) == 0');
6172 vrfy(isreal(ofd) == 0, '6532: isreal(ofd) == 0');
6173 vrfy(isreal(cfd) == 0, '6533: isreal(cfd) == 0');
6174 vrfy(isreal(blk) == 0, '6534: isreal(blk) == 0');
6175 vrfy(isreal(nblk) == 0, '6535: isreal(nblk) == 0');
6176 vrfy(isreal(cfg) == 0, '6536: isreal(cfg) == 0');
6177 vrfy(isreal(serr) == 0, '6537: isreal(serr) == 0');
6178 vrfy(isreal(nerr) == 0, '6538: isreal(nerr) == 0');
6179 vrfy(isreal(odd) == 1, '6539: isreal(odd) == 1');
6180 vrfy(isreal(even) == 1, '6540: isreal(even) == 1');
6181 vrfy(isreal(hash) == 0, '6541: isreal(hash) == 0');
6182 vrfy(isreal(id) == 0, '6542: isreal(id) == 0');
6183 vrfy(isreal(list) == 0, '6543: isreal(list) == 0');
6184 vrfy(isreal(matrix) == 0, '6544: isreal(matrix) == 0');
6185 vrfy(isreal(nul) == 0, '6545: isreal(nul) == 0');
6186 vrfy(isreal(object) == 0, '6546: isreal(object) == 0');
6187 vrfy(isreal(rand) == 0, '6547: isreal(rand) == 0');
6188 vrfy(isreal(random) == 0, '6548: isreal(random) == 0');
6189 vrfy(isreal(real) == 1, '6549: isreal(real) == 1');
6190 vrfy(isreal(prime) == 1, '6550: isreal(prime) == 1');
6191 vrfy(isreal(square) == 1, '6551: isreal(square) == 1');
6192 vrfy(isreal(string) == 0, '6552: isreal(string) == 0');
6193 vrfy(isreal(com) == 0, '6553: isreal(com) == 0');
6194 print '6554: test unused';
6195 print '6555: test unused';
6196 print '6555: test unused';
6197 print '6556: test unused';
6198 print '6557: test unused';
6199 print '6558: test unused';
6200 print '6559: test unused';
6205 vrfy(isrel(odd,even) == 0, '6560: isrel(odd,even) == 0');
6206 vrfy(isrel(even,odd) == 0, '6561: isrel(even,odd) == 0');
6207 vrfy(isrel(odd,odd) == 0, '6562: isrel(odd,odd) == 0');
6208 vrfy(isrel(even,prime) == 1, '6563: isrel(even,prime) == 1');
6209 vrfy(isrel(square,prime) == 0, '6564: isrel(square,prime) == 0');
6210 vrfy(isrel(prime,square) == 0, '6565: isrel(prime,square) == 0');
6211 vrfy(isrel(even,square) == 1, '6566: isrel(even,square) == 1');
6212 vrfy(isrel(prime,even) == 1, '6567: isrel(prime,even) == 1');
6213 print '6568: test unused';
6214 print '6569: test unused';
6217 * test bit (this was isset and thus was included here, however
6218 * we leave it here for now rather than renumber
6221 vrfy(bit(odd,0) == 1, '6570: bit(odd,0) == 1');
6222 vrfy(bit(odd,1) == 0, '6571: bit(odd,1) == 0');
6223 vrfy(bit(odd,2) == 0, '6572: bit(odd,2) == 0');
6224 vrfy(bit(odd,3) == 1, '6573: bit(odd,3) == 1');
6225 vrfy(bit(real,4) == 1, '6574: bit(real,4) == 1');
6226 vrfy(bit(real,5) == 0, '6575: bit(real,5) == 0');
6227 vrfy(bit(real,6) == 1, '6576: bit(real,6) == 1');
6228 vrfy(bit(real,7) == 0, '6577: bit(real,7) == 0');
6229 print '6578: test unused';
6230 print '6579: test unused';
6235 vrfy(issimple(loc) == 1, '6580: issimple(loc) == 1');
6236 vrfy(issimple(a) == 0, '6581: issimple(a) == 0');
6237 vrfy(issimple(ofd) == 0, '6582: issimple(ofd) == 0');
6238 vrfy(issimple(cfd) == 0, '6583: issimple(cfd) == 0');
6239 vrfy(issimple(blk) == 0, '6584: issimple(blk) == 0');
6240 vrfy(issimple(nblk) == 0, '6585: issimple(nblk) == 0');
6241 vrfy(issimple(cfg) == 0, '6586: issimple(cfg) == 0');
6242 vrfy(issimple(serr) == 0, '6587: issimple(serr) == 0');
6243 vrfy(issimple(nerr) == 0, '6588: issimple(nerr) == 0');
6244 vrfy(issimple(odd) == 1, '6589: issimple(odd) == 1');
6245 vrfy(issimple(even) == 1, '6590: issimple(even) == 1');
6246 vrfy(issimple(hash) == 0, '6591: issimple(hash) == 0');
6247 vrfy(issimple(id) == 0, '6592: issimple(id) == 0');
6248 vrfy(issimple(list) == 0, '6593: issimple(list) == 0');
6249 vrfy(issimple(matrix) == 0, '6594: issimple(matrix) == 0');
6250 vrfy(issimple(nul) == 1, '6595: issimple(nul) == 1');
6251 vrfy(issimple(object) == 0, '6596: issimple(object) == 0');
6252 vrfy(issimple(rand) == 0, '6597: issimple(rand) == 0');
6253 vrfy(issimple(random) == 0, '6598: issimple(random) == 0');
6254 vrfy(issimple(real) == 1, '6599: issimple(real) == 1');
6255 vrfy(issimple(prime) == 1, '6600: issimple(prime) == 1');
6256 vrfy(issimple(square) == 1, '6601: issimple(square) == 1');
6257 vrfy(issimple(string) == 1, '6602: issimple(string) == 1');
6258 vrfy(issimple(com) == 1, '6603: issimple(com) == 1');
6259 print '6604: test unused';
6260 print '6605: test unused';
6261 print '6606: test unused';
6262 print '6607: test unused';
6263 print '6608: test unused';
6264 print '6609: test unused';
6269 vrfy(issq(loc) == 1, '6610: issq(loc) == 1');
6270 vrfy(issq(odd) == 0, '6611: issq(odd) == 0');
6271 vrfy(issq(even) == 0, '6612: issq(even) == 0');
6272 vrfy(issq(prime) == 0, '6613: issq(prime) == 0');
6273 vrfy(issq(square) == 1, '6614: issq(square) == 1');
6274 print '6615: test unused';
6275 print '6616: test unused';
6276 print '6618: test unused';
6277 print '6618: test unused';
6278 print '6619: test unused';
6283 vrfy(isstr(loc) == 0, '6620: isstr(loc) == 0');
6284 vrfy(isstr(a) == 0, '6621: isstr(a) == 0');
6285 vrfy(isstr(ofd) == 0, '6622: isstr(ofd) == 0');
6286 vrfy(isstr(cfd) == 0, '6623: isstr(cfd) == 0');
6287 vrfy(isstr(blk) == 0, '6624: isstr(blk) == 0');
6288 vrfy(isstr(nblk) == 0, '6625: isstr(nblk) == 0');
6289 vrfy(isstr(cfg) == 0, '6626: isstr(cfg) == 0');
6290 vrfy(isstr(serr) == 0, '6627: isstr(serr) == 0');
6291 vrfy(isstr(nerr) == 0, '6628: isstr(nerr) == 0');
6292 vrfy(isstr(odd) == 0, '6629: isstr(odd) == 0');
6293 vrfy(isstr(even) == 0, '6630: isstr(even) == 0');
6294 vrfy(isstr(hash) == 0, '6631: isstr(hash) == 0');
6295 vrfy(isstr(id) == 0, '6632: isstr(id) == 0');
6296 vrfy(isstr(list) == 0, '6633: isstr(list) == 0');
6297 vrfy(isstr(matrix) == 0, '6634: isstr(matrix) == 0');
6298 vrfy(isstr(nul) == 0, '6635: isstr(nul) == 0');
6299 vrfy(isstr(object) == 0, '6636: isstr(object) == 0');
6300 vrfy(isstr(rand) == 0, '6637: isstr(rand) == 0');
6301 vrfy(isstr(random) == 0, '6638: isstr(random) == 0');
6302 vrfy(isstr(real) == 0, '6639: isstr(real) == 0');
6303 vrfy(isstr(prime) == 0, '6640: isstr(prime) == 0');
6304 vrfy(isstr(square) == 0, '6641: isstr(square) == 0');
6305 vrfy(isstr(string) == 1, '6642: isstr(string) == 1');
6306 vrfy(isstr(com) == 0, '6643: isstr(com) == 0');
6307 print '6644: test unused';
6308 print '6645: test unused';
6309 print '6645: test unused';
6310 print '6646: test unused';
6311 print '6647: test unused';
6312 print '6648: test unused';
6313 print '6649: test unused';
6318 vrfy(istype(odd,even) == 1, '6650: istype(odd,even) == 1');
6319 vrfy(istype(even,odd) == 1, '6651: istype(even,odd) == 1');
6320 vrfy(istype(odd,odd) == 1, '6652: istype(odd,odd) == 1');
6321 vrfy(istype(even,prime) == 1, '6653: istype(even,prime) == 1');
6322 vrfy(istype(square,prime) == 1, '6654: istype(square,prime) == 1');
6323 vrfy(istype(prime,square) == 1, '6655: istype(prime,square) == 1');
6324 vrfy(istype(even,square) == 1, '6656: istype(even,square) == 1');
6325 vrfy(istype(prime,even) == 1, '6657: istype(prime,even) == 1');
6326 vrfy(istype(prime,com) == 0, '6658: istype(prime,com) == 0');
6327 vrfy(istype(matrix,com) == 0, '6659: istype(matrix,com) == 0');
6329 vrfy(istype(matrix,list) == 0, '6660: istype(matrix,list) == 0');
6330 vrfy(istype(matrix,odd) == 0, '6661: istype(matrix,odd) == 0');
6331 vrfy(istype(a,odd) == 0, '6662: istype(a,odd) == 0');
6334 * perform more extensive issq() testing
6337 for (i=0; i < 256; ++i) {
6338 /* rndval will be a square - even powers>0 of x>1 */
6339 rndexp = random(1, 16) * 2;
6340 rndint = random(2, 4294967296);
6344 rndval = rndint ^ rndexp;
6345 if (issq(rndval) == 0) {
6346 prob(strprintf("issq(%d^%d) returned 0",
6352 print '6663: issq() on 256 squares';
6354 print '****: failure(s): 6663: faiissq() on 256 squares';
6356 for (i=0; i < 256; ++i) {
6357 /* rndval will not be a square - 1 + even powers>0 of x>1 */
6358 rndexp = random(1, 16) * 2;
6359 rndint = random(2, 4294967296);
6360 rndval = rndint ^ rndexp;
6361 if (issq(rndval+1) != 0) {
6362 prob(strprintf("issq(%d^%d)+1 returned non-zero",
6368 print '6664: issq() on 256 squares+1';
6370 print '****: failure(s): 6664: issq() on 256 squares+1';
6372 print '6664: issq() on 256 squares+1';
6373 for (i=0; i < 256; ++i) {
6374 /* rndval will not be a square - odd powers>0 of x>1 */
6375 rndexp = (random(1, 16) * 2) + 1;
6376 rndint = random(2, 4294967296);
6380 rndval = rndint ^ rndexp;
6381 if (issq(rndval) != 0) {
6382 prob(strprintf("issq(%d^%d) returned non-zero",
6388 print '6665: issq() on 256 non-squares';
6390 print '****: failure(s): 6665: issq() on 256 non-squares';
6397 print '6666: blkfree("blk5900")';
6399 print '6667: fclose(ofd)';
6401 print '6668: Ending test_is';
6403 print '168: test_is()';
6407 * test_blk - test block of octets
6411 local A, B, C, A1, A2, B1;
6413 print '6700: Beginning test_blk';
6416 print '6701: A = blk(20);';
6417 vrfy(size(A) == 20, '6702: size(A) == 20');
6418 vrfy(sizeof(A) == 256, '6703: sizeof(A) == 256');
6420 print '6704: B = A;';
6421 vrfy(size(B) == 20, '6705: size(B) == 20');
6422 vrfy(A == B, '6706: A == B');
6425 print '6707: A[5] = 21;';
6426 vrfy(A[5] == 21, '6708: A[5] == 21');
6429 print '6709: A[6] = "abc";';
6430 vrfy(A[6] == ord('a'), '6710: A[6] == ord("a")');
6433 print '6711: A[7] = 260;';
6434 vrfy(A[7] == 4, '6712: A[7] == 4');
6437 print '6713: A[8] = 3+4i;';
6438 vrfy(A[8] == 3, '6714: A[8] == 3');
6440 vrfy(A != B, '6715: A != B');
6442 /* Equality of blocks of same data-length is unaffected by maxsizes */
6445 print '6716: C = blk(A, ,128);';
6446 vrfy(size(C) == size(A), '6717: size(C) == size(A)');
6447 vrfy(sizeof(C) == 128, '6718: sizeof(C) == 128');
6448 vrfy(C == A, '6719: C == A');
6450 /* Blocks of different lengths test as unequal */
6453 print '6720: C = blk(A,30);';
6454 vrfy(size(C) == 30, '6721: size(C) == 30');
6455 vrfy(C != A, '6722: C != A;');
6457 /* Reducing length to that of original data restores equality */
6460 print '6723: C = blk(C,20);';
6461 vrfy(C == A, '6724: C == A');
6463 /* Reading block beyond data length extends length */
6466 print '6725: A[29] = 7;';
6467 vrfy(A[29] == 7, '6726: A[29] == 7');
6468 vrfy(size(A) == 30, '6727: size(A) == 30');
6470 /* Reducing length clears memory beyond new length */
6473 print '6728: A = blk(A, 20);';
6474 vrfy(A[29] == 0, '6729: A[29] == 0');
6476 /* Reducing length to zero and initializing a few early values */
6478 A = blk(A,0) = {1,,3,,5};
6479 print '6730: A = blk(A,0) = {1,,3,5};';
6481 vrfy(A[4] == 5, '6731: A[4] == 5');
6482 vrfy(size(A) == 5, '6732: size(A) == 5');
6484 /* Assignment of copy with initialization */
6487 print '6733: B = A;';
6488 C=blk(A)={,,,,,,,,,,0xbb};
6489 print '6734: C=blk(A)={,,,,,,,,,,0xbb};';
6491 /* A has not been changed */
6493 vrfy(A == B, '6735: A == B');
6494 vrfy(C[10] == 0xbb, '6736: C[10] == 0xbb');
6496 /* Testing named blocks */
6498 A1 = blk("blk6700");
6499 print '6737: A1 = blk("blk6700");';
6500 A2 = blk("blk6700");
6501 print '6738: A2 = blk("blk6700");';
6502 vrfy(A1 == A2, '6739: A1 == A2');
6503 vrfy(size(A1) == 0, '6740: size(A1) == 0');
6504 vrfy(sizeof(A1) == 256, '6741: sizeof(A1) == 256');
6505 print '6742: test disabled: test(A1) == 0';
6506 print '6743: test disabled: str(A1) == "blk6700"';
6507 vrfy(blocks() == 1, '6744: blocks() == 1');
6508 vrfy(blocks(1) == A1, '6745: blocks(1) == A1');
6510 /* A second named block */
6512 B1 = blk("+++6700", 15, 10) = {1,2,3,4,5};
6514 '6746: B1 = blk("+++6700", 15 , 10) = {1,2,3,4,5};';
6515 vrfy(size(B1) == 15, '6747: size(B1) == 15');
6516 vrfy(sizeof(B1) == 20, '6748: sizeof(B1) == 20');
6517 vrfy(test(B1) == 1, '6749: test(B1) == 1');
6518 print '6750: test disabled: str(B1) == "+++6700"';
6519 vrfy(blocks() == 2, '6751: blocks() == 2');
6520 vrfy(blocks(2) == B1, '6752: blocks(2) == B1');
6521 vrfy(B1 != A1, '6753: B1 != A1');
6523 /* Referencing octets beyond datalen increases datalen */
6526 print '6754: A1[15] = 29;';
6527 vrfy(A1[15] == 29, '6755: A1[15] == 29');
6528 vrfy(A2[15] == 29, '6756: A2[15] == 29');
6529 vrfy(size(A1) == 16, '6757: size(A1) == 16');
6530 vrfy(test(A1) == 1, '6758: test(A1) == 1');
6532 print '6759: A1[99] = 11;';
6533 vrfy(size(A1) == 100, '6760: size(A1) == 100');
6534 vrfy(A1[99] == 11, '6761: A1[99] == 11');
6536 /* increasing chunksize */
6538 null(blk(A1, , 1000));
6539 print '6762: null(blk(A1, , 1000));';
6540 vrfy(size(A1) == 100, '6763: size(A1) == 100');
6541 vrfy(sizeof(A1) == 1000, '6764: sizeof(A1) == 1000');
6542 vrfy(A1[99] == 11, '6765: A1[99] == 11');
6544 /* reducing data-length */
6547 print '6766: A1 = blk(A1, 10);';
6548 vrfy(size(A1) == 10, '6767: size(A1) == 10');
6550 /* all octets now zero */
6552 vrfy(test(A1) == 0, '6768: test(A1) == 0');
6553 vrfy(A1[99] == 0, '6769: A1[99] == 0');
6555 /* freeing memory */
6558 print '6770: blkfree(A1);';
6560 /* freeing named block memory reduces number of unfreed blocks */
6562 vrfy(blocks() == 1, '6771: blocks() == 1');
6564 /* 'removed' block still exists but has zero size and maxsize */
6566 vrfy(blocks(1) == A1, '6772: blocks(1) == A1');
6567 vrfy(size(A1) == 0, '6773: size(A1) == 0');
6568 vrfy(sizeof(A1) == 0, '6774: sizeof(A1) == 0');
6569 vrfy(test(A1) == 0, '6775: test(A1) == 0');
6570 print '6776: test disabled: str(A1) == "blk6700"';
6572 /* Equality of named blocks not affected by freeing of memory */
6574 vrfy(A1 == A2, '6777: A1 == A2');
6576 /* Executing blk('blk6700') reallocates memory for A1 */
6578 null(blk('blk6700'));
6579 print '6778: null(blk("blk6700"));';
6580 vrfy(size(A1) == 0, '6779: size(A1) == 0');
6581 vrfy(sizeof(A1) == 1000, '6780: sizeof(A1) == 1000');
6583 /* A2 still refers to same block as A1 */
6586 print '6781: A1[100] = 0xff;';
6587 vrfy(A2[100] == 0xff, '6782: A2[100] == 0xff');
6589 /* A possibly confusing initialization and assignment */
6591 mat A1[2] = {A1, B1};
6592 print '6783: mat A1[2] = {A1, B1};';
6593 vrfy(A1[0] == A2, '6784: A1[0] == A2');
6594 vrfy(A1[1] == B1, '6785: A1[1] == B1');
6595 vrfy(A1[0][100] == 0xff, '6786: A1[0][100] == 0xff');
6597 print '6800: reserved for future expansion of test_blk';
6599 print '6899: Ending test_blk';
6601 print '169: parsed test_blk()';
6605 * test_blkcpy - test the new copy builtin function
6607 define test_blkcpy()
6609 local A, B, C, A1, A2, B1, fs, S, M1, M2, L1, L2, x;
6611 print '6800: Beginning test_blkcpy';
6613 A = blk() = {1,2,3,4,5};
6614 print '6801: A = blk() = {1,2,3,4,5};';
6616 print '6802: B = blk();';
6618 print '6803: blkcpy(B, A);';
6619 vrfy(A == B, '6804: A == B');
6621 print '6805: blkcpy(B, A, ,10)';
6622 vrfy(size(B) == 15, '6806: size(B) == 15');
6623 blkcpy(B, A, , 15, 3);
6624 print '6807: blkcpy(A, 3, B, 15);';
6625 vrfy(size(B) == 17, '6808: size(B) == 17');
6626 vrfy(B[16] == 5, '6809: B[16] == 5');
6628 /* create named block A1 and blkcpy A into B[0]... and B[100]... */
6630 x = rm("-f", "blk6800");
6631 print '6810: x = rm("-f", "blk6800")';
6632 A1 = blk("blk6800");
6633 print '6811: A1 = blk("blk6800");';
6634 vrfy(size(A1) == 0, '6812: size(A1) == 0');
6636 print '6813: blkcpy(A1, A);';
6637 vrfy(size(A1) == 5, '6814: size(A1) == 5');
6638 blkcpy(A1, A, ,100);
6639 print '6815: blkcpy(A1, A, ,100);';
6640 vrfy(size(A1) == 105, '6816: size(A1) == 105');
6642 /* create named block B1 and blkcpy first 5 octets of A1 to B[100]... */
6645 print '6817: B1 = blk("beta")';
6646 vrfy(size(B1) == 0, '6818: size(B1) == 0');
6647 blkcpy(B1, A1, 5, 100, 0);
6648 print '6819: blkcpy(B1, A1, 5, 100, 0)';
6649 vrfy(size(B1) == 105, '6820: size(B1) == 105');
6651 /* blkcpy the last 5 octets of B1 to a new block C */
6653 blkcpy(C = blk(), B1,5,,100);
6654 print '6821: blkcpy(C = blk(), B1,5,,100);';
6655 vrfy(C == A, '6822: C == A');
6657 /* blkcpy to and from a file */
6659 fs = fopen("junk6800", "w+");
6660 print '6823: fs = fopen("junk6800", "w+");';
6662 print '6824: blkcpy(fs, A);';
6663 vrfy(size(fs) == 5, '6825: size(f) == 5');
6664 blkcpy(B = blk(), fs);
6665 print '6826: blkcpy(B = blk(), fs);';
6666 vrfy(B == A, '6827: B == A');
6667 blkcpy(fs, A, ,100);
6668 print '6828: blkcpy(fs, A, ,100);';
6669 vrfy(size(fs) == 105, '6829: size(f) == 105');
6670 blkcpy(C = blk(), fs,2,,100);
6671 print '6830: blkcpy(C = blk(), fs,2,,100)';
6672 vrfy(C == (blk() = {1,2}), '6831: C == (blk() = {1,2}');
6674 /* blkcpy string to a block */
6677 print '6832: A = blk();';
6679 /* Note that "blk6800" is not here considered to name a block */
6681 blkcpy(A, "blk6800 ");
6682 print '6833: blkcpy(A, "blk6800");';
6683 vrfy(size(A) == 9, '6834: size(A) == 9');
6684 blkcpy(A, "beta", , 7);
6685 print '6835: blkcpy(A, "beta", , 7);';
6686 vrfy(size(A) == 12, '6836: size(A) == 12');
6688 /* read strings from A */
6690 S = strprintf("%s", A[0]);
6691 print '6837: S = strprintf("%s", A[0]);';
6692 vrfy(S == "blk6800beta", '6838: S == "blk6800beta"');
6693 S = strprintf("%s", A[8]);
6694 print '6839: S = strprintf("%s", A[8]);';
6695 vrfy(S == "eta", '6840: S == "eta"');
6697 mat M1[2,2] = {1,2,3,4};
6698 print '6841: mat M1[2,2] = {1,2,3,4};';
6700 print '6842: mat M2[4];';
6702 print '6843: blkcpy(M2, M1)';
6703 vrfy(M2 == (mat[4]={1,2,3,4}), '6844: M2 == (mat[4]={1,2,3,4}');
6704 blkcpy(M2, M2, 2, 2, 0);
6705 print '6845: blkcpy(M2, M2, 2, 2, 0);';
6706 vrfy(M2 == (mat[4]={1,2,1,2}), '6846: M2 == (mat[4]={1,2,1,2}');
6708 /* blkcpy between blocks and matrices */
6711 print '6847: B = blk()';
6713 print '6848: blkcpy(B, M1)';
6714 vrfy(B == (blk() = {1,2,3,4}), '6849: B == (blk() = {1,2,3,4}');
6715 blkcpy(M2, B, 2, ,2);
6716 print '6850: blkcpy(B,2,2,M2);';
6717 vrfy(M2 == (mat[4]={3,4,1,2}), '6851: M2 == (mat[4]={3,4,1,2})');
6719 /* blkcpy between matrices and lists */
6722 print '6852: L1 = makelist(4);';
6724 print '6853: blkcpy(L1, M2);';
6726 blkcpy(M2, L1, 2, ,2);
6727 print '6854: blkcpy(M2, L1, 2, ,2);';
6728 vrfy(M2 == (mat[4]={1,2,1,2}), '6855: M2 == (mat[4]={1,2,1,2}');
6730 /* blkcpy lists to lists */
6733 print '6856: L2 = makelist(4);';
6735 print '6857: blkcpy(L2, L1);';
6736 vrfy(L1 == L2, '6858: L1 == L2');
6737 blkcpy(L2, L1, 2, 2, 0);
6738 print '6859: blkcpy(L2, L1, 2, 2, 0)';
6739 vrfy(L2 == list(3,4,3,4), '6860: L2 == list(3,4,3,4)');
6741 /* blkcpy between structures and substructures */
6744 print '6861: M2[0] = L2;';
6746 print '6862: blkcpy(M2, M2[0]);';
6747 vrfy(M2 == (mat[4]={3,4,3,4}), '6863: M2 == (mat[4]={3,4,3,4})');
6748 M2[2] = list(1,2,3,4);
6749 print '6864: M2[2] = list(1,2,3,4);';
6751 print '6865: blkcpy(M2[2], M2);';
6752 vrfy(M2[2][[2]][[2]] == 3, '6866: M2[2][[2]][[2]] == 3');
6756 print '6867: fclose(fs)';
6758 print '6868: x = rm("junk6800")';
6760 print '6868: Ending test_blkcpy';
6762 print '170: parsed test_blkcpy()';
6766 * test_name - test the name builtin
6772 print '6900: Beginning test_name';
6774 x = rm("-f", "junk6900");
6775 print '6901: x = rm("-f", "junk6900")';
6776 f = fopen("junk6900", "w");
6777 print '6902: f = fopen("junk6900", "w")';
6778 vrfy(name(f) == "junk6900", '6903: name(f) == "junk6900"');
6780 /* file stream loses name when file is closed */
6783 print '6904: fclose(f)';
6784 vrfy(name(f) == null(), '6905: name(f) == null()');
6786 print '6906: A = blk("blk6900")';
6787 vrfy(name(A) == "blk6900", '6907: name(A) == "blk6900"');
6789 /* name of block is not lost when its data memory is freed */
6792 print '6908: blkfree("blk6900");';
6793 vrfy(name(A) == "blk6900", '6909: name(A) == "blk6900"');
6795 /* values other than named blocks and files have no name */
6797 vrfy(name(27) == null(), '6910: name(27) == null()');
6802 print '6911: x = rm("junk6900")';
6804 print '6912: Ending test_name';
6806 print '171: parsed test_name()';
6810 * test_blkprintf - test blk printf
6812 define test_blkprintf()
6816 print '7000: Beginning test_blkprintf';
6818 print '7001: A = blk("alpha")';
6820 print '7002: B = blk();';
6822 print '7003: copy("abc yz", A);';
6824 print '7004: copy("defg", B);';
6825 vrfy(strprintf("%s", A) == "abc yz",
6826 '7005: strprintf("%s", A) == "abc yz"');
6827 vrfy(strprintf("%s", A[2]) == "c yz",
6828 '7006: strprintf("%s", A[2]) == "c yz"');
6829 vrfy(strprintf("%s", A[7]) == "",
6830 '7007: strprintf("%s", A[7]) == ""');
6831 vrfy(strprintf("%c", A) == "a",
6832 '7008: strprintf("%c", A == "a"');
6833 vrfy(strprintf("%c", A[4]) == "y",
6834 '7009: strprintf("%c", A[4]) == "y"');
6835 vrfy(strprintf("%s", B) == "defg",
6836 '7010: strprintf("%s", B) == "defg"');
6837 vrfy(strprintf("%s", B[1]) == "efg",
6838 '7011: strprintf("%s", B[1]) == "efg"');
6839 vrfy(strprintf("%s", B[7]) == "",
6840 '7012: strprintf("%s", B[7]) == ""');
6841 vrfy(strprintf("%c", B) == "d",
6842 '7013: strprintf("%c", B == "d"');
6843 vrfy(strprintf("%c", B[2]) == "f",
6844 '7014: strprintf("%c", B[2]) == "f"');
6846 print '7015: Ending test_blkprintf';
6848 print '172: parsed test_blkprintf()';
6852 * test_sha1 - test the sha1 hash
6856 local a, b, c, d, e, f, x, y, z, L, M, B;
6858 print '7200: Beginning test_sha1';
6860 print '7201: y = sha1();';
6862 print '7202: z = sha1();';
6863 vrfy(y == z, '7203: y == z');
6865 print '7204: z = sha1(1);';
6866 vrfy(sha1(y,1) == z, '7205: sha1(y,1) == z');
6867 vrfy(sha1(z,2) == sha1(1,2), '7206: sha1(z,2) == sha1(1,2)');
6868 vrfy(sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709,
6869 '7207: sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709');
6870 vrfy(sha1("x", "y", "z") == sha1("xyz"),
6871 '7208: sha1("x", "y", "z") == sha1("xyz")');
6873 vrfy(sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) ==
6874 0xc3e1b562bf45b3bcfc055ac65b5b39cdeb6a6c55,
6875 '7209: sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == ...');
6878 z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));
6879 print '7210: z = sha1(list(1,2,3), "curds and whey",',
6880 '2^21701-1, pi(1e-100));';
6881 vrfy(sha1(z) == 0x158cc87deeb9dd478ca14e3ab359205b0fb15b83,
6882 '7211: sha1(z) == 0x158cc87deeb9dd478ca14e3ab359205b0fb15b83');
6885 print '7212: y = sha1();';
6886 y = sha1(y, list(1,2,3), "curds and whey");
6887 print '7213: y = sha1(y, list(1,2,3), "curds and whey");';
6888 y = sha1(y, 2^21701-1);
6889 print '7214: y = sha1(y, 2^21701-1);';
6890 y = sha1(y, pi(1e-100));
6891 print '7215: y = sha1(y, pi(1e-100));';
6892 vrfy(y == z, '7216: y == z');
6894 vrfy(sha1(sha1("a"))==0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8,
6895 '7217: sha1(sha1("a"))==0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8');
6897 vrfy(sha1(sha1("ab"))==0xda23614e02469a0d7c7bd1bdab5c9c474b1904dc,
6898 '7218: sha1(sha1("ab"))==0xda23614e02469a0d7c7bd1bdab5c9c474b1904dc');
6899 vrfy(sha1(sha1("abc"))==0xa9993e364706816aba3e25717850c26c9cd0d89d,
6900 '7219: sha1(sha1("abc"))==0xa9993e364706816aba3e25717850c26c9cd0d89d'
6902 vrfy(sha1(sha1("abcd"))==0x81fe8bfe87576c3ecb22426f8e57847382917acf,
6903 '7220: sha1(sha1("abcd"))==0x81fe8bfe87576c3ecb22426f8e57847382917acf');
6904 vrfy(sha1(sha1("abcde"))==0x03de6c570bfe24bfc328ccd7ca46b76eadaf4334,
6905 '7221: sha1(sha1("abcde"))==0x03de6c570bfe24bfc328ccd7ca46b76eadaf4334');
6906 vrfy(sha1(sha1("abcdef"))== 0x1f8ac10f23c5b5bc1167bda84b833e5c057a77d2,
6907 '7222: sha1(sha1("abcdef"))==0x1f8ac10f23c5b5bc1167bda84b833e5c057a77d2');
6908 vrfy(sha1(sha1("abcdefg"))==0x2fb5e13419fc89246865e7a324f476ec624e8740,
6909 '7223: sha1(sha1("abcdefg"))==0x2fb5e13419fc89246865e7a324f476ec624e8740');
6910 vrfy(sha1(sha1("abcdefgh"))==0x425af12a0743502b322e93a015bcf868e324d56a,
6911 '7224: sha1(sha1("abcdefgh"))==0x425af12a0743502b322e93a015bcf868e324d56a');
6913 vrfy(sha1(sha1(1))==0x53dd4e1734ad47d45e41c23e4ce42d7f1f98c1e8,
6914 '7225: sha1(sha1(1))==0x53dd4e1734ad47d45e41c23e4ce42d7f1f98c1e8');
6915 vrfy(sha1(sha1(22/7))==0xf8e2510f85f7b9bf088b321188e9f70620f44246,
6916 '7226: sha1(sha1(22/7))==0xf8e2510f85f7b9bf088b321188e9f70620f44246');
6917 vrfy(sha1(sha1(isqrt(2e1000)))==
6918 0x6852a1365c51050c3d039e3c5d9cf29c12283ef4,
6919 '7227: sha1(sha1(isqrt(2e1000)))==0x6852a1365c51050c3d039e3c5d9cf29c12283ef4'
6922 print '7228: L = list(1,2,3)';
6924 print '7229: mat M[3] = {4,5,6}';
6925 B = blk() = {7,8,9};
6926 print '7230: B = blk() = {7,8,9}';
6927 vrfy(sha1(sha1(L), M, B) == sha1(L, M, B),
6928 '7231: sha1(sha1(L), M, B) == sha1(L, M, B)');
6929 vrfy(sha1(sha1(L,M), B) == sha1(L, M, B),
6930 '7232: sha1(sha1(L, M), B) == sha1(L, M, B)');
6932 print '7233: Ending test_sha1';
6934 print '174: parsed test_sha1()';
6938 * The 7400's contain tests for saveval and dot. These tests are
6939 * done inline near the bottom.
6944 * test_ptr - test pointers
6946 define g7500a(a,b) = a = b;
6947 print '176: define g7500a(a,b) = a = b';
6948 define g7500b(a,b) = a + b;
6949 print '177: define g7500b(a,b) = a + b';
6950 define g7500c(a,b) = *(a + b);
6951 print '178: define g7500c(a,b) = *(a + b)';
6952 define g7500d(a) = &a;
6953 print '179: define g7500d(a) = &a';
6954 define g7500e(a,b) = *a = b;
6955 print '180: define g7500e(a,b) = *a = b'
6958 local a, b, c, A, B, B1, B2, M, L, p, q, p0, q0;
6960 print '7500: Beginning test_ptr';
6962 vrfy(isoctet(27) == 0, '7501: isoctet(27) == 0');
6963 vrfy(isptr(27) == 0, '7502: isptr(27) == 0');
6965 /* testing octet pointers */
6967 B = blk() = {1,2,3,4,5,6};
6968 print '7503: B = blk() = {1,2,3,4,5,6};';
6969 vrfy(isoctet(B[0]) == 1, '7504: isoctet(B[0]) == 1');
6970 vrfy(isnum(B[0]) == 0, '7505: isnum(B[0]) == 0');
6971 vrfy(isptr(B[0]) == 0, '7506: isptr(B[0]) == 0');
6972 vrfy(isoctet(*B[0]) == 0, '7507: isoctet(*B[0]) == 0');
6973 vrfy(isnum(*B[0]) == 1, '7508: isnum(*B[0]) == 1');
6974 vrfy(isoctet(&B[0]) == 0, '7509: isoctet(&B[0]) == 0');
6975 vrfy(isptr(&B[0]) == 1, '7510: isptr(&B[0]) == 1');
6976 vrfy(*B[3] == B[3], '7511: *B[3]== B[3]');
6977 vrfy(*&B[3] == B[3], '7512: *&B[3] == B[3]');
6978 vrfy(&B[0] + 3 == &B[3], '7513: &B[0] + 3 == &B[3]');
6979 vrfy(&B[3] - &B[0] == 3, '7514: &B[3] - &B[0] == 3');
6980 vrfy(&B[3] - 3 == &B[0], '7515: &B[3 - 3 == &B[1]');
6981 vrfy(&B[3] > &B[0], '7516: &B[3] > &B[0]');
6983 print '7517: swap(B[0], B[5]);';
6984 vrfy(B[0] == 6 && B[5] == 1, '7518: B[0] == 6 && B[5] == 1');
6986 /* testing octet-pointer-valued variables */
6988 p = &B[0], q = &B[5];
6989 print '7519: p = &B[0], q = &B[5]';
6990 vrfy(isoctet(p) == 0, '7520: isoctet(p) == 0');
6991 vrfy(isptr(p) == 1, '7521: isptr(p) == 1');
6992 vrfy(isoctet(*p) == 1, '7522: isoctet(*p) == 1');
6993 vrfy(isptr(*p) == 0, '7523: isptr(*p) == 0');
6994 vrfy(p == &B[0], '7524: p == &B[0]');
6995 vrfy(q != p, '7525: q != p');
6996 vrfy(q > p, '7526: q > p');
6997 vrfy(*p == B[0], '7527: *p == B[0]');
6998 vrfy(&B[1] == p + 1, '7528: &B[1] == p + 1');
6999 vrfy(q == p + 5, '7529: q == p + 5');
7001 print '7530: *p = 1, *q = 6';
7002 vrfy(B[0] == 1 && B[5] == 6, '7531: B[0] == 1 && B[5] == 6');
7004 print '7532: a = *p, b = *q';
7005 vrfy(a == 1 && b == 6, '7533: a == 1 && b == 6');
7007 print '7534: *(p + 3) = 7;';
7008 vrfy(B[3] == 7, '7535: B[3] == 7');
7010 print '7536: *(q - 2) = 8;';
7011 vrfy(B[3] == 8, '7537: B[3] == 8');
7013 print '7538: p0 = p++;';
7014 vrfy(p0 == &B[0] && p == &B[1], '7539: p0 == &B[0] && p == &B[1]');
7016 print '7540: q0 = --q';
7017 vrfy(q0 == &B[4] && q == q0, '7541: q0 == &B[4] && q == q0');
7019 print '7542: a = *p++, b = *q--;';
7020 vrfy(a == 2 && b == 5, '7543: a == 2 && b == 5');
7021 vrfy(p - &B[0] == 2 && q == &B[0] + 3,
7022 '7544: p - &B[0] == 2 && q == &B[0] + 3');
7023 a = *--q, b = *----q;
7024 print '7545: a = *--q, b = *----q;';
7025 vrfy(q == &B[0], '7546: q == &B[0]');
7026 vrfy(a == 3 && b == 1, '7547: a == 3 && b == 1');
7028 print '7548: a = (*p)++;';
7029 vrfy(a == 3 && B[2] == 4, '7549: a == 3 && B[2] == 4');
7031 print '7550: a = ++(*++p)++;';
7032 vrfy(a == 9 && B[3] == 10, '7551: a == 9 && B[3] == 10');
7034 /* testing octets, & and * in arguments of user-defined functions */
7036 A = blk() = {1,2,3};
7037 print '7552: A = blk() = {1,2,3};';
7038 vrfy(g7500a(A[0],5) == 5, '7553: g7500a(A[0],5) == 5');
7039 vrfy(A[0] == 5, '7554: A[0] == 5');
7040 vrfy(g7500a(`A[0],5) == 5, '7555: g7500a(`A[0],5) == 5');
7041 vrfy(A[0] == 5, '7556: A[0] == 5');
7042 vrfy(g7500b(&A[0],3) == &A[3], '7557: g7500b(&A[0],3) == &A[3]');
7043 vrfy(g7500c(&A[0],2) == 3, '7558: g7500c(&A[0], 2) == 3');
7044 vrfy(g7500d(`A[0]) == &A[0], '7559: g7500d(`A[0]) == &A[0]');
7046 print '7560: p = &A[0];';
7047 vrfy(g7500a(*p, 6) == 6, '7561: g7500a(*p, 6) == 6');
7048 vrfy(*p == 6, '7562: *p == 6');
7049 vrfy(g7500a(`*p,6) == 6, '7563: g7500a(`*p,6) == 6');
7050 vrfy(*p == 6, '7564: *p == 6');
7051 vrfy(g7500b(p,3) == p + 3, '7565: g7500b(p,3) == p + 3');
7052 vrfy(g7500c(p,2) == 3, '7566: g7500c(p,2) == 3');
7053 vrfy(g7500d(`*p) == p, '7567: g7500d(`*p) == p');
7054 vrfy(g7500e(p,4) == 4, '7568: g7500e(p,4) == 4');
7055 vrfy(A[0] == 4, '7569: A[0] == 4');
7056 vrfy(g7500e(p+2,5) == 5, '7570: g7500e(p+2,5) == 5');
7057 vrfy(A[2] == 5, '7571: A[2] == 5');
7059 /* testing pointers to values */
7062 print '7572: A = 27, p = &A;';
7063 vrfy(isptr(A) == 0, '7573: isptr(A) == 0');
7064 vrfy(isptr(&A) == 2, '7574: isptr(&A) == 2');
7065 vrfy(isptr(p) == 2, '7575: isptr(p) == 2');
7066 vrfy(*p == 27, '7576: *p == 27');
7067 vrfy(p == &A, '7577: p == &A');
7069 print '7578: *p = 45;';
7070 vrfy(A == 45, '7579: A == 45');
7072 print '7580: q = p;';
7073 vrfy(q == &A, '7581: q == &A');
7075 print '7582: q = &p';
7076 vrfy(*q == p, '7583: *q == p');
7077 vrfy(**q == A, '7584: **q == A');
7078 vrfy(***q == A, '7585: ***q == A');
7079 M = mat[4] = {1,2,3,4};
7080 print '7586: M = mat[4] = {1,2,3,4};';
7082 print '7587: p = &M[0], *p = 5;';
7083 vrfy(M[0] == 5, '7588: M[0] == 5');
7085 print '7589: *++p = 6;';
7086 vrfy(M[1] == 6, '7590: M[1] == 6');
7088 print '7591: q = p++;';
7089 vrfy(q == &M[1], '7592: q == &M[1]');
7090 vrfy(p == &M[2], '7593: p == &M[2]');
7092 print '7594: quomod(17,5,*p,*q);';
7093 vrfy(M[1] == 3 && M[2] == 2, '7595: M[1] == 3 && M[2] == 2');
7095 print '7596: swap(*p, *q);';
7096 vrfy(M[1] == 2 && M[2] == 3, '7597: M[1] == 2 && M[2] == 3');
7098 print '7598: A = *M = {7,8};';
7099 vrfy(M == (mat[4] = {5,2,3,4}), '7599: M == (mat[4] = {5,2,3,4})');
7100 vrfy(A == (mat[4] = {7,8,3,4}), '7600: A == (mat[4] = {7,8,3,4})');
7102 /* Values which point to themselves */
7105 print '7601: A = &A;';
7106 vrfy(&A == A && *A == A, '7602: &A == A && *A == A');
7108 print '7603: A = &B, B = &A;';
7109 vrfy(**A == A && ***A == B, '7604: **A == A && ***A == B');
7111 /* Testing functions that return pointers */
7114 print '7605: M[3] = 7;';
7115 vrfy(*g7500b(&M[1], 2) == 7, '7606: *g7500b(&M[1], 2) == 7');
7117 *g7500b(&M[1], 2) = 8;
7118 print '7607: *g7500b(&M[1], 2) = 8;';
7119 vrfy(M[3] == 8, '7608: M[3] == 8');
7121 print '7609: M[3] = list(9,10);';
7122 vrfy((*g7500b(&M[1], 2))[[1]] == 10,
7123 '7610: (*g7500b(&M[1], 2))[[1]] == 10');
7125 /* Testing number and string pointers */
7127 a = 24, b = 4 * 6, c = 4!;
7128 print '7611: a = 24, b = 4 * 6, c= 4!;';
7129 vrfy(isptr(&*a) == 4, '7612: isptr(&*a) == 4');
7130 vrfy(&*a == &24, '7613: &*a == &24');
7131 vrfy(&*a == &*b, '7614: &*a == &*b');
7132 vrfy(&*a != &*c, '7615: &*a != &*c');
7134 a = b = "abc", c = strcat("a", "bc");
7135 print '7616: a = b = "abc", c = strcat("a", "bc");';
7136 vrfy(isptr(&*a) == 3, '7617: isptr(&*a) == 3');
7137 vrfy(&*a == &"abc", '7618: &*a == &"abc"');
7138 vrfy(&*a == &*b, '7619: &*a == &*b');
7139 vrfy(&*a != &*c, '7620: &*a != &*c');
7141 print '7621: a = c;';
7142 vrfy(&*a == &*c, '7622: &*a == &*c');
7144 /* Verifying null-ness of freed numbers */
7146 c = 4!, p = &*c, free(c);
7147 print '7623: c = 4!, p = &*c, free(c)';
7148 vrfy(isnull(*p), '7624: isnull(*p)');
7150 print '7625: Ending test_ptr';
7152 print '181: parsed test_ptr()';
7156 * test_newstring - test new string operations
7158 define test_newstring()
7160 local A, B, C, D, S, p, q;
7162 print '7700: Beginning test_newstring';
7164 A = "abcdef", B = "xyz";
7165 print '7701: A = "abcdef", B = "xyz";';
7166 vrfy(A + B == "abcdefxyz", '7702: A + B == "abcdefxyz"');
7167 vrfy(-A == "fedcba", '7703: -A == "fedcba"');
7168 vrfy(A - B == "abcdefzyx", '7704: A - B == "abcdefzyx"');
7169 vrfy(2 * B == "xyzxyz", '7705: 2 * B == "xyzxyz"');
7170 vrfy(-2 * B == "zyxzyx", '7706: -2 * B == "zyxzyx"');
7171 vrfy(B * 3 == "xyzxyzxyz", '7707: B * 3 == "xyzxyzxyz"');
7172 vrfy(2.5 * B == "xyzxyzx", '7708: 2.5 * B == "xyzxyzx"');
7173 vrfy(0 * B == "", '7709: 0 * B == ""');
7174 vrfy(3 * "12" == "121212", '7710: 2 * "12" == "121212"');
7175 vrfy(A/2 == "abc", '7711: A/2 == "abc"');
7176 vrfy(A | B == "y\173\173def", '7712: A | B == "y\\173\\173def"');
7177 vrfy(A & B == "``b", '7713: A & B == "``b"');
7178 vrfy(A \ B == "\1\2\1def", '7714: A \\ B == "\\1\\2\\1def"');
7179 vrfy(A ~ B == "\31\e\31def", '7715: A ~ B == "\\31\\e\\31def"');
7180 vrfy(~B == "\207\206\205", '7716: ~B == "\\207\\206\\205"');
7182 print '7717: C = "abcdef";';
7183 vrfy(&*A == &*C, '7718: &*A == &*C');
7185 print '7719: D = "abc\0ef;"';
7186 vrfy(size(D) == 6, '7720: size(D) == 6');
7187 vrfy(strlen(D) == 3, '7721: strlen(D) == 3');
7188 vrfy(strcat(D,B) == "abcxyz", '7722: strcat(D,B) == "abcxyz"');
7190 vrfy(bit(A,0) == 1, '7723: bit(A,0) == 1');
7191 vrfy(!bit(A,12), '7724: !bit(A,12)');
7192 vrfy(bit(A,13), '7725: bit(A,13)');
7193 vrfy(lowbit(A) == 0, '7726: lowbit(A) == 0');
7194 vrfy(highbit(A) == 46, '7727: highbit(A) == 46');
7195 vrfy(#A == 21, '7728: #A == 21');
7197 vrfy(A[2] == "c", '7729: A[2] == "c"');
7198 vrfy(char(A[2]) == "c", '7730: char(A[2]) == "c"');
7199 vrfy(A[2] == 99, '7731: A[2] == 99');
7200 vrfy(ord(A[2]) == 99, '7731: ord(A[2]) == 99');
7201 vrfy(A[2] == A[0] + 2, '7732: A[2] == A[0] + 2');
7202 vrfy(3 * A[2] == 297, '7733: 3 * A[2] == 297');
7203 vrfy(3 * char(A[2]) == "ccc", '7734: 3 * char(A[2]) == "ccc"');
7205 vrfy(head(A,3) == "abc", '7735: head(A,3) == "abc"');
7206 vrfy(head(A,-3) == "cba", '7736: head(A,-3) == "cba"');
7207 vrfy(tail(A,3) == "def", '7737: tail(A,3) == "def"');
7208 vrfy(tail(A,-3) == "fed", '7738: tail(A,-3) == "fed"');
7209 vrfy(segment(A,2) == "c", '7739: segment(A,2) == "c"');
7210 vrfy(segment(A,2,4) == "cde", '7740: segment(A,2,4) == "cde"');
7211 vrfy(segment(A,4,2) == "edc", '7741: segment(A,4,2) == "edc"');
7213 vrfy(search(A, "c") == 2, '7742: search(A, "c") == 2');
7214 vrfy(search(A, "x") == null(), '7743: search(A, "x") == null()');
7215 vrfy(search("abbcbc", "bc") == 2,
7216 '7744: search("abbcbc", "bc") == 2');
7217 vrfy(search("abbcbc", "bc", 2) == 2,
7218 '7745: search("abbcbc", "bc", 2) == 2');
7219 vrfy(search("abbcbc", "bc", 3) == 4,
7220 '7746: search("abbcbc", "bc", 3) == 4');
7221 vrfy(search("abbcbc", "bc", -3) == 4,
7222 '7747: search("abbcbc", "bc", -3) == 4');
7223 vrfy(search("abbcbc", "bc", -4) == 2,
7224 '7748: search("abbcbc", "bc", -4) == 2');
7225 vrfy(search("abbcbc", "bc", , 3) == null(),
7226 '7749: search("abbcbc", "bc", , 3) == null()');
7227 vrfy(search("abbcbc", "bc", , 4) == 2,
7228 '7750: search("abbcbc", "bc", , 4) == 2');
7230 vrfy(rsearch("abbcbc", "bc") == 4,
7231 '7751: rsearch("abbcbc", "bc") == 4');
7234 print '7752: p = &A[0];';
7235 vrfy(-*p == -97, '7753: -*p == -97');
7236 vrfy(~*p == char(158), '7754: ~*p == char(158)');
7237 vrfy(/-#~*p == -1/5, '7755: /-#~*p == -1/5');
7240 print '7756: A[0] = "A";';
7241 vrfy(A == "Abcdef", '7757: A == "Abcdef"');
7243 print '7758: A[1] = 173;';
7244 vrfy(A == "A\255cdef", '7759: A == "A\\255cdef"');
7246 print '7760: setbit(A,10);';
7247 vrfy(A == "A\255gdef", '7761: A == "A\\255gdef"');
7249 print '7762: setbit(A, 16, 0);';
7250 vrfy(A == "A\255fdef", '7763: A == "A\255fdef"');
7252 q = "curds" " and " "whey";
7253 print '7764: q = "curds" " and " "whey"';
7254 vrfy(q == "curds and whey", '7765: q == "curds and whey"');
7255 q = "chongo" ' was ' "here";
7256 print '7766: q = "chongo" \' was \' "here"';
7257 vrfy(q == "chongo was here", '7767: q == "chongo was here"');
7259 print '7768: Ending test_newstring';
7261 print '182: parsed test_newstring()';
7266 * test_newcomb - test combinatoric and permutation functions
7268 define test_newcomb()
7270 print '7800: Beginning test_newcomb';
7271 vrfy(comb(2, 5) == 0, '7801: comb(2, 5) == 0');
7272 vrfy(comb(2, -2) == 0, '7802: comb(2, -2) == 0');
7273 vrfy(comb(1/2, 4) == -5/128, '7803: comb(1/2, 4) == -5/128');
7274 vrfy(comb(1/2, 5) == 7/256, '7804: comb(1/2, 5) == 7/256');
7276 vrfy(perm(2, -1) == 1/3, '7805: perm(2, -1) == 1/3');
7277 vrfy(perm(2, -2) == 1/12, '7806: perm(2, -2) == 1/12');
7278 vrfy(perm(2, -3) == 1/60, '7807: perm(2, -3) == 1/60');
7279 vrfy(perm(1/2, 4) == -15/16, '7808: perm(1/2, 4) == -15/16');
7280 vrfy(perm(1/2, 5) == 105/32, '7809: perm(1/2, 5) == 105/32');
7281 vrfy(perm(1/2,-1) == 2/3, '7810: perm(1/2, -1) == 2/3');
7282 vrfy(perm(1/2,-2) == 4/15, '7811: perm(1/2, -2) == 4/15');
7284 print '7812: Ending test_newcomb';
7286 print '183: parsed test_newcomb()';
7290 * The following functions f, g should be equal when b-a is an
7291 * integer, and n is any integer other than -1.
7298 return -f7900(b, a, n);
7299 for (s = 0, x = a; x < b; x++)
7303 print '184: define f7900(a,b,n) {... }';
7305 define g7900(a,b,n) = (perm(b, n + 1) - perm(a, n + 1))/(n + 1);
7306 print '185: define g7900(a,b,n) = ...';
7310 * test_bigcomb - test big combinations and permutations
7312 define test_bigcomb()
7314 local a, b, n, i, v1, v2;
7316 print '7900: Starting test_bigcomb';
7318 print '7901: a = 1234/4321';
7320 print '7902: b = 3456/6543';
7322 print '7903: n = 47';
7323 v1 = perm(a + b, n);
7324 print '7904: v1 = perm(a + b, n)';
7326 print '7905: v2 = 0';
7327 for (i = 0; i <= n; i++)
7328 v2 += comb(n, i) * perm(a, i) * perm(b, n - i);
7329 print '7906: for (i=0;i<=n;i++) v2 += comb(n,i)*perm(a,i)*perm(b,n-i)';
7330 vrfy(v1 == v2, '7910: v1 == v2');
7332 vrfy(f7900(-10,10,5) == g7900(-10,10,5),
7333 '7911: f7900(-10,10,5) == g7900(10,10,5)');
7334 vrfy(f7900(5,15,-4) == g7900(5,15,-4),
7335 '7912: f7900(5,15,-4) == g7900(5,15,-4)');
7336 vrfy(f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2),
7337 '7913: f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2)');
7339 print '7914: Ending test_bigcomb';
7341 print '186: parsed test_bigcomb()';
7345 * natnumset - test natural numbers not exceeding a fixed bound
7347 read -once natnumset;
7348 print '187: read -once natnumset;';
7350 define test_natnumset()
7352 local A, B, C, D, P, P1, L1, L2;
7354 print '8000: Starting test_natnumset';
7356 A = set(17, 2, 0, 24, 2);
7357 print '8101: A = set(17, 2, 0, 24, 2);';
7358 B = set(41, 17, 11, 2, 19, 17);
7359 print '8102: B = set(41, 17, 11, 2, 19, 17);';
7360 vrfy(A | B == set(0,2,11,17,19,24,41),
7361 '8103: A | B == set(0,2,11,17,19,24,41)');
7362 vrfy(A & B == set(2,17), '8104: A & B == set(2,17)');
7363 vrfy(A \ B == set(0,24), '8105: A \\ B == set(0, 24)');
7364 vrfy(B \ A == set(11,19,41), '8106: B \\ A == set(11,19,41)');
7365 vrfy(A ~ B == set(0,11,19,24,41),
7366 '8107: A ~ B == set(0,11,19,24,41)');
7367 vrfy(#A == 4, '8108: #A == 4');
7368 vrfy(#~A == 97, '8109: #~A == 97');
7369 vrfy(A + 5 == set(5,7,22,29), '8110: A + 5 == set(5,7,22,29)');
7370 vrfy(A - 5 == set(12,19), '8111: A - 5 == set(12,19)');
7371 vrfy(30 - A == set(6,13,28,30), '8112: 30 - A == set(6,13,28,30)');
7372 vrfy(2 * A == set(0,4,34,48), '8113: 2 * A == set(0,4,34,48)');
7373 vrfy(10 * A == set(0,20), '8114: 10 * A == set(0,20)');
7374 vrfy(A + A == set(0,2,4,17,19,24,26,34,41,48),
7375 '8115: A + A == set(0,2,4,17,19,24,26,34,41,48)');
7376 vrfy(A - A == set(0,2,7,15,17,22,24),
7377 '8116: A - A == set(0,2,7,15,17,22,24)');
7378 vrfy(set(2,3,5,7)^2 == set(4,9,25,49),
7379 '8117: set(2,3,5,7)^2 == set(4,9,25,49)');
7380 vrfy(interval(8,12) == set(8,9,10,11,12),
7381 '8118: interval(8,12) == set(8,9,10,11,12)');
7382 vrfy(min(A) == 0, '8119: min(A) == 0');
7383 vrfy(max(A) == 24, '8120: max(A) == 24');
7385 print '8121: P = primes();';
7386 vrfy(#P == 25, '8122: #P == 25');
7387 vrfy(+P == 1060, '8123: +P == 1060');
7388 vrfy(isin(P,31), '8124: isin(P,31)');
7389 vrfy(!isin(P,51), '8125: !isin(P,51)');
7391 print '8126: P1 = primes(20,40)';
7392 vrfy(P1 == set(23,29,31,37), '8127: P1 == set(23,29,31,37)');
7393 vrfy(P1 < P, '8128: P1 < P');
7394 vrfy(P1 & (set(3) % 4) == set(23,31),
7395 '8129: P1 & (set(3) % 4) == set(23,31)');
7398 print '8130: L1 = list(3,2,1);';
7400 print '8131: C = set(2,3,5,7);';
7401 vrfy(polyvals(L1, C) == set(11,18,38,66),
7402 '8132: polyvals(L1, C) == set(11,18,38,66)');
7403 L2 = list(0,list(0,1),1);
7404 print '8133: L2 = list(0,list(0,1),1);';
7406 print '8134: D = set(4,6);';
7408 vrfy(polyvals2(L2,C,D) == set(12,16,21,27,45,55,77,91),
7409 '8135: polyvals(L2,C,D) == set(12,16,21,27,45,55,77,91)');
7411 print '8136: Ending test_natnumset';
7413 print '188: parsed test_natnumset()';
7417 * test_somenew - test some new features
7419 define func8200(x,y) {if (x>0) return calclevel()+func8200(x-1,y)-y; return 0;}
7420 print '189: define func8200(x,y)';
7421 define test_somenew()
7425 print '8200: Starting test_somenew';
7427 vrfy(char(-1) == char(255), '8201: char(-1) == char(255)');
7428 vrfy(char(258) == char(2), '8202: char(258) == char(2)');
7430 vrfy(size(char(0)) == 1, '8203: size(char(0)) == 1');
7431 vrfy(strlen(char(0)) == 0, '8204: strlen(char(0)) == 0');
7432 vrfy(char(0) != "", '8205: char(0) != ""');
7433 vrfy(str(char(0)) == "", '8206: str(char(0)) == ""');
7435 vrfy(str("abc") == "abc", '8207: str("abc") == "abc"');
7437 vrfy(2^-3^2 == 1/512, '8208: 2^-3^2 == 1/512');
7438 vrfy(/2 == .5, '8209: /2 == .5');
7439 vrfy(/-2 == -.5, '8210: /-2 == -.5');
7440 vrfy(1+/2 == 1.5, '8211: 1+/2 == 1.5');
7443 print '8212: ecnt += 6';
7444 vrfy(0^-2 == 1/0, '8213: 0^-2 == 1/0');
7445 vrfy(inverse(0) == 1/0, '8214: inverse(0) == 1/0');
7446 vrfy(1/(1/0) == 0, '8215: 1/(1/0) == 0');
7447 vrfy(inverse(1/0) == 0, '8216: inverse(1/0) == 0');
7449 a = isqrt(2e1000); s = "xyz";
7450 print '8217: a = isqrt(2e1000); s = "xyz";';
7451 vrfy(hash(a,s) == 2708885378, '8218: hash(a,s) == 2708885378');
7452 vrfy(hash("curds n whey") == 2376141927,
7453 '8219: hash("curds n whey") == 2376141927');
7456 print '8220: y = calclevel()';
7457 vrfy(func8200(0,y) == 0, '8221: func8200(0,y) == 0');
7458 vrfy(func8200(1,y) == 1, '8222: func8200(1,y) == 1');
7459 vrfy(func8200(10,y) == 55, '8223: func8200(10,y) == 55');
7460 vrfy(func8200(100,y) == 5050, '8224: func8200(100,y) == 5050');
7462 vrfy(inputlevel() == 1, '8225: inputlevel() == 1');
7464 print '8226: Ending test_somenew';
7466 print '190: parsed test_somenew()';
7470 * test_exponentiation - test new exponentiation functionaltiy
7472 define test_exponentiation()
7476 print '8800: Starting test_somenew';
7478 /* unexpected help file cases */
7479 vrfy(2^3 == 8, '8801: 2^3 == 8');
7480 vrfy(2.5 ^ 3.5 == power(2.5, 3.5),
7481 '8802: 2.5 ^ 3.5 == power(2.5, 3.5)');
7482 vrfy(2.5 ^ 2.718i == power(2.5, 2.718i),
7483 '8803: 2.5 ^ 2.718i == power(2.5, 2.718i)');
7484 vrfy(3i^4 == 81, '8804: 3i^4 == 81');
7485 vrfy(0.5i ^ 0.25 == power(0.5i, 0.25),
7486 '8804: 0.5i ^ 0.25 == power(0.5i, 0.25)');
7487 vrfy(3.13145i^0.30103i == power(3.13145i, 0.30103i),
7488 '8806: 3.13145i^0.30103i == power(3.13145i, 0.30103i)');
7490 /* deal with some corner error cases */
7492 print '8807: ecnt += 2';
7493 vrfy((1/0) ^ -1 == 0, '8808: (1/0) ^ -1 == 0');
7494 vrfy((1/0) ^ -2 == 0, '8809: (1/0) ^ -2 == 0');
7495 vrfy((1/0) ^ 0 == error(10001), '8810: (1/0) ^ 0 == error(10001)');
7496 vrfy((1/0) ^ 3 == error(10001), '8811: (1/0) ^ 3 == error(10001)');
7497 vrfy(0 ^ -2 == error(10001), '8812: 0 ^ -2 == error(10001)');
7498 vrfy((1/0) ^ 1i == error(10001),'8813: (1/0) ^ 1i == error(10001)');
7499 vrfy((1/0) ^ 0i == error(10001),'8814: (1/0) ^ 0i == error(10001)');
7502 vrfy(5^6 == 15625, '8815: 5^6 == 15625');
7503 vrfy(10^31 == 1e31, '8816: 10^31 == 1e31');
7504 vrfy(10 ^ (127/31) == power(10, 127/31),
7505 '8817: 10 ^ (127/31) == power(10, 127/31)');
7506 vrfy((10^31) ^ 10 == 1e310, '8818: (10^31) ^ 10 == 1e310');
7508 /* complex ^ real */
7509 vrfy(10i ^ 10 == -1e10, '8819: 10i ^ 10 == -1e10');
7510 vrfy((-10i) ^ 10 == -1e10, '8820: (-10i) ^ 10 == -1e10');
7511 vrfy((1+1i) ^ 4 == -4, '8821: (1+1i) ^ 4 == -4');
7512 vrfy((1+1i) ^ 65536 == 2^32768, '8822: (1+1i) ^ 65536 == 2^32768');
7513 vrfy((1+1i) ^ (2^20) == 2^(2^19),
7514 '8823: (1+1i) ^ (2^20) == 2^(2^19)');
7515 vrfy((31+17i) ^ pi() == power(31+17i, pi()),
7516 '8824: (31+17i) ^ pi() == power(31+17i, pi()');
7517 vrfy((5+7i) ^ exp(5) == power(5+7i, exp(5)),
7518 '8825: (5+7i) ^ exp(5) == power(5+7i, exp(5))');
7520 /* real ^ complex */
7521 vrfy(10 ^ 1i == power(10, 1i), '8826: 10 ^ 1i == power(10, 1i)');
7522 vrfy(10 ^ (2+3i) == power(10, 2+3i),
7523 '8827: 10 ^ (2+3i) == power(10, 2+3i)');
7524 vrfy(pi() ^ (2+3i) == power(pi(), 2+3i),
7525 '8828: pi() ^ (2+3i) == power(pi(), 2+3i)');
7526 vrfy(exp(64) ^ (2+3i) == power(exp(64), 2+3i),
7527 '8828: exp(64) ^ (2+3i) == power(exp(64), 2+3i)');
7528 vrfy(pi() ^ (257+127i) == power(pi(), 257+127i),
7529 '8829: pi() ^ (257+127i) == power(pi(), 257+127i)');
7530 vrfy(pi() ^ asin(-2) == power(pi(), asin(-2)),
7531 '8830: pi() ^ asin(-2) == power(pi(), asin(-2)');
7533 /* complex ^ complex */
7534 vrfy((3+4i) ^ (2+3i) == power(3+4i, 2+3i),
7535 '8831: (3+4i) ^ (2+3i) == power(3+4i, 2+3i)');
7536 vrfy(ln(-10) ^ (2+3i) == power(ln(-10), 2+3i),
7537 '8832: ln(-10) ^ (2+3i) == power(ln(-10), 2+3i)');
7538 vrfy((pi()*1i) ^ asin(-2) == power(pi()*1i, asin(-2)),
7539 '8833: (pi()*1i) ^ asin(-2) == power(pi()*1i, asin(-2))');
7540 vrfy((exp(1)+pi()*1i) ^ asin(-2) == power(exp(1)+pi()*1i, asin(-2)),
7541 '8834: (exp(1)+pi()*1i) ^ asin(-2) == power(exp(1)+pi()*1i, asin(-2))');
7543 print '8835: Ending test_somenew';
7545 print '191: parsed test_exponentiation()';
7549 * test_quit - test the QUIT functionality
7553 local x8400 = 23209; /* watch for lost memory */
7554 static s8400 = 21701; /* watch for lost memory */
7556 print '8400: Starting test_quit';
7559 prob('quit did not end the test_quit() function');
7561 /* 8400 serise continued after return, do not print end here */
7563 print '191: parsed test_quit()';
7567 * Reserved for top level test use
7569 print '200: Reserved for top level test use';
7573 * Report the number of errors found.
7575 define count_errors()
7578 print "9997: passed all tests /\\../\\";
7580 print "****", prob, "error(s) found \\/++\\/";
7583 print '298: parsed count_errors()';
7586 print '299: Ending main part of regression test suite read';
7590 return test_booleans();
7592 return test_variables();
7594 return test_arithmetic();
7596 return test_config();
7598 return test_bignums();
7600 return test_functions();
7602 return _test_underscore();
7604 return test_assoc();
7613 print '1700: Beginning read test';
7615 vrfy(value == 0, '1701: value == 0');
7617 print '1702: read "test1700";';
7618 vrfy(value == 1, '1703: value == 1');
7619 read -once "test1700";
7620 print '1704: read -once "test1700";';
7621 vrfy(value == 1, '1705: value == 1');
7622 read "test1700.cal";
7623 print '1706: read "test1700.cal";';
7624 vrfy(value == 2, '1707: value == 2');
7625 read -once "test1700.cal";
7626 print '1708: read -once "test1700.cal";';
7627 vrfy(value == 2, '1709: value == 2');
7628 read "test1700.cal";
7629 print '1710: read "test1700.cal";';
7630 vrfy(value == 3, '1711: value == 3');
7631 {++value;} read "test1700.cal";
7632 print '1712: {++value;} read "test1700.cal";';
7633 vrfy(value == 5, '1713: value == 5');
7634 {++value;} read -once "test1700.cal";
7635 print '1714: {++value;} read -once "test1700.cal";';
7636 vrfy(value == 6, '1715: value == 6');
7637 print '1716: Ending read test';
7642 return test_prime();
7644 return test_lucas();
7646 return test_newop();
7648 return test_xx_incdec();
7650 return test_round();
7656 return test_matrix();
7658 return test_strings();
7660 return test_matobj();
7670 return test_error();
7672 return test_param();
7674 return test_noarg();
7676 return test_ptest();
7680 return test_fileops();
7682 return test_matdcl();
7684 return test_objmat();
7686 return test_fileop();
7688 return test_charset();
7690 return test_strprintf();
7692 return test_listsearch();
7694 return test_filesearch();
7696 return test_newdecl();
7698 return test_globstat();
7700 return test_random();
7702 return test_newsyn();
7704 vrfy(s5500 == 78, '5548: s5500 == 78');
7707 return test_commaeq();
7713 * 5800 assignment tests
7715 return test_assign(5800, 1);
7716 define xy5800_assign(a,b) { };
7717 print '5812: define xy5800_assign(a,b) { }';
7718 return test_assign(5820, 0);
7719 undefine xy5800_assign;
7720 print '5832: undefine xy5800_assign';
7721 return test_assign(5840, 1);
7722 define xy5800_assign(a, b) = a.y = b;
7723 print '5852: define xy5800_assign(a, b) = a.y = b';
7725 print '5853: X5800 = 9';
7726 vrfy(X5800 == (obj xy5800 = {3,9}),
7727 '5854: X5800 == (obj xy5800 = {3,9})');
7728 asserr = newerror("Incompatible types for =");
7729 print '5855: asserr = newerror("Incompatible types for =")';
7730 define xy5800_assign(a, b) {
7731 if (istype(b, obj xy5800)) {
7734 } else if (isreal(b)) {
7741 print '5856: xy5800_assign(a, b) { ... };';
7743 print '5857: ecnt += 2';
7745 print '5858: X5800 = 2 + 3i';
7746 vrfy(X5800 == (obj xy5800 = {3,9}),
7747 '5859: X5800 == (obj xy5800 = {3,9})');
7748 vrfy(errno() > 0, '5860: errno() > 0');
7749 vrfy(strerror() == "Incompatible types for =",
7750 '5861: strerror() == "Incompatible types for ="');
7752 print '5862: X5800 = 2';
7753 vrfy(X5800 == (obj xy5800 = {2,0}),
7754 '5863: X5800 == (obj xy5800 = {2,0})');
7755 X5800 = obj xy5800 = {1,2};
7756 print '5864: X5800 = obj xy5800 = {1,2}';
7757 vrfy(X5800 == (obj xy5800 = {1,2}),
7758 '5865: X5800 == (obj xy5800 = {1,2})');
7759 define f5800(a5800 = mat[2] = {3,4}) = 5 * a5800;
7760 print '5866: define f5800(a5800 = mat[2] = {3,4}) = 5 * a5800;'
7761 vrfy(f5800() == (mat[] = {15,20}),'5867: f5800() == (mat[] = {15,20})');
7762 print '5868: End of 5800 sequence';
7769 return test_blkcpy();
7773 return test_blkprintf();
7778 print '7400: Beginning test_savedot';
7779 print '7401: saveval(1);';
7781 print '7402: a7400 = 2;';
7783 vrfy(. == 2, '7403: . == 2;');
7784 vrfy((. += 3, . == 5), '7404: (. += 3, . == 5)');
7785 vrfy(. == 5, '7405: . == 5;');
7786 print '7406: a7400 = 5; b7400 = 6;';
7787 a7400 = 5; b7400 = 6;
7788 vrfy(. == 6, '7407: . == 6');
7789 print '7408: a7400 = 7; b7400 = 8; null()';
7790 a7400 = 7; b7400 = 8; null();
7791 vrfy(. == 6, '7409: . == 6');
7792 print '7410: saveval(0);';
7794 print '7411: a7400 = 9;';
7796 vrfy(. == 6, '7412: . == 6');
7797 print '7413: a7400 = 2; saveval(1); b7400 = 3; saveval(0); c7400 = 4;';
7798 a7400 = 2; saveval(1); b7400 = 3; saveval(0); c7400 = 4;
7799 vrfy(. == 3, '7414: . == 3');
7800 print '7415: free(.);';
7802 vrfy(isnull(.), '7416: isnull(.)');
7803 print '7417: a7400 = 4;';
7805 vrfy(isnull(.), '7418: isnull(.)');
7806 print '7419: saveval(1);';
7809 print '7420: obj pair7400 {one,two} = {1,2};';
7810 obj pair7400 {one,two} = {1,2};
7811 vrfy(. .one == 1, '7421: . .one == 1');
7812 print '7422: Ending test_savedot';
7817 return test_newstring();
7819 return test_newcomb();
7821 return test_bigcomb();
7823 return test_natnumset();
7825 return test_somenew();
7832 print '8300: Starting define tests';
7833 define f8300(x) = x^2; define g8300(x) = 1 - x;
7834 print '8301: define f8300(x) = x^2; define g8300(x) = 1 - x;';
7835 vrfy(f8300(10) == 100, '8302: f8300(10) == 100');
7836 vrfy(g8300(10) == -9, '8303: g8300(10) == -9');
7837 define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1;
7838 print '8304: define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1;';
7839 vrfy(h8300(10) == 1000, '8305: h8300(10) == 1000');
7840 vrfy(i8300(10) == 9, '8306: i8300(10) == 9');
7841 vrfy(j8300(10) == 11, '8307: j8300(10) == 11');
7842 {static k8300 = 5} define l8300(x) = k8300 + x;
7843 print '8308: {static k8300 = 5} define l8300(x) = k8300 + x;';
7844 vrfy(l8300(10) == 15, '8309: l8300(10) == 15');
7845 static a8300 = 1, b8300;
7846 vrfy(a8300 == 1, '8310: a8300 == 1');
7847 print '8311: Ending define tests';
7855 read -once test8400;
7856 print '8404: read -once test8400';
7857 vrfy(test8400() == 64434, '8405: test8400() == 64434');
7858 print '8406: Ending test_quit';
7862 * test_divmod - psuedo-random tests on the // and % with various rounding modes
7865 print '8500: Starting test of divmod'
7866 read -once "test8500";
7867 /* 85xx: Ending test of divmod is printed by test8500.cal */
7871 * test_maxargs - test up to 1024 args being passed to a builtin function
7874 print '8600: Starting test of up to 1024 args'
7875 read -once "test8600";
7876 /* 860x: Ending test of up to 1024 args is printed by test8600.cal */
7880 * dupvar_warn and redecl_warn testing
7883 print '8650: Starting test of dupvar_warn and redecl_warn config parameters';
7884 vrfy(config("redecl_warn",0), '8651: config("redecl_warn",0)');
7885 vrfy(config("dupvar_warn",0), '8652: config("dupvar_warn",0)');
7886 vrfy(u_glob == 6, '8653: u_glob == 6');
7887 global u_glob = 555;
7888 print '8654: reclare u_glob';
7889 vrfy(u_glob == 555, '8655: u_glob == 555');
7890 define func_8650(u_glob) { local u_glob; return u_glob; }
7891 print '8656: u_glob as both local and parameter';
7892 define func_8650a(u_glob) { static u_glob; return u_glob; }
7893 print '8657: u_glob as both static and parameter';
7894 vrfy(config("redecl_warn",1)==0, '8658: config("redecl_warn",1)==0');
7895 vrfy(config("dupvar_warn",1)==0, '8659: config("dupvar_warn",1)==0');
7896 /* 865x: Ending test of up to 1024 args is printed by test8600.cal */
7902 * We use the dotest driver to evaluate test-97xx data files.
7905 print '8700: Starting dotest runs'
7906 print '8701: read -once "dotest"';
7907 read -once "dotest";
7908 print '8702: read -once "set8700"';
7909 read -once "set8700";
7910 vrfy(dotest("set8700.line", 8703) == 0,
7911 '8703: dotest("set8700.line", 8703) == 0');
7912 /* 87xx: Ending dotest runs is printed by set8700.test */
7916 * new exponentiation functionaltiy
7919 return test_exponentiation();
7920 /* 88xx: test exponentiation */
7924 * calc resource functions by Christoph Zurnieden
7927 print '8900: Starting test of calc resource functions by Christoph Zurnieden';
7928 print '8901: read -once "test8900"';
7929 read -once "test8900";
7930 print '8902: about to run test8900(1,,8903)';
7931 testnum = test8900(1,,8903);
7932 /* 89xx: test calc resource functions by Christoph Zurnieden */
7936 * read various calc resource files
7938 * We read most of the standard calc resource files. There are a few
7939 * resource files that are not read:
7941 * beer.cal - prints a bunch of things when loaded
7942 * hello.cal - designed to go into an infinite loop
7943 * lucal.cal - already read by this file
7944 * lucas_chk.cal - already read by this file
7945 * lucas_tbl.cal - duplicatres code already read by another file
7946 * regress.cal - this file
7947 * surd.cal - already read by this file
7948 * test9999.cal - files of this form are already read by this file
7949 * xx_print.cal - prints a bunch of things when loaded
7951 * We want to do this 2nd to last; ahead of any final cleanup and behind
7952 * all of real actions of regress.cal.
7955 print '9800: Starting read of selected calc resource files';
7956 read -once bernoulli;
7957 print '9801: read -once bernoulli';
7958 read -once bigprime;
7959 print '9802: read -once bigprime';
7961 print '9803: read -once chrem';
7963 print '9804: read -once deg';
7965 print '9805: read -once ellip';
7966 read -once mersenne;
7967 print '9806: read -once mersenne';
7969 print '9807: read -once mfactor';
7971 print '9808: read -once mod';
7972 read -once natnumset;
7973 print '9809: read -once natnumset';
7975 print '9810: read -once pell';
7977 print '9811: read -once pi';
7979 print '9812: read -once pix';
7981 print '9813: read -once pollard';
7983 print '9814: read -once poly';
7985 print '9815: read -once prompt';
7987 print '9816: read -once psqrt';
7989 print '9817: read -once quat';
7990 read -once randbitrun;
7991 print '9818: read -once randbitrun';
7992 read -once randmprime;
7993 print '9819: read -once randmprime';
7994 read -once randombitrun;
7995 print '9820: read -once randombitrun';
7996 read -once randomrun;
7997 print '9821: read -once randomrun';
7999 print '9822: read -once randrun';
8000 read -once seedrandom;
8001 print '9823: read -once seedrandom';
8003 print '9824: read -once solve';
8005 print '9825: read -once sumsq';
8006 read -once unitfrac;
8007 print '9826: read -once unitfrac';
8009 print '9827: read -once varargs';
8011 print '9828: read -once qtime';
8013 print '9829: read -once chi';
8015 print '9830: read -once intfile';
8017 print '9831: read -once lucas';
8018 read -once lucas_tbl;
8019 print '9832: read -once lucas_tbl';
8020 read -once natnumset;
8021 print '9833: read -once natnumset';
8023 print '9834: read -once repeat';
8025 print '9835: read -once screen';
8027 print '9836: read -once linear';
8028 print '9837: skipping read -once beer.cal because it is an infinite loop';
8029 print '9838: skipping read -once hello.cal because it is an infinite loop';
8030 print '9839: skipping read -once xx_print.cal because it is a printing demo';
8031 read -once sumtimes;
8032 print '9840: read -once sumtimes';
8034 print '9841: read -once dms';
8036 print '9842: read -once hms';
8037 print '9843: Ending read of selected calc resource files';
8041 * cleanup and report the results
8045 print '9995: freeredc()';
8047 print '9996: freestatics()';
8048 return count_errors();
8050 print '9998: freeglobals()';
8051 print '9999: Ending regression tests';