/* * Copyright (c) 1997 David I. Bell * Permission is granted to use, distribute, or modify this source, * provided that this copyright notice remains intact. * * Test the correct execution of the calculator by reading this library file. * Errors are reported with '****' messages, or worse. :-) * * NOTE: Unlike most calc lib files, this one performs its work when * it is read. Normally one would just define functions and * values for later use. In the case of the regression test, * we do not want to do this. */ print '000: Beginning regression tests'; print '001: Some of these tests may take a while ...'; print '002: Within each section, output should be numbered sequentially'; global prob; /* libregress.cal problem counter */ prob = 0; /* clear problem counter */ global junk; /* throw away value */ junk = errcount(0); /* clear error count */ junk = errmax(-1); /* prevent errcount from abouting */ global ecnt; /* expected value of errcount() */ ecnt = 0; /* clear expected errcount() value */ initcfg = config("all", "oldstd"); /* set config to startup default */ initcfg = config("lib_debug", 0); /* disable lib startup messages */ initcfg = config("calc_debug", 0); /* disable internal debugging */ initcnf = config("verbose_quit", 0); /* disable quit messages */ initcfg = config("all"); /* save state for later use */ print '003: parsed global definitions'; /* * vrfy - vrfy that a test is true * * Counts and reports errors or prints test string if successful. * * This function also detects when errcount() exceeds ecnt * and reports when this happens. A side effect is that a * new ecnt level is established. If errcount exceeds errcount * but otherwise the test is successful, the string is still printed. */ define vrfy(test, str) { if (errcount() > ecnt) { print '**** errcount:' : errcount(), ' > ecnt:' : ecnt; ecnt = errcount(); ++prob; } if (test != 1) { print '**** Non-true result (' : test : '): ' : str; ++prob; } else { print str; } return; } print '004: parsed vrfy()'; /* * prob - alternate error notification and count */ define prob(str) { print '****' , str; ++prob; } print '005: parsed prob(str)'; /* * getglobalvar - used to return a global value */ define getglobalvar() { global globalvar; return globalvar; } print '006: parsed getglobalvar()'; /* * Test boolean operations and IF tests. * * Some of these tests are done twice, once to print the message and * once to count any errors. This means that some successful tests * will display a passing message twice. Oh well, no biggie. */ define test_booleans() { local x; local y; local t1, t2, t3; print '300: Beginning test_booleans'; if (0) print '**** if (0)'; if (0) prob = prob + 1; if (1) print '301: if (1)'; if (2) print '302: if (2)'; if (1) print '303: if (1) else'; else print '**** if (1) else'; if (1) print '304: if (1) else'; else prob = prob + 1; if (0) print '**** if (0) else'; else print '305: if (0) else'; if (0) prob = prob + 1; else print '306: if (0) else'; if (1 == 1) print '307: if 1 == 1'; else print '**** if 1 == 1'; if (1 == 1) print '308: if 1 == 1'; else prob = prob + 1; if (1 != 2) print '309: if 1 != 2'; else print '**** if 1 != 2'; if (1 != 2) print '310: if 1 != 2'; else prob = prob + 1; vrfy(1, '311: vrfy 1'); vrfy(2 == 2, '312: vrfy 2 == 2'); vrfy(2 != 3, '313: vrfy 2 != 3'); vrfy(2 < 3, '314: vrfy 2 < 3'); vrfy(2 <= 2, '315: vrfy 2 <= 2'); vrfy(2 <= 3, '316: vrfy 2 <= 3'); vrfy(3 > 2, '317: vrfy 3 > 2'); vrfy(2 >= 2, '318: vrfy 2 >= 2'); vrfy(3 >= 2, '319: vrfy 3 >= 2'); vrfy(!0, '320: vrfy !0'); vrfy(!1 == 0,'321: vrfy !1 == 0'); vrfy((1 ? 2 ? 3 : 4 : 5) == 3, '322: (1 ? 2 ? 3 : 4 : 5) == 3'); print '323: Ending test_booleans'; } print '007: parsed test_booleans()'; /* * Test variables, simple assignments, AND and OR operators, short-circuit eval */ define test_variables() { local x1, x2, x3; global g1, g2; local t; global globalvar; local x; print '350: Beginning test_variables'; x1 = 5; x3 = 7 * 2; x2 = 9 + 1; globalvar = 22; g1 = 19 - 3; g2 = 79; vrfy(x1 == 5, '351: x1 == 5'); vrfy(x2 == 10, '352: x2 == 10'); vrfy(x3 == 14, '353: x3 == 14'); vrfy(g1 == 16, '354: g1 == 16'); vrfy(g2 == 79, '355: g2 == 79'); vrfy(globalvar == 22, '356: globalvar == 22'); vrfy(getglobalvar() == 22, '357: getglobalvar() == 22'); x1 = x2 + x3 + g1; vrfy(x1 == 40, '358: x1 == 40'); g1 = x3 + g2; vrfy(g1 == 93, '359: g1 == 207'); x1 = 5; vrfy(x1++ == 5, '360: x1++ == 5'); vrfy(x1 == 6, '361: x1 == 6'); vrfy(++x1 == 7, '362: ++x1 == 7'); x1 += 3; vrfy(x1 == 10, '363: x1 == 10'); x1 -= 6; vrfy(x1 == 4, '364: x1 == 4'); x1 *= 3; vrfy(x1 == 12, '365: x1 == 12'); x1 /= 4; vrfy(x1 == 3, '366: x1 == 3'); x1 = x2 = x3; vrfy(x2 == 14, '367: x2 == 14'); vrfy(x1 == 14, '368: x1 == 14'); if (2 && 3) { print '369: if (2 && 3)'; } else { print '**** if (2 && 3)'; ++prob; } if (2 && 0) { print '**** if (2 && 0)'; ++prob; } else { print '370: if (2 && 0)'; } if (0 && 2) { print '**** if (0 && 2)'; ++prob; } else { print '371: if (0 && 2)'; } if (0 && 0) { print '**** if (0 && 0)'; ++prob; } else { print '372: if (0 && 0)'; } if (2 || 0) { print '373: if (2 || 0)'; } else { print '**** if (2 || 0)'; ++prob; } if (0 || 2) { print '374: if (0 || 2)'; } else { print '**** if (0 || 2)'; ++prob; } if (0 || 0) { print '**** if (0 || 0)'; ++prob; } else { print '375: if (0 || 0)'; } x = 2 || 3; vrfy(x == 2, '376: (2 || 3) == 2'); x = 2 || 0; vrfy(x == 2, '377: (2 || 0) == 2'); x = 0 || 3; vrfy(x == 3, '378: (0 || 3) == 3'); x = 0 || 0; vrfy(x == 0, '379: (0 || 0) == 0'); x = 2 && 3; vrfy(x == 3, '380: (2 && 3) == 3'); x = 2 && 0; vrfy(x == 0, '381: (2 && 0) == 0'); x = 0 && 3; vrfy(x == 0, '382: (0 && 3) == 0'); x = 2 || prob('2 || prob()'); print "383: x = 2 || prob('2 || prob()'"; x = 0 && prob('0 && prob()'); print "384: x = 0 && prob('0 && prob()'"; print '385: Ending test_variables'; } print '008: parsed test_variables()'; /* * Test simple arithmetic operations and expressions. */ define test_arithmetic() { print '400: Beginning test_arithmetic'; vrfy(3+4==7, '401: 3 + 4 == 7'); vrfy(4-1==3, '402: 4 - 1 == 3'); vrfy(2*3==6, '403: 2 * 3 == 6'); vrfy(8/4==2, '404: 8 / 4 == 2'); vrfy(2^3==8, '405: 2 ^ 3 == 8'); vrfy(9-4-2==3, '406: 9-4-2 == 3'); vrfy(9-4+2==7, '407: 9-4+2 == 6'); vrfy(-5+2==-3, '408: -5+2 == -3'); vrfy(2*3+1==7, '409: 2*3+1 == 7'); vrfy(1+2*3==7, '410: 1+2*3 == 7'); vrfy((1+2)*3==9, '411: (1+2)*3 == 9'); vrfy(2*(3+1)==8, '412: 2*(3+1) == 8'); vrfy(9-(2+3)==4, '413: 9-(2+3) == 4'); vrfy(9+(2-3)==8, '414: 9+(2-3) == 8'); vrfy((2+3)*(4+5)==45, '415: (2+3)*(4+5) == 45'); vrfy(10/(2+3)==2, '416: 10/(2+3) == 2'); vrfy(12/3+4==8, '417: 12/3+4 == 8'); vrfy(6+12/3==10, '418: 6+12/3 == 10'); vrfy(2+3==1+4, '419: 2+3 == 1+4'); vrfy(-(2+3)==-5, '420: -(2+3) == -5'); vrfy(7&18==2, '421: 7&18 == 2'); vrfy(3|17==19, '422: 3|17 == 19'); vrfy(2&3|1==3, '423: 2&3|1 == 3'); vrfy(2&(3|1)==2, '424: 2&(3|1) == 2'); vrfy(3<<4==48, '425: 3<<4 == 48'); vrfy(5>>1==2, '426: 5>>1 == 2'); vrfy(3<<-1==1, '427: 3<<-1 == 1'); vrfy(5>>-2==20, '428: 5>>-2 == 20'); vrfy(1<<2<<3==65536, '429: 1<<2<<3 == 65536'); vrfy((1<<2)<<3==32, '430: (1<<2)<<3 == 32'); vrfy(2^3^2==512, '431: 2^3^2 == 512'); vrfy((2^3)^2==64, '432: (2^3)^2 == 64'); vrfy(4//3==1, '433: 4//3==1'); vrfy(4//-3==-1, '434: 4//-3==-1'); vrfy(0.75//-0.51==-1, '435: 0.75//-0.51==-1'); vrfy(0.75//-0.50==-1, '436: 0.75//-0.50==-1'); vrfy(0.75//-0.49==-1, '437: 0.75//-0.49==-1'); vrfy((3/4)//(-1/4)==-3, '438: (3/4)//(-1/4)==-3'); vrfy(7%3==1, '439: 7%3==1'); vrfy(0-.5==-.5, '440: 0-.5==-.5'); vrfy(0^0 == 1, '441: 0^0 == 1'); vrfy(0^1 == 0, '442: 0^1 == 0'); vrfy(1^0 == 1, '443: 1^0 == 1'); vrfy(1^1 == 1, '444: 1^1 == 1'); vrfy(1/(.8+.8i)==.625-.625i, '445: 1/(.8+.8i)==.625-.625i'); vrfy((.6+.8i)*(3.6-4.8i)==6, '446: (.6+.8i)*(3.6-4.8i)==6'); vrfy(-16^-2 == -1/256, '447: -16^-2 == -1/256'); vrfy(-7^2 == -49, '448: -7^2 == -49'); vrfy(-3! == -6, '449: -3! == -6'); print '450: Ending test_arithmetic'; } print '009: parsed test_arithmetic()'; /* * test_config - test config control */ define test_config() { local callcfg; /* caller configuration value */ local oldcfg; /* caller configuration value */ local newcfg; /* caller configuration value */ print '500: Beginning test_config'; /* check the set and return of all config */ callcfg = config("all"); print '501: callcfg = config("all")'; callcfg = config("all", "oldstd"); print '502: callcfg = config("all","oldstd")'; oldcfg = config("all", "newstd"); print '503: oldcfg = config("all","newstd")'; vrfy(callcfg == initcfg, '504: callcfg == initcfg'); newcfg = config("all"); print '505: newcfg = config("all")'; vrfy(config("all") == newcfg, '506: config("all") == newcfg'); vrfy(config("all", oldcfg) == newcfg, '507: config("all", oldcfg) == newcfg'); /* vrfy the state of the default config */ vrfy(config("all") == oldcfg, '508: config("all") == oldcfg'); vrfy(config("mode") == "real", '509: config("mode") == "real"'); vrfy(config("display") == 20, '510: config("display") == 20'); vrfy(config("epsilon") == 1e-20, '511: config("epsilon") == 1e-20'); vrfy(config("trace") == 0, '512: config("trace") == 0'); vrfy(config("maxprint") == 16, '513: config("maxprint") == 16'); vrfy(config("mul2") == 20, '514: config("mul2") == 20'); vrfy(config("sq2") == 20, '515: config("sq2") == 20'); vrfy(config("pow2") == 40, '516: config("pow2") == 40'); vrfy(config("redc2") == 50, '517: config("redc2") == 50'); vrfy(config("tilde") == 1, '518: config("tilde") == 1'); vrfy(config("tab") == 1, '519: config("tab") == 1'); vrfy(config("quomod") == 0, '520: config("quomod") == 0'); vrfy(config("quo") == 2, '521: config("quo") == 2'); vrfy(config("mod") == 0, '522: config("mod") == 0'); vrfy(config("sqrt") == 24, '523: config("sqrt") == 24'); vrfy(config("appr") == 24, '524: config("appr") == 24'); vrfy(config("cfappr") == 0, '525: config("cfappr") == 0'); vrfy(config("cfsim") == 8, '526: config("cfsim") == 8'); vrfy(config("outround") == 2, '527: config("outround") == 2'); vrfy(config("round") == 24, '528: config("round") == 24'); vrfy(config("leadzero") == 0, '529: config("leadzero") == 0'); vrfy(config("fullzero") == 0, '530: config("fullzero") == 0'); vrfy(config("maxscan") == 20, '531: config("maxscan") == 20'); vrfy(config("prompt") == "> ", '532: config("prompt") == "> "'); vrfy(config("more") == ">> ", '533: config("more") == ">> "'); /* convert to "newstd" config by individual changes */ vrfy(config("display", 10) == 20, '534: config("display") == 20'); vrfy(config("epsilon",1e-10)==1e-20, '535: config("epsilon",1e-10)==1e-20'); vrfy(config("quo", 0) == 2, '536: config("quo", 0) == 2'); vrfy(config("outround", 24) == 2, '537: config("outround", 24) == 2'); vrfy(config("leadzero", "y") == 0, '538: config("leadzero", "y") == 0'); vrfy(config("fullzero", 1) == 0, '539: config("fullzero", 1) == 0'); vrfy(config("prompt", "; ") == "> ", '540: config("prompt", "; ") == "> "'); vrfy(config("more", ";; ") == ">> ", '541: config("more", ";; ") == ">> "'); vrfy(config("all") == newcfg, '542: config("all") == newcfg'); /* check on the new config("fullzero") effect */ vrfy(config("all","oldstd") == newcfg, '543: config("all",callcfg) == newcfg'); vrfy(config("display",2) == 20, '544: config("display",2) == 20'); vrfy(config("fullzero",1) == 0, '545: config("fullzero",1) == 0'); vrfy(strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00", '546: strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00"'); vrfy(config("display",20) == 2, '547: config("display",20) == 2'); vrfy(config("fullzero",0) == 1, '548: config("fullzero",0) == 1'); vrfy(strprintf("%d %d %d", 0, 1, 2) == "0 1 2", '549: strprintf("%d %d %d", 0, 1, 2) == "0 1 2"'); /* restore calling config */ vrfy(config("all",callcfg) == oldcfg, '550: config("all",callcfg) == oldcfg'); vrfy(config("all") == callcfg, '551: config("all") == callcfg'); vrfy(config("all") == initcfg, '552: config("all") == initcfg'); print '553: Ending test_config'; } print '010: parsed test_config()'; /* * Do multiplication and division on three numbers in various ways * and vrfy the results agree. */ define muldivcheck(a, b, c, str) { local abc, acb, bac, bca, cab, cba; abc = (a * b) * c; acb = (a * c) * b; bac = (b * a) * c; bca = (b * c) * a; cab = (c * a) * b; cba = (c * b) * a; if (abc != acb) {print '**** abc != acb:', str; ++prob;} if (acb != bac) {print '**** acb != bac:', str; ++prob;} if (bac != bca) {print '**** bac != bca:', str; ++prob;} if (bca != cab) {print '**** bca != cab:', str; ++prob;} if (cab != cba) {print '**** cab != cba:', str; ++prob;} if (abc/a != b*c) {print '**** abc/a != bc:', str; ++prob;} if (abc/b != a*c) {print '**** abc/b != ac:', str; ++prob;} if (abc/c != a*b) {print '**** abc/c != ab:', str; ++prob;} print str; } print '011: parsed muldivcheck(a, b, c, str)'; /* * Use the identity for squaring the sum of two squares to check * multiplication and squaring. */ define squarecheck(a, b, str) { local a2, b2, tab, apb, apb2, t; a2 = a^2; b2 = b^2; tab = a * b * 2; apb = a + b; apb2 = apb^2; if (a2 != a*a) {print '**** a^2 != a*a:', str; ++prob;} if (b2 != b*b) {print '**** b^2 != b*b:', str; ++prob;} if (apb2 != apb*apb) { print '**** (a+b)^2 != (a+b)*(a+b):', str; ++prob; } if (a2+tab+b2 != apb2) { print '**** (a+b)^2 != a^2 + 2ab + b^2:', str; ++prob; } if (a2/a != a) {print '**** a^2/a != a:', str; ++prob;} if (b2/b != b) {print '**** b^2/b != b:', str; ++prob;} if (apb2/apb != apb) {print '**** (a+b)^2/(a+b) != a+b:', str; ++prob;} if (a2*b2 != (a*b)^2) {print '**** a^2*b^2 != (ab)^2:', str; ++prob;} print str; } print '012: parsed squarecheck(a, b, str)'; /* * Use the raising of numbers to large powers to check multiplication * and exponentiation. */ define powercheck(a, p1, p2, str) { local a1, a2, a3; a1 = (a^p1)^p2; a2 = (a^p2)^p1; a3 = a^(p1*p2); if (a1 != a2) {print '**** (a^p1)^p2 != (a^p2)^p1:', str; ++prob;} if (a1 != a3) {print '**** (a^p1)^p2 != a^(p1*p2):', str; ++prob;} print str; } print '013: parsed powercheck(a, p1, p2, str)'; /* * Test fraction reductions. * Arguments MUST be relatively prime. */ define fraccheck(a, b, c, str) { local ab, bc, ca, aoc, boc, aob; ab = a * b; bc = b * c; ca = c * a; aoc = ab / bc; if (num(aoc) != a) {print '**** num(aoc) != a:', str; ++prob;} if (den(aoc) != c) {print '**** den(aoc) != c:', str; ++prob;} boc = ab / ca; if (num(boc) != b) {print '**** num(boc) != b:', str; ++prob;} if (den(boc) != c) {print '**** den(boc) != c:', str; ++prob;} aob = ca / bc; if (num(aob) != a) {print '**** num(aob) != a:', str; ++prob;} if (den(aob) != b) {print '**** den(aob) != b:', str; ++prob;} if (aob*boc != aoc) {print '**** aob*boc != aoc;', str; ++prob;} print str; } print '014: parsed fraccheck(a, b, c, str)'; /* * Test multiplication and squaring algorithms. */ define algcheck(a, b, str) { local ss, ms, t1, t2, t3, t4, t5, t6, t7; local a1, a2, a3, a4, a5, a6, a7; local oldmul2, oldsq2; oldmul2 = config("mul2", 2); oldsq2 = config("sq2", 2); a1 = a * b; a2 = a * a; a3 = b * b; a4 = a^2; a5 = b^2; a6 = a2^2; a7 = pmod(3,a-1,a); for (ms = 2; ms < 20; ms++) { for (ss = 2; ss < 20; ss++) { config("mul2", ms); config("sq2", ss); t1 = a * b; t2 = a * a; t3 = b * b; t4 = a^2; t5 = b^2; t6 = t2^2; if (((ms + ss) % 37) == 4) t7 = pmod(3,a-1,a); if (t1 != a1) {print '**** t1 != a1:', str; ++prob;} if (t2 != a2) {print '**** t2 != a2:', str; ++prob;} if (t3 != a3) {print '**** t3 != a3:', str; ++prob;} if (t4 != a4) {print '**** t4 != a4:', str; ++prob;} if (t5 != a5) {print '**** t5 != a5:', str; ++prob;} if (t6 != a6) {print '**** t6 != a6:', str; ++prob;} if (t7 != a7) {print '**** t7 != a7:', str; ++prob;} } } config("mul2", oldmul2); config("sq2", oldsq2); print str; } print '015: parsed algcheck(a, b, str)'; /* * Test big numbers using some identities. */ define test_bignums() { local a, b, c, d; print '600: Beginning test_bignums'; a = 64357824568234938591; b = 12764632632458756817; c = 43578234973856347982; muldivcheck(a, b, c, '601: muldivcheck 1'); a = 3^100; b = 5^97; c = 7^88; muldivcheck(a, b, c, '602: muldivcheck 2'); a = 2^160 - 1; b = 2^161 - 1; c = 2^162 - 1; muldivcheck(a, b, c, '603: muldivcheck 3'); a = 3^35 / 5^35; b = 7^35 / 11^35; c = 13^35 / 17^35; muldivcheck(a, b, c, '604: muldivcheck 4'); a = (10^97-1) / 9; b = (10^53-1) / 9; c = (10^37-1) / 9; muldivcheck(a, b, c, '605: muldivcheck 5'); a = 17^50; b = 19^47; squarecheck(a, b, '606: squarecheck 1'); a = 2^111-1; b = 2^17; squarecheck(a, b, '607: squarecheck 2'); a = 23^43 / 29^43; b = 31^42 / 37^29; squarecheck(a, b, '608: squarecheck 3'); a = 4657892345743659834657238947854639; b = 43784356784365893467659347867689; squarecheck(a, b, '609: squarecheck 4'); a = (10^80-1) / 9; b = (10^50-1) / 9; squarecheck(a, b, '610: squarecheck 5'); a = 101^99; b = 2 * a; squarecheck(a, b, '611: squarecheck 6'); a = (10^19-1) / 9; vrfy(ptest(a, 20), '612: primetest R19'); a = (10^23-1) / 9; vrfy(ptest(a, 20), '613: primetest R23'); a = 2^127 - 1; vrfy(ptest(a, 1), '614: primetest M127'); a = 2^521 - 1; vrfy(ptest(a, 1), '615: primetest M521'); powercheck(17, 127, 30, '616: powercheck 1'); powercheck(111, 899, 6, '617: powercheck 2'); powercheck(3, 87, 89, '618: powercheck 3'); fraccheck(3^200, 5^173, 7^138, '619: fraccheck 1'); fraccheck(11^100, 12^98, 13^121, '620: fraccheck 2'); fraccheck(101^270, 103^111, 105^200, '621: fraccheck 3'); a = 0xffff0000ffffffff00000000ffff0000000000000000ffff; b = 0x555544440000000000000000000000000000000011112222333344440000; c = 0x999911113333000011111111000022220000000000000000333300000000ffff; d = 0x3333ffffffff0000000000000000ffffffffffffffff000000000000; algcheck(a, a, '622: algcheck 1'); algcheck(a, b, '623: algcheck 2'); algcheck(a, c, '624: algcheck 3'); algcheck(a, d, '625: algcheck 4'); algcheck(b, b, '626: algcheck 5'); algcheck(b, c, '627: algcheck 6'); algcheck(b, d, '628: algcheck 7'); algcheck(c, c, '629: algcheck 8'); algcheck(c, d, '630: algcheck 9'); algcheck(d, d, '631: algcheck 10'); print '632: Ending test_bignums'; } print '016: parsed test_bignums()'; /* * Test many of the built-in functions. */ define test_functions() { local a, b; local pi; local h, n, r, m, v; local n2, m2, v2; print '700: Beginning test_functions'; vrfy(abs(3) == 3, '701: abs(3) == 3'); vrfy(abs(-4) == 4, '702: abs(-4) == 4'); vrfy(avg(7) == 7, '703: avg(7) == 7'); vrfy(avg(3,5) == 4, '704: avg(3,5) == 4'); vrfy(cmp(2,3) == -1, '705: cmp(2,3) == -1'); vrfy(cmp(6,6) == 0, '706: cmp(6,6) == 0'); vrfy(cmp(7,4) == 1, '707: cmp(7,4) == 1'); vrfy(comb(9,9) == 1, '708: comb(9,9) == 1'); vrfy(comb(5,2) == 10, '709: comb(5,2) == 10'); vrfy(conj(4) == 4, '710: conj(4) == 4'); vrfy(conj(2-3i) == 2+3i, '711: conj(2-3i) == 2+3i'); vrfy(den(17) == 1, '712: den(17) == 1'); vrfy(den(3/7) == 7, '713: den(3/7) == 7'); vrfy(den(-2/3) == 3, '714: den(-2/3) == 3'); vrfy(digits(0) == 1, '715: digits(0) == 1'); vrfy(digits(9) == 1, '716: digits(9) == 1'); vrfy(digits(10) == 2, '717: digits(10) == 2'); vrfy(digits(-691) == 3, '718: digits(-691) == 3'); vrfy(eval('2+3') == 5, "719: eval('2+3') == 5"); vrfy(fcnt(11,3) == 0, '720: fcnt(11,3) == 0'); vrfy(fcnt(18,3) == 2, '721: fcnt(18,3) == 2'); vrfy(fib(0) == 0, '722: fib(0) == 0'); vrfy(fib(1) == 1, '723: fib(1) == 1'); vrfy(fib(9) == 34, '724: fib(9) == 34'); vrfy(frem(12,5) == 12, '725: frem(12,5) == 12'); vrfy(frem(45,3) == 5, '726: frem(45,3) == 5'); vrfy(fact(0) == 1, '727: fact(0) == 1'); vrfy(fact(1) == 1, '728: fact(1) == 1'); vrfy(fact(5) == 120, '729: fact(5) == 120'); vrfy(frac(3) == 0, '730: frac(3) == 0'); vrfy(frac(2/3) == 2/3, '731: frac(2/3) == 2/3'); vrfy(frac(17/3) == 2/3, '732: frac(17/3) == 2/3'); vrfy(gcd(0,3) == 3, '733: gcd(0,3) == 3'); vrfy(gcd(1,12) == 1, '734: gcd(1,12) == 1'); vrfy(gcd(11,7) == 1, '735: gcd(11,7) == 1'); vrfy(gcd(20,65) == 5, '736: gcd(20,65) == 5'); vrfy(gcdrem(20,3) == 20, '737: gcdrem(20,3) == 20'); vrfy(gcdrem(100,6) == 25, '738: gcdrem(100,6) == 25'); vrfy(highbit(1) == 0, '739: highbit(1) == 0'); vrfy(highbit(15) == 3, '740: highbit(15) == 3'); vrfy(hypot(3,4) == 5, '741: hypot(3,4) == 5'); vrfy(ilog(90,3) == 4, '742: ilog(90,3) == 4'); vrfy(ilog10(123) == 2, '743: ilog10(123) == 2'); vrfy(ilog2(17) == 4, '744: ilog2(17) == 4'); vrfy(im(3) == 0, '745: im(3) == 0'); vrfy(im(2+3i) == 3, '746: im(2+3i) == 3'); vrfy(fact(20) == 2432902008176640000, '747: fact(20) == 2432902008176640000'); vrfy(fact(100) == 100*fact(99), '748: fact(100) == 100*fact(99)'); vrfy(comb(100,25) == 100!/75!/25!, '749: comb(100,25) == 100!/75!/25!'); vrfy(perm(100,50) == 100!/50!, '750: perm(100,50) == 100!/50!'); print '751: test unused'; print '752: test unused'; print '753: test unused'; print '754: test unused'; print '755: test unused'; print '756: test unused'; vrfy(int(5) == 5, '757: int(5) == 5'); vrfy(int(19/3) == 6, '758: int(19/3) == 6'); vrfy(inverse(3/2) == 2/3, '759: inverse(3/2) == 2/3'); vrfy(iroot(18,2) == 4, '760: iroot(18,2) == 4'); vrfy(iroot(100,3) == 4, '761: iroot(100,3) == 4'); vrfy(iseven(10) == 1, '762: iseven(10) == 1'); vrfy(iseven(13) == 0, '763: iseven(13) == 0'); vrfy(iseven('a') == 0, "764: iseven('a') == 0"); vrfy(isint(7) == 1, '765: isint(7) == 1'); vrfy(isint(19/2) == 0, '766: isint(19/2) == 0'); vrfy(isint('a') == 0, "767: isint('a') == 0"); vrfy(islist(3) == 0, '768: islist(3) == 0'); vrfy(islist(list(2,3)) == 1, '769: islist(list(2,3)) == 1'); vrfy(ismat(3) == 0, '770: ismat(3) == 0'); vrfy(ismult(7,3) == 0, '771: ismult(7,3) == 0'); vrfy(ismult(15,5) == 1, '772: ismult(15,5) == 1'); vrfy(isnull(3) == 0, '773: isnull(3) == 0'); vrfy(isnull(null()) == 1, '774: isnull(null()) == 1'); vrfy(isnum(2/3) == 1, '775: isnum(2/3) == 1'); vrfy(isnum('xx') == 0, "776: isnum('xx') == 0"); vrfy(isobj(3) == 0, '777: isobj(3) == 0'); vrfy(isodd(7) == 1, '778: isodd(7) == 1'); vrfy(isodd(8) == 0, '779: isodd(8) == 0'); vrfy(isodd('x') == 0, "780: isodd('a') == 0"); vrfy(isqrt(27) == 5, '781: isqrt(27) == 5'); vrfy(isreal(3) == 1, '782: isreal(3) == 1'); vrfy(isreal('x') == 0, "783: isreal('x') == 0"); vrfy(isreal(2+3i) == 0, '784: isreal(2+3i) == 0'); vrfy(isstr(5) == 0, '785: isstr(5) == 0'); vrfy(isstr('foo') == 1, "786: isstr('foo') == 1"); vrfy(isrel(10,14) == 0, '787: isrel(10,14) == 0'); vrfy(isrel(15,22) == 1, '788: isrel(15,22) == 1'); vrfy(issimple(6) == 1, '789: issimple(6) == 1'); vrfy(issimple(3-2i) == 1, '790: issimple(3-2i) == 1'); vrfy(issimple(list(5)) == 0, '791: issimple(list(5)) == 0'); vrfy(issq(26) == 0, '792: issq(26) == 0'); vrfy(issq(9/4) == 1, '793: issq(9/4) == 1'); print '794: test unused'; vrfy(istype(9,4) == 1, '795: istype(9,4) == 1'); vrfy(istype(3,'xx') == 0, "796: istype(3,'xx') == 0"); vrfy(jacobi(5,11) == 1, '797: jacobi(2,7) == 1'); vrfy(jacobi(6,13) == -1, '798: jacobi(6,13) == -1'); vrfy(lcm(3,4,5,6) == 60, '799: lcm(3,4,5,6) == 60'); vrfy(lcmfact(8) == 840, '800: lcmfact(8) == 840'); vrfy(lfactor(21,5) == 3, '801: lfactor(21,5) == 3'); vrfy(lfactor(97,20) == 1, '802: lfactor(97,20) == 1'); vrfy(lowbit(12) == 2, '803: lowbit(12) == 2'); vrfy(lowbit(17) == 0, '804: lowbit(17) == 0'); vrfy(ltol(1) == 0, '805: ltol(1) == 0'); vrfy(max(3,-9,7,4) == 7, '806: max(3,-9,7,4) == 7'); vrfy(meq(13,33,10) == 1, '807: meq(13,33,10) == 1'); vrfy(meq(7,19,11) == 0, '808: meq(7,19,11) == 0'); vrfy(min(9,5,12) == 5, '809: min(9,5,12) == 5'); vrfy(minv(13,97) == 15, '810: minv(13,97) == 15'); vrfy(mne(16,37,10) == 1, '811: mne(16,37,10) == 1'); vrfy(mne(46,79,11) == 0, '812: mne(46,79,11) == 0'); vrfy(norm(4) == 16, '813: norm(4) == 16'); vrfy(norm(2-3i) == 13, '814: norm(2-3i) == 13'); vrfy(num(7) == 7, '815: num(7) == 7'); vrfy(num(11/4) == 11, '816: num(11/4) == 11'); vrfy(num(-9/5) == -9, '817: num(-9/5) == -9'); vrfy(char(ord('a')+2) == 'c', "818: char(ord('a')+2) == 'c'"); vrfy(perm(7,3) == 210, '819: perm(7,3) == 210'); vrfy(pfact(10) == 210, '820: pfact(10) == 210'); vrfy(places(3/7) == -1, '821: places(3/7) == -1'); vrfy(places(.347) == 3, '822: places(.347) == 3'); vrfy(places(17) == 0, '823: places(17) == 0'); vrfy(pmod(3,36,37) == 1, '824: pmod(3,36,37) == 1'); vrfy(poly(2,3,5,2) == 19, '825: poly(2,3,5,2) == 19'); vrfy(ptest(101,10) == 1, '826: ptest(101,10) == 1'); vrfy(ptest(221,30) == 0, '827: ptest(221,30) == 0'); vrfy(re(9) == 9, '828: re(9) == 9'); vrfy(re(-7+3i) == -7, '829: re(-7+3i) == -7'); vrfy(scale(3,4) == 48, '830: scale(3,4) == 48'); vrfy(sgn(-4) == -1, '831: sgn(-4) == -1'); vrfy(sgn(0) == 0, '832: sgn(0) == 0'); vrfy(sgn(3) == 1, '833: sgn(3) == 1'); vrfy(size(7) == 1, '834: size(7) == 1'); vrfy(sqrt(121) == 11, '835: sqrt(121) == 11'); vrfy(ssq(2,3,4) == 29, '836: ssq(2,3,4) == 29'); vrfy(str(45) == '45', "837: str(45) == '45'"); vrfy(strcat('a','bc','def')=='abcdef', "838: strcat('a','bc','def')=='abcdef'"); vrfy(strlen('') == 0, "839: strlen('') == 0"); vrfy(strlen('abcd') == 4, "840: strlen('abcd') == 4"); vrfy(substr('abcd',2,1) == 'b', "841: substr('abcd',2,1) == 'b'"); vrfy(substr('abcd',3,4) == 'cd', "842: substr('abcd',3,4) == 'cd'"); vrfy(substr('abcd',1,3) == 'abc', "843: substr('abcd',1,3) == 'abc'"); vrfy(xor(17,17) == 0, '844: xor(17,17) == 0'); vrfy(xor(12,5) == 9, '845: xor(12,5) == 9'); vrfy(mmin(3,7) == 3, '846: mmin(3,7) == 3'); vrfy(mmin(4,7) == -3, '847: mmin(4,7) == -3'); vrfy(digit(123,2) == 1, '848: digit(123,2) == 1'); vrfy(ismult(3/4, 1/7) == 0, '849: ismult(3/4, 1/7) == 0'); vrfy(gcd(3/4, 1/7) == 1/28, '850: gcd(3/4,1/7) == 1/28'); vrfy(gcd(2,3,1/2) == 1/2, '851: gcd(2,3,1/2) == 1/2'); vrfy(gcd(17,7,1/7) == 1/7, '852: gcd(17,7,1/7) == 1/7'); vrfy(gcd(2) == 2, '853: gcd(2) == 2'); vrfy(gcd(-2) == 2, '854: gcd(-2) == 2'); vrfy(floor(1.5) == 1, '855: floor(1.5) == 1'); vrfy(floor(.5) == 0, '856: floor(.5) == 0'); vrfy(floor(-.5) == -1, '857: floor(-.5) == -1'); vrfy(floor(-1.5) == -2, '858: floor(-1.5) == -2'); vrfy(ceil(1.5) == 2, '859: ceil(1.5) == 2'); vrfy(ceil(.5) == 1, '860: ceil(.5) == 1'); vrfy(ceil(-.5) == 0, '861: ceil(-.5) == 0'); vrfy(ceil(-1.5) == -1, '862: ceil(-1.5) == -1'); vrfy(frac(-7.2) == -.2, '863: frac(-7.2) == -.2'); vrfy(gcd(4, 5, 1/3) == 1/3, '864: gcd(4, 5, 1/3) == 1/3'); vrfy(ltol(7/25) == 24/25, '865: ltol(7/25) == 24/25'); vrfy(hmean(1,2,3) == 18/11, '866: hmean(1,2,3) == 18/11'); vrfy(ilog2(2^-20) == -20, '867: ilog2(2^-20) == -20'); vrfy(ord("DBell") == 68, '868: ord("DBell") == 68'); vrfy(cmp("a","b") == -1, '869: cmp("a","b") == -1'); vrfy(cmp("abcd","abc") == 1, '870: cmp("abcd","abc") == 1'); vrfy(cmp(3,4i) == 1-1i, '871: cmp(3,4i) == 1-1i'); vrfy(cmp(4,4i) == 1-1i, '872: cmp(4,4i) == 1-1i'); vrfy(cmp(5,4i) == 1-1i, '873: cmp(5,4i) == 1-1i'); vrfy(cmp(-5,4i) == -1-1i, '874: cmp(-5,4i) == -1-1i'); vrfy(cmp(-4i,5) == -1-1i, '875: cmp(-4i,5) == -1-1i'); vrfy(cmp(-4i,-5) == 1-1i, '876: cmp(-4i,-5) == 1-1i'); vrfy(cmp(3i,4i) == -1i, '877: cmp(3i,4i) == -1i'); vrfy(cmp(4i,4i) == 0, '878: cmp(4i,4i) == 0'); vrfy(cmp(5i,4i) == 1i, '879: cmp(5i,4i) == 1i'); vrfy(cmp(3+4i,5) == -1+1i, '880: cmp(3+4i,5) == -1+1i'); vrfy(cmp(3+4i,-5) == 1+1i, '881: cmp(3+4i,-5) == 1+1i'); vrfy(cmp(3+4i,3+4i) == 0, '882: cmp(3+4i,3+4i) == 0'); vrfy(cmp(3+4i,3-4i) == 1i, '883: cmp(3+4i,3-4i) == 1i'); vrfy(cmp(3+4i,2+3i) == 1+1i, '884: cmp(3+4i,2+3i) == 1+1i'); vrfy(cmp(3+4i,-4-5i) == 1+1i, '885: cmp(3+4i,-4-5i) == 1+1i'); vrfy(comb(7,0) == 1, '886: comb(7,0) == 1'); vrfy(comb(0,0) == 1, '887: comb(0,0) == 1'); vrfy(perm(7,0) == 1, '888: perm(7,0) == 1'); vrfy(perm(0,0) == 1, '889: perm(0,0) == 1'); vrfy(isfile(files(0)) == 1, '890: isfile(files(0)) == 1'); vrfy(isfile(0) == 0, '891: isfile(0) == 0'); vrfy(ismult(4^67, 2^59) == 1, '892: ismult(4^67, 2^59) == 1'); vrfy(ismult(13, 4/67) == 0, '893: ismult(13, 4/67) == 0'); vrfy(ismult(13, 7/56) == 1, '894: ismult(13, 7/56) == 1'); vrfy(isnum(2i) == 1, '895: isnum(2i) == 1'); vrfy(iseven(1/3) == 0, '896: iseven(1/3) == 0'); vrfy(isodd(1/3) == 0, '897: isodd(1/3) == 0'); vrfy(isrel(-5, 6) == 1, '898: isrel(-5, 6) == 1'); vrfy(isrel(-2, 6) == 0, '899: isrel(-2, 6) == 0'); vrfy(bit(9,0) == 1, '900: bit(9,0) == 1'); vrfy(bit(9,1) == 0, '901: bit(9,1) == 0'); vrfy(bit(9,2) == 0, '902: bit(9,2) == 0'); vrfy(bit(9,3) == 1, '903: bit(9,3) == 1'); vrfy(bit(1.25, -2) == 1, '904: bit(1.25, -2) == 1'); vrfy(bit(1.25, -1) == 0, '905: bit(1.25, -1) == 0'); vrfy(bit(1.25, 0) == 1, '906: bit(1.25, 0) == 1'); vrfy(bit(pi(), 1) == 1, '907: bit(pi(), 1) == 1'); vrfy(bit(pi(), -2) == 0, '908: bit(pi(), -2) == 0'); vrfy(bit(pi(), -3) == 1, '909: bit(pi(), -3) == 1'); vrfy(istype(2, 3.0) == 1, '910: istype(2, 3.0) == 1'); vrfy(istype(2, "2") == 0, '911: istype(2, "2") == 0'); vrfy(istype(2, 3i) == 0, '912: istype(2, 3i) == 0'); vrfy(istype(2i+2, 3i) == 1, '913: istype(2i+2, 3i) == 1'); a = epsilon(); print '914: a = epsilon()'; vrfy(epsilon(a) == epsilon(), '915: epsilon(a) == epsilon()'); vrfy(epsilon(a) == epsilon(), '916: epsilon(a) == epsilon()'); vrfy(epsilon(a) == epsilon(), '917: epsilon(a) == epsilon()'); vrfy(epsilon() == a, '918: epsilon() == a'); b = 1e-6; print '919: b = 1e-6'; vrfy(epsilon(b) == a, '920: epsilon(b) == a'); vrfy(epsilon(b) == epsilon(), '921: epsilon(b) == epsilon()'); vrfy(epsilon(b) == epsilon(), '922: epsilon(b) == epsilon()'); vrfy(epsilon(b) == epsilon(), '923: epsilon(b) == epsilon()'); vrfy(epsilon() == 1e-6, '924: epsilon() == 1e-6'); vrfy(epsilon(a) == b, '925: epsilon(a) == b'); vrfy(epsilon(a) == epsilon(), '926: epsilon(a) == epsilon()'); vrfy(epsilon(a) == epsilon(), '927: epsilon(a) == epsilon()'); vrfy(epsilon(a) == epsilon(), '928: epsilon(a) == epsilon()'); vrfy(epsilon(a) == a, '929: epsilon(a) == a'); vrfy(quomod(13,5,a,b) == 1, '930: quomod(13,5,a,b) == 1'); vrfy(a == 2, '931: a == 2'); vrfy(b == 3, '932: b == 3'); vrfy(quomod(15.6,5.2,a,b) == 0, '933: quomod(15.6,5.2,a,b) == 0'); vrfy(a == 3, '934: a == 3'); vrfy(b == 0, '935: b == 0'); vrfy(putenv("abcd=efg") == 0, '936: putenv("abcd=efg")'); vrfy(getenv("abcd") == "efg", '937: getenv("abcd") == "efg"'); vrfy(putenv("abcd","123")==0, '938: putenv("abcd","123")'); vrfy(getenv("abcd") == "123", '939: getenv("abcd") == "123"'); vrfy(isnull(getenv("notavar")) == 1, '940: isnull(getenv("notavar")) == 1'); a = "abcdefg"; print '941: a = "abcdefg"'; vrfy(strpos(a, "c") == 3, '942: strpos(a, "c") == 3'); vrfy(strpos(a, "def") == 4, '943: strpos(a, "def") == 4'); vrfy(strpos(a, "defg") == 4, '944: strpos(a, "defg") == 4'); vrfy(strpos(a, "defgh") == 0, '945: strpos(a, "defgh") == 0'); vrfy(strpos(a, "abc") == 1, '946: strpos(a, "abc") == 1'); vrfy(strpos(a, "xyz") == 0, '947: strpos(a, "xyz") == 0'); vrfy(strpos(a, a) == 1, '948: strpos(a, a) == 1'); vrfy(system("") == 0, '949: system("") == 0'); vrfy(system("true") == 0, '950: system("true") == 0'); print '951: test disabled due to stdin dependency'; print '952: test removed'; print '953: test removed'; vrfy(isstr(cmdbuf()) == 1, '954: isstr(cmdbuf()) == 1'); vrfy(abs(root(4,3,0.1)-1.5874) < 0.1, '955: abs(root(4,3,0.1)-1.5874) < 0.1'); print '956: a = 2^300 + 69962309754533779525365054067'; a = 2^300 + 69962309754533779525365054067; a /= 2^211; print '957: a /= 2^211'; vrfy(appr(a, 1e-20) == 2^89, '958: appr(a, 1e-20) == 2^89'); vrfy(digits(5e149) == 150, '959: digits(5e149) == 150'); vrfy(highbit(2) == 1, '960: highbit(2) == 1'); vrfy(highbit(3) == 1, '961: highbit(3) == 1'); vrfy(highbit(4) == 2, '962: highbit(4) == 2'); vrfy(highbit(-15) == 3, '963: highbit(-15) == 3'); vrfy(highbit(2^27) == 27, '964: highbit(2^27) == 27'); a = 12.34; print '965: a = 12.34'; vrfy(digit(a,2) == 0, '966: digit(a,2) == 0'); vrfy(digit(a,1) == 1, '967: digit(a,1) == 1'); vrfy(digit(a,0) == 2, '968: digit(a,0) == 2'); vrfy(digit(a,-1) == 3, '969: digit(a,-1) == 3'); vrfy(digit(a,-2) == 4, '970: digit(a,-2) == 4'); a = 10/7; print '971: a = 10/7'; vrfy(digit(a,1) == 0, '972: digit(a,1) == 0'); vrfy(digit(a,0) == 1, '973: digit(a,0) == 1'); vrfy(digit(a,-1) == 4, '974: digit(a,-1) == 4'); vrfy(digit(a,-2) == 2, '975: digit(a,-2) == 2'); vrfy(digit(a,-3) == 8, '976: digit(a,-3) == 8'); vrfy(digits(0) == 1, '977: digits(0) == 1'); vrfy(digits(0.0123) == 1, '978: digits(0.0123) == 1'); vrfy(digits(3.7) == 1, '979: digits(3.7) == 1'); vrfy(digits(-27) == 2, '980: digits(-27) == 2'); vrfy(digits(-99.7) == 2, '981: digits(-99.7) == 2'); vrfy(ilog2(1) == 0, '982: ilog2(1) == 0'); vrfy(ilog2(2) == 1, '983: ilog2(2) == 1'); vrfy(ilog2(3) == 1, '984: ilog2(3) == 1'); vrfy(ilog2(4) == 2, '985: ilog2(4) == 2'); vrfy(ilog2(1/15) == -4, '986: ilog2(1/15) == -4'); vrfy(places(3) == 0, '987: places(3) == 0'); vrfy(places(0.0123) == 4, '988: places(0.0123) == 4'); vrfy(places(3.70) == 1, '989: places(3.70) == 1'); vrfy(places(1e-10) == 10, '990: places(1e-10) == 10'); vrfy(places(3/7) == -1, '991: places(/37) == -1'); vrfy(ilog10(7.7) == 0, '992: ilog10(7.7) == 0'); vrfy(ilog10(77.7) == 1, '993: ilog10(77.7) == 1'); vrfy(ilog10(777) == 2, '994: ilog10(777) == 2'); vrfy(ilog10(.00777) == -3, '995: ilog10(.00777) == -3'); vrfy(ilog10(1e27) == 27, '996: ilog10(1e27) == 27'); vrfy(lowbit(2) == 1, '997: lowbit(2) == 1'); vrfy(lowbit(3) == 0, '998: lowbit(3) == 0'); vrfy(lowbit(4) == 2, '999: lowbit(4) == 2'); vrfy(lowbit(-15) == 0, '1000: lowbit(-15) == 0'); vrfy(lowbit(2^27) == 27, '1001: lowbit(2^27) == 27'); vrfy(char(0102) == 'B', '1002: char(0102) == \'B\''); vrfy(char(0x6f) == 'o', '1003: char(0x6f) == \'o\''); vrfy(char(119) == 'w', '1004: char(119) == \'w\''); vrfy(char(0145) == 'e', '1005: char(0145) == \'e\''); vrfy(char(0x6e) == 'n', '1006: char(0x6e) == \'n\''); vrfy(den(-1.25) == 4, '1007: den(-1.25) == 4'); vrfy(den(121/33) == 3, '1008: den(121/33) == 3'); vrfy(gcd(9/10, 11/5, 4/25) == 0.02, '1009: gcd(9/10, 11/5, 4/25) == 0.02'); vrfy(gcd(0,0,0,0,0) == 0, '1010: gcd(0,0,0,0,0) == 0'); vrfy(hypot(3, 4, 1e-6) == 5, '1011: hypot(3, 4, 1e-6) == 5'); vrfy(hypot(2,-3,1e-6) == 3605551/1e6, '1012: hypot(2,-3,1e-6) == 3605551/1e6'); vrfy(im(-4.25 - 7i) == -7, '1013: im(-4.25 - 7i) == -7'); vrfy(lcm(12, -24, 30) == -120,'1014: lcm(12, -24, 30) == -120'); vrfy(lcm(9/10, 11/5, 4/25) == 79.2, '1015: lcm(9/10, 11/5, 4/25) == 79.2'); vrfy(lcm(2) == 2, '1016: lcm(2) == 2'); vrfy(max(2) == 2, '1017: max(2) == 2'); vrfy(min(2) == 2, '1018: min(2) == 2'); vrfy(re(-4.25 - 7i) == -4.25, '1019: re(-4.25 - 7i) == -4.25'); vrfy(size("abc") == 3, '1020: size("abc") == 3'); vrfy(str("") == "", '1021: str("") == ""'); vrfy(str(null()) == "", '1022: str(null()) == ""'); vrfy(str("Ernest Bowen") == "Ernest Bowen", '1023: str("Ernest Bowen") == "Ernest Bowen"'); vrfy(strlen("a b\tc\\d") == 7, '1024: strlen("a b\tc\\d") == 7'); vrfy(xor(2) == 2, '1025: xor(2) == 2'); vrfy(xor(5, 3, 7, 2, 9) == 10, '1026: xor(5, 3, 7, 2, 9) == 10'); vrfy(xor(0,0) == 0, '1027: xor(0,0) == 0'); vrfy(xor(0,1) == 1, '1028: xor(0,1) == 1'); vrfy(xor(1,0) == 1, '1029: xor(1,0) == 1'); vrfy(xor(1,1) == 0, '1030: xor(1,1) == 0'); vrfy(xor(5,3,-7,2,9) == -12, '1031: xor(5,3,-7,2,9) == -12'); vrfy(fib(-2) == -1, '1032: fib(-2) == -1'); vrfy(fib(-1) == 1, '1033: fib(-1) == 1'); vrfy(fib(-10) == -55, '1034: fib(-10) == -55'); vrfy(ilog(1/8, 3) == -2, '1035: ilog(1/8, 3) == -2'); vrfy(ilog(8.9, 3) == 1, '1036: ilog(8.9, 3) == 1'); vrfy(iroot(1,9) == 1, '1037: iroot(1,9) == 1'); vrfy(iroot(pi()^8,5) == 6, '1038: iroot(pi()^8,5)'); vrfy(isqrt(8.5) == 2, '1039: isqrt(8.5) == 2'); vrfy(isqrt(2e56) == 14142135623730950488016887242, '1040: isqrt(2e56) == 14142135623730950488016887242'); vrfy(near(22/7, 3.15, .01) == -1, '1041: near(22/7, 3.15, .01) == -1'); vrfy(near(22/7, 3.15, .005) == 1, '1042: near(22/7, 3.15, .005) == 1'); vrfy(norm(3.4) == 11.56, '1043: isqrt(3.4) == 11.56'); vrfy(pi(1e-5) == 3.14159, '1044: pi(1e-5) == 3.14159'); pi = pi(1e-10); print '1045: pi = pi(1e-10)'; vrfy(pi == 3.1415926536, '1046: pi == 3.1415926536'); vrfy(polar(2,pi/2,1e-5)==2i, '1047: polar(2,pi/2,1e-5)==2i'); vrfy(power(exp(1,1e-20),pi(1e-20)*1i/2,1e-20) == 1i, '1048: power(exp(1,1e-20),pi(1e-20)*1i/2,1e-20) == 1i'); vrfy(ssq(1+2i, 3-4i, 5 +6i) == -21+40i, '1049: ssq(1+2i, 3-4i, 5 +6i) == -21+40i'); vrfy(isreal(ln(1 + 1e-10i, 1e-5)), '1050: isreal(ln(1 + 1e-10i, 1e-5))'); vrfy(isreal(exp(pi(1e-10)*1i, 1e-5)), '1051: isreal(exp(pi(1e-10)*1i, 1e-5))'); vrfy(cfappr(43/30, 10, 0) == 10/7, '1052: cfappr(43/30, 10, 0) == 10/7'); vrfy(cfappr(43/30, 10, 1) == 13/9, '1053: cfappr(43/30, 10, 1) == 13/9'); vrfy(cfappr(43/30, 10, 16) == 10/7, '1054: cfappr(43/30, 10, 16) == 10/7'); vrfy(cfappr(6/5, 1/2, 16) == 1, '1055: cfappr(6/5, 1/2, 16) == 1'); vrfy(cfsim(13,8) == 0, '1056: cfsim(13,8) == 0'); vrfy(cfsim(1057,8) == 0, '1057: cfsim(1057,8) == 0'); vrfy(mod(11,5,0) == 1, '1058: mod(11,5,0) == 1'); vrfy(mod(11,5,1) == -4, '1059: mod(11,5,1) == -4'); vrfy(mod(-11,5,2) == -1, '1060: mod(-11,5,2) == -1'); vrfy(mod(-11,-5,3) == 4, '1061: mod(-11,-5,3) == 4'); vrfy(mod(12.5,5,16) == 2.5, '1062: mod(12.5,5,16) == 2.5'); vrfy(mod(12.5,5,17) == -2.5, '1063: mod(12.5,5,17) == -2.5'); vrfy(mod(12.5,5,24) == 2.5, '1064: mod(12.5,5,24) == 2.5'); vrfy(mod(-7.5,-5,24) == 2.5, '1065: mod(-7.5,-5,24) == 2.5'); vrfy(quo(11,5,0) == 2, '1066: quo(11,5,0) == 2'); vrfy(quo(11,5,1) == 3, '1067: quo(11,5,1) == 3'); vrfy(quo(-11,5,2) == -2, '1068: quo(-11,5,2) == -2'); vrfy(quo(-11,-5,3) == 3, '1069: quo(-11,-5,3) == 3'); vrfy(quo(12.5,5,16) == 2, '1070: quo(12.5,5,16) == 2'); vrfy(quo(12.5,5,17) == 3, '1071: quo(12.5,5,17) == 3'); vrfy(quo(12.5,5,24) == 2, '1072: quo(12.5,5,24) == 2'); vrfy(quo(-7.5,-5,24) == 2, '1073: quo(-7.5,-5,24) == 2'); vrfy(frac(2.5 + 3i) == .5, '1074: frac(2.5 + 3i) == .5'); vrfy(root(1i,1000,1e-2)==1, '1075: root(1i,1000,1e-2) == 1'); vrfy(scale(2+3i,2)==8+12i, '1076: scale(2+3i,2) == 8+12i'); vrfy(frem(8,4) == 2, '1077: frem(8,4) == 2'); vrfy(jacobi(80,199) == 1, '1078: jacobi(80,199) == 1'); vrfy(test(1), '1079: test(1)'); vrfy(!test(0), '1080: !test(0)'); vrfy(hnrmod(2^177-1,1,177,-1)==0, '1081: hnrmod(2^177-1,1,177,-1)==0'); vrfy(hnrmod(2^178-2,1,177,-1)==0, '1082: hnrmod(2^178-2,1,177,-1)==0'); vrfy(hnrmod(2^178-3,1,177,1)==2^177-4, '1083: hnrmod(2^178-3,1,177,1)==2^177-4'); vrfy(hnrmod(2^179-4,1,177,0)==2^177-4, '1084: hnrmod(2^179-4,1,177,0)==2^177-4'); vrfy(hnrmod(1234567^2,13,17,-1)==1155404, '1085: hnrmod(1234567^2,13,17,-1)==1155404'); vrfy(hnrmod(3276^54,45,415,1)==3276^54%(45*2^415+1), '1086: hnrmod(3276^54,45,415,1)==3276^54%(45*2^415+1)'); vrfy(hnrmod(3276^54,45,415,0)==3276^54%(45*2^415), '1087: hnrmod(3276^54,45,415,0)==3276^54%(45*2^415)'); vrfy(hnrmod(3276^54,45,415,-1)==3276^54%(45*2^415-1), '1088: hnrmod(3276^54,45,415,-1)==3276^54%(45*2^415-1)'); vrfy(hnrmod(10^40, 17, 51, 1) == 33827019788296445, '1089: hnrmod(10^40, 17, 51, 1) == 33827019788296445'); vrfy(hnrmod(3192487935759423423521,16,65,1)==241008883965895164956, '1090: hnrmod(3192487935759423423521,16,65,1)==241008883965895164956'); /* * minv bug fix */ a = 2868611690182699929873981931; print '1091: a = 2868611690182699929873981931'; b = 502922899875329926125584830; print '1092: b = 502922899875329926125584830'; vrfy(minv(b,a) == 1111092570983877189739032190, '1093: minv(b,a) == 1111092570983877189739032190'); vrfy(mod(minv(b,a)*b,a) == 1, '1094: mod(minv(b,a)*b,a) == 1'); /* * more functions to test */ vrfy(popcnt(32767) == 15, '1095: popcnt(32767) == 15'); vrfy(popcnt(3/2) == 3, '1096: popcnt(3/2) == 3'); vrfy(popcnt(-237/39929,1) == 17, '1097: popcnt(-237/39929,1) == 17'); vrfy(popcnt(-237/39929,0) == 7, '1098: popcnt(-237/39929,0) == 7'); vrfy(popcnt(-237/39929) == 17, '1099: popcnt(-237/39929) == 17'); vrfy(popcnt(pi(1e-20)) == 65, '1100: popcnt(pi(1e-20)) == 65'); vrfy(popcnt(pi(1e-20),0) == 69, '1101: popcnt(pi(1e-20),0) == 69'); vrfy(popcnt(17^777) == 1593, '1102: popcnt(17^777) == 1593'); /* * more hnrmod testing */ vrfy(hnrmod(21<<100+5,3,100,1) == (21<<100+5)%(3<<100+1), '1103: hnrmod(21<<100+5,3,100,1) == (21<<100+5)%(3<<100+1)'); vrfy(hnrmod(21<<500+7,3,500,1) == (21<<500+7)%(3<<500+1), '1104: hnrmod(21<<500+7,3,500,1) == (21<<500+7)%(3<<500+1)'); vrfy(hnrmod(-767256,84,1,0) == (-767256)%(84<<1+0), '1105: hnrmod(-767256,84,1,0) == (-767256)%(84<<1+0)'); vrfy(hnrmod(-831150,75,1,0) == (-831150)%(75<<1+0), '1106: hnrmod(-831150,75,1,0) == (-831150)%(75<<1+0)'); vrfy(hnrmod(-767256,84,1,1) == (-767256)%(84<<1+1), '1107: hnrmod(-767256,84,1,1) == (-767256)%(84<<1+1)'); vrfy(hnrmod(-831150,75,1,1) == (-831150)%(75<<1+1), '1108: hnrmod(-831150,75,1,1) == (-831150)%(75<<1+1)'); vrfy(hnrmod(-767256,84,1,-1) == (-767256)%(84<<1-1), '1109: hnrmod(-767256,84,1,-1) == (-767256)%(84<<1-1)'); vrfy(hnrmod(-831150,75,1,-1) == (-831150)%(75<<1-1), '1110: hnrmod(-831150,75,1,-1) == (-831150)%(75<<1-1)'); vrfy(hnrmod(21<<100+5,3,100,0) == (21<<100+5)%(3<<100+0), '1111: hnrmod(21<<100+5,3,100,0) == (21<<100+5)%(3<<100+0)'); vrfy(hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1), '1112: hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1)'); print '1113: Ending test_functions'; } print '017: parsed test_functions()'; /* * _test_underscore - test use of _'s in identifiers */ _ = 49; print '018: _ = 49'; __ = 63; print "019: __ = 63"; define _test_underscore() { local _a = 27; local __a = 23209; print "1200: Beginning _test_underscore"; vrfy(_a == 27, '1201: _a == 27'); vrfy(_ == 49, '1202: _ == 49'); vrfy(__ == 63, '1203: __ == 63'); vrfy(__a == 23209, '1204: __a == 23209'); print "1205: Ending _test_underscore"; } print '020: parsed _test_underscore'; /* * place holder for any print items */ print "021:", "reserved for future use"; print "022:": " reserved for future use"; /* * Test associations */ define test_assoc() { static a; static b; local A; print '1300: Beginning associations test'; a = assoc(); vrfy(size(a) == 0, '1301: size(a) == 0'); a["curds"] = 13; print '1302: a["curds"] = 13'; vrfy(a["curds"] == 13, '1303: a["curds"] == 13'); a[13] = 17; print '1304: a[13] = 17'; vrfy(a[13] == 17, '1305: a[13] == 17'); vrfy(a[a["curds"]] == 17, '1306: a[a["curds"]] == 17'); a[17] = 19; print '1307: a[17] = 19'; vrfy(a[17] == 19, '1308: a[17] == 19'); vrfy(a[a["curds"]+4] == 19, '1309: a[a["curds"]+4] == 19'); vrfy(size(a) == 3, '1310: size(a) == 3'); vrfy(a[[search(a,17)]] == 17, '1311: (a[[search(a,17)]] == 17'); vrfy(isnull(search(a,16)), '1312: isnull(search(a,16))'); a["curds","whey"] = "spider"; print '1313: a["curds","whey"] = "spider"'; vrfy(a["curds","whey"] == "spider", '1314: a["curds","whey"] == "spider"'); vrfy(a[[rsearch(a,"spider")]] == "spider", '1315: a[[rsearch(a,"spider")]] == "spider"'); b = a; print '1316: b = a'; vrfy(b[17] == 19, '1317: b[17] == 19'); vrfy(a == b, '1318: a == b'); vrfy(isassoc(a) == 1, '1319: isassoc(a) == 1'); vrfy(isassoc(1) == 0, '1320: isassoc(1) == 0'); A = assoc(); vrfy(quomod(13, 5, A[1], A[2]) == 1, '1321: quomod(13, 5, A[1], A[2]) == 1'); vrfy(A[1] == 2, '1322: A[1] == 2'); vrfy(A[2] == 3, '1323: A[2] == 3'); print '1324: Ending associations test'; } print '023: parsed test_assoc()'; /* * Test lists */ define test_list() { static a; static b; static x = list(11,13,17,23,29); static y0 = list(1,3,7,3,9); static y1 = list(-9,-7,-3,-7,-1); static y2 = list(-9,-7,-3,3,9); static y3 = list(1,3,7,-7,-1); static y4 = list(1,3,-3,3,-1); local A,B,C,D,E; local y,z; local list1, list2; print '1400: Beginning list test'; a = list(2,3,5); vrfy(a == list(2,3,5), '1401: a == list(2,3,5)'); vrfy(a[[0]] == 2, '1402: a[[0]] == 2'); vrfy(a[[1]] == 3, '1403: a[[1]] == 3'); vrfy(a[[2]] == 5, '1404: a[[2]] == 5'); vrfy(size(a) == 3, '1405: size(a) == 3'); vrfy(search(a,3) == 1, '1406: search(a,3) == 1'); vrfy(isnull(search(a,3,2)), '1407: isnull(search(a,3,2))'); vrfy(rsearch(a,3,2) == 1, '1408: rsearch(a,3,2) == 1'); push(a,7); print '1409: push(a,7)'; vrfy(search(a,7) == 0, '1410: search(a,7) == 0'); vrfy(pop(a) == 7, '1411: pop(a) == 7'); vrfy(size(a) == 3, '1412: size(a) == 3'); append(a,7); print '1413: append(a,7)'; vrfy(search(a,7) == 3, '1414: search(a,7) == 3'); vrfy(size(a) == 4, '1415: size(a) == 4'); vrfy(remove(a) == 7, '1416: remove(a) == 7'); vrfy(size(a) == 3, '1417: size(a) == 3'); b = a; print '1418: b = a'; insert(a,1,7); print '1419: insert(a,1,7)'; vrfy(search(a,2) == 0, '1420: search(a,2) == 0'); vrfy(search(a,7) == 1, '1421: search(a,7) == 1'); vrfy(search(a,3) == 2, '1422: search(a,3) == 2'); vrfy(search(a,5) == 3, '1423: search(a,5) == 3'); vrfy(size(a) == 4, '1424: size(a) == 4'); vrfy(delete(a,1) == 7, '1425: remove(a) == 7'); vrfy(search(a,2) == 0, '1426: search(a,2) == 0'); vrfy(search(a,3) == 1, '1427: search(a,3) == 1'); vrfy(search(a,5) == 2, '1428: search(a,5) == 2'); vrfy(size(a) == 3, '1429: size(a) == 3'); vrfy(a == b, '1430: a == b'); A = list(1,2,3); print '1431: A = list(1,2,3)'; B = list(4,5); print '1432: B = list(4,5)'; C = join(A,B); print '1433: C = join(A,B)'; D = list(1,2,3,4,5); print '1434: D = list(1,2,3,4,5)'; vrfy(C == D, '1435: C == D'); E = list(5,4,3,2,1); print '1436: E = list(5,4,3,2,1)'; vrfy(reverse(D) == E, '1437: reverse(D) == E'); vrfy(sort(list(1,3,5,2,4))==D,'1438: sort(list(1,3,5,2,4))==D'); vrfy(head(D,2) == list(1,2), '1439: head(D,2) == list(1,2)'); vrfy(head(D,-2) == list(2,1), '1440: head(D,-2) == list(2,1)'); vrfy(head(D,5) == D, '1441: head(D,5) == D'); vrfy(head(D,6) == D, '1442: head(D,6) == D'); vrfy(head(D,-5) == E, '1443: head(D,-5) == E'); vrfy(head(D,-6) == E, '1444: head(D,-6) == E'); vrfy(tail(E,2) == list(2,1), '1445: tail(E,2) == list(2,1)'); vrfy(tail(E,-2) == list(1,2), '1446: tail(E,-2) == list(1,2)'); vrfy(tail(E,5) == E, '1447: tail(E,5) == E'); vrfy(tail(E,6) == E, '1448: tail(E,6) == E'); vrfy(tail(E,-5) == D, '1449: tail(E,-5) == D'); vrfy(tail(E,-6) == D, '1450: tail(E,-6) == D'); vrfy(segment(D,1,3) == list(2,3,4), '1451: segment(D,1,3) == list(2,3,4)'); vrfy(segment(D,3,1) == list(4,3,2), '1452: segment(D,3,1) == list(4,3,2)'); vrfy(segment(D,0,2) == head(D,3), '1453: segment(D,0,2) == head(D,3)'); vrfy(segment(D,2,0) == tail(E,3), '1454: segment(D,2,0) == tail(E,3)'); vrfy(segment(D,0,4) == head(D,5), '1455: segment(D,0,4) == head(D,5)'); vrfy(segment(D,4,0) == head(E,5), '1456: segment(D,4,0) == head(E,5)'); vrfy(segment(D,3,4) == tail(D,2), '1457: segment(D,3,4) == tail(D,2)'); vrfy(segment(D,4,3) == head(E,2), '1458: segment(D,4,3) == head(E,2)'); for (y=0; y < size(D); ++y) { for (z=y; z < size(D); ++z) { if (D != join(head(D,y), segment(D,y,z), tail(D,size(D)-z-1))) { prob(strcat("join loop failed at y=",str(y)," z=",str(z))); } } } print '1459: join loop test'; vrfy(mod(x,10,0) == y0, '1460: mod(x,10,0) == y0'); vrfy(mod(x,10,1) == y1, '1461: mod(x,10,1) == y1'); vrfy(mod(x,10,2) == y0, '1462: mod(x,10,2) == y0'); vrfy(mod(x,10,3) == y1, '1463: mod(x,10,3) == y1'); vrfy(mod(x,10,4) == y0, '1464: mod(x,10,4) == y0'); vrfy(mod(x,10,5) == y1, '1465: mod(x,10,5) == y1'); vrfy(mod(x,10,6) == y0, '1466: mod(x,10,6) == y0'); vrfy(mod(x,10,7) == y1, '1467: mod(x,10,7) == y1'); vrfy(mod(x,10,8) == y2, '1468: mod(x,10,8) == y2'); vrfy(mod(x,10,9) == y3, '1469: mod(x,10,9) == y3'); vrfy(mod(x,10,10) == y2, '1470: mod(x,10,10) == y2'); vrfy(mod(x,10,11) == y3, '1471: mod(x,10,11) == y3'); vrfy(mod(x,10,12) == y2, '1472: mod(x,10,12) == y2'); vrfy(mod(x,10,13) == y3, '1473: mod(x,10,13) == y3'); vrfy(mod(x,10,14) == y2, '1474: mod(x,10,14) == y2'); vrfy(mod(x,10,15) == y3, '1475: mod(x,10,15) == y3'); vrfy(mod(x,10,16) == y4, '1476: mod(x,10,16) == y4'); vrfy(mod(x,10,16) == y4, '1477: mod(x,10,16) == y4'); vrfy(mod(x,10,18) == y4, '1478: mod(x,10,18) == y4'); vrfy(mod(x,10,19) == y4, '1479: mod(x,10,18) == y4'); vrfy(mod(x,10,20) == y4, '1480: mod(x,10,20) == y4'); vrfy(mod(x,10,21) == y4, '1481: mod(x,10,21) == y4'); vrfy(mod(x,10,22) == y4, '1482: mod(x,10,22) == y4'); vrfy(mod(x,10,23) == y4, '1483: mod(x,10,23) == y4'); vrfy(mod(x,10,24) == y4, '1484: mod(x,10,24) == y4'); vrfy(mod(x,10,25) == y4, '1485: mod(x,10,25) == y4'); vrfy(mod(x,10,26) == y4, '1486: mod(x,10,26) == y4'); vrfy(mod(x,10,27) == y4, '1487: mod(x,10,27) == y4'); vrfy(mod(x,10,28) == y4, '1488: mod(x,10,28) == y4'); vrfy(mod(x,10,29) == y4, '1489: mod(x,10,29) == y4'); vrfy(mod(x,10,30) == y4, '1490: mod(x,10,30) == y4'); vrfy(mod(x,10,31) == y4, '1491: mod(x,10,31) == y4'); list1 = list(3,1,"x",2,null()); print '1492: list1 = list(3,1,"x",2,null())'; list2 = list(null(),1,2,3,"x"); print '1493: list2 = list(null(),1,2,3,"x")'; vrfy(sort(list1) == list2, '1494: sort(list1) == list2'); A = list(1,2,3,4); print '1495: A = list(1,2,3,4)'; B = makelist(4) = {1,2,3,4}; print '1496: B = makelist(4) = {1,2,3,4}'; vrfy(A == B, '1497: A == B'); vrfy((A = {,,5}) == list(1,2,5,4), '1498: (A = {,,5}) == list(1,2,5,4)'); print '1499: Ending list test'; } print '024: parsed test_list()'; /* * Test rand - a55 shuffle pseudo-random number generator */ define test_rand() { local init; /* initial generator state */ local state0; /* a generator state */ local tmp; local n; print '1500: Beginning rand test'; /* test save and restore of the initial state */ tmp = srand(0); print '1501: tmp = srand(0)'; init = srand(); print '1502: init = srand()'; state0 = srand(0); print '1503: state0 = srand(0)'; vrfy(state0 == init, '1504: state0 == init'); /* test the additive 55 shuffle generator */ tmp = srand(0); print '1505: tmp = srand(0)'; vrfy(rand() == 0xc79ef743e2e6849c, \ '1506: rand() == 0xc79ef743e2e6849c'); vrfy(rand() == 0x8d2dcb2bed321284, \ '1507: rand() == 0x8d2dcb2bed321284'); tmp = srand(init); print '1508: tmp = srand(init)'; vrfy(rand() == 0xc79ef743e2e6849c, \ '1509: rand() == 0xc79ef743e2e6849c'); vrfy(rand() == 0x8d2dcb2bed321284, \ '1510: rand() == 0x8d2dcb2bed321284'); /* test range interface */ tmp = srand(0); print '1511: tmp = srand(0)'; vrfy(rand(12345678901234567890) == 0x8d2dcb2bed321284, \ '1512: rand(12345678901234567890) == 0x8d2dcb2bed321284'); vrfy(rand(216091) == 0x13d2b, '1513: rand(216091) == 0x13d2b'); vrfy(rand(100) == 0x26, '1514: rand(100) == 0x26'); vrfy(rand(-46,46) == -0xf, '1515: rand(-46,46) == -0xf'); tmp = srand(0); print '1516: tmp = srand(0)'; vrfy(rand(2^64) == 0xc79ef743e2e6849c, \ '1517: rand(2^64) == 0xc79ef743e2e6849c'); vrfy(rand(0,2^64) == 0x8d2dcb2bed321284, \ '1518: rand(0,2^64) == 0x8d2dcb2bed321284'); /* test different forms of seeding the initial state */ tmp = srand(0); print '1519: tmp = srand(0)'; vrfy(srand() == init, '1520: srand() == init'); tmp = srand(0x87e6ec938ff55aa5<<64); print '1521: tmp = srand(0x87e6ec938ff55aa5<<64)'; vrfy(srand() == init, '1522: srand() == init'); tmp = srand(state0); print '1523: tmp = srand(state0)'; vrfy(srand() == init, '1524: srand() == init'); tmp = srand(init); print '1525: tmp = srand(init)'; vrfy(srand() == init, '1526: srand() == init'); vrfy(tmp == init, '1527: tmp == init'); /* test the bit length interface */ tmp = srand(0); print '1528: tmp = srand(0)'; vrfy(randbit(64) == 0xc79ef743e2e6849c, \ '1529: randbit(64) == 0xc79ef743e2e6849c'); vrfy(randbit(128) == 0x8d2dcb2bed3212844f4ad31f3818af34, \ '1530: randbit(128) == 0x8d2dcb2bed3212844f4ad31f3818af34'); vrfy(randbit(64) == 0x23a252f60bae4907, \ '1531: randbit(64) == 0x23a252f60bae4907'); vrfy(randbit(128) == 0xa8ed5b6203e2b1da32848cd9b3f1e3fa, \ '1532: randbit(128) == 0xa8ed5b6203e2b1da32848cd9b3f1e3fa'); tmp = srand(0); print '1533: tmp = srand(0)'; vrfy(randbit(32) == 0xc79ef743, '1534: randbit(32) == 0xc79ef743'); vrfy(randbit(32) == 0xe2e6849c, '1535: randbit(32) == 0xe2e6849c'); vrfy(randbit(1) == 0x1, '1536: randbit(1) == 0x1'); vrfy(randbit(5) == 0x3, '1537: randbit(5) == 0x3'); vrfy(randbit(33) == 0x96e595f6, '1538: randbit(33) == 0x96e595f6'); vrfy(randbit(25) == 0x1321284, '1539: randbit(25) == 0x1321284'); vrfy(randbit(2) == 0x1, '1540: randbit(2) == 0x1'); vrfy(randbit(13) == 0x7a5, '1541: randbit(13) == 0x7a5'); vrfy(randbit(18) == 0x1a63e, '1542: randbit(18) == 0x1a63e'); vrfy(randbit(8) == 0x70, '1543: randbit(8) == 0x70'); vrfy(randbit(9) == 0x62, '1544: randbit(9) == 0x62'); vrfy(randbit(70) == 0x2f3423a252f60bae49, \ '1545: randbit(70) == 0x2f3423a252f60bae49'); print '1546: test unused'; vrfy(randbit(8) == 0x7, '1547: randbit(8) == 0x7'); vrfy(randbit(65) == 0x151dab6c407c563b4, \ '1548: randbit(65) == 0x151dab6c407c563b4'); vrfy(randbit(63) == 0x32848cd9b3f1e3fa, \ '1549: randbit(63) == 0x32848cd9b3f1e3fa'); /* check to be sure that the srand(1) bug was fixed */ tmp = srand(1); print '1550: tmp = srand(1)'; n = 1; print '1551: n = 1'; vrfy(num(n), '1552: num(n)'); vrfy(den(n), '1553: den(n)'); vrfy(randbit(64) == 0x4280429f8069cb27, \ '1554: randbit(64) == 0x4280429f8069cb27'); /* test randbit skip interface */ tmp = srand(0); print '1555: tmp = srand(0)'; vrfy(randbit(20) == 817647, '1556: randbit(20) == 817647'); vrfy(randbit(20) == 476130, '1557: randbit(20) == 476130'); vrfy(randbit(20) == 944201, '1558: randbit(20) == 944201'); vrfy(randbit(20) == 822573, '1559: randbit(20) == 822573'); tmp = srand(0); print '1560: tmp = srand(0)'; vrfy(randbit(-20) == 20, '1561: randbit(-20) == 20'); vrfy(randbit(20) == 476130, '1562: randbit(20) == 476130'); vrfy(randbit(-20) == 20, '1563: randbit(-20) == 20'); vrfy(randbit(20) == 822573, '1564: randbit(20) == 822573'); /* test randbit without and arg */ tmp = srand(0); print '1565: tmp = srand(0)'; vrfy(randbit() == 1, '1566: randbit() == 1'); vrfy(randbit() == 1, '1567: randbit() == 1'); vrfy(randbit() == 0, '1568: randbit() == 0'); /* test seed() as best as we can */ vrfy(seed() >= 0, '1569: seed() >= 0'); vrfy(seed() < 2^64, '1570: seed() < 2^64'); vrfy(isrand(srand(seed())), '1571: isrand(srand(seed()))'); print '1572: Ending rand test'; } print '025: parsed test_rand()'; /* * Config mode/base testing */ define test_mode() { local tmp; print '1600: Beginning mode/base test'; tmp = config("mode", "frac"); print '1601: tmp = config("mode", "frac")'; tmp = config("mode", "frac"); print '1602: tmp = config("mode", "frac")'; vrfy(base() == 1/3, '1603: base() == 1/3'); tmp = config("mode", "int"); print '1604: tmp = config("mode", "int")'; vrfy(tmp == "frac", '1605: tmp == "frac"'); vrfy(base() == -10, '1606: base() == -10'); tmp = config("mode", "real"); print '1607: tmp = config("mode", "real")'; vrfy(tmp == "int", '1608: tmp == "int"'); vrfy(base() == 10, '1609: base() == 10'); tmp = config("mode", "exp"); print '1610: tmp = config("mode", "exp")'; vrfy(tmp == "real", '1611: tmp == "real"'); vrfy(base() == 1e20, '1612: base() == 1e20'); tmp = config("mode", "hex"); print '1613: tmp = config("mode", "hex")'; vrfy(tmp == "exp", '1614: tmp == "exp"'); vrfy(base() == 16, '1615: base() == 16'); tmp = config("mode", "oct"); print '1616: tmp = config("mode", "oct")'; vrfy(tmp == "hexadecimal", '1617: tmp == "hexadecimal"'); vrfy(base() == 8, '1618: base() == 8'); tmp = config("mode", "bin"); print '1619: tmp = config("mode", "bin")'; vrfy(tmp == "octal", '1620: tmp == "octal"'); vrfy(base() == 2, '1621: base() == 2'); tmp = config("mode", "real"); print '1622: tmp = config("mode", "real")'; vrfy(tmp == "binary", '1623: tmp == "binary"'); tmp = base(1/3); print '1624: tmp = base(1/3)'; vrfy(config("mode") == "frac", '1625: config("mode") == "frac"'); tmp = base(-10); print '1626: tmp = base(-10)'; vrfy(config("mode") == "int", '1627: config("mode") == "int"'); tmp = base(10); print '1628: tmp = base(10)'; vrfy(config("mode") == "real", '1629: config("mode") == "real"'); tmp = base(1e20); print '1630: tmp = base(1e20)'; vrfy(config("mode") == "exp", '1631: config("mode") == "exp"'); tmp = base(16); print '1632: tmp = base(16)'; vrfy(config("mode") == "hexadecimal", \ '1633: config("mode") == "hexadecimal"'); tmp = base(8); print '1634: tmp = base(8)'; vrfy(config("mode") == "octal", '1635: config("mode") == "octal"'); tmp = base(2); print '1636: tmp = base(2)'; vrfy(config("mode") == "binary",'1637: config("mode") == "binary"'); tmp = base(8); print '1638: tmp = base(8)'; vrfy(str(0x80000000) == "020000000000", \ '1639: str(0x8000000) == \"020000000000\"'); vrfy(str(0xffffffff) == "037777777777", \ '1640: str(0xffffffff) == \"037777777777\"'); vrfy(str(3e9) == "026264057000", \ '1641: str(3e9) == \"026264057000\"'); tmp = base(16); print '1642: tmp = base(16)'; vrfy(str(0x80000000) == "0x80000000", \ '1643: str(0x8000000) == \"0x80000000\"'); vrfy(str(0xffffffff) == "0xffffffff", \ '1644: str(0xffffffff) == \"0xffffffff\"'); vrfy(str(3e9) == "0xb2d05e00", \ '1645: str(3e9) == \"0xb2d05e00\"'); tmp = base(10); print '1646: tmp = base(10)'; vrfy(config("mode") == "real", \ '1647: config("mode") == "real"'); vrfy(str(0x80000000) == "2147483648", \ '1648: str(0x80000000) == \"2147483648\"'); vrfy(str(0xffffffff) == "4294967295", \ '1649: str(0xffffffff) == \"4294967295\"'); vrfy(str(3e9) == "3000000000", \ '1650: str(3e9) == \"3000000000\"'); print '1651: Ending mode/base test'; } print '026: parsed test_mode()'; /* * The 1700's contain tests for reading scripts. These tests are * done inline near the bottom. */ /* * Test objects */ read -once "surd"; print '027: read -once surd'; /**/ define test_obj() { static obj surd a; static obj surd b; print '1800: Beginning object test'; surd_type = -1; vrfy(surd_type == -1, '1801: surd_type == -1'); a = surd(2,3); print '1802: a = surd(2,3)'; vrfy(a == surd(2,3), '1803: a == surd(2,3)'); vrfy(surd_value(a) == 2+3i, '1804: surd_value(a) == 2+3i'); vrfy(conj(a) == surd(2,-3), '1805: conj(a) == surd(2,-3)'); vrfy(norm(a) == 13, '1806: norm(a) == 13'); vrfy(a+1 == surd(3,3), '1807: a+1 == surd(3,3)'); b = surd(3,4); print '1808: b = surd(3,4)'; vrfy(a+b == surd(5,7), '1809: a+b == surd(5,7)'); vrfy(a-b == surd(-1,-1), '1810: a-b == surd(-1,-1)'); vrfy(++a == surd(3,3), '1811: ++a == surd(3,3)'); vrfy(--a == surd(2,3), '1812: --a == surd(2,3)'); vrfy(-a == surd(-2,-3), '1813: -a == surd(-2,-3)'); vrfy(a*2 == surd(4,6), '1814: a*2 == surd(4,6)'); vrfy(a*b == surd(-6,17), '1815: a*b == surd(-6,17)'); vrfy(a^2 == surd(-5,12), '1816: a^2 == surd(-5,12)'); vrfy(scale(a,2) == surd(8,12), '1817: scale(a,2) == surd(8,12)'); vrfy(a<<3 == surd(16,24), '1818: a<<3 == surd(16,24)'); vrfy(a/2 == surd(1,1.5), '1819: a/2 == surd(1,1.5)'); vrfy(a/b == surd(0.72,0.04), '1820: a/b == surd(0.72,0.04)'); vrfy(1/b == surd(0.12,-0.16), '1821: 1/b == surd(0.12,-0.16)'); vrfy(inverse(b) == 1/b, '1822: inverse(b) == 1/b'); vrfy(a != b, '1823: a != b'); surd_type = 2; print '1824: surd_type = 2'; vrfy(surd_type == 2, '1825: surd_type == 2'); vrfy(sgn(a) == 1, '1826: sgn(a) == 1'); vrfy(a < b, '1827: a < b'); vrfy(a <= a, '1828: a < a'); vrfy(isobj(a) == 1, '1829: isobj(a) == 1'); print '1830: Ending object test'; } print '028: parsed test_obj()'; /* * Prime builtin function testing */ define test_prime() { print '1900: Beginning prime builtins test'; vrfy(isprime(-3) == 1, '1901: isprime(-3) == 1'); vrfy(isprime(-1) == 0, '1902: isprime(-1) == 0'); vrfy(isprime(0) == 0, '1903: isprime(0) == 0'); vrfy(isprime(1) == 0, '1904: isprime(1) == 0'); vrfy(isprime(2) == 1, '1905: isprime(2) == 1'); vrfy(isprime(3) == 1, '1906: isprime(3) == 1'); vrfy(isprime(4) == 0, '1907: isprime(4) == 0'); vrfy(isprime(5) == 1, '1908: isprime(5) == 1'); vrfy(isprime(17) == 1, '1909: isprime(17) == 1'); vrfy(isprime(100) == 0, '1910: isprime(100) == 0'); vrfy(isprime(21701,-1) == 1, '1911: isprime(21701,-1) == 1'); vrfy(isprime(65521,-1) == 1, '1912: isprime(65521,-1) == 1'); vrfy(isprime(65535,-1) == 0, '1913: isprime(65535,-1) == 0'); vrfy(isprime(65536,-1) == 0, '1914: isprime(65536,-1) == 0'); vrfy(isprime(1234577) == 1, '1915: isprime(1234577) == 1'); vrfy(isprime(1234579) == 0, '1916: isprime(1234579) == 0'); vrfy(isprime(2^31-9) == 0, '1917: isprime(2^31-9) == 0'); vrfy(isprime(2^31-1) == 1, '1918: isprime(2^31-1) == 1'); vrfy(isprime(2^31+9) == 0, '1919: isprime(2^31+11) == 0'); vrfy(isprime(2^31+11) == 1, '1920: isprime(2^31+11) == 1'); vrfy(isprime(3e9) == 0, '1921: isprime(3e9) == 0'); vrfy(isprime(3e9+19) == 1, '1922: isprime(3e9+19) == 1'); vrfy(isprime(2^32-7) == 0, '1923: isprime(2^32-7) == 0'); vrfy(isprime(2^32-5) == 1, '1924: isprime(2^32-5) == 1'); vrfy(isprime(2^32,-1) == 0, '1925: isprime(2^32,-1) == 0'); vrfy(isprime(2^32+1,-1) == -1, '1926: isprime(2^32+1,-1) == -1'); vrfy(isprime(3^99,2) == 2, '1927: isprime(3^99,2) == 2'); vrfy(isprime(4^99,2) == 0, '1928: isprime(3^99,2) == 0'); vrfy(nextprime(-3) == 5, '1929: nextprime(-3) == 5'); vrfy(nextprime(0) == 2, '1930: nextprime(0) == 2'); vrfy(nextprime(1) == 2, '1931: nextprime(1) == 2'); vrfy(nextprime(2) == 3, '1932: nextprime(2) == 3'); vrfy(nextprime(3) == 5, '1933: nextprime(3) == 5'); vrfy(nextprime(4) == 5, '1934: nextprime(4) == 5'); vrfy(nextprime(5) == 7, '1935: nextprime(5) == 7'); vrfy(nextprime(17) == 19, '1936: nextprime(17) == 19'); vrfy(nextprime(100) == 101, '1937: nextprime(100) == 101'); vrfy(nextprime(21701,-1) == 21713, '1938: nextprime(21701,-1) == 21713'); vrfy(nextprime(65519) == 65521, '1939: nextprime(65519) == 65521'); vrfy(nextprime(65520) == 65521, '1940: nextprime(65520) == 65521'); vrfy(nextprime(65521,-1) == 65537, '1941: nextprime(65521,-1) == 65537'); vrfy(nextprime(65531) == 65537, '1942: nextprime(65531) == 65537'); vrfy(nextprime(65535,-1) == 65537, '1943: nextprime(65535,-1) == 65537'); vrfy(nextprime(65536) == 65537, '1944: nextprime(65536) == 65537'); vrfy(nextprime(1234576,2)==1234577, '1945: nextprime(1234576,2)==1234577'); vrfy(nextprime(2^31-9) == 2^31-1, '1946: nextprime(2^31-9) == 2^31-1'); vrfy(nextprime(2^31-1) == 2^31+11, '1947: nextprime(2^31-1) == 2^31+11'); vrfy(nextprime(3e9) == 3e9+19,'1948: nextprime(3e9) == 3e9+19'); vrfy(nextprime(2^32-7) == 2^32-5, '1949: nextprime(2^32-7) == 2^32-5'); vrfy(nextprime(2^32,-1) == -1, '1950: nextprime(2^32,-1) == -1'); vrfy(nextprime(2^32+5,-1) == -1,'1951: nextprime(2^32+5,-1) == -1'); vrfy(nextprime(3^99,-1) == -1, '1952: nextprime(3^99,-1) == -1'); vrfy(nextprime(3^99,2) == 2, '1953: nextprime(3^99,2) == 2'); vrfy(prevprime(-3,-1) == 2, '1954: prevprime(-3,-1) == 2'); vrfy(prevprime(0,-1) == 0, '1955: prevprime(0,-1) == 0'); vrfy(prevprime(1,-1) == 0, '1956: prevprime(1,-1) == 0'); vrfy(prevprime(2,-2) == 0, '1957: prevprime(2,-2) == 0'); vrfy(prevprime(5) == 3, '1958: prevprime(5) == 3'); vrfy(prevprime(4) == 3, '1959: prevprime(4) == 3'); vrfy(prevprime(7) == 5, '1960: prevprime(7) == 5'); vrfy(prevprime(19) == 17, '1961: prevprime(19) == 17'); vrfy(prevprime(100) == 97, '1962: prevprime(100) == 97'); vrfy(prevprime(21713,-1) == 21701, '1963: prevprime(21713,-1) == 21701'); vrfy(prevprime(65520) == 65519, '1964: prevprime(65520) == 65519'); vrfy(prevprime(65521) == 65519, '1965: prevprime(65521) == 65519'); vrfy(prevprime(65522) == 65521, '1966: prevprime(65520) == 65521'); vrfy(prevprime(65523) == 65521, '1967: prevprime(65523) == 65521'); vrfy(prevprime(65531) == 65521, '1968: prevprime(65531) == 65521'); vrfy(prevprime(65535) == 65521, '1969: prevprime(65535) == 65521'); vrfy(prevprime(65536) == 65521, '1970: prevprime(65536) == 65521'); vrfy(prevprime(65537) == 65521, '1971: prevprime(65537) == 65521'); vrfy(prevprime(65539) == 65537, '1972: prevprime(65539) == 65537'); vrfy(prevprime(1234578,2)==1234577, '1973: prevprime(1234578,2)==1234577'); vrfy(prevprime(2^31-1) == 2^31-19, '1974: prevprime(2^31-1) == 2^31-19'); vrfy(prevprime(2^31+11) == 2^31-1, '1975: prevprime(2^31+11) == 2^31-1'); vrfy(prevprime(3e9) == 3e9-71,'1976: prevprime(3e9) == 3e9-17'); vrfy(prevprime(2^32-3) == 2^32-5, '1977: prevprime(2^32-3) == 2^32-5'); vrfy(prevprime(2^32-1) == 2^32-5, '1978: prevprime(2^32-1) == 2^32-5'); vrfy(prevprime(2^32,-1) == -1, '1979: prevprime(2^32,-1) == -1'); vrfy(prevprime(3^99,-1) == -1, '1980: prevprime(3^99,-1) == -1'); vrfy(prevprime(3^99,2) == 2, '1981: prevprime(3^99,2) == 2'); vrfy(pix(-1) == 0, '1982: pix(-1) == 0'); vrfy(pix(1) == 0, '1983: pix(1) == 0'); vrfy(pix(2) == 1, '1984: pix(2) == 1'); vrfy(pix(3) == 2, '1985: pix(3) == 2'); vrfy(pix(100) == 25, '1986: pix(100) == 25'); vrfy(pix(1000) == 168, '1987: pix(1000) == 168'); vrfy(pix(10000) == 1229, '1988: pix(10000) == 1229'); vrfy(pix(100000) == 9592, '1989: pix(100000) == 9592'); vrfy(pix(2^19+59) == 43393, '1990: pix(2^19+59) == 43393'); vrfy(pix(1000000) == 78498, '1991: pix(1000000) == 78498'); vrfy(pix(10000000) == 664579, '1992: pix(10000000) == 664579'); vrfy(pix(2^32-6) == 203280220, '1993: pix(2^32-6) == 203280220'); vrfy(pix(2^32-5) == 203280221, '1994: pix(2^32-5) == 203280221'); vrfy(pix(2^32-1) == 203280221, '1995: pix(2^32-1) == 203280221'); vrfy(pfact(40) == 7420738134810,'1996: pfact(40) == 7420738134810'); vrfy(pfact(200)/pfact(198)==199,'1997: pfact(200)/pfact(198)==199'); vrfy(nextprime(3e9)==nextcand(3e9), '1998: nextprime(3e9)==nextcand(3e9)'); vrfy(prevprime(3e9)==prevcand(3e9), '1999: prevprime(3e9)==prevcand(3e9)'); vrfy(nextcand(2^100,0)-2^100 == 3, '2000: nextcand(2^100,0)-2^100 == 3'); vrfy(nextcand(2^100)-2^100 == 277, '2001: nextcand(2^100)-2^100 == 277'); vrfy(2^100-prevcand(2^100,0) == 5, '2002: 2^100-prevcand(2^100,0) == 5'); vrfy(2^100-prevcand(2^100) == 15, '2003: 2^100-prevcand(2^100) == 15'); vrfy(nextcand(2^50,4,5)-2^50 == 55, '2004: nextcand(2^50,4,5)-2^50 == 55'); vrfy(2^50-prevcand(2^50,4,5) == 27, '2005: 2^50-prevcand(2^50,4,5) == 27'); vrfy(nextprime(2^32-6) == 2^32-5, '2006: nextprime(2^32-6) == 2^32-5'); vrfy(nextprime(2^32-5) == 2^32+15, '2007: nextprime(2^32-5) == 2^32+15'); vrfy(prevprime(2^32-1) == 2^32-5, '2008: prevprime(2^32-1) == 2^32-5'); vrfy(prevcand(2^50,4,5,0,4) == 0, '2009: prevcand(2^50,4,5,0,4) == 0'); vrfy(2^50-prevcand(2^50,4,5,1,4) == 27, '2010: 2^50-prevcand(2^50,4,5,1,4) == 27'); vrfy(prevcand(2^50,4,5,2,4) == 2, '2011: prevcand(2^50,4,5,2,4) == 2'); vrfy(2^50-prevcand(2^50,4,5,3,4) == 113, '2012: 2^50-prevcand(2^50,4,5,3,4) == 113'); vrfy(2^50-prevcand(2^50,4,5,7,17) == 813, '2013: 2^50-prevcand(2^50,4,5,7,17) == 813'); vrfy(nextcand(2^50,4,5,0,4) == 0, '2014: nextcand(2^50,4,5,0,4) == 0'); vrfy(nextcand(2^50,4,5,1,4)-2^50 == 145, '2015: nextcand(2^50,4,5,1,4)-2^50 == 145'); vrfy(nextcand(2^50,4,5,2,4) == 0, '2016: nextcand(2^50,4,5,2,4) == 0'); vrfy(nextcand(2^50,4,5,3,4)-2^50 == 55, '2017: nextcand(2^50,4,5,3,4)-2^50 == 55'); vrfy(nextcand(2^50,4,5,7,17)-2^50 == 853, '2018: nextcand(2^50,4,5,7,17)-2^50 == 853'); vrfy(ptest(2^100+277) == 1, '2019: ptest(2^100+277) == 1'); vrfy(ptest(2^50-27,4,5) == 1, '2020: ptest(2^50-27,4,5) == 1'); vrfy(ptest(2^50+55,4,5) == 1, '2021: ptest(2^50+55,4,5) == 1'); vrfy(ptest(2^32+1,10) == 0, '2022: ptest(2^32+1,10) == 0'); vrfy(lfactor(1001,100) == 7, '2023: lfactor(1001,100) == 7'); vrfy(lfactor(1001,4) == 7, '2024: lfactor(1001,4) == 7'); vrfy(lfactor(1001,3) == 1, '2025: lfactor(1001,3) == 1'); vrfy(lfactor(127,10000) == 1, '2026: lfactor(127,10000) == 1'); vrfy(lfactor(2^19-1,10000) == 1,'2027: lfactor(2^19-1,10000) == 1'); vrfy(lfactor(2^31-1,10000) == 1,'2028: lfactor(2^31-1,10000) == 1'); vrfy(lfactor(2^32-5,10000) == 1,'2029: lfactor(2^32-5,10000) == 1'); vrfy(lfactor(2^38+7,50000) == 1,'2030: lfactor(2^38+7,50000) == 1'); vrfy(lfactor(1009^2,pix(1009)) == 1009, '2031: lfactor(1009^2,pix(1009)) == 1009'); vrfy(lfactor(1009^2,pix(1009)-1) == 1, '2032: lfactor(1009^2,pix(1009)-1) == 1'); vrfy(lfactor(65519*65521,7000) == 65519, '2033: lfactor(65519*65521,7000) == 65519'); vrfy(lfactor(65521^2,pix(65521)) == 65521, '2034: lfactor(65521^2,pix(65521)) == 65521'); vrfy(lfactor(65521^2,pix(65521)-1) == 1, '2035: lfactor(65521^2,pix(65521)-1) == 1'); vrfy(lfactor(524309^6,100000) == 524309, '2036: lfactor(524309^6,100000) == 524309'); print '2037: Ending prime builtins test'; } print '029: parsed test_prime()'; /* * Test the Lucas primality test library */ read -once "lucas_chk"; /* obtain our needed Lucas library */ print '030: read lucas_chk'; /**/ define test_lucas() { print '2100: Beginning lucas check test'; vrfy(lucas_chk(100,1) == 1, '2101: lucas_chk(100,1) == 1'); print '2102: Ending lucas check test'; } print '031: parsed test_lucas()'; /* * Test new operator functionality */ define test_newop() { static mat A[3] = {1,2,3}; static mat A2[3] = {1,2,3}; local B; local v; local a; local b; print '2200: Beginning new operator functionality test'; (v = 3) = 4; print '2201: (v = 3) = 4'; vrfy(v == 4, '2202: v == 4'); (v += 3) *= 4; print '2203: (v += 3) *= 4'; vrfy(v == 28, '2204: v == 28'); vrfy(A == A2, '2205: A == A2'); matfill(B = A, 4); print '2206: matfill(B = A, 4)'; vrfy(A == A2, '2207: A == A2'); vrfy(size(B) == 3, '2208: size(B) == 3'); vrfy(B[0] == 4, '2209: B[0] == 4'); vrfy(B[1] == 4, '2210: B[1] == 4'); vrfy(B[2] == 4, '2211: B[2] == 4'); a = 3; print '2212: a = 3'; ++(b = a); print '2213: ++(b = a)'; vrfy(a == 3, '2214: a == 3'); vrfy(b == 4, '2215: b == 4'); ++++a; print '2216: ++++a'; vrfy(a == 5, '2217: a == 5'); vrfy((++a)++ == 6, '2218: (++a)++ == 6'); vrfy(a == 7, '2219: a == 7'); (++a) *= b; print '2220: (++a) *= b'; vrfy(a == 32, '2221: a == 32'); vrfy(b == 4, '2222: b == 4'); vrfy(++(a*=b) == 129, '2223: ++(a*=b) == 129'); vrfy(a == 129, '2224: a == 129'); vrfy(b == 4, '2225: b == 4'); vrfy((a = (--a / b++))-- == 32, '2226: (a = (--a / b++))-- == 32'); vrfy(a == 31, '2227: a == 31'); vrfy(b == 5, '2228: b == 5'); vrfy((++++a / ----b) == 11, '2229: (++++a / ----b) == 11'); vrfy(a == 33, '2230: a == 33'); vrfy(b == 3, '2231: b == 3'); vrfy((a/=(--a/++b))-- == 4, '2232: (a/=(--a/++b))-- == 4'); vrfy(a == 3, '2233: a == 3'); vrfy(b == 4, '2234: b == 4'); v = a----; print '2235: v = a----'; vrfy(v == 3, '2236: v == 3'); vrfy(a == 1, '2237: a == 1'); a = ----v; print '2238: a = ----v'; vrfy(a == 1, '2239: a == 1'); vrfy(v == 1, '2240: v == 1'); v = a++++; print '2241: v = a++++'; vrfy(a == 3, '2242: a == 3'); vrfy(v == 1, '2243: v == 1'); a = ++++v; print '2244: a = ++++v'; vrfy(a == 3, '2245: a == 3'); vrfy(v == 3, '2246: v == 3'); a = ----v----; print '2247: a = ----v----'; vrfy(a == 1, '2248: a == 1'); vrfy(v == -1, '2249: v == -1'); v = ++++a++++; print '2250: v = ++++a++++'; vrfy(a == 5, '2251: a == 5'); vrfy(v == 3, '2252: v == 3'); a = ++++v----; print '2253: a = ++++v----'; vrfy(a == 5, '2254: a == 5'); vrfy(v == 3, '2255: v == 3'); v = --++a--++; print '2256: v = --++a--++'; vrfy(a == 5, '2257: a == 5'); vrfy(v == 5, '2258: v == 5'); a = -++v; print '2259: a = -++v'; vrfy(a == -6, '2260: a == -6'); vrfy(v == 6, '2261: v == 6'); print '2262: Ending new operator functionality test'; } print '032: parsed test_newop()'; /* * Test object increment/decrement */ read -once "test2300"; print '033: read -once test2300'; /**/ define test_xx_incdec() { local A, B; print '2300: Beginning object increment/decrement test'; A = mkmat(1,2,3); print '2301: A = mkmat(1,2,3)'; vrfy(ckmat(A,1,2,3) == 1, '2302: ckmat(A,1,2,3) == 1'); B = A++; print '2303: B = A++'; vrfy(ckmat(B,1,2,3) == 1, '2304: ckmat(B,1,2,3) == 1'); vrfy(ckmat(A,2,3,4) == 1, '2305: ckmat(A,2,3,4) == 1'); B = A--; print '2306: B = A--'; vrfy(ckmat(A,1,2,3) == 1, '2307: ckmat(A,1,2,3) == 1'); vrfy(ckmat(B,2,3,4) == 1, '2308: ckmat(B,2,3,4) == 1'); B = ++A; print '2309: B = ++A'; vrfy(ckmat(A,2,3,4) == 1, '2310: ckmat(A,2,3,4) == 1'); vrfy(ckmat(B,2,3,4) == 1, '2311: ckmat(B,2,3,4) == 1'); B = --A; print '2312: B = --A'; vrfy(ckmat(A,1,2,3) == 1, '2313: ckmat(A,1,2,3) == 1'); vrfy(ckmat(B,1,2,3) == 1, '2314: ckmat(B,1,2,3) == 1'); print '2315: Ending object increment/decrement test'; } print '034: parsed test_xx_incdec()'; /* * testing rounding config modes */ define test_round() { local mode; print '2400: Beginning config rounding mode test'; /* appr mode 0 */ mode = 0; print '2401: mode = 0'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2402: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.4, '2403: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 5, '2404: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -6, '2405: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2406: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2407: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 6, '2408: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -5, '2409: appr(-5.7,-1,mode) == -5'); /* appr mode 1 */ mode = 1; print '2410: mode = 1'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2411: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.5, '2412: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 6, '2413: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -5, '2414: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2415: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2416: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 5, '2417: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -6, '2418: appr(-5.7,-1,mode) == -6'); /* appr mode 2 */ mode = 2; print '2419: mode = 2'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2420: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.4, '2421: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 5, '2422: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -5, '2423: appr(-5.7,1,mode) == -5'); /* appr mode 3 */ mode = 3; print '2424: mode = 3'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2425: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.5, '2426: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 6, '2427: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -6, '2428: appr(-5.7,1,mode) == -6'); /* appr mode 4 */ mode = 4; print '2429: mode = 4'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2430: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.4, '2431: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 5, '2432: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -6, '2433: appr(-5.7,1,mode) == -6'); /* appr mode 5 */ mode = 5; print '2434: mode = 5'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2435: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.5, '2436: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 6, '2437: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -5, '2438: appr(-5.7,1,mode) == -5'); /* appr mode 6 */ mode = 6; print '2439: mode = 6'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2440: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.4, '2441: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 5, '2442: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -5, '2443: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2444: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2445: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 6, '2446: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -6, '2447: appr(-5.7,-1,mode) == -6'); /* appr mode 7 */ mode = 7; print '2448: mode = 7'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2449: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.5, '2450: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 6, '2451: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -6, '2452: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2453: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2454: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 5, '2455: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -5, '2456: appr(-5.7,-1,mode) == -5'); /* appr mode 8 */ mode = 8; print '2457: mode = 8'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2458: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.4, '2459: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 6, '2460: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -6, '2461: appr(-5.7,1,mode) == -6'); /* appr mode 9 */ mode = 9; print '2462: mode = 9'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2463: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.5, '2464: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 5, '2465: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -5, '2466: appr(-5.7,1,mode) == -5'); /* appr mode 10 */ mode = 10; print '2467: mode = 10'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2468: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.4, '2469: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 6, '2470: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -5, '2471: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2472: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2473: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 5, '2474: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -6, '2475: appr(-5.7,-1,mode) == -6'); /* appr mode 11 */ mode = 11; print '2476: mode = 11'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2477: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.5, '2478: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 5, '2479: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -6, '2480: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2481: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2482: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 6, '2483: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -5, '2484: appr(-5.7,-1,mode) == -5'); /* appr mode 12 */ mode = 12; print '2485: mode = 12'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2486: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.4, '2487: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 6, '2488: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -6, '2489: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2490: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2491: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 5, '2492: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -5, '2493: appr(-5.7,-1,mode) == -5'); /* appr mode 13 */ mode = 13; print '2494: mode = 13'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2495: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.5, '2496: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 5, '2497: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -5, '2498: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2499: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2500: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 6, '2501: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -6, '2502: appr(-5.7,-1,mode) == -6'); /* appr mode 14 */ mode = 14; print '2503: mode = 14'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2504: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.4, '2505: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 6, '2506: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -5, '2507: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2508: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2509: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 6, '2510: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -5, '2511: appr(-5.7,-1,mode) == -5'); /* appr mode 15 */ mode = 15; print '2512: mode = 15'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2513: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.5, '2514: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 5, '2515: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -6, '2516: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2517: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2518: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 5, '2519: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -6, '2520: appr(-5.7,-1,mode) == -6'); print '2521: Ending config rounding mode test'; } print '035: parsed test_round()'; /* * Test certain numeric functions extensively * * Test multiplication, sqrt(), exp(), ln(), power(), gcd(), complex * power, complex exp, complex log. */ read -once "test2600"; print '036: read -once test2600'; define test_2600() { local tnum; /* test number */ local i; print '2600: Beginning extensive numeric function test'; i = config("sqrt"); print '2601: i = config("sqrt")'; tnum = test2600(1, 2602); i = config("sqrt", i); print tnum++: ': i = config("sqrt", i)'; print tnum: ': Ending extensive numeric function test'; } print '037: parsed test_2600()'; /* * Test complex sqrt */ read -once "test2700"; print '038: read -once test2700'; define test_2700() { local tnum; /* test number */ print '2700: Beginning complex sqrt test'; tnum = test2700(1, 2701); print tnum: ': Ending complex sqrt test'; } print '039: parsed test_2700()'; /* * Test matrix operations */ mat mat_C[2] = {1,2}; print '040: mat mat_C[2] = {1,2}'; mat_C[0] = mat_C; print '041: C[0] = mat_C'; global mat_D; print '042: global mat_D'; /**/ define test_matrix() { static mat b[4,4]; static mat binv[4,4] = { 0, 1, 0, 0, 2, -3/2, 2, -1/2, -3, 0.5, -1.0, 0.5, 1.0, 0.0, 0.0, 0.0 }; static mat c[] = { 1, 2+3i, -5+4i, 5i+6, -7i }; static mat d[-1:1, -2:2, -3:3, -4:4]; static mat A[2] = {1,2}; static mat id0[2,2] = {1,0,0,1}; static mat id1[0:2,-1:1] = {1,0,0,0,1,0,0,0,1}; static mat noid0[2,2] = {1,2,0,1}; static mat noid1[2,3] = {1,0,0,1,0,0}; static mat noid2[4] = {1,0,0,1}; static mat xp[3] = {2,3,4}; static mat yp[3] = {3,4,5}; static mat zp[3] = {-1,2,-1}; static mat X[2,2] = {1,2,3,4}; static mat Y[2,2] = {5,6,7,8}; static mat Z[2,2] = {190,232,286,352}; static mat x[] = {11,13,17,23,29}; static mat y0[] = {1,3,7,3,9}; static mat y1[] = {-9,-7,-3,-7,-1}; static mat y2[] = {-9,-7,-3,3,9}; static mat y3[] = {1,3,7,-7,-1}; static mat y4[] = {1,3,-3,3,-1}; local B; local mat e[5,5]; local mat M[2]; local mat zero3[3]; print '2800: Beginning test_matrix'; b[0,0] = 0; vrfy(b[0,0] == 0, '2801: b[0,0] == 0'); b[0,1] = 0; vrfy(b[0,1] == 0, '2802: b[0,1] == 0'); b[0,2] = 0; vrfy(b[0,2] == 0, '2803: b[0,2] == 0'); b[0,3] = 1; vrfy(b[0,3] == 1, '2804: b[0,3] == 1'); b[1,0] = 1; vrfy(b[1,0] == 1, '2805: b[1,0] == 1'); b[1,1] = 0; vrfy(b[1,1] == 0, '2806: b[1,1] == 0'); b[1,2] = 0; vrfy(b[1,2] == 0, '2807: b[1,2] == 0'); b[1,3] = 0; vrfy(b[1,3] == 0, '2808: b[1,3] == 0'); b[2,0] = 1; vrfy(b[2,0] == 1, '2809: b[2,0] == 1'); b[2,1] = 1; vrfy(b[2,1] == 1, '2810: b[2,1] == 1'); b[2,2] = 1; vrfy(b[2,2] == 1, '2811: b[2,2] == 1'); b[2,3] = 1; vrfy(b[2,3] == 1, '2812: b[2,3] == 1'); b[3,0] = 1; vrfy(b[3,0] == 1, '2813: b[3,0] == 1'); b[3,1] = 2; vrfy(b[3,1] == 2, '2814: b[3,1] == 2'); b[3,2] = 4; vrfy(b[3,2] == 4, '2815: b[3,2] == 4'); b[3,3] = 8; vrfy(b[3,3] == 8, '2816: b[3,3] == 8'); vrfy(det(b) == -2, '2817: det(b) == -2'); vrfy(binv[0,0] == 0, '2818: binv[0,0] == 0'); vrfy(binv[0,1] == 1, '2819: binv[0,1] == 1'); vrfy(binv[0,2] == 0, '2820: binv[0,2] == 0'); vrfy(binv[0,3] == 0, '2821: binv[0,3] == 0'); vrfy(binv[1,0] == 2, '2822: binv[1,0] == 2'); vrfy(binv[1,1] == -3/2, '2823: binv[1,1] == -3/2'); vrfy(binv[1,2] == 2, '2824: binv[1,2] == 2'); vrfy(binv[1,3] == -1/2, '2825: binv[1,3] == -1/2'); vrfy(binv[2,0] == -3, '2826: binv[2,0] == -3'); vrfy(binv[2,1] == 1/2, '2827: binv[2,1] == 1/2'); vrfy(binv[2,2] == -1, '2828: binv[2,2] == -1'); vrfy(binv[2,3] == 1/2, '2829: binv[2,3] == 1/2'); vrfy(binv[3,0] == 1, '2830: binv[3,0] == 1'); vrfy(binv[3,1] == 0, '2831: binv[3,1] == 0'); vrfy(binv[3,2] == 0, '2832: binv[3,2] == 0'); vrfy(binv[3,3] == 0, '2833: binv[3,3] == 0'); vrfy(inverse(b) == binv, '2834: inverse(b) == binv'); vrfy(avg(b) == b, '2835: avg(b) == b'); vrfy(avg(binv) == binv, '2836: avg(binv) == binv'); vrfy((b+binv)/2 == avg(b,binv), '2837: (b+binv)/2 == avg(b,binv)'); vrfy(ismat(b) == 1, '2838: ismat(b) == 1'); vrfy(matsum(b) == 21, '2839: matsum(b) == 21'); vrfy(matsum(binv) == 1, '2840: matsum(binv) == 1'); vrfy(c[0] == 1, '2841: c[0] == 1'); vrfy(c[1] == 2+3i, '2842: c[1] == 2+3i'); vrfy(c[2] == -5+4i, '2843: c[2] == -5+4i'); vrfy(c[3] == 6+5i, '2844: c[3] == 6+5i'); vrfy(c[4] == -7i, '2845: c[4] == -7i'); vrfy(matsum(c) == 4+5i, '2846: matsum(c) == 4+5i'); vrfy(matdim(b) == 2, '2847: matdim(b) == 2'); vrfy(matdim(c) == 1, '2848: matdim(c) == 1'); vrfy(matdim(d) == 4, '2849: matdim(c) == 4'); vrfy(matmax(c,1) == 4, '2850: matmax(c,1) == 4'); vrfy(matmin(c,1) == 0, '2851: matmin(c,1) == 0'); vrfy(matmin(d,1) == -1, '2852: matmin(d,1) == -1'); vrfy(matmin(d,3) == -3, '2853: matmin(d,3) == -3'); vrfy(matmax(d,1) == 1, '2854: matmin(d,1) == 1'); vrfy(matmax(d,3) == 3, '2855: matmin(d,3) == 3'); vrfy(size(binv) == 16, '2856: size(binv) == 16'); vrfy(size(c) == 5, '2857: size(c) == 5'); vrfy(size(d) == 945, '2858: size(d) == 945'); vrfy(size(e) == 25, '2859: size(e) == 25'); matfill(d,1); print '2860: matfill(d,1)'; vrfy(matsum(d) == 945, '2861: matsum(d) == 945'); matfill(e,1,0); print '2862: matfill(e,1,0)'; vrfy(matsum(d) == 945, '2863: matsum(d) == 945'); vrfy(matsum(e) == 20, '2864: matsum(e) == 20'); vrfy(search(binv,1) == 1, '2865: search(binv,1) == 1'); vrfy(search(binv,2) == 4, '2866: search(binv,2) == 4'); vrfy(search(binv,2,4) == 4, '2867: search(binv,2,4) == 4'); vrfy(search(binv,2,5) == 6, '2868: search(binv,2,5) == 6'); vrfy(rsearch(binv,2) == 6, '2869: rsearch(binv,2) == 6'); vrfy(rsearch(binv,2,6) == 6, '2870: rsearch(binv,2,6) == 6'); vrfy(rsearch(binv,2,5) == 4, '2871: rsearch(binv,2,5) == 4'); vrfy(A[0] == 1, '2872: A[0] == 1'); vrfy(A[1] == 2, '2873: A[1] == 2'); A[0] = A; print '2874: A[0] = A'; B = A[0]; print '2875: B = A[0]'; vrfy(B[0] == 1, '2876: B[0] == 1'); vrfy(B[1] == 2, '2877: B[1] == 2'); mat_D = mat_C[0]; print '2878: mat_D = mat_C[0]'; vrfy(mat_D[0] == 1, '2879: mat_D[0] == 1'); vrfy(mat_D[1] == 2, '2880: mat_D[1] == 2'); vrfy(quomod(15.6,5.2,M[0],M[1]) == 0, '2881: quomod(15.6,5.2,M[0],M[1]) == 0'); vrfy(M[0] == 3, '2882: M[0] == 3'); vrfy(M[1] == 0, '2883: M[1] == 0'); vrfy(isident(id0) == 1, '2884: isident(id0) == 1'); vrfy(isident(id1) == 1, '2885: isident(id1) == 1'); vrfy(isident(noid0) == 0, '2886: isident(noid0) == 0'); vrfy(isident(noid1) == 0, '2887: isident(noid1) == 0'); vrfy(isident(noid2) == 0, '2888: isident(noid2) == 0'); vrfy(xp[0] == 2, '2889: xp[0] == 2'); vrfy(xp[1] == 3, '2890: xp[1] == 3'); vrfy(xp[2] == 4, '2891: xp[2] == 4'); vrfy(yp[0] == 3, '2892: yp[0] == 3'); vrfy(yp[1] == 4, '2893: yp[1] == 4'); vrfy(yp[2] == 5, '2894: yp[2] == 5'); vrfy(zp[0] == -1, '2895: zp[0] == -1'); vrfy(zp[1] == 2, '2896: zp[1] == 2'); vrfy(zp[2] == -1, '2897: zp[2] == -1'); vrfy(cp(xp,yp) == zp, '2898: cp(xp,yp) == zp'); vrfy(cp(yp,xp) == -zp, '2899: cp(yp,xp) == -zp'); matfill(zero3,0); print '2900: matfill(zero3,0)'; vrfy(cp(xp,xp) == zero3, '2901: cp(xp,xp) == zero3'); vrfy(dp(xp,yp) == 38, '2902: dp(xp,yp) == 38'); vrfy(dp(yp,xp) == 38, '2903: dp(yp,xp) == 38'); vrfy(dp(zp,dp(xp,yp)*zp) == 228,'2904: dp(zp,dp(xp,yp)*zp) == 228'); vrfy(ssq(X, Y, X + Y) == Z, '2905: ssq(X, Y, X + Y) == Z'); vrfy(mod(x,10,0) == y0, '2906: mod(x,10,0) == y0'); vrfy(mod(x,10,1) == y1, '2907: mod(x,10,1) == y1'); vrfy(mod(x,10,2) == y0, '2908: mod(x,10,2) == y0'); vrfy(mod(x,10,3) == y1, '2909: mod(x,10,3) == y1'); vrfy(mod(x,10,4) == y0, '2910: mod(x,10,4) == y0'); vrfy(mod(x,10,5) == y1, '2911: mod(x,10,5) == y1'); vrfy(mod(x,10,6) == y0, '2912: mod(x,10,6) == y0'); vrfy(mod(x,10,7) == y1, '2913: mod(x,10,7) == y1'); vrfy(mod(x,10,8) == y2, '2914: mod(x,10,8) == y2'); vrfy(mod(x,10,9) == y3, '2915: mod(x,10,9) == y3'); vrfy(mod(x,10,10) == y2, '2916: mod(x,10,10) == y2'); vrfy(mod(x,10,11) == y3, '2917: mod(x,10,11) == y3'); vrfy(mod(x,10,12) == y2, '2918: mod(x,10,12) == y2'); vrfy(mod(x,10,13) == y3, '2919: mod(x,10,13) == y3'); vrfy(mod(x,10,14) == y2, '2920: mod(x,10,14) == y2'); vrfy(mod(x,10,15) == y3, '2921: mod(x,10,15) == y3'); vrfy(mod(x,10,16) == y4, '2922: mod(x,10,16) == y4'); vrfy(mod(x,10,16) == y4, '2923: mod(x,10,16) == y4'); vrfy(mod(x,10,18) == y4, '2924: mod(x,10,18) == y4'); vrfy(mod(x,10,19) == y4, '2925: mod(x,10,18) == y4'); vrfy(mod(x,10,20) == y4, '2926: mod(x,10,20) == y4'); vrfy(mod(x,10,21) == y4, '2927: mod(x,10,21) == y4'); vrfy(mod(x,10,22) == y4, '2928: mod(x,10,22) == y4'); vrfy(mod(x,10,23) == y4, '2929: mod(x,10,23) == y4'); vrfy(mod(x,10,24) == y4, '2930: mod(x,10,24) == y4'); vrfy(mod(x,10,25) == y4, '2931: mod(x,10,25) == y4'); vrfy(mod(x,10,26) == y4, '2932: mod(x,10,26) == y4'); vrfy(mod(x,10,27) == y4, '2933: mod(x,10,27) == y4'); vrfy(mod(x,10,28) == y4, '2934: mod(x,10,28) == y4'); vrfy(mod(x,10,29) == y4, '2935: mod(x,10,29) == y4'); vrfy(mod(x,10,30) == y4, '2936: mod(x,10,30) == y4'); vrfy(mod(x,10,31) == y4, '2937: mod(x,10,31) == y4'); print '2938: Ending mat_functions'; } print '043: parsed test_matrix()'; /* * Test string constants and comparisons */ define test_strings() { local x, y, z; print '3000: Beginning test_strings'; x = 'string'; print "3001: x = 'string'"; y = "string"; print '3002: y = "string"'; z = x; print '3003: z = x'; vrfy(z == "string", '3004: z == "string"'); vrfy(z != "foo", '3005: z != "foo"'); vrfy(z != 3, '3006: z != 3'); vrfy('' == "", '3007: \'\' == ""'); vrfy("a" == "a", '3008: "a" == "a"'); vrfy("c" != "d", '3009: "c" != "d"'); vrfy("" != "a", '3010: "" != "a"'); vrfy("rs" < "rt", '3011: "rs" < "rt"'); vrfy("rs" < "ss", '3012: "rs < "ss"'); vrfy("rs" <= "rs", '3013: "rs" <= "rs"'); vrfy("rs" <= "tu", '3014: "rs" <= "tu"'); vrfy("rs" > "cd", '3015: "rs" > "cd"'); vrfy("rs" >= "rs", '3016: "rs" >= "rs"'); vrfy("rs" >= "cd", '3017: "rs" >= "cd"'); vrfy("abc" > "ab", '3018: "abc" > "ab"'); print '3019: Ending test_strings'; } print '044: parsed test_strings()'; /* * test_matobj - test determinants of a matrix containing objects */ read -once "test3100"; print '045: read -once test3100'; /**/ define test_matobj() { local mat A[3,3] = {2, 3, 5, 7, 11, 13, 17, 19, 23}; local mat B[2,2]; print '3100: Beginning test_matobj'; vrfy(det(A) == -78, '3101: det(A) == -78'); vrfy(det(A^2) == 6084, '3102: det(A^2) == 6084'); vrfy(det(A^3) == -474552, '3103: det(A^3) == -474552'); vrfy(det(A^-1) == -1/78, '3104: det(A^-1) == -1/78'); md = 0; print '3105: md = 0'; B[0,0] = res(2); print '3106: B[0,0] = res(2)'; B[0,1] = res(3); print '3107: B[0,1] = res(2)'; B[1,0] = res(5); print '3108: B[1,0] = res(2)'; B[1,1] = res(7); print '3109: B[1,1] = res(2)'; print '3110: md = 0'; md = 0; vrfy(det(B) == res(-1), '3111: det(B) == res(-1)'); md = 1; print '3112: md = 1'; vrfy(det(B) == 0, '3113: det(B) == 0'); md = 2; print '3114: md = 2'; vrfy(det(B) == res(1), '3115: det(B) == res(1)'); md = 3; print '3116: md = 3'; vrfy(det(B) == res(2), '3117: det(B) == res(2)'); md = 4; print '3118: md = 4'; vrfy(det(B) == res(3), '3119: det(B) == res(3)'); md = 5; print '3120: md = 5'; vrfy(det(B) == res(4), '3121: det(B) == res(4)'); md = 6; print '3122: md = 6'; vrfy(det(B) == res(5), '3123: det(B) == res(5)'); md = 7; print '3124: md = 7'; vrfy(det(B) == res(6), '3125: det(B) == res(6)'); md = 8; print '3126: md = 8'; vrfy(det(B) == res(7), '3127: det(B) == res(7)'); md = 9; print '3128: md = 9'; vrfy(det(B) == res(8), '3129: det(B) == res(8)'); md = 10; print '3130: md = 10'; vrfy(det(B) == res(9), '3131: det(B) == res(9)'); md = 11; print '3132: md = 11'; vrfy(det(B) == res(10), '3133: det(B) == res(10)'); md = 12; print '3134: md = 12'; vrfy(det(B) == res(11), '3135: det(B) == res(11)'); md = 13; print '3136: md = 13'; vrfy(det(B) == res(12), '3137: det(B) == res(12)'); md = 14; print '3138: md = 14'; vrfy(det(B) == res(13), '3139: det(B) == res(13)'); md = 15; print '3140: md = 15'; vrfy(det(B) == res(14), '3141: det(B) == res(14)'); print '3142: Ending test_matobj'; } print '046: parsed test_matobj()'; /* * test_poly - test the polynomial function */ define test_poly() { print '3200: Beginning test_matobj'; vrfy(poly(2,3,5,2) == 19, '3201: poly(2,3,5,2) == 19'); vrfy(poly(list(5,3,2),2) == 19,\ '3202: poly(list(5,3,2),2) == 19'); vrfy(poly(list(5,3,2)) == 5, '3203: poly(list(5,3,2)) == 5'); vrfy(poly(2) == 2, '3204: poly(2) == 2'); vrfy(poly(list(5,3,2),2,3) == 19,\ '3205: poly(list(5,3,2),2,3) == 19'); vrfy(poly(list()) == 0, '3206: poly(list()) == 0'); vrfy(poly(list(),2,3) == 0, '3207: poly(list(),2,3) == 0'); vrfy(poly(list(list(5,3,2)),7,2) == 19,\ '3208: poly(list(list(5,3,2)),7,2) == 19'); vrfy(poly(list(list(1,2,3),list(4,5),6),7) == 323,\ '3209: poly(list(list(1,2,3),list(4,5),6),7) == 323'); vrfy(poly(list(list(1,2,3),list(4,5),6),7,8) == 811,\ '3210: poly(list(list(1,2,3),list(4,5),6),7,8) == 811'); vrfy(poly(list(list(1,2,3),list(4,5),6),7,8,9) == 811,\ '3211: poly(list(list(1,2,3),list(4,5),6),7,8,9)==811'); vrfy(poly(list(5,3,2), list()) == 5,\ '3212: poly(list(5,3,2), list() == 5'); vrfy(poly(list(5,3,2), list(2)) == 19,\ '3213: poly(list(5,3,2), list(2)) == 19'); vrfy(poly(list(5,3,2), list(2,3)) == 19,\ '3214: poly(list(5,3,2), list(2,3)) == 19'); vrfy(poly(list(list(list(0,0,0,0,0,1))),2,3,4) == 4^5,\ '3215: poly(list(list(list(0,0,0,0,0,1))),2,3,4)==4^5'); vrfy(poly(list(list(list(0,0,0,0,0,1))),2,list(3,4)) == 4^5,\ '3216: poly(list(list(list(0,0,0,0,0,1))),2,list(3,4))==4^5'); print '3217: Ending test_poly'; } print '047: parsed test_poly()'; /* * test_det - more determinent testing */ read -once "test3300"; print '048: read -once test3300'; /**/ define test_det() { local tnum; /* test number */ local i; print '3300: Beginning test_det'; tnum = test3300(1, 3301); print tnum: ': Ending test_det'; } print '049: parsed test_det()'; /* * test_trig - trig function testing */ read -once "test3400"; print '050: read -once test3400'; /**/ define test_trig() { local tnum; /* test number */ local i; print '3400: Beginning test_trig'; tnum = test3400(1, 3401); print tnum: ': Ending test_trig'; } print '051: parsed test_trig()'; /* * test_frem - tests of the functions frem, fcnt, gcdrem */ read -once "test3500"; print '052: read -once test3500'; /**/ define test_frem() { local tnum; /* test number */ print '3500: Beginning test_frem'; tnum = test3500(1, 3501, 200, 61); print tnum: ': Ending test_frem'; } print '053: parsed test_frem()'; /* * test_error - test the error() builtin * * This function is designed to trigger 148 errors, so we bump the * errmax by 148 during this call. */ define test_error() { local strx, e99, list1, e999; local a, b, c, n, x; /* used by newerror() */ print '3600: Beginning test_error'; /* bump ecnt up by 148 */ ecnt += 148; print '3601: ecnt += 148'; strx = "x"; print '3602: strx = "x"'; e99 = error(99); print '3603: e99 = error(99)'; vrfy(1/0 == error(10001), '3604: 1/0 == error(10001)'); vrfy(0/0 == error(10002), '3605: 0/0 == error(10002)'); vrfy(2 + "x" == error(10003), '3606: 2 + "x" == error(10003)'); vrfy("x" - 2 == error(10004), '3607: "x" - 2 == error(10004)'); vrfy("x" * "y" == error(10005), '3608: "x" * "y" == error(10005)'); vrfy("x" / "y" == error(10006), '3609: "x" / "y" == error(10006)'); vrfy(-list(1) == error(10007), '3610: -list(1) == error(10007)'); vrfy("x"^2 == error(10008), '3611: "x"^2 == error(10008)'); vrfy(inverse("x")==error(10009),'3612: inverse("x") == error(10009)'); vrfy(++strx == error(10010), '3613: ++strx == error(10010)'); vrfy(strx == error(10010), '3614: strx == error(10010)'); strx = "x"; print '3615: strx = "x"'; vrfy(strx++ == "x", '3616: strx++ == "x"'); vrfy(strx == error(10010), '3617: strx == error(10010)'); strx = "x"; print '3618: strx = "x"'; vrfy(--strx == error(10011), '3619: strx == error(10011)'); vrfy(int("x") == error(10012), '3620: int("x") == error(10012)'); vrfy(frac("x") == error(10013), '3621: frac("x") == error(10013)'); vrfy(conj("x") == error(10014), '3622: conj("x") == error(10014)'); vrfy(appr("x",.1) == error(10015), '3623: appr("x",.1) == error(10015)'); vrfy(appr(1.27,.1i) == error(10016), '3624: appr(1.27,.1i) == error(10016)'); vrfy(appr(1.27,.1,.1) == error(10017), '3625: appr(1.27,.1,.1) == error(10017)'); vrfy(round("x") == error(10018), '3626: round("x") == error(10018)'); vrfy(round(1.25,.1) == error(10019), '3627: round(1.25,.1) == error(10019)'); vrfy(round(1.25,"x") == error(10019), '3628: round(1.25,"x") == error(10019)'); vrfy(round(1.25,1,.1) == error(10020), '3629: round(1.25,1,.1) == error(10020)'); vrfy(bround("x") == error(10021), '3630: bround("x") == error(10021)'); vrfy(bround(1.25,.1) == error(10022), '3631: bround(1.25,.1) == error(10022)'); vrfy(bround(1.25,"x") == error(10022), '3632: bround(1.25,"x") == error(10022)'); vrfy(bround(1.25,1,.1) == error(10023), '3633: bround(1.25,1,.1) == error(10023)'); vrfy(sqrt("x") == error(10024), '3634: sqrt("x") == error(10024)'); vrfy(sqrt(2,"x") == error(10025), '3635: sqrt(2,"x") == error(10025)'); vrfy(sqrt(2,0) == error(10025), '3636: sqrt(2,0) == error(10025)'); vrfy(sqrt(2,.1,.1) == error(10026), '3637: sqrt(2,.1,.1) == error(10026)'); vrfy(root("x",3) == error(10027), '3638: root("x",3) == error(10027)'); vrfy(root(3,"x") == error(10028), '3639: root(3,"x") == error(10028)'); vrfy(root(3,-2) == error(10028), '3640: root(3,-2) == error(10028)'); vrfy(root(3,0) == error(10028), '3641: root(3,0) == error(10028)'); vrfy(root(3,.1) == error(10028), '3642: root(3,.1) == error(10028)'); vrfy(root(3,2,"x") == error(10029), '3643: root(3,2,"x") == error(10029)'); vrfy(root(3,2,0) == error(10029), '3644: root(3,2,0) == error(10029)'); vrfy(norm("x") == error(10030), '3645: norm("x") == error(10030)'); vrfy(null() << 2 == error(10031),'3646: null() << 2 == error(10031)'); vrfy(1.5 << 2 == error(10031), '3647: 1.5 << 2 == error(10031)'); vrfy(3 << "x" == error(10032), '3648: 3 << "x" == error(10032)'); vrfy(3 << 1.5 == error(10032), '3649: 3 << 1.5 == error(10032)'); vrfy(3 << 2^31 == error(10032), '3650: 3 << 2^31 == error(10032)'); vrfy(scale("x",2) == error(10033), '3651: scale("x",2) == error(10033)'); vrfy(scale(3,"x") == error(10034), '3652: scale(3,"x") == error(10034)'); vrfy(scale(3,1.5) == error(10034), '3653: scale(3,1.5) == error(10034)'); vrfy(scale(3,2^31) == error(10034), '3654: scale(3,2^31) == error(10034)'); vrfy("x" ^ 3 == error(10035), '3655: "x" ^ 3 == error(10035)'); vrfy(2 ^ "x" == error(10036), '3656: 2 ^ "x" == error(10036)'); vrfy(2 ^ 2.5 == error(10036), '3657: 2 ^ 2.5 == error(10036)'); vrfy(power("x",2.1) == error(10037), '3658: power("x",2.1) == error(10037)'); vrfy(power(2,"x") == error(10038), '3659: power(2,"x") == error(10038)'); vrfy(power(2,2.1,"x") == error(10039), '3660: power(2,2.1,"x") == error(10039)'); vrfy(quo("x",3) == error(10040), '3661: quo("x",3) == error(10040)'); vrfy(quo(8,"x") == error(10041), '3662: quo(8,"x") == error(10041)'); vrfy(quo(8,3,"x") == error(10042), '3663: quo(8,3,"x") == error(10042)'); vrfy(quo(8,3,2.1) == error(10042), '3664: quo(8,3,2.1) == error(10042)'); vrfy(mod("x",3) == error(10043), '3665: mod("x",3) == error(10043)'); vrfy(mod(8,"x") == error(10044), '3666: mod(8,"x") == error(10044)'); vrfy(mod(8,3,"x") == error(10045), '3667: mod(8,3,"x") == error(10045)'); vrfy(mod(8,3,2.1) == error(10045), '3668: mod(8,3,2.1) == error(10045)'); vrfy(sgn("x") == error(10046), '3669: sgn("x") == error(10046)'); vrfy(abs("x") == error(10047), '3670: abs("x") == error(10047)'); vrfy(abs(2+3i,"x") == error(10048), '3671: abs(2+3i,"x") == error(10048)'); vrfy(abs(2+3i,0) == error(10048), '3672: abs(2+3i,0) == error(10048)'); list1 = list(2,3,"x",4,5); print '3673: list1 = list(2,3,"x",4,5)'; vrfy(avg(list1) == error(10003), '3674: avg(list1) == error(10003)'); vrfy(iserror(e99)==99, '3675: iserror(e99) == 99'); vrfy(e99 + 2 == e99, '3676: e99 + 2 == e99'); vrfy(e99 - 2 == e99, '3677: e99 - 2 == e99'); vrfy(e99 * 2 == e99, '3678: e99 * 2 == e99'); vrfy(e99 / 2 == e99, '3679: e99 / 2 == e99'); vrfy(e99 // 2 == e99, '3680: e99 // 2 == e99'); vrfy(e99 % 2 == e99, '3681: e99 % 2 == e99'); vrfy(e99 ^ 2 == e99, '3682: e99 ^ 2 == e99'); vrfy(2 + e99 == e99, '3683: 2 + e99 == e99'); vrfy(2 - e99 == e99, '3684: 2 - e99 == e99'); vrfy(2 * e99 == e99, '3685: 2 * e99 == e99'); vrfy(2 / e99 == e99, '3686: 2 / e99 == e99'); vrfy(2 // e99 == e99, '3687: 2 // e99 == e99'); vrfy(2 % e99 == e99, '3688: 2 % e99 == e99'); vrfy(2 ^ e99 == e99, '3689: 2 ^ e99 == e99'); vrfy(- e99 == e99, '3690: -e99 == e99'); vrfy(inverse(e99) == e99, '3691: inverse(e99) == e99'); vrfy(++e99 == e99, '3692: ++e99 == e99'); vrfy(--e99 == e99, '3693: --e99 == e99'); vrfy(int(e99) == e99, '3694: int(e99) == e99'); vrfy(frac(e99) == e99, '3695: frac(e99) == e99'); vrfy(conj(e99) == e99, '3696: conj(e99) == e99'); vrfy(norm(e99) == e99, '3697: norm(e99) == e99'); vrfy(sgn(e99) == e99, '3698: sgn(e99) == e99'); vrfy(appr(e99,1,0) == e99, '3699: appr(e99,1,0) == e99'); vrfy(round(e99) == e99, '3700: round(e99) == e99'); vrfy(bround(e99) == e99, '3701: bround(e99) == e99'); vrfy(sqrt(e99) == e99, '3702: sqrt(e99) == e99'); print '3703: a = newerror("alpha")'; a = newerror("alpha"); print '3704: b = newerror("beta")'; b = newerror("beta"); print '3705: c = newerror("alpha")'; c = newerror("alpha"); vrfy(a == c, '3706: a == c'); vrfy(strerror(a) == "alpha", '3707: strerror(a) == "alpha"'); print '3708: n = iserror(a)'; n = iserror(a); vrfy(a == error(n), '3709: a == error(n)'); vrfy(newerror() == newerror("???"), '3710: newerror() == newerror("???")'); vrfy(newerror("") == newerror(), '3711: newerror("") == newerror()'); e999 = error(999); print '3712: e999 = error(999)'; vrfy(errno() == 999, '3713: errno() == 999'); vrfy(error() == e999, '3714: error() == e999'); vrfy(strerror() == "Error 999", '3715: strerror() == "Error 999"'); x = newerror("Alpha"); print '3716: x = newerror("Alpha")'; n = iserror(x); print '3717: n = iserror(x)'; vrfy(errno() == n, '3718: errno() == n'); vrfy(error() == x, '3719: error() == x'); vrfy(strerror() == "Alpha", '3720: strerror() == "Alpha"'); vrfy(errno(999) == n, '3721: errno() == n'); vrfy(errno() == 999, '3722: errno() == 999'); vrfy(error() == e999, '3723: error() == e999'); vrfy(strerror() == "Error 999", '3724: strerror() == "Error 999"'); a = 1/0; print '3725: a = 1/0'; vrfy(strerror() == "Division by zero", '3726: strerror() == "Division by zero"'); /* errmax and errcount should be bumped up the 148 errors above */ vrfy(errcount() == ecnt, '3727: errcount() == ecnt'); print '3728: Ending test_error'; } print '054: parsed test_error()'; /* * test_param - test new param() functionality. */ define g_param() = (param(2) = param(1)); print '055: define g_param() = (param(2) = param(1))'; define h_param() = (param(1)++, param(2)--); print '056: define h_param() = (param(1)++, param(2)--)'; /**/ global u_glob = 5; print '057: global u_glob = 5'; global v_glob = 10; print '058: global v_glob = 10'; vrfy(g_param(u_glob, `v_glob) == 5, '059: g_param(u_glob, `v_glob) == 5'); vrfy(u_glob == 5, '060: u_glob == 5'); vrfy(v_glob == 5, '061: v_glob == 5'); vrfy(h_param(`u_glob, `v_glob) == 5, '062: h_param(`u_glob, `v_glob) == 5'); vrfy(u_glob == 6, '063: u_glob == 6'); vrfy(v_glob == 4, '064: v_glob == 4'); /**/ define test_param() { local u, v; print '3800: Beginning test_param'; u = 5; print '3801: u = 5'; v = 10; print '3802: v = 10'; vrfy(g_param(u, `v) == 5, '3803: g_param(u, `v) == 5'); vrfy(u == 5, '3804: u == 5'); vrfy(v == 5, '3805: v == 5'); vrfy(h_param(`u, `v) == 5, '3806: h_param(`u, `v) == 5'); vrfy(u == 6, '3807: u == 6'); vrfy(v == 4, '3808: v == 4'); print '3809: Ending test_param'; } print '065: parsed test_param()'; /* * test_noarg - test missing argment functionality */ define test_noarg() { local A,B,C,D; print '3900: Beginning test_noarg'; A = list(1,,3); print '3901: A = list(1,,3)'; vrfy(A[[0]] == 1, '3902: A[[0]] == 1'); vrfy(isnull(A[[1]]), '3903: isnull(A[[1]])'); vrfy(A[[2]] == 3, '3904: A[[2]] == 3'); vrfy(size(A) == 3, '3905: size(A) == 3'); B = list(,,); print '3906: B = list(,,)'; vrfy(isnull(B[[0]]), '3907: isnull(B[[0]])'); vrfy(isnull(B[[1]]), '3908: isnull(B[[1]])'); vrfy(isnull(B[[2]]), '3909: isnull(B[[2]])'); vrfy(size(B) == 3, '3910: size(B) == 3'); mat C[] = {,,}; print '3911: mat C[] = {,,}'; vrfy(C[0] == 0, '3912: C[0] == 0'); vrfy(C[1] == 0, '3913: C[1] == 0'); vrfy(C[2] == 0, '3914: C[2] == 0'); vrfy(size(C) == 3, '3915: size(C) == 3'); mat D[] = { }; print '3916: mat D[] = { }'; vrfy(D[0] == 0, '3917: D[0] == 0'); vrfy(size(D) == 1, '3918: size(D) == 1'); print '3919: Ending test_noarg'; } print '066: parsed test_noarg'; /* * test_ptest - more tests of the functions ptest, nextcand, prevcand */ read -once "test4000"; print '067: read -once test4000'; /**/ define test_ptest() { local tnum; /* test number */ print '4000: Beginning test_ptest'; tnum = test4000(1, 4001); print tnum: ': Ending test_ptest'; } print '068: parsed test_ptest()'; /* * test_redc - REDC operation tests */ read -once "test4100"; print '069: read -once test4100'; /**/ define test_redc() { local tnum; /* test number */ print '4100: Beginning test_redc'; tnum = test4100(1, 4101); print tnum: ': Ending test_redc'; } print '070: parsed test_redc()'; /* * test_fileops - test various file operations */ define test_fileops() { local a, b, c, f, m, n, x, y, z; local L = "Landon"; local C = "Curt"; local N = "Noll"; local LCN = "Landon\nCurt\nNoll\n"; print '4200: Beginning test_fileops'; /* * fputs tests */ x = rm("-f", "junk4200"); print '4201: x = rm("-f", "junk4200")'; vrfy(!iserror(f = fopen("junk4200", "w+")), '4202: !iserror(f = fopen("junk4200", "w+"))'); vrfy(!iserror(fputs(f, LCN)), '4203: !iserror(fputs(f, LCN))'); vrfy(isnull(rewind(f)), '4204: isnull(rewind(f))'); vrfy(fgetfield(f) == L, '4205: fgetfield(f) == L'); vrfy(fgetfield(f) == C, '4206: fgetfield(f) == C'); vrfy(fgetfield(f) == N, '4207: fgetfield(f) == N'); vrfy(isnull(fgetfield(f)), '4208: isnull(fgetfield(f))'); vrfy(isnull(rewind(f)), '4209: isnull(rewind(f))'); vrfy(fgetline(f) == L, '4210: fgetline(f) == L'); vrfy(fgetline(f) == C, '4211: fgetline(f) == C'); vrfy(fgetline(f) == N, '4212: fgetline(f) == N'); vrfy(isnull(fgetline(f)), '4213: isnull(fgetline(f))'); vrfy(isnull(rewind(f)), '4214: isnull(rewind(f))'); vrfy(fgets(f) == strcat(L,"\n"), '4215: fgets(f) == strcat(L,"\\n")'); vrfy(fgets(f) == strcat(C,"\n"), '4216: fgets(f) == strcat(C,"\\n")'); vrfy(fgets(f) == strcat(N,"\n"), '4217: fgets(f) == strcat(N,"\\n")'); vrfy(isnull(fgets(f)), '4218: isnull(fgets(f))'); vrfy(isnull(rewind(f)), '4219: isnull(rewind(f))'); vrfy(fgetstr(f) == LCN, '4220: fgetstr(f) == LCN'); vrfy(isnull(fclose(f)), '4221: isnull(fclose(f))'); vrfy(isnull(fclose(f)), '4222: isnull(fclose(f))'); /* * fgetstr tests */ vrfy(!iserror(f = fopen("junk4200", "w+")), '4223: !iserror(f)'); vrfy(isnull(fputstr(f, L, C, N)), '4224: isnulll(fputstr(f, L, C, N))'); vrfy(isnull(rewind(f)), '4225: isnull(rewind(f))'); vrfy(fgetstr(f) == L, '4226: fgetstr(f) == L'); vrfy(fgetstr(f) == C, '4227: fgetstr(f) == C'); vrfy(fgetstr(f) == N, '4228: fgetstr(f) == N'); vrfy(isnull(fgetstr(f)), '4229: isnull(fgetstr(f))'); n = ftell(f); print '4230: n = ftell(f)'; vrfy(isnull(fputs(f,L,"\n",C,"\n",N,"\n")), '4231: isnull(fputs(f,L,"\\n",C,"\\n",N,"\\n"))'); fseek(f, n); print '4232: fseek(f, n)'; vrfy(fgetstr(f) == LCN, '4233: fgetstr(f) == LCN'); vrfy(isnull(fclose(f)), '4234: isnull(fclose(f))'); /* * fscanf tests */ a = exp(27, 1e-1000); print '4235: a = exp(27, 1e-1000)'; b = sqrt(7 + 5i, 1e-2000); print '4236: b = sqrt(7 + 5i, 1e-2000)'; c = config("display", 1000); print '4237: c = config("display", 1000)'; vrfy(!iserror(f=fopen("junk4200","w+")), '4238: !iserror(f=fopen("junk4200","w+"))'); vrfy(!iserror(fprintf(f, "%f\n\tand\n\t%r",a,b)), '4239: !iserror(fprintf(f, "%f\\n\\tand\\n\\t%r",a,b))'); vrfy(isnull(rewind(f)), '4240: isnull(rewind(f))'); vrfy(fscanf(f,"%f and %r",x,y)==2, '4241: fscanf(f,"%f and %r",x,y)==2'); vrfy(x == a && y == b, '4242: x == a && y == b'); vrfy(!iserror(freopen(f, "w+")), '4243: !iserror(freopen(f, "w+"))'); L = "Landon\n"; print '4244: L = "Landon\\n"'; C = "\tCurt\n"; print '4245: C = "\tCurt\\n"'; N = "\t\tNoll\n"; print '4246: N = "\\t\\tNoll\\n"'; vrfy(isnull(fputs(f, L, "|", C, "[", N, "]" )), '4247: isnull(fputs(f, L, "|", C, "[", N, "]" ))'); vrfy(isnull(rewind(f)), '4248: isnull(rewind(f))'); vrfy(fscanf(f, "%[^|]%*c%[^[]%*c%[^]]", x,y,z) == 3, '4249: fscanf(f, "%[^|]%*c%[^[]%*c%[^]]", x,y,z) == 3'); vrfy(x == L && y == C && z == N, '4250: x == L && y == C && z == N'); vrfy(isnull(rewind(f)), '4251: isnull(rewind(f))'); vrfy(fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2, '4252: fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2'); fseek(f, m); print '4253: fseek(f, m)'; vrfy(fscanf(f, "%3c", x) == 1, '4254: fscanf(f, "%3c", x) == 1'); vrfy(x == "\tCu", '4255: x == "\tCu"'); fseek(f, n); print '4256: fseek(f, n)'; vrfy(fscanf(f, "%s", y) == 1, '4257: fscanf(f, "%s", y) == 1'); vrfy(y == "Noll", '4258: y == "Noll"'); vrfy(isnull(fclose(f)), '4259: isnull(fclose(f))'); /* * cleanup */ x = rm("junk4200"); print '4260: x = rm("junk4200")'; print '4261: Ending test_fileops'; } print '071: parsed test_fileops()'; /* * test_matdcl - test new matrix declaration syntax */ mat_X0 = mat[4]; print '072: mat_X = mat[4]'; mat mat_X1, mat_X2[2]; mat mat_X3[3]; print '073: mat mat_X1, mat_X2[2]; mat mat_X3[3]'; mat mat_Z0, mat_Z1 [2] = {1,2}; print '074: mat mat_Z0, mat_Z1 [2] = {1,2}'; define test_matdcl() { local mat_Y0; local mat mat_Y1, mat_Y2[2], mat_Y3[3]; local mat M0, M1, M2[2,2]; local i; print '4300: Beginning test_matdcl'; vrfy(size(mat_X0) == 4, '4301: size(mat_X0) == 4'); vrfy(size(mat_X1) == 2, '4302: size(mat_X1) == 2'); vrfy(size(mat_X2) == 2, '4303: size(mat_X2) == 2'); vrfy(size(mat_X3) == 3, '4304: size(mat_X3) == 3'); vrfy(ismat(mat_X0), '4305: ismat(mat_X0)'); vrfy(ismat(mat_X1), '4306: ismat(mat_X1)'); vrfy(ismat(mat_X2), '4307: ismat(mat_X2)'); vrfy(ismat(mat_X3), '4308: ismat(mat_X3)'); mat_Y0 = mat[4]; print '4309: mat_Y0 = mat[4]'; vrfy(size(mat_Y0) == 4, '4310: size(mat_Y0) == 4'); vrfy(size(mat_Y1) == 2, '4311: size(mat_Y1) == 2'); vrfy(size(mat_Y2) == 2, '4312: size(mat_Y2) == 2'); vrfy(size(mat_Y3) == 3, '4313: size(mat_Y3) == 3'); vrfy(ismat(mat_Y0), '4314: ismat(mat_Y0)'); vrfy(ismat(mat_Y1), '4315: ismat(mat_Y1)'); vrfy(ismat(mat_Y2), '4316: ismat(mat_Y2)'); vrfy(ismat(mat_Y3), '4317: ismat(mat_Y3)'); vrfy(size(mat_Z0) == 2, '4318: size(mat_Z0) == 2'); vrfy(size(mat_Z1) == 2, '4319: size(mat_Z1) == 2'); vrfy(ismat(mat_Z0), '4320: ismat(mat_Z0)'); vrfy(ismat(mat_Z1), '4321: ismat(mat_Z1)'); vrfy(mat_Z0 == mat_Z1, '4322: mat_Z0 == mat_Z1'); vrfy(mat_Z0 == (mat[2] = {1,2}), '4323: mat_Z0 == (mat[2] = {1,2})'); vrfy(mat_Z0[0] == 1, '4324: mat_Z0[0] == 1'); vrfy(mat_Z0[1] == 2, '4325: mat_Z0[1] == 2'); mat_Z1 = {,3}; print '4326: mat_Z1 = {,3}'; vrfy(mat_Z0 != mat_Z1, '4327: mat_Z0 != mat_Z1'); vrfy(mat_Z1[0] == 1, '4328: mat_Z1[0] == 1'); vrfy(mat_Z1[1] == 3, '4329: mat_Z1[1] == 3'); mat_X3 = {2,3,5}; print '4330: mat_X3 = {2,3,5}'; mat_X3 += {3,4,5}; print '4331: mat_X3 += {3,4,5}'; vrfy(mat_X3[0] == 5, '4332: mat_X3[0] == 5'); vrfy(mat_X3[1] == 7, '4333: mat_X3[1] == 7'); vrfy(mat_X3[2] == 10, '4334: mat_X3[2] == 10'); mat_Y3 = mat_X3; print '4335: mat_Y3 = mat_X3'; mat_Y3 -= {,1,2}; print '4336: mat_Y3 -= {0,1,}'; vrfy(mat_Y3[0] == 0, '4337: mat_Y3[0] == 0'); vrfy(mat_Y3[1] == 6, '4338: mat_Y3[1] == 6'); vrfy(mat_Y3[2] == 8, '4339: mat_Y3[2] == 8'); ecnt += 2; print '4340: ecnt += 2'; mat_Y3 += 2; print '4341: mat_Y3 += 2'; vrfy(mat_Y3 == error(10003), '4342: mat_Y3 == error(10003)'); vrfy(errcount() == ecnt, '4343: errcount() == ecnt'); mat_Z0 += { }; print '4344: mat_Z0 += { }'; vrfy(mat_Z0[0] == 2, '4345: mat_Z0[0] == 2'); vrfy(mat_Z0[1] == 4, '4346: mat_Z0[1] == 4'); mat_Y0 = {mat_Z0, ,mat_Z1, mat_X3}; print '4347: mat_Y0 = {mat_Z0, ,mat_Z1, mat_X3}'; vrfy(size(mat_Y0) == 4, '4348: size(mat_Y0) == 4'); for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i]); print '4349: for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i])'; mat_X0==(mat[4]={2,1,2,3}); print '4350: mat_X0==(mat[4]={2,1,2,3})'; vrfy(mat_Y0[0] == mat_Z0, '4351: mat_Y0[0] == mat_Z0'); vrfy(mat_Y0[1] == 0, '4352: mat_Y0[1] == 0'); vrfy(mat_Y0[2] == mat_Z1, '4353: mat_Y0[2] == mat_Z1'); vrfy(mat_Y0[3] == mat_X3, '4354: mat_Y0[3] == mat_X3'); vrfy(mat_Y0[0][0] == 2, '4355: mat_Y0[0][0] == 2'); vrfy(mat_Y0[0][1] == 4, '4356: mat_Y0[0][1] == 4'); vrfy(mat_Y0[2][0] == 1, '4357: mat_Y0[2][0] == 1'); vrfy(mat_Y0[2][1] == 3, '4358: mat_Y0[2][1] == 3'); vrfy(mat_Y0[3][0] == 5, '4359: mat_Y0[3][0] == 5'); vrfy(mat_Y0[3][1] == 7, '4360: mat_Y0[3][1] == 7'); vrfy(mat_Y0[3][2] == 10, '4361: mat_Y0[3][2] == 10'); M0 = {(mat[2]={5,17}),(mat[2]={3,4}),(mat[2]={2,3}),(mat[2]={1,2})}; print '4362: M0 = {(mat[2]={5,17}), ...}'; M1 = {(mat[2]={5,3}),(mat[2]={2,5}),(mat[2]={1,5}),(mat[2]={3,2})}; print '4363: M1 = {(mat[2]={5,3}), ...}'; M2 = M0+M1; print '4364: M2 = M0+M1'; vrfy(M2[0,0]==(mat[2]={10,20}), '4365: M2[0,0]==(mat[2]={10,20})'); vrfy(M2[0,1]==(mat[2]={5,9}), '4366: M2[0,1]==(mat[2]={5,9})'); vrfy(M2[1,0]==(mat[2]={3,8}), '4367: M2[1,0]==(mat[2]={3,20})'); vrfy(M2[1,1]==(mat[2]={4,4}), '4368: M2[1,1]==(mat[2]={4,4})'); print '4369: Ending test_matdcl'; } print '075: parsed test_matdcl()'; /* * test_objmat - test combined obj and mat operations */ define test_objmat() { static obj surd P, R, S, T, U; local mat M0[2] = {5,17}; local mat M1[2] = {3,4}; local mat M2[2,2] = {1,2,3,5}; local mat M3[2,2] = {3,5,7,11}; local mat M4[2,2] = {51,82,116,187}; local Q; local V; local A,B,C,M; print '4400: Beginning test_objmat'; surd_type = -1; print '4401: surd_type == -1'; P = {M0,M1}; print '4402: P = {M0,M1}'; vrfy(P == surd(M0,M1), '4403: P == surd(M0,M1)'); vrfy(P != surd(M1,M0), '4404: P != surd(M1,M0)'); vrfy(conj(P)==surd(M0,-M1), '4405: conj(P)==surd(M0,-M1)'); Q = surd_value(P); print '4406: Q = surd_value(P)'; vrfy(ismat(Q), '4407: ismat(Q)'); vrfy(Q == (mat[2]={5+3i,17+4i}), '4408: Q == (mat[2]={5+3i,17+4i})'); R = {M2,M3}; print '4409: R = {M2,M3}'; vrfy(norm(R) == M4, '4410: norm(R) == M4'); vrfy(det(surd_value(R^2)) == -23-6i, \ '4411: det(surd_value(R^2)) == -23-6i'); vrfy(det(norm(R^5))==268107761663283843865, \ '4412: det(norm(R^5))==268107761663283843865'); S = {M2+M3, M2-M3}; print '4413: S = {M2+M3, M2-M3}'; T = {M2+3*M3, 5*M2-M3}; print '4414: T = {M2+3*M3, 5*M2-M3}'; U = {(M4 -= {50,80,110,180}), M4+M2}; print '4415: U = {(M4 -= {50,80,110,180}), M4+M2}'; vrfy(det(surd_value(R*S*T*U)) == 480-15040i, '4416: det(surd_value(R*S*T*U)) == 480-15040i'); vrfy(det(surd_value(R*S+T*U)) == 78+514i, '4417: det(surd_value(R*S+T*U)) == 78+514i'); V = norm(det(surd_value(R^5+S^5+T^5+U^5))); print '4418: V = norm(det(surd_value(R^5+S^5+T^5+U^5)))'; vrfy(V == 41952632964892462488299378, \ '4419: V == 41952632964892462488299378'); V = norm(det(surd_value(R^5-S^5+T^5-U^5))); print '4420: V = norm(det(surd_value(R^5-S^5+T^5-U^5)))'; vrfy(V == 40891924356202870926321650, \ '4421: V == 40891924356202870926321650'); vrfy((mat [3] = {2,3,5})+(mat[3] = {7,11,13}) == (mat[3]={9,14,18}),\ '4422: (mat [3] = {2,3,5})+(mat[3] = {7,11,13}) == (mat[3]={9,14,18})'); vrfy((mat [2,2] = {2,3,5,7})^2 == (mat[2,2] = {19, 27, 45, 64}),\ '4423: (mat [2,2] = {2,3,5,7})^2 == (mat[2,2] = {19, 27, 45, 64})'); vrfy((mat [] = {1,2,3}) == (mat[3] = {1,2,3}), '4424: (mat [] = {1,2,3}) == (mat[3] = {1,2,3})'); mat A[3] = {2,3,5}; print '4425: mat A[3] = {2,3,5}'; mat A[3] = {A[0], A[2], A[1]}; print '4426: mat A[3] = {A[0], A[2], A[1]}'; vrfy(A == (mat[3] = {2, 5, 3}), '4427: A == (mat[3] = {2, 5, 3})'); B = mat[3] = {2,5,3}; print '4428: B = mat[3] = {2,5,3}'; vrfy(A == B, '4429: A == B'); mat A[2] = {A[1], A[2]}; print '4430: mat A[2] = {A[1], A[2]}'; vrfy(A == (mat[2] = {5, 3}), '4431: A == (mat[2] = {5, 3})'); A = B; print '4432: A = B'; A = {A[0], A[2], A[1]}; print '4433: A = {A[0], A[2], A[1]}'; vrfy(A == (mat[3] = {2, 3, 3}), '4434: A == (mat[3] = {2, 3, 3})'); A = mat[3] = {1,2} = {,3,4}; print '4435: A = mat[3] = {1,2} = {,3,4}'; vrfy(A == (mat[3] = {1,3,4}), '4436: A == (mat[3] = {1,3,4})'); mat A[4] = {1,2,3,4}; print '4437: mat A[4] = {1,2,3,4}'; A = {,5,,6}; print '4438: A = {,5,,6}'; vrfy(A == (mat[4] = {1,5,3,6}), '4439: A == (mat[4] = {1,5,3,6})'); A = {7}; print '4440: A = {7}'; vrfy(A == (mat[4] = {7,5,3,6}), '4441: A == (mat[4] = {7,5,3,6})'); mat M[2]; print '4442: mat M[2]'; mat A, B, C [3] = {M, M, M}; print '4443: mat A, B, C [3] = {M, M, M}'; A = {{2, 3}, {5, 7}, {11, 13}}; print '4444: A = {{2, 3}, {5, 7}, {11, 13}}'; B = {{1, 2}, {3, 4}, {5, 6}}; print '4445: B = {{1, 2}, {3, 4}, {5, 6}}'; C = {{3, 5}, {8, 11}, {16, 19}}; print '4446: C = {{3, 5}, {8, 11}, {16, 19}}'; vrfy(A + B == C, '4447: A + B == C'); mat A[2][3]; print '4448: mat A[2][3]'; A = {{1, 2, 3}, {4, 5, 6}}; print '4449: A = {{1, 2, 3}, {4, 5, 6}}'; vrfy(A[0][1] == 2, '4450: A[0][1] == 2'); vrfy(A[1,0] == 4, '4451: A[1,0] == 4'); B = mat[2][3] = {{1, 2, 3}, {4, 5, 6}}; print '4452: B = mat[2][3] = {{1, 2, 3}, {4, 5, 6}}'; vrfy(A == B, '4453: A == B'); mat A[2][3] = {{1, 2, 3}, {4, 5, 6}}; print '4454: mat A[2][3] = {{1, 2, 3}, {4, 5, 6}}'; vrfy(A == B, '4455: A == B'); mat A[2][3] = {{1,2,3},4}; print '4456: mat A[2][3] = {{1,2,3},4}'; vrfy(A[0] == (mat[3] = {1,2,3}), '4457: A[0] == (mat[3] = {1,2,3})'); vrfy(A[1] == 4, '4458: A[1] == 4'); A += {{3,5,7}, 11}; print '4459: A += {{3,5,7}, 11}'; vrfy(A[0] == (mat[3]={4,7,10}), '4460: A[0] == (mat[3]={4,7,10})'); vrfy(A[1] == 15, '4461: A[1] == 15'); mat A[2,2][2,2]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}; print '4462: mat A[2,2][2,2]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}'; B = A^2; print '4463: B = A^2'; vrfy(B[0,0] == (mat[2,2] = {118, 132, 166, 188}), \ '4464: B[0,0] == (mat[2,2] = {118, 132, 166, 188})'); print '4465: Ending test_objmat'; print; print '4500: reserved for future expansion of test_objmat'; } print '076: parsed test_objmat()'; /* * test_fileop - test file operations */ read -once "test4600"; print '077: read -once test4600'; /**/ define test_fileop() { local tnum; /* test number */ print '4600: Beginning test_fileop'; tnum = test4600(1, 4601); print tnum: ': Ending test_fileop'; } print '078: parsed test_fileop()'; /* * test write/read */ x_081 = isqrt(2e5000); print '079: x_081 = isqrt(2e5000)' s_x_081 = str(x_081); print '080: s_x_081 = str(x_081)'; d_081 = rm("-f", "test082.cal"); print '081: d_081 = rm("-f", "test082.cal")'; write test082.cal; print '082: write test082.cal'; read "./test082.cal"; print '083: read "./test082.cal"'; d_081 = rm("test082.cal"); print '084: d081 = rm("test082.cal")'; vrfy(__ == 63, '085: __ == 63'); vrfy(x_081 == isqrt(2e5000), '086: x_081 == isqrt(2e5000)'); /* * test_charset - test the ASCII character set and \'s */ define test_charset() { print '4700: Beginning test_charset'; vrfy("\a" == char(7), '4701: "\\a" == char(7)'); vrfy("\v" == char(11), '4702: "\\v" == char(11)'); vrfy("\e" == char(27), '4703: "\\e" == char(27)'); vrfy("\\" == char(92), '4704: "\\\\" == char(92)'); vrfy("\101" == "A", '4705: "\\101" == "A"'); vrfy("\123" == char(0123), '4706: "\\123" == char(0123)'); vrfy("\123\124" == "ST", '4707: "\\123\\124" == "ST"'); vrfy("\311" == char(201), '4708: "\\311" == char(201)'); vrfy("\119" == "\t9", '4709: "\\119" == "\t9"'); vrfy("\765" == "\365", '4710: "\\765" == "\365"'); vrfy("\x61" == "a", '4711: "\\x61" == "a"'); vrfy("\x73" == "s", '4712: "\\x73" == "s"'); vrfy("\xea" == char(234), '4713: "\\xea" == char(234)'); vrfy("\x61\x62\x63" == "abc", '4714: "\\x61\\x62\\x63" == "abc"'); vrfy("\x8g" == "\bg", '4715: "\\x8g" == "\bg"'); vrfy(eval('"\\\\"') == "\\", '4716: eval(\'"\\\\\\\\"\') == "\\\\"'); print '4717: Ending test_charset'; } print '087: parsed test_fileop()'; /* * test_strprintf - test strprintf calls */ define test_strprintf() { local callcfg; /* caller configuration value */ local c; /* modified configuration */ print '4800: Beginning test_strprintf'; /* setup */ callcfg = config("all"); print '4801: callcfg = config("all")'; c = config("mode", "frac"); print '4802: c = config("mode", "frac")'; c = config("outround", 24); print '4803: c = config("outround", 24)'; c = config("display", 2); print '4804: c = config("display", 2)'; c = config("tilde", 0); print '4805: c = config("tilde", 0)'; c = config("leadzero", 0); print '4806: c = config("leadzero", 0)'; c = config("fullzero", 0); print '4807: c = config("fullzero", 0)'; /* tests with tilde == 0 */ vrfy(strprintf("%d%d", 27, 29) == "2729", '4808: strprintf("%d%d", 27, 29) == "2729"'); vrfy(strprintf("%5d%3d", 27, 29) == " 27 29", '4809: strprintf("%5d%3d", 27, 29) == " 27 29"; '); vrfy(strprintf("%-5d%-3d", 27, 29) == "27 29 ", '4810: strprintf("%-5d%-3d", 27, 29) == "27 29 "'); vrfy(strprintf("%f", 1.375) == "1.38", '4811: strprintf("%f", 1.375) == "1.38"'); vrfy(strprintf("%f", 1.385) == "1.38", '4812: strprintf("%f", 1.385) == "1.38"'); vrfy(strprintf("%f", .375) == ".38", '4813: strprintf("%f", .375) == ".38"'); vrfy(strprintf("%f", .385) == ".38", '4814: strprintf("%f", .385) == ".38"'); /* tests with tilde == 1 */ c = config("tilde", 1); print '4815: c = config("tilde", 1)'; vrfy(strprintf("%f", 1.375) == "~1.38", '4816: strprintf("%f", 1.375) == "~1.38"'); vrfy(strprintf("%f", 27/29) == "~.93", '4817: strprintf("%f", 27/29) == "~.93"'); vrfy(strprintf("%r", 27/29) == "27/29", '4818: strprintf("%r", 27/29) == "27/29"'); vrfy(strprintf("%o", 27/29) == "033/035", '4819: strprintf("%o", 27/29) == "033/035"'); vrfy(strprintf("%x", 27/29) == "0x1b/0x1d", '4820: strprintf("%x", 27/29) == "0x1b/0x1d"'); vrfy(strprintf("%b", 27/29) == "0b11011/0b11101", '4821: strprintf("%b", 27/29) == "0b11011/0b11101"'); vrfy(strprintf("%e", 12345) == "~1.23e4", '4822: strprintf("%e", 12345) == "~1.23e4"'); /* mode tests with tilde == 0 */ c = config("tilde", 0); print '4823: c = config("tilde", 0)'; vrfy(strprintf("%e", 12345) == "1.23e4", '4824: strprintf("%e", 12345) == "1.23e4"'); vrfy(strprintf("%.3e", 12345) == "1.234e4", '4825: strprintf("%.3e", 12345) == "1.234e4"'); vrfy(strprintf("%e", .00012345) == "1.23e-4", '4826: strprintf("%e", .00012345) == "1.23e-4"'); vrfy(strprintf("%d %d", 27) == "27 ", '4827: strprintf("%d %d", 27) == "27 "'); vrfy(strprintf("%d", 27, 29) == "27", '4828: strprintf("%d", 27, 29) == "27"'); vrfy(strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93", '4829: strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93"'); vrfy(strprintf("%s", "abc") == "abc", '4830: strprintf("%s", "abc") == "abc"'); vrfy(strprintf("%f", "abc") == "abc", '4831: strprintf("%f", "abc") == "abc"'); vrfy(strprintf("%e", "abc") == "abc", '4832: strprintf("%e", "abc") == "abc"'); vrfy(strprintf("%5s", "abc") == " abc", '4833: strprintf("%5s", "abc") == " abc"'); vrfy(strprintf("%-5s", "abc") == "abc ", '4834: strprintf("%-5s", "abc") == "abc "'); /* restore config */ c = config("all", callcfg); print '4835: c = config("all", callcfg)'; print '4836: Ending test_strprintf'; } print '088: parsed test_fileop()'; /* * global and static assignment tests */ global a = 10, b, c d = 20, e, f; print '089: global a = 10, b, c d = 20, e, f'; vrfy(a == 10, '090: a == 10'); vrfy(b == 0, '091: b == 0'); vrfy(c == 20, '092: c == 20'); vrfy(d == 20, '093: d == 20'); vrfy(e == 0, '094: e == 0'); vrfy(f == 0, '095: f == 0'); static a b = 30, c, e = 30; print '096: static a b = 30, c, e = 30'; vrfy(a == 30, '097: a == 30'); vrfy(b == 30, '098: b == 30'); vrfy(c == 0, '099: c == 0'); vrfy(e == 30, '100: e == 30'); global a, b; print '101: global a, b'; vrfy(a == 10, '102: a == 10'); vrfy(b == 0, '103: b == 0'); static mat A, B[2,2] = {1,2,3,4}; print '104: static mat A, B[2,2] = {1,2,3,4}'; define f100(x,y) = (mat [2,2] = {x,0,0,y}) * A; print '105: define f100(x,y) = (mat [2,2] = {x,0,0,y}) * A'; define g100(x) = (mat[2,2] = {x,x,x,x}) + B; print '106: define g100(x) = (mat[2,2] = {x,x,x,x}) + B'; define h100(a,b,c,d) = ((B = {a,b,c,d}), null()); print '107: define h100(a,b,c,d) = ((B = {a,b,c,d}), null())'; global A, B; print '108: global A, B'; vrfy(A == 0, '109: A == 0'); vrfy(B == 0, '110: B == 0'); x = test(f100(2,3) == (mat[2,2] = {2, 4, 9, 12})); vrfy(x, '111: test(f100(2,3) == (mat[2,2] = {2, 4, 9, 12}))'); x = test(g100(4) == (mat[2,2] = {5,6,7,8})); vrfy(x, '112: test(g100(4) == (mat[2,2] = {5,6,7,8}))'); x = test(h100(2,3,5,7) == null()); vrfy(x, '113: test(h100(2,3,5,7) == null())'); x = test(g100(4) == (mat[2,2] = {6,7,9,11})); vrfy(x, '114: test(g100(4) == (mat[2,2] = {6,7,9,11}))'); global obj point {x,y} P Q = {1,2}, R={3,4}, S; print '115: global obj point {x,y} P, Q = {1,2}, R={3,4}, S'; vrfy(P.x == 1, '116: P.x == 1'); vrfy(P.y == 2, '117: P.y == 2'); vrfy(Q.x == 1, '118: Q.x == 1'); vrfy(Q.y == 2, '119: Q.y == 2'); vrfy(R.x == 3, '120: R.x == 3'); vrfy(R.y == 4, '121: R.y == 4'); vrfy(S.x == 0, '122: S.x == 0'); vrfy(S.y == 0, '123: S.y == 0'); /* * test_listsearch - test searching in lists */ define test_listsearch() { local L; print '4900: Beginning test_listsearch'; L = list(); print '4901: L = list()'; vrfy(isnull(search(L,1)), '4902: isnull(search(L,1))'); vrfy(isnull(rsearch(L,1)), '4903: isnull(search(L,1))'); L = list(0,1,2,3,0,1,2,3,0,1); print '4904: L = list(0,1,2,3,0,1,2,3,0,1)'; vrfy(search(L,0) == 0, '4905: search(L,0) == 0'); vrfy(rsearch(L,0) == 8, '4906: rsearch(L,0) == 8'); vrfy(search(L,0,2) == 4, '4907: search(L,0,2) == 4'); vrfy(rsearch(L,0,7) == 4, '4908: rsearch(L,0,7) == 4'); vrfy(isnull(search(L,2,7)), '4909: isnull(search(L,2,7))'); vrfy(isnull(rsearch(L,3,2)), '4910: isnull(rsearch(L,3,2))'); vrfy(isnull(search(L,0,1,4)), '4911: isnull(search(L,0,1,4)'); vrfy(isnull(rsearch(L,0,1,4)), '4912: isnull(rsearch(L,0,1,4)'); vrfy(search(L,0,-5) == 8, '4913: search(L,0,-5) == 8'); vrfy(rsearch(L,0,-9,-2) == 4, '4914: rsearch(L,0,-9,-2) == 4'); vrfy(isnull(search(L,3,20)), '4915: isnull(search(L,3,20)'); vrfy(isnull(search(L,3,0,-20)), '4916: isnull(search(L,3,0,-20)'); vrfy(isnull(rsearch(L,3,20,2)), '4917: isnull(rsearch(L,3,20,2)'); vrfy(rsearch(L,3,-20,20) == 7, '4918: rsearch(L,3,-20,20) == 7'); print '4919: Ending test_strprintf'; } print '124: parsed test_listsearch()'; /* * test_filesearch - test searching in files * * This function is designed to trigger 22 errors, so we bump the * errmax by 22 during this call. */ define test_filesearch() { local f, g; /* open files */ local s; /* local string */ local a, b, c, d; /* new error values */ local x; print '5000: Beginning test_filesearch'; /* * setup */ print '5001: x = rm("-f", "junk5000")'; x = rm("-f", "junk5000"); f = fopen("junk5000", "w"); print '5002: f = fopen("junk5000", "w")'; if (iserror(f)) { prob("Unable to open \"junk5000\" for writing"); return; } print '5003: if (iserror(f)) { ... }'; s = "alpha beta gamma "; print '5004: s = "alpha beta gamma "'; fputs(f, s); print '5005: fputs(f, s)'; fflush(f); print '5006: fflush(f)'; print '5007: test unused'; /* bump errmax up by 16 */ ecnt += 16; print '5008: ecnt += 16'; vrfy(search(f, 45) == error(10122), '5009: search(f, 45) == error(10122)'); vrfy(search(f, "a", 1/2) == error(10123), '5010: search(f, "a", 1/2) == error(10123)'); vrfy(search(f, "a", 0, "b") == error(10124), '5011: search(f, "a", 0, "b") == error(10124)'); vrfy(search(f, "a", 0) == error(10126), '5012: search(f, "a") == error(10126)'); vrfy(rsearch(f, 45) == error(10128), '5013: rsearch(f, 45) == error(10128)'); vrfy(rsearch(f, "a", "b") == error(10129), '5014: rsearch(f, "a", "b") == error(10129)'); vrfy(rsearch(f, "a", 0, "b") == error(10130), '5015: rsearch(f, "a", 0, "b") == error(10130)'); vrfy(rsearch(f, "a", 0) == error(10132), '5016: rsearch(f,"a",0) == error(10132)'); /* errmax and errcount should be bumped up the 16 errors above */ vrfy(errcount() == ecnt, '5017: errcount() == ecnt'); if (freopen(f, "r")) { prob("Unable to reopen \"junk5000\" for reading"); return; } print '5018: if (freopen(f, "r")) { ... }'; vrfy(fsize(f) == 17, '5019: fsize(f) == 17'); vrfy(search(f, s, 0) == 0, '5020: search(f, s, 0) == 0'); vrfy(ftell(f) == 17, '5021: ftell(f) == 17'); vrfy(rsearch(f, s, 0) == 0, '5022: rsearch(f, s, 0) == 0'); vrfy(ftell(f) == 16, '5023: ftell(f) == 16'); vrfy(search(f, "", 2) == 2, '5024: search(f, "", 2) == 2'); vrfy(ftell(f) == 2, '5025: ftell(f) == 2'); vrfy(search(f, "", 17) == 17, '5026: search(f, "", 17) == 17'); vrfy(ftell(f) == 17, '5027: ftell(f) == 17'); vrfy(isnull(search(f, "", 100)), '5028: isnull(search(f, "", 100))'); vrfy(ftell(f) == 17, '5029: ftell(f) == 17'); vrfy(rsearch(f, "", 5) == 5, '5030: rsearch(f, "", 5) == 5'); vrfy(ftell(f) == 5, '5031: ftell(f) == 5'); vrfy(search(f, "beta", 0) == 6, '5032: search(f, "beta", 0) == 6'); vrfy(ftell(f) == 10, '5033: ftell(f) == 10'); vrfy(rsearch(f, "beta", 100) == 6, '5034: rsearch(f, "beta", 100) == 6'); vrfy(ftell(f) == 9, '5035: ftell(f) == 9'); vrfy(search(f, "a", 2) == 4, '5036: search(f, "a", 2) == 4'); vrfy(ftell(f) == 5, '5037: ftell(f) == 5'); vrfy(search(f, "a", 4) == 4, '5038: search(f, "a", 4) == 4'); vrfy(search(f, "m") == 13, '5039: search(f, "m") == 13'); vrfy(search(f, "m") == 14, '5040: search(f, "m") == 14'); vrfy(isnull(search(f, "m")), '5041: isnull(search(f, "m"))'); vrfy(rsearch(f, "m", 15) == 14, '5042: rsearch(f, "m", 14) == 14'); vrfy(isnull(search(f, "beta", 7)), '5043: isnull(search(f, "beta", 7))'); vrfy(ftell(f) == 14, '5044: ftell(f) == 14'); vrfy(search(f,"a",2,15) == 4, '5045: search(f,"a",2,15) == 4'); vrfy(ftell(f) == 5, '5046: ftell(f) == 5'); vrfy(isnull(search(f,"a",2,4)), '5047: isnull(search(f,"a",2,4))'); vrfy(ftell(f) == 4, '5048: ftell(f) == 4'); vrfy(search(f,"a",,5) == 4, '5049: search(f,"a",,5) == 4'); vrfy(rsearch(f,"a",2,15) == 12, '5050: rsearch(f,"a",2,15) == 12'); vrfy(ftell(f) == 12, '5051: ftell(f) == 12'); vrfy(rsearch(f,"a",2,12) == 9, '5052: rsearch(f,"a",2,12) == 9'); /* generate 2 more errors */ ecnt += 2; print '5053: ecnt += 2'; a = 2 + ""; print '5054: a = 2 + ""'; g = fopen(3, "r"); print '5055: g = fopen(3, "r")'; c = 5^2; print '5056: c = 5^2'; vrfy(errcount() == ecnt, '5057: errcount() == ecnt'); /* generate 4 more errors by testing newerror */ ecnt += 4; print '5058: ecnt += 4'; a = newerror("alpha"); print '5059: a = newerror("alpha")'; b = newerror("beta"); print '5060: b = newerror("beta")'; c = newerror("alpha"); print '5061: c = newerror("alpha")'; d = newerror("beta"); print '5062: d = newerror("beta")'; vrfy(errcount() == ecnt, '5063: errcount() == ecnt'); vrfy(a == c, '5064: a == c'); vrfy(b == d, '5065: b == d'); /* test error(0) */ error(0); print '5066: error(0)'; vrfy(strerror() == "No error", '5067: strerror() == "No error"'); /* * close down */ fclose(f); print '5068: fclose(f)'; rm("junk5000"); print '5069: rm("junk5000")'; print '5070: Ending test_filesearch'; } print '125: parsed test_filesearch()'; /* * test_newdecl - test the new code generator declaration scope and order */ read -once "test5100"; print '126: read -once test5100'; /**/ define test_newdecl() { print '5100: Beginning test_newdecl'; /* * test5100 calls */ test5100(1); print '5101: test5100(1)'; vrfy(a5100 == 0, '5102: a5100 == 0'); vrfy(b5100 == 2, '5103: b5100 == 2'); test5100(1); print '5104: test5100(1)'; vrfy(a5100 == 0, '5105: a5100 == 0'); vrfy(b5100 == 3, '5106: b5100 == 3'); test5100(1); print '5107: test5100(1)'; vrfy(a5100 == 0, '5108: a5100 == 0'); vrfy(b5100 == 4, '5109: b5100 == 4'); test5100(2); print '5110: test5100(2)'; vrfy(a5100 == 3, '5111: a5100 == 3'); vrfy(b5100 == 4, '5112: b5100 == 4'); test5100(2); print '5113: test5100(2)'; vrfy(a5100 == 4, '5114: a5100 == 4'); vrfy(b5100 == 4, '5115: b5100 == 4'); test5100(2); print '5116: test5100(2)'; vrfy(a5100 == 5, '5117: a5100 == 5'); vrfy(b5100 == 4, '5118: b5100 == 4'); test5100(3); print '5119: test5100(3)'; vrfy(a5100 == 5, '5120: a5100 == 5'); vrfy(b5100 == 5, '5121: b5100 == 5'); test5100(9); print '5122: test5100(9)'; vrfy(a5100 == 5, '5123: a5100 == 5'); vrfy(b5100 == 6, '5124: b5100 == 6'); test5100(0); print '5125: test5100(0)'; vrfy(a5100 == 5, '5126: a5100 == 5'); vrfy(b5100 == 6, '5127: b5100 == 6'); test5100(-1); print '5128: test5100(-1)'; vrfy(a5100 == 5, '5129: a5100 == 5'); vrfy(b5100 == 6, '5130: b5100 == 6'); print '5131: Ending test_newdecl'; } print '127: parsed test_newdecl()'; /* * test_globstat - test the fix of a global/static bug */ read -once "test5200"; print '128: read -once test5200'; /**/ define test_globstat() { print '5200: Beginning test_globstat'; /* * test {f,g,h}5200 calls */ vrfy(a5200 == 10, '5201: a5200 == 10'); vrfy(eval("a5200") == 10, '5202: eval("a5200") == 10'); vrfy(f5200(1) == 21, '5203: f5200(1) == 21'); vrfy(a5200 == 10, '5204: a5200 == 10'); vrfy(eval("a5200") == 10, '5205: eval("a5200") == 10'); vrfy(h5200(2) == 12, '5206: h5200(2) == 12'); vrfy(a5200 == 10, '5207: a5200 == 10'); vrfy(eval("a5200") == 10, '5208: eval("a5200") == 10'); vrfy(g5200(3) == 33, '5209: g5200(3) == 33'); vrfy(a5200 == 30, '5210: a5200 == 30'); vrfy(eval("a5200") == 30, '5211: eval("a5200") == 30'); vrfy(h5200(4) == 34, '5212: h5200(4) == 34'); vrfy(f5200(5) == 25, '5213: f5200(5) == 25'); vrfy(h5200(6) == 36, '5214: h5200(6) == 36'); vrfy(g5200(7) == 37, '5215: g5200(7) == 37'); vrfy(f5200(8) == 28, '5216: f5200(8) == 28'); vrfy(g5200(9) == 39, '5217: g5200(9) == 39'); vrfy(a5200 == 30, '5218: a5200 == 30'); vrfy(eval("a5200") == 30, '5219: eval("a5200") == 30'); print '5220: Ending test_globstat'; } print '129: parsed test_globstat()'; /* * test_newop2 - test new label stuff */ define test_newop2(x) {if (x < 0) goto l130; ++x; l130: return x;} print '130: define test_newop3(x) {if (x < 0) goto l130; ++x; l130: return x;}' vrfy(test_newop2(100) == 101, '131: test_newop2(100) == 101'); vrfy(test_newop2(-100) == -100, '132: test_newop2(-100) == -100'); /* * test_newop3 - test new label stuff */ define test_newop3(x) { if (x < 4) if (iseven(x)) goto l135; else return 2; return 3; l135: return 1; } print '133: define test_newop3(x) ...'; vrfy(test_newop3(2) == 1, '134: test_newop3(2) == 1'); vrfy(test_newop3(3) == 2, '135: test_newop3(3) == 2'); vrfy(test_newop3(4) == 3, '136: test_newop3(4) == 3'); /* * Test random - Blum-Blum-Shub pseudo-random number generator */ define test_random() { local init; /* initial generator state */ local state0; /* a generator state */ local state1; /* a generator state */ local tmp; local n; print '5300: Beginning random test'; /* test save and restore of the initial state */ tmp = srandom(0); print '5301: tmp = srandom(0)'; init = srandom(); print '5302: init = srandom()'; state0 = srandom(0); print '5303: state0 = srandom(0)'; vrfy(state0 == init, '5304: state0 == init'); /* test the additive 55 shuffle generator */ tmp = srandom(0); print '5305: tmp = srandom(0)'; vrfy(random() == 0x7fb838a8a0a95046, \ '5306: random() == 0x7fb838a8a0a95046'); vrfy(random() == 0xb9d9d9fb4440f7bb, \ '5307: random() == 0xb9d9d9fb4440f7bb'); tmp = srandom(init); print '5308: tmp = srandom(init)'; vrfy(random() == 0x7fb838a8a0a95046, \ '5309: random() == 0x7fb838a8a0a95046'); vrfy(random() == 0xb9d9d9fb4440f7bb, \ '5310: random() == 0xb9d9d9fb4440f7bb'); /* test range interface */ tmp = srandom(0); print '5311: tmp = srandom(0)'; vrfy(random(12345678901234567890) == 0x7fb838a8a0a95046, \ '5312: random(12345678901234567890) == 0x7fb838a8a0a95046'); vrfy(random(216091) == 0x2e767, '5313: random(216091) == 0x2e767'); vrfy(random(100) == 0x33, '5314: random(100) == 0x33'); vrfy(random(-46,46) == -0xc, '5315: random(-46,46) == -0xc'); tmp = srandom(0); print '5316: tmp = srandom(0)'; vrfy(random(2^64) == 0x7fb838a8a0a95046, \ '5317: random(2^64) == 0x7fb838a8a0a95046'); vrfy(random(0,2^64) == 0xb9d9d9fb4440f7bb, \ '5318: random(0,2^64) == 0xb9d9d9fb4440f7bb'); /* test different forms of seeding the initial state */ tmp = srandom(0); print '5319: tmp = srandom(0)'; vrfy(srandom() == init, '5320: srandom() == init'); tmp = srandom(0x87e6ec938ff55aa5<<64); print '5321: tmp = srandom(0x87e6ec938ff55aa5<<64)'; vrfy(srandom() == init, '5322: srandom() == init'); tmp = srandom(state0); print '5323: tmp = srandom(state0)'; vrfy(srandom() == init, '5324: srandom() == init'); tmp = srandom(init); print '5325: tmp = srandom(init)'; vrfy(srandom() == init, '5326: srandom() == init'); vrfy(tmp == init, '5327: tmp == init'); /* test the bit length interface */ tmp = srandom(0); print '5328: tmp = srandomom(0)'; vrfy(randombit(64) == 0x7fb838a8a0a95046, \ '5329: randombit(64) == 0x7fb838a8a0a95046'); vrfy(randombit(128) == 0xb9d9d9fb4440f7bbc1a7bd3b4e853fc9, \ '5330: randombit(128) == 0xb9d9d9fb4440f7bbc1a7bd3b4e853fc9'); vrfy(randombit(64) == 0x2d4e1588719986aa, \ '5331: randombit(64) == 0x2d4e1588719986aa'); vrfy(randombit(128) == 0x8d68905434b020ccb849e17a03a5c441, \ '5332: randombit(128) == 0x8d68905434b020ccb849e17a03a5c441'); tmp = srandom(0); print '5333: tmp = srandom(0)'; vrfy(randombit(32) == 0x7fb838a8, '5334: randombit(32) == 0x7fb838a8'); vrfy(randombit(32) == 0xa0a95046, '5335: randombit(32) == 0xa0a95046'); vrfy(randombit(1) == 0x1, '5336: randombit(1) == 0x1'); vrfy(randombit(5) == 0xe, '5337: randombit(5) == 0xe'); vrfy(randombit(33) == 0xececfda2, '5338: randombit(33) == 0xececfda2'); vrfy(randombit(25) == 0x40f7bb, '5339: randombit(25) == 0x40f7bb'); vrfy(randombit(2) == 0x3, '5340: randombit(2) == 0x3'); vrfy(randombit(13) == 0xd3, '5341: randombit(13) == 0xd3'); vrfy(randombit(18) == 0x37a76, '5342: randombit(18) == 0x37a76'); vrfy(randombit(8) == 0x9d, '5343: randombit(8) == 0x9d'); vrfy(randombit(9) == 0x14, '5344: randombit(9) == 0x14'); vrfy(randombit(70) == 0x3fc92d4e1588719986, \ '5345: randombit(70) == 0x3fc92d4e1588719986'); vrfy(randombit(123) == 0x5546b4482a1a5810665c24f0bd01d2e, \ '5346: randombit(123) == 0x5546b4482a1a5810665c24f0bd01d2e'); vrfy(randombit(8) == 0x22, '5347: randombit(8) == 0x22'); vrfy(randombit(65) == 0x1d2a104aaf523699, \ '5348: randombit(65) == 0x1d2a104aaf523699'); vrfy(randombit(63) == 0x60e63d498ba690ec, \ '5349: randombit(63) == 0x60e63d498ba690ec'); vrfy(randombit(1) == 0x1, '5350: randombit(1) == 0x1'); vrfy(randombit(2) == 0x3, '5351: randombit(2) == 0x3'); vrfy(randombit(4) == 0x0, '5352: randombit(4) == 0x0'); vrfy(randombit(3) == 0x0, '5353: randombit(3) == 0x0'); state1 = srandom(); print '5354: state1 = srandom()'; /* test randombit skip interface */ tmp = srandom(0); print '5355: tmp = srandom(0)'; vrfy(randombit(20) == 523139, '5356: randombit(20) == 523139'); vrfy(randombit(20) == 567456, '5357: randombit(20) == 567456'); vrfy(randombit(20) == 693508, '5358: randombit(20) == 693508'); vrfy(randombit(20) == 440793, '5359: randombit(20) == 440793'); tmp = srandom(0); print '5360: tmp = srandom(0)'; vrfy(randombit(-20) == 20, '5361: randombit(-20) == 20'); vrfy(randombit(20) == 567456, '5362: randombit(20) == 567456'); vrfy(randombit(-20) == 20, '5363: randombit(-20) == 20'); vrfy(randombit(20) == 440793, '5364: randombit(20) == 440793'); /* test randombit without and arg */ tmp = srandom(0); print '5365: tmp = srandom(0)'; vrfy(randombit() == 0, '5366: randombit() == 0'); vrfy(randombit() == 1, '5367: randombit() == 1'); vrfy(randombit() == 1, '5368: randombit() == 1'); /* test range interface some more */ tmp = srandom(state1); print '5369: tmp = srandom(state1)'; vrfy(random(-46,46) == -0x7, '5370: random(-46,46) == -0x7'); vrfy(random(21701,23209) == 23061, '5371: random(21701,23209) == 23061'); vrfy(random(0x22,0x1d2a104aaf523699) == 0x17c97dfa80bbdf1b, '5372: random(0x22,0x1d2a104aaf523699) == 0x17c97dfa80bbdf1b'); vrfy(random(0x2d4e16aa,0x7fb83046) == 0x48e98d92, '5373: random(0x2d4e16aa,0x7fb83046) == 0x48e98d92'); vrfy(random(-0x2d4986aa,0x7fb83846) == 0x3b3f6c0c, '5374: random(-0x2d4986aa,0x7fb83846) == 0x3b3f6c0c'); vrfy(random(-0x2d9986aa,-0x7fb9504) == -0x235f9ce1, '5375: random(-0x2d9986aa,-0x7fb9504) == -0x235f9ce1'); /* test pre-compiled random states */ tmp = srandom(init); print '5376: tmp = srandom(init)'; state0 = srandom(0,1); print '5377: state0 = srandom(0,1)'; vrfy(randombit(123) == 0x4cf8834399f8832d5c1ec35f20095f0, \ '5378: randombit(123) == 0x4cf8834399f8832d5c1ec35f20095f0'); state1 = srandom(123455432112345,1); print '5379: state1 = srandom(123455432112345,1)'; vrfy(randombit(123) == 0x437c9618d5a9c07d935b0ff7cef7346, \ '5380: randombit(123) == 0x437c9618d5a9c07d935b0ff7cef7346'); tmp = srandom(0,1); print '5381: tmp = srandom(0,1)'; vrfy(randombit(-123) == 123, '5382: randombit(-123) == 123'); vrfy(srandom() == state1, '5383: srandom() == state1'); tmp = srandom(0,2); print '5384: tmp = srandom(0,2)'; vrfy(randombit(123) == 0x7d53b2dbfe1edcb07df84f7fe96d5e9, \ '5385: randombit(123) == 0x7d53b2dbfe1edcb07df84f7fe96d5e9'); tmp = srandom(0,3); print '5386: tmp = srandom(0,3)'; vrfy(randombit(123) == 0x365cbae1adb9a706816abe3b64c1f2a, \ '5387: randombit(123) == 0x365cbae1adb9a706816abe3b64c1f2a'); tmp = srandom(0,4); print '5388: tmp = srandom(0,4)'; vrfy(randombit(123) == 0x63d9621736e59a3a5a8311117a1ef01, \ '5389: randombit(123) == 0x63d9621736e59a3a5a8311117a1ef01'); tmp = srandom(0,5); print '5390: tmp = srandom(0,5)'; vrfy(randombit(123) == 0x38d90517d6d532d1efb6eaf26bf927, \ '5391: randombit(123) == 0x38d90517d6d532d1efb6eaf26bf927'); tmp = srandom(0,6); print '5392: tmp = srandom(0,6)'; vrfy(randombit(123) == 0x146f2a1ce8cabcc313ab24f73747fbc, \ '5393: randombit(123) == 0x146f2a1ce8cabcc313ab24f73747fbc'); tmp = srandom(0,7); print '5394: tmp = srandom(0,7)'; vrfy(randombit(123) == 0x7a4a2b4ed817e5267358ea2979155d8, \ '5395: randombit(123) == 0x7a4a2b4ed817e5267358ea2979155d8'); tmp = srandom(0,8); print '5396: tmp = srandom(0,8)'; vrfy(randombit(123) == 0x5f30f211464854a37989cca3a8ecd0a, \ '5397: randombit(123) == 0x5f30f211464854a37989cca3a8ecd0a'); tmp = srandom(0,9); print '5398: tmp = srandom(0,9)'; vrfy(randombit(123) == 0x73aa8e572ee77682ae317804ed8d6e5, \ '5399: randombit(123) == 0x73aa8e572ee77682ae317804ed8d6e5'); tmp = srandom(0,10); print '5400: tmp = srandom(0,10)'; vrfy(randombit(123) == 0x49c7acca8f461ad2edf4cb7651f18d3, \ '5401: randombit(123) == 0x49c7acca8f461ad2edf4cb7651f18d3'); tmp = srandom(0,11); print '5402: tmp = srandom(0,11)'; vrfy(randombit(123) == 0x6042e2169a73140ffab1881df99a0ee, \ '5403: randombit(123) == 0x6042e2169a73140ffab1881df99a0ee'); tmp = srandom(0,12); print '5404: tmp = srandom(0,12)'; vrfy(randombit(123) == 0x7b98097947d478611d96f4d7a1cd2af, \ '5405: randombit(123) == 0x7b98097947d478611d96f4d7a1cd2af'); tmp = srandom(0,13); print '5406: tmp = srandom(0,13)'; vrfy(randombit(123) == 0x12324fd76d7a4a5a979765be2d57cfa, \ '5407: randombit(123) == 0x12324fd76d7a4a5a979765be2d57cfa'); tmp = srandom(0,14); print '5408: tmp = srandom(0,14)'; vrfy(randombit(123) == 0x377ff9ef04ee24887984995f91489a3, \ '5409: randombit(123) == 0x377ff9ef04ee24887984995f91489a3'); tmp = srandom(0,15); print '5410: tmp = srandom(0,15)'; vrfy(randombit(123) == 0x7db2b6245c5a24a1a52f74c8f828c6f, \ '5411: randombit(123) == 0x7db2b6245c5a24a1a52f74c8f828c6f'); tmp = srandom(0,16); print '5412: tmp = srandom(0,16)'; vrfy(randombit(123) == 0x5958e6cc460c28a5e741706fd442f12, \ '5413: randombit(123) == 0x5958e6cc460c28a5e741706fd442f12'); tmp = srandom(0,17); print '5414: tmp = srandom(0,17)'; vrfy(randombit(123) == 0x68c40ccf3805b2734d0d2881ca268d, \ '5415: randombit(123) == 0x68c40ccf3805b2734d0d2881ca268d'); tmp = srandom(0,18); print '5416: tmp = srandom(0,18)'; vrfy(randombit(123) == 0x4afc6cd3b9e14dadc5b75c6a81602e5, \ '5417: randombit(123) == 0x4afc6cd3b9e14dadc5b75c6a81602e5'); tmp = srandom(0,19); print '5418: tmp = srandom(0,19)'; vrfy(randombit(123) == 0x3ea4d30abf7da6596d2425e0a9a6348, \ '5419: randombit(123) == 0x3ea4d30abf7da6596d2425e0a9a6348'); tmp = srandom(0,20); print '5420: tmp = srandom(0,20)'; vrfy(randombit(123) == 0x77f848c70d4622ed41956eceb3f15f6, \ '5421: randombit(123) == 0x77f848c70d4622ed41956eceb3f15f6'); vrfy(randombit(123) == 0x5bfa034925acaf7ad5ba5d8f7f32369, \ '5422: randombit(123) == 0x5bfa034925acaf7ad5ba5d8f7f32369'); vrfy(randombit(123) == 0x761100a4cecbdac8c8d539dee0e278e, \ '5423: randombit(123) == 0x761100a4cecbdac8c8d539dee0e278e'); tmp = srandom(7^23+19,2); print '5424: tmp = srandom(7^23+19,2)'; vrfy(randombit(123) == 0x89b7ec9413e8af84a0c64ffc64d5a8, \ '5425: randombit(123) == 0x89b7ec9413e8af84a0c64ffc64d5a8'); tmp = srandom(7^23+19,3); print '5426: tmp = srandom(7^23+19,3)'; vrfy(randombit(123) == 0x7a2b8a6ca93a29deb1c3a674a30bf26, \ '5427: randombit(123) == 0x7a2b8a6ca93a29deb1c3a674a30bf26'); tmp = srandom(7^23+19,4); print '5428: tmp = srandom(7^23+19,4)'; vrfy(randombit(123) == 0x5425c6614dffcc0f376de4e9355c7df, \ '5429: randombit(123) == 0x5425c6614dffcc0f376de4e9355c7df'); tmp = srandom(7^23+19,5); print '5430: tmp = srandom(7^23+19,5)'; vrfy(randombit(123) == 0x70fca502499fa3717e346df5438886d, \ '5431: randombit(123) == 0x70fca502499fa3717e346df5438886d'); tmp = srandom(7^23+19,6); print '5432: tmp = srandom(7^23+19,6)'; vrfy(randombit(123) == 0x6ff886ac0918ad503290544af2cbd03, \ '5433: randombit(123) == 0x6ff886ac0918ad503290544af2cbd03'); tmp = srandom(7^23+19,7); print '5434: tmp = srandom(7^23+19,7)'; vrfy(randombit(123) == 0x5747d8c33d6d6dc53357779dffcc430, \ '5435: randombit(123) == 0x5747d8c33d6d6dc53357779dffcc430'); tmp = srandom(7^23+19,8); print '5436: tmp = srandom(7^23+19,8)'; vrfy(randombit(123) == 0x12769f65324d5e7986120b0caf071ad, \ '5437: randombit(123) == 0x12769f65324d5e7986120b0caf071ad'); tmp = srandom(7^23+19,9); print '5438: tmp = srandom(7^23+19,9)'; vrfy(randombit(123) == 0x3f94d3585b986539158f6ccd97d261e, \ '5439: randombit(123) == 0x3f94d3585b986539158f6ccd97d261e'); tmp = srandom(7^23+19,10); print '5440: tmp = srandom(7^23+19,10)'; vrfy(randombit(123) == 0x12874c359fffc6c0eda2aebfea97c71, \ '5441: randombit(123) == 0x12874c359fffc6c0eda2aebfea97c71'); tmp = srandom(7^23+19,11); print '5442: tmp = srandom(7^23+19,11)'; vrfy(randombit(123) == 0x7e0480a70c6f32f6594db8fd58ada7, \ '5443: randombit(123) == 0x7e0480a70c6f32f6594db8fd58ada7'); tmp = srandom(7^23+19,12); print '5444: tmp = srandom(7^23+19,12)'; vrfy(randombit(123) == 0x7f900aa8c7b9dacb6bf4ca0f5f81cb8, \ '5445: randombit(123) == 0x7f900aa8c7b9dacb6bf4ca0f5f81cb8'); tmp = srandom(7^23+19,13); print '5446: tmp = srandom(7^23+19,13)'; vrfy(randombit(123) == 0x39311c5aa41e42bb5d7807bdb60aecc, \ '5447: randombit(123) == 0x39311c5aa41e42bb5d7807bdb60aecc'); tmp = srandom(7^23+19,14); print '5448: tmp = srandom(7^23+19,14)'; vrfy(randombit(123) == 0x508bc8c5bd4555262b7ecd32a1ecd8e, \ '5449: randombit(123) == 0x508bc8c5bd4555262b7ecd32a1ecd8e'); tmp = srandom(7^23+19,15); print '5450: tmp = srandom(7^23+19,15)'; vrfy(randombit(123) == 0x442d2076b8d58d3815841180e8401b6, \ '5451: randombit(123) == 0x442d2076b8d58d3815841180e8401b6'); tmp = srandom(7^23+19,16); print '5452: tmp = srandom(7^23+19,16)'; vrfy(randombit(123) == 0x38db53974de9d3eea82a6ba35d2dc53, \ '5453: randombit(123) == 0x38db53974de9d3eea82a6ba35d2dc53'); tmp = srandom(7^23+19,17); print '5454: tmp = srandom(7^23+19,17)'; vrfy(randombit(123) == 0x42c1d9d86c9c67acb518ee008ce8f38, \ '5455: randombit(123) == 0x42c1d9d86c9c67acb518ee008ce8f38'); tmp = srandom(7^23+19,18); print '5456: tmp = srandom(7^23+19,18)'; vrfy(randombit(123) == 0x10dc81d7ef0a7aeb4aea1d4ac1fac2a, \ '5457: randombit(123) == 0x10dc81d7ef0a7aeb4aea1d4ac1fac2a'); tmp = srandom(7^23+19,19); print '5458: tmp = srandom(7^23+19,19)'; vrfy(randombit(123) == 0x469f8d91b643e0bcc4b5d5c2fe61cfb, \ '5459: randombit(123) == 0x469f8d91b643e0bcc4b5d5c2fe61cfb'); tmp = srandom(7^23+19,20); print '5460: tmp = srandom(7^23+19,20)'; vrfy(randombit(123) == 0x7f056e87cfcbe04a072e17502ef38f5, \ '5461: randombit(123) == 0x7f056e87cfcbe04a072e17502ef38f5'); vrfy(randombit(123) == 0x5d10d7665e56dee0ec5ea7d918ba073, \ '5462: randombit(123) == 0x5d10d7665e56dee0ec5ea7d918ba073'); vrfy(randombit(123) == 0x2058f802dd42b3aee4e734eacc13057, \ '5463: randombit(123) == 0x2058f802dd42b3aee4e734eacc13057'); /* test seed() as best as we can */ vrfy(seed() >= 0, '5464: seed() >= 0'); vrfy(seed() < 2^64, '5465: seed() < 2^64'); vrfy(israndom(srandom(seed())), '5466: israndom(srandom(seed()))'); print '5467: Ending test_random'; } print '137: parsed test_random()'; /* * test_newsyn - test new command completion syntax and scope rules */ for (s5500 = 0, i = 0; i < 5; i++) s5500 += i; print "138: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;"; vrfy(s5500 == 10, '139: s5500 == 10'); vrfy(i == 5, '140: i == 5'); for (s5500 = 0, i = 0; i < 9; i++) { s5500 += i; } print "141: for (s5500 = 0, i = 0; i < 9; i++) { s5500 += i; }"; vrfy(s5500 == 36, '142: s5500 == 36'); vrfy(i == 9, '143: i == 9'); { local i; for (s5500 = 0, i = 0; i < 10; i++) s5500 += i; vrfy(s5500 == 45, '144: s5500 == 45'); vrfy(i == 10, '145: i == 10'); } print "146: { local i; for (s5500 = 0, i = 0; i < 10; i++) s5500 += i; ... }"; vrfy(s5500 == 45, '147: s5500 == 45'); vrfy(i == 9, '148: i == 9'); /**/ define test_newsyn() { local i; /* loop counter */ print '5500: Beginning test_newsyn'; /* * check basic for loop completion and scoping */ for (s5500 = 0, i = 0; i < 5; i++) s5500 += i; print "5501: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;"; vrfy(s5500 == 10, '5502: s5500 == 10'); vrfy(i == 5, '5503: i == 5'); /**/ for (s5500 = 0, i = 0; i < 6; i++) { s5500 += i; } print "5504: for (s5500 = 0, i = 0; i < 6; i++) { s5500 += i; }"; vrfy(s5500 == 15, '5505: s5500 == 15'); vrfy(i == 6, '5506: i == 6'); /**/ for (s5500 = 0, i = 0; i < 3; i++) { s5500 += i; } print "5507: for (s5500 = 0, i = 0; i < 3; i++) { s5500 += i; }"; vrfy(s5500 == 3, '5508: s5500 == 3'); vrfy(i == 3, '5509: i == 3'); /**/ { local i; for (s5500 = 0, i = 0; i < 11; i++) s5500 += i; vrfy(s5500 == 55, '5510: s5500 == 45'); vrfy(i == 11, '5511: i == 11'); } print "5512: { local i; for (s5500 = 0, i = 0; i < 10; i++) s5500 += i; ... }"; vrfy(s5500 == 55, '5513: s5500 == 55'); vrfy(i == 11, '5514: i == 11'); /* * test completion of while loops */ i = 0; print '5515: i = 0'; s5500 = 0; print '5516: s5500 = 0'; while (++i < 4) s5500 += i; print "5517: while (++i < 4) s5500 += i;"; vrfy(s5500 == 6, '5518: s5500 == 6'); vrfy(i == 4, '5519: i == 4'); /**/ i = 0; print '5520: i = 0'; s5500 = 0; print '5521: s5500 = 0'; while (++i < 7) { s5500 += i; } print "5522: while (++i < 7) { s5500 += i; }"; vrfy(s5500 == 21, '5523: s5500 == 21'); vrfy(i == 7, '5524: i == 7'); /**/ i = 0; print '5525: i = 0'; s5500 = 0; print '5526: s5500 = 0'; while (++i < 8) { s5500 += i; } print "5527: while (++i < 8) { s5500 += i; }"; vrfy(s5500 == 28, '5528: s5500 == 28'); vrfy(i == 8, '5529: i == 8'); /* * test completion of do-while loops */ i = 0; print '5530: i = 0'; s5500 = 0; print '5531: s5500 = 0'; do s5500 += i; while (++i < 12); print "5532: do s5500 += i; while (++i < 12);"; vrfy(s5500 == 66, '5533: s5500 == 66'); vrfy(i == 12, '5534: i == 12'); /**/ i = 0; print '5535: i = 0'; s5500 = 0; print '5536: s5500 = 0'; do { s5500 += i; } while (++i < 14) print "5537: do { s5500 += i; } while (++i < 14);"; vrfy(s5500 == 91, '5538: s5500 == 91'); vrfy(i == 14, '5539: i == 14'); /**/ i = 0; print '5540: i = 0'; s5500 = 0; print '5541: s5500 = 0'; do { s5500 += i; } while (++i < 13) ; print "5542: do { s5500 += i; } while (++i < 13);"; vrfy(s5500 == 78, '5543: s5500 == 78'); vrfy(i == 13, '5544: i == 13'); /* * test the completion of switch */ switch (i) { case 12: prob("switch showed i was 12 instead of 13"); break; case 13: vrfy(i == 13, '5545: i == 13'); break; default: prob("switch showed i was something other than 13"); break; } switch ( i ) { case 1 : prob( "switch showed i was 1 instead of 13" ) ; break ; case 2 : prob( "switch showed i was 2 instead of 13" ) ; break ; default : vrfy ( i == 13 , '5546: i == 13' ) ; } print '5547: Ending test_newsyn'; } print '149: parsed test_newsyn()'; vrfy(s5500 == 45, '150: s5500 == 45'); vrfy(i == 9, '151: i == 9'); /* * test_commaeq - test changes to , and = */ obj xx5600 {} xx5600; print '152: obj xx5600 {} xx5600'; define xx5600_print() = printf("xx"); print '153: xx5600_print() = printf("xx")'; /**/ define test_commaeq() { local i; local A, B, C, D; local a5600 = 0, b5600 = 0; obj xy5600 {x, y}; /* * Calculations with i */ print '5600: Beginning test_commaeq'; i = 5; print '5601: i = 5'; vrfy(i == 5, '5602: i == 5'); i += 2 *= 3 -= 1; print '5603: i += 2 *= 3 -= 1'; vrfy(i == 20, '5604: i == 20'); ++i /= 7; print '5607: ++i /= 7'; vrfy(i == 3, '5608: i == 3'); /* * xx5600 object type */ mat A[3] = {1,2,xx5600}; print '5609: mat A[3] = {1,2,xx5600}'; vrfy(A[2] == xx5600, '5610: A[2] == xx5600'); vrfy(strprintf("%d", xx5600) == "xx", '5611: strprintf("%d", xx5600) == "xx"'); /* * xy5600 object type */ obj xy5600 A = {1, 2} = {3, 4}; print '5612: obj xy5600 A = {1, 2} = {3, 4}'; vrfy(A.x == 3, '5613: A.x == 3'); vrfy(A.y == 4, '5614: A.y == 4'); obj xy5600 B = {A,A}; print '5613: obj xy5600 B = {A,A}'; vrfy(B.x.x == 3, '5615: B.x.x == 3'); vrfy(B.y.y == 4, '5616: B.y.y == 4'); obj xy5600 C; print '5617: obj xy5600 C'; C = {1, 2} = {C, C}; print '5618: C = {1, 2} = {C, C}'; vrfy(C.x.x == 1, '5619: C.x.x == 1'); vrfy(C.y.x.y == 2, '5620: C.y.x.y == 2'); D = 7; print '5621: D = 7'; obj xy5600 D = {1,2} = {D,D}; print '5622: obj xy5600 D = {1,2} = {D,D}'; vrfy(D.x == 7, '5623: D.x == 7'); vrfy(D.y == 7, '5624: D.y == 7'); /* * matrix assignment */ mat A[3] = {1,2,3}, B[2] = {1,2}; print '5625: mat A[3] = {1,2,3}, B[2] = {1,2}'; vrfy(A[0] == 1, '5626: A[0] == 1'); vrfy(B[1] == 2, '5627: B[1] == 2'); /* * misc = and , expressions */ vrfy(((a5600 = 2, b5600) = 3) && a5600 + b5600 == 5, '5628: ((a5600 = 2, b5600) = 3) && a5600 + b5600 == 5'); vrfy((2 ? a5600 : b5600 = 4) && a5600 == 4, '5629: (2 ? a5600 : b5600 = 4) && a5600 == 4'); vrfy((0 ? a5600 : b5600 = 5) && b5600 == 5, '5630: (0 ? a5600 : b5600 = 5) && b5600 == 5'); vrfy((a5600 || b5600 = 6) && a5600 == 6 && b5600 == 5, '5631: (a5600 || b5600 = 6) && a5600 == 6 && b5600 == 5'); vrfy((a5600 && b5600 = 7) && a5600 == 6 && b5600 == 7, '5632: (a5600 && b5600 = 7) && a5600 == 6 && b5600 == 7'); print '5633: Ending test_commaeq'; } print '155: parsed test_commaeq()'; /* * test_size - test what we can about sizes * * Since sizeof() and memsize() deal with machine specific sizes and * compiler structure layout issues, we cannot just determine if * these builtin values return a specific value. */ define test_size() { local z; /* test integer values */ local q; /* test rational values */ local c; /* test complex values */ local m; /* test matrix */ local l; /* test list */ local a; /* test association */ print '5700: Beginning test_size'; /* * 0, -1 and 1 values are reported as 0 sizeof */ vrfy(sizeof(0) == 0, '5701: sizeof(0) == 0'); vrfy(sizeof(1) == 0, '5702: sizeof(1) == 0'); vrfy(sizeof(-1) == 0, '5703: sizeof(-1) == 0'); z = 0; print '5704: z = 0'; vrfy(sizeof(z) == 0, '5705: sizeof(z) == 0'); z = 1; print '5706: z = 1'; vrfy(sizeof(z) == 0, '5707: sizeof(z) == 0'); z = -1; print '5708: z = -1'; vrfy(sizeof(z) == 0, '5709: sizeof(z) == 0'); /* * non-integer rationals are larger than integers */ q = 13/2; print '5710: q = 13/2'; vrfy(sizeof(13)*2 == sizeof(q), '5711: sizeof(13)*2 == sizeof(q)'); q = 13; print '5712: q = 13'; vrfy(sizeof(13) == sizeof(q), '5713: sizeof(13) == sizeof(q)'); q = (17^139 + 674) / (17^139 + 686); print '5714: q = (17^139 + 674) / (17^139 + 686)'; vrfy(sizeof(17^139 + 674)*2 == sizeof(q), '5715: sizeof(17^139 + 674)*2 == sizeof(q)'); /* * recipricals are the same size of their integer inverses */ q = 1/13; print '5716: q = 1/13'; vrfy(sizeof(13) == sizeof(q), '5717: sizeof(13) == sizeof(q)'); q = 1/(17^139 + 674); print '5718: q = 1/(17^139 + 674)'; vrfy(sizeof(17^139 + 674) == sizeof(q), '5717: sizeof(17^139 + 674) == sizeof(q)'); /* * negative values are the same size as positive values */ vrfy(sizeof(17^139 + 674) == sizeof(-q), '5718: sizeof(17^139 + 674) == sizeof(-q)'); vrfy(sizeof(-(17^139 + 674)) == sizeof(-q), '5719: sizeof(-(17^139 + 674)) == sizeof(-q)'); q = 1/-13; print '5720: q = 1/-13'; vrfy(sizeof(13) == sizeof(q), '5721: sizeof(13) == sizeof(q)'); /* * complex values with a real or imaginary part of 0, 1 or -1 * are the same size as rationals */ c = 0 + 4i; print '5722: c = 0 + 4i'; vrfy(sizeof(3) == sizeof(c), '5723: sizeof(3) == sizeof(c)'); c = 3 + 0i; print '5724: c = 3 + 0i'; vrfy(sizeof(3) == sizeof(c), '5725: sizeof(3) == sizeof(c)'); c = 1 + 4i; print '5726: c = 1 + 4i'; vrfy(sizeof(3) == sizeof(c), '5727: sizeof(3) == sizeof(c)'); c = 3 + 1i; print '5728: c = 3 + 1i'; vrfy(sizeof(3) == sizeof(c), '5729: sizeof(3) == sizeof(c)'); c = -1 + 4i; print '5730: c = -1 + 4i'; vrfy(sizeof(3) == sizeof(c), '5731: sizeof(3) == sizeof(c)'); c = 3 + -1i; print '5732: c = 3 + -1i'; vrfy(sizeof(3) == sizeof(c), '5733: sizeof(3) == sizeof(c)'); /* * general complex values are twice the size as rationals */ c = 3 + 4i; print '5734: c = 3 + 4i'; vrfy(sizeof(3)*2 == sizeof(c), '5735: sizeof(3)*2 == sizeof(c)'); z = 17^139 + 686; print '5736: z = 17^139 + 686'; c = z + z*1i; print '5737: c = z + z*1i'; vrfy(sizeof(z)*2 == sizeof(c), '5738: sizeof(z)*2 == sizeof(c)'); q = 1/(17^139 + 674); print '5739: q = 1/(17^139 + 674)'; c = q + q*1i; print '5740: c = q + q*1i'; vrfy(sizeof(q)*2 == sizeof(c), '5741: sizeof(q)*2 == sizeof(c)'); c = (z*q) + (1/(z*q))*1i; print '5742: c = (z*q) + (1/(z*q))*1i'; vrfy(sizeof(z*q)*2 == sizeof(c), '5743: sizeof(z*q)*2 == sizeof(c)'); vrfy(sizeof(z)*4 == sizeof(c), '5744: sizeof(z)*4 == sizeof(c)'); vrfy(sizeof(q)*4 == sizeof(c), '5745: sizeof(q)*4 == sizeof(c)'); /* * size of numeric values is always 1 */ vrfy(size(0) == 1, '5746: size(0) == 1'); vrfy(size(1) == 1, '5747: size(1) == 1'); vrfy(size(13^10) == 1, '5748: size(13^10) == 1'); vrfy(size(z) == 1, '5749: size(z) == 1'); vrfy(size(q) == 1, '5750: size(q) == 1'); vrfy(size(c) == 1, '5751: size(c) == 1'); /* * size of a matrix is the sum of the sizes of the elements * sizeof of a matrix is the sum of the sizeofs of the elements */ mat m[] = {z,q,c}; print '5752: mat m[] = {z,q,c}'; vrfy(size(m) == size(z)+size(q)+size(c), '5753: size(m) == size(z)+size(q)+size(c)'); vrfy(sizeof(m) == sizeof(z)+sizeof(q)+sizeof(c), '5754: sizeof(m) == sizeof(z)+sizeof(q)+sizeof(c)'); /* * size of a list is the number of elements * sizeof of a list is the sum of the sizeof's of the elements */ l = list(z,q,c,m); print '5755: list(z,q,c,m)'; vrfy(size(l) == 4, '5756: size(l) == 4'); vrfy(sizeof(l) == 2*sizeof(m), '5757: sizeof(l) == 2*sizeof(m)'); /* * size of an assoc is the number of elements * sizeof of an assoc is the sum of the sizeof's of the elements */ a = assoc(); print '5758: a = assoc()'; a["z"] = z+1; print '5759: a["z"] = z+1'; a["q"] = q+2; print '5760: a["q"] = q+2'; a["c"] = c+3; print '5761: a["c"] = c+3'; a[m] = m; print '5762: a[m] = m'; a[l] = l; print '5763: a[l] = l'; vrfy(size(a) == 5, '5764: size(a) == 5'); vrfy(sizeof(a) == 25*sizeof(z), '5765: sizeof(a) == 25*sizeof(z)'); /* * about all we can say about memsize is that it will always be * larger than sizeof */ vrfy(sizeof(z) < memsize(z), '5766: sizeof(z) < memsize(z)'); vrfy(sizeof(q) < memsize(q), '5767: sizeof(q) < memsize(q)'); vrfy(sizeof(c) < memsize(c), '5768: sizeof(c) < memsize(c)'); vrfy(sizeof(m) < memsize(m), '5769: sizeof(m) < memsize(m)'); vrfy(sizeof(l) < memsize(l), '5770: sizeof(l) < memsize(l)'); vrfy(sizeof(a) < memsize(a), '5771: sizeof(a) < memsize(a)'); print '5772: Ending test_size'; } print '156: parsed test_size()'; /* * test_assign - test assignment of constants and variables */ global A, B; /* A, B for "constants" */ print '157: global A, B'; global X5800, Y5800; /* X5800, Y5800 for "variables" */ print '158: global X5800, Y5800'; obj xy5800 {x, y}; print '159: obj xy5800 {x, y}'; /**/ define test_assign(base, work) { print base: ': Beginning test_assign'; /* * value assignments */ A = base+1; print base+1: ': A = base+1'; B = base+2; print base+2: ': B = base+2'; X5800 = base+3; print base+3: ': X5800 = base+3'; Y5800 = base+4; print base+4: ': Y5800 = base+4'; obj xy5800 A={1,2}, B={3,4}; print base+5: ': obj xy5800 A={1,2}, B={3,4}'; /* * test assignment */ X5800 = A; print base+6: ': X5800 = A'; if (work) { vrfy(X5800 == A, strprintf('%d: X5800 == A', base+7)); X5800 = Y5800 = B; print base+8: ': X5800 = Y5800 = B'; } else { vrfy(X5800 == B, strprintf('%d: X5800 == B', base+7)); X5800 = Y5800 = A; print base+8: ': X5800 = Y5800 = A'; } vrfy(X5800 == B, strprintf('%d: X5800 == B', base+9)); vrfy(Y5800 == B, strprintf('%d: Y5800 == B', base+10)); print base+11: ': Ending test_assign'; } print '160: test_assign()'; /* * test_is - test is functions */ vrfy(isobjtype("xy5900") == 0, '161: isobjtype("xy5900") == 0'); obj xy5900 {x, y}; print '162: obj xy5900 {x, y}'; vrfy(isobjtype("xy5900") == 1, '163: isobjtype("xy5900") == 1'); /**/ vrfy(isdefined("fun5900") == 0, '164: isdefined("fun5900") == 0'); define fun5900() { return 1; }; print '165: define fun5900() { return 1; }'; vrfy(isdefined("fun5900") == 2, '166: isdefined("fun5900") == 2'); undefine fun5900; vrfy(isdefined("fun5900") == 0, '167: isdefined("fun5900") == 0'); /**/ define test_is() { local loc; /* unassigned local variable */ local a; /* assoc */ local ofd; /* open file descriptor */ local cfd; /* closed file descriptor */ local blk; /* unnamed block */ local nblk; /* named block */ local cfg; /* config state */ local serr; /* system value */ local nerr; /* new error value */ local odd; /* odd integer */ local even; /* even integer that is 10 times odd */ local hash; /* sha hash value */ local id; /* identity matrix */ local list; /* list value */ local matrix; /* non-identity matrix */ local nul; /* null value */ local object; /* object */ local rand; /* rand seed */ local random; /* random seed */ local real; /* real non-intger value */ local prime; /* odd prime */ local square; /* square of an odd prime */ local string; /* string */ local com; /* complex value */ print '5900: Beginning test_is'; /* * setup values */ a = assoc(); print '5901: a = assoc()'; ofd = fopen("/dev/null", "r"); print '5902: ofd = fopen("/dev/null", "r")'; cfd = fopen("/dev/null", "r"); print '5903: cfd = fopen("/dev/null", "r")'; fclose(cfd); print '5904: fclose(cfd)'; blk = blk(); print '5905: blk = blk()'; nblk = blk("blk5900"); print '5906: nblk = blk("blk5900")'; cfg = config("all"); print '5907: cfg = config("all")'; ecnt += 2; print '5908: ecnt += 2'; serr = error(1); print '5909: serr = error(1)'; nerr = newerror("curds"); print '5910: nerr = newerror("curds")'; odd = 23209; print '5911: odd = 23209'; even = odd*10; print '5912: even = odd*10'; hash = sha(); print '5913: hash = sha()'; mat id[3,3] = {1,0,0,0,1,0,0,0,1}; print '5914: id[3,3] = {1,0,0,0,1,0,0,0,1}'; list = list(2,3,4); print '5915: list = list(2,3,4)'; mat matrix[2]; print '5916: mat matrix[2]'; nul = null(); print '5917: nul = null()'; obj xy5900 object; print '5918: obj xy5900 object'; rand = srand(0); print '5919: rand = srand(0)'; random = srandom(0); print '5920: random = srandom(0)'; real = 345.23045897; print '5921: real = 345.23045897'; prime = 3217; print '5922: prime = 3217'; square = prime^2; print '5923: square = prine^2'; string = "a string"; print '5924: string = "a string"'; com = 3+4i; print '5925: com = 3+4i'; print '5926: test unused'; print '5927: test unused'; print '5928: test unused'; print '5929: test unused'; /* * test isassoc */ vrfy(isassoc(loc) == 0, '5930: isassoc(loc) == 0'); vrfy(isassoc(a) == 1, '5931: isassoc(a) == 1'); vrfy(isassoc(ofd) == 0, '5932: isassoc(ofd) == 0'); vrfy(isassoc(cfd) == 0, '5933: isassoc(cfd) == 0'); vrfy(isassoc(blk) == 0, '5934: isassoc(blk) == 0'); vrfy(isassoc(nblk) == 0, '5935: isassoc(nblk) == 0'); vrfy(isassoc(cfg) == 0, '5936: isassoc(cfg) == 0'); vrfy(isassoc(serr) == 0, '5937: isassoc(serr) == 0'); vrfy(isassoc(nerr) == 0, '5938: isassoc(nerr) == 0'); vrfy(isassoc(odd) == 0, '5939: isassoc(odd) == 0'); vrfy(isassoc(even) == 0, '5940: isassoc(even) == 0'); vrfy(isassoc(hash) == 0, '5941: isassoc(hash) == 0'); vrfy(isassoc(id) == 0, '5942: isassoc(id) == 0'); vrfy(isassoc(list) == 0, '5943: isassoc(list) == 0'); vrfy(isassoc(matrix) == 0, '5944: isassoc(matrix) == 0'); vrfy(isassoc(nul) == 0, '5945: isassoc(nul) == 0'); vrfy(isassoc(object) == 0, '5946: isassoc(object) == 0'); vrfy(isassoc(rand) == 0, '5947: isassoc(rand) == 0'); vrfy(isassoc(random) == 0, '5948: isassoc(random) == 0'); vrfy(isassoc(real) == 0, '5949: isassoc(real) == 0'); vrfy(isassoc(prime) == 0, '5950: isassoc(prime) == 0'); vrfy(isassoc(square) == 0, '5951: isassoc(square) == 0'); vrfy(isassoc(string) == 0, '5952: isassoc(string) == 0'); vrfy(isassoc(com) == 0, '5953: isassoc(com) == 0'); print '5954: test unused'; print '5955: test unused'; print '5955: test unused'; print '5956: test unused'; print '5957: test unused'; print '5958: test unused'; print '5959: test unused'; /* * test isatty */ vrfy(isatty(loc) == 0, '5960: isatty(loc) == 0'); vrfy(isatty(a) == 0, '5961: isatty(a) == 0'); vrfy(isatty(ofd) == 0, '5962: isatty(ofd) == 0'); vrfy(isatty(cfd) == 0, '5963: isatty(cfd) == 0'); vrfy(isatty(blk) == 0, '5964: isatty(blk) == 0'); vrfy(isatty(nblk) == 0, '5965: isatty(nblk) == 0'); vrfy(isatty(cfg) == 0, '5966: isatty(cfg) == 0'); vrfy(isatty(serr) == 0, '5967: isatty(serr) == 0'); vrfy(isatty(nerr) == 0, '5968: isatty(nerr) == 0'); vrfy(isatty(odd) == 0, '5969: isatty(odd) == 0'); vrfy(isatty(even) == 0, '5970: isatty(even) == 0'); vrfy(isatty(hash) == 0, '5971: isatty(hash) == 0'); vrfy(isatty(id) == 0, '5972: isatty(id) == 0'); vrfy(isatty(list) == 0, '5973: isatty(list) == 0'); vrfy(isatty(matrix) == 0, '5974: isatty(matrix) == 0'); vrfy(isatty(nul) == 0, '5975: isatty(nul) == 0'); vrfy(isatty(object) == 0, '5976: isatty(object) == 0'); vrfy(isatty(rand) == 0, '5977: isatty(rand) == 0'); vrfy(isatty(random) == 0, '5978: isatty(random) == 0'); vrfy(isatty(real) == 0, '5979: isatty(real) == 0'); vrfy(isatty(prime) == 0, '5980: isatty(prime) == 0'); vrfy(isatty(square) == 0, '5981: isatty(square) == 0'); vrfy(isatty(string) == 0, '5982: isatty(string) == 0'); vrfy(isatty(com) == 0, '5983: isatty(com) == 0'); print '5984: test disabled due to stdin dependency'; /* if we pipe to awk (for make chk), stdout and stderr are not ttys */ print '5985: test unused'; print '5986: test unused'; vrfy(isatty(files(3)) == 0, '5987: isatty(files(3)) == 0'); print '5988: test unused'; print '5989: test unused'; /* * test isblk */ vrfy(isblk(loc) == 0, '5990: isblk(loc) == 0'); vrfy(isblk(a) == 0, '5991: isblk(a) == 0'); vrfy(isblk(ofd) == 0, '5992: isblk(ofd) == 0'); vrfy(isblk(cfd) == 0, '5993: isblk(cfd) == 0'); vrfy(isblk(blk) == 1, '5994: isblk(blk) == 1'); vrfy(isblk(nblk) == 2, '5995: isblk(nblk) == 2'); vrfy(isblk(cfg) == 0, '5996: isblk(cfg) == 0'); vrfy(isblk(serr) == 0, '5997: isblk(serr) == 0'); vrfy(isblk(nerr) == 0, '5998: isblk(nerr) == 0'); vrfy(isblk(odd) == 0, '5999: isblk(odd) == 0'); vrfy(isblk(even) == 0, '6000: isblk(even) == 0'); vrfy(isblk(hash) == 0, '6001: isblk(hash) == 0'); vrfy(isblk(id) == 0, '6002: isblk(id) == 0'); vrfy(isblk(list) == 0, '6003: isblk(list) == 0'); vrfy(isblk(matrix) == 0, '6004: isblk(matrix) == 0'); vrfy(isblk(nul) == 0, '6005: isblk(nul) == 0'); vrfy(isblk(object) == 0, '6006: isblk(object) == 0'); vrfy(isblk(rand) == 0, '6007: isblk(rand) == 0'); vrfy(isblk(random) == 0, '6008: isblk(random) == 0'); vrfy(isblk(real) == 0, '6009: isblk(real) == 0'); vrfy(isblk(prime) == 0, '6010: isblk(prime) == 0'); vrfy(isblk(square) == 0, '6011: isblk(square) == 0'); vrfy(isblk(string) == 0, '6012: isblk(string) == 0'); vrfy(isblk(com) == 0, '6013: isblk(com) == 0'); print '6014: test unused'; print '6015: test unused'; print '6015: test unused'; print '6016: test unused'; print '6017: test unused'; print '6018: test unused'; print '6019: test unused'; /* * test isconfig */ vrfy(isconfig(loc) == 0, '6020: isconfig(loc) == 0'); vrfy(isconfig(a) == 0, '6021: isconfig(a) == 0'); vrfy(isconfig(ofd) == 0, '6022: isconfig(ofd) == 0'); vrfy(isconfig(cfd) == 0, '6023: isconfig(cfd) == 0'); vrfy(isconfig(blk) == 0, '6024: isconfig(blk) == 0'); vrfy(isconfig(nblk) == 0, '6025: isconfig(nblk) == 0'); vrfy(isconfig(cfg) == 1, '6026: isconfig(cfg) == 1'); vrfy(isconfig(serr) == 0, '6027: isconfig(serr) == 0'); vrfy(isconfig(nerr) == 0, '6028: isconfig(nerr) == 0'); vrfy(isconfig(odd) == 0, '6029: isconfig(odd) == 0'); vrfy(isconfig(even) == 0, '6030: isconfig(even) == 0'); vrfy(isconfig(hash) == 0, '6031: isconfig(hash) == 0'); vrfy(isconfig(id) == 0, '6032: isconfig(id) == 0'); vrfy(isconfig(list) == 0, '6033: isconfig(list) == 0'); vrfy(isconfig(matrix) == 0, '6034: isconfig(matrix) == 0'); vrfy(isconfig(nul) == 0, '6035: isconfig(nul) == 0'); vrfy(isconfig(object) == 0, '6036: isconfig(object) == 0'); vrfy(isconfig(rand) == 0, '6037: isconfig(rand) == 0'); vrfy(isconfig(random) == 0, '6038: isconfig(random) == 0'); vrfy(isconfig(real) == 0, '6039: isconfig(real) == 0'); vrfy(isconfig(prime) == 0, '6040: isconfig(prime) == 0'); vrfy(isconfig(square) == 0, '6041: isconfig(square) == 0'); vrfy(isconfig(string) == 0, '6042: isconfig(string) == 0'); vrfy(isconfig(com) == 0, '6043: isconfig(com) == 0'); print '6044: test unused'; print '6045: test unused'; print '6045: test unused'; print '6046: test unused'; print '6047: test unused'; print '6048: test unused'; print '6049: test unused'; /* * test isdefined */ vrfy(isdefined("loc") == 0, '6050: isdefined("loc") == 0'); vrfy(isdefined("a") == 0, '6051: isdefined("a") == 0'); vrfy(isdefined("ofd") == 0, '6052: isdefined("ofd") == 0'); vrfy(isdefined("cfd") == 0, '6053: isdefined("cfd") == 0'); vrfy(isdefined("blk") == 1, '6054: isdefined("blk") == 1'); vrfy(isdefined("nblk") == 0, '6055: isdefined("nblk") == 0'); vrfy(isdefined("cfg") == 0, '6056: isdefined("cfg") == 0'); vrfy(isdefined("serr") == 0, '6057: isdefined("serr") == 0'); vrfy(isdefined("nerr") == 0, '6058: isdefined("nerr") == 0'); vrfy(isdefined("odd") == 0, '6059: isdefined("odd") == 0'); vrfy(isdefined("even") == 0, '6060: isdefined("even") == 0'); vrfy(isdefined("hash") == 1, '6061: isdefined("hash") == 1'); vrfy(isdefined("id") == 0, '6062: isdefined("id") == 0'); vrfy(isdefined("list") == 1, '6063: isdefined("list") == 1'); vrfy(isdefined("matrix") == 0, '6064: isdefined("matrix") == 0'); vrfy(isdefined("nul") == 0, '6065: isdefined("nul") == 0'); vrfy(isdefined("object") == 0, '6066: isdefined("object") == 0'); vrfy(isdefined("rand") == 1, '6067: isdefined("rand") == 1'); vrfy(isdefined("random") == 1, '6068: isdefined("random") == 1'); vrfy(isdefined("real") == 0, '6069: isdefined("real") == 0'); vrfy(isdefined("prime") == 0, '6070: isdefined("prime") == 0'); vrfy(isdefined("square") == 0, '6071: isdefined("square") == 0'); vrfy(isdefined("string") == 0, '6072: isdefined("string") == 0'); vrfy(isdefined("abs") == 1, '6073: isdefined("abs") == 1'); vrfy(isdefined("notafunc") == 0, '6074: isdefined("notafunc") == 0'); vrfy(isdefined("com") == 0, '6075: isdefined("com") == 0'); print '6076: test unused'; print '6077: test unused'; print '6078: test unused'; print '6079: test unused'; /* * test iserror */ vrfy(iserror(loc) == 0, '6080: iserror(loc) == 0'); vrfy(iserror(a) == 0, '6081: iserror(a) == 0'); vrfy(iserror(ofd) == 0, '6082: iserror(ofd) == 0'); vrfy(iserror(cfd) == 0, '6083: iserror(cfd) == 0'); vrfy(iserror(blk) == 0, '6084: iserror(blk) == 0'); vrfy(iserror(nblk) == 0, '6085: iserror(nblk) == 0'); vrfy(iserror(cfg) == 0, '6086: iserror(cfg) == 0'); vrfy(iserror(serr) == 1, '6087: iserror(serr) == 1'); vrfy(iserror(nerr) > 0, '6088: iserror(nerr) > 0'); vrfy(iserror(odd) == 0, '6089: iserror(odd) == 0'); vrfy(iserror(even) == 0, '6090: iserror(even) == 0'); vrfy(iserror(hash) == 0, '6091: iserror(hash) == 0'); vrfy(iserror(id) == 0, '6092: iserror(id) == 0'); vrfy(iserror(list) == 0, '6093: iserror(list) == 0'); vrfy(iserror(matrix) == 0, '6094: iserror(matrix) == 0'); vrfy(iserror(nul) == 0, '6095: iserror(nul) == 0'); vrfy(iserror(object) == 0, '6096: iserror(object) == 0'); vrfy(iserror(rand) == 0, '6097: iserror(rand) == 0'); vrfy(iserror(random) == 0, '6098: iserror(random) == 0'); vrfy(iserror(real) == 0, '6099: iserror(real) == 0'); vrfy(iserror(prime) == 0, '6100: iserror(prime) == 0'); vrfy(iserror(square) == 0, '6101: iserror(square) == 0'); vrfy(iserror(string) == 0, '6102: iserror(string) == 0'); vrfy(iserror(com) == 0, '6103: iserror(com) == 0'); print '6104: test unused'; print '6105: test unused'; print '6105: test unused'; print '6106: test unused'; print '6107: test unused'; print '6108: test unused'; print '6109: test unused'; /* * test iseven */ vrfy(iseven(loc) == 1, '6110: iseven(loc) == 1'); vrfy(iseven(a) == 0, '6111: iseven(a) == 0'); vrfy(iseven(ofd) == 0, '6112: iseven(ofd) == 0'); vrfy(iseven(cfd) == 0, '6113: iseven(cfd) == 0'); vrfy(iseven(blk) == 0, '6114: iseven(blk) == 0'); vrfy(iseven(nblk) == 0, '6115: iseven(nblk) == 0'); vrfy(iseven(cfg) == 0, '6116: iseven(cfg) == 0'); vrfy(iseven(serr) == 0, '6117: iseven(serr) == 0'); vrfy(iseven(nerr) == 0, '6118: iseven(nerr) == 0'); vrfy(iseven(odd) == 0, '6119: iseven(odd) == 0'); vrfy(iseven(even) == 1, '6120: iseven(even) == 1'); vrfy(iseven(hash) == 0, '6121: iseven(hash) == 0'); vrfy(iseven(id) == 0, '6122: iseven(id) == 0'); vrfy(iseven(list) == 0, '6123: iseven(list) == 0'); vrfy(iseven(matrix) == 0, '6124: iseven(matrix) == 0'); vrfy(iseven(nul) == 0, '6125: iseven(nul) == 0'); vrfy(iseven(object) == 0, '6126: iseven(object) == 0'); vrfy(iseven(rand) == 0, '6127: iseven(rand) == 0'); vrfy(iseven(random) == 0, '6128: iseven(random) == 0'); vrfy(iseven(real) == 0, '6129: iseven(real) == 0'); vrfy(iseven(prime) == 0, '6130: iseven(prime) == 0'); vrfy(iseven(square) == 0, '6131: iseven(square) == 0'); vrfy(iseven(string) == 0, '6132: iseven(string) == 0'); vrfy(iseven(com) == 0, '6133: iseven(com) == 0'); print '6134: test unused'; print '6135: test unused'; print '6135: test unused'; print '6136: test unused'; print '6137: test unused'; print '6138: test unused'; print '6139: test unused'; /* * test isfile */ vrfy(isfile(loc) == 0, '6140: isfile(loc) == 0'); vrfy(isfile(a) == 0, '6141: isfile(a) == 0'); vrfy(isfile(ofd) == 1, '6142: isfile(ofd) == 1'); vrfy(isfile(cfd) == 1, '6143: isfile(cfd) == 1'); vrfy(isfile(blk) == 0, '6144: isfile(blk) == 0'); vrfy(isfile(nblk) == 0, '6145: isfile(nblk) == 0'); vrfy(isfile(cfg) == 0, '6146: isfile(cfg) == 0'); vrfy(isfile(serr) == 0, '6147: isfile(serr) == 0'); vrfy(isfile(nerr) == 0, '6148: isfile(nerr) == 0'); vrfy(isfile(odd) == 0, '6149: isfile(odd) == 0'); vrfy(isfile(even) == 0, '6150: isfile(even) == 0'); vrfy(isfile(hash) == 0, '6151: isfile(hash) == 0'); vrfy(isfile(id) == 0, '6152: isfile(id) == 0'); vrfy(isfile(list) == 0, '6153: isfile(list) == 0'); vrfy(isfile(matrix) == 0, '6154: isfile(matrix) == 0'); vrfy(isfile(nul) == 0, '6155: isfile(nul) == 0'); vrfy(isfile(object) == 0, '6156: isfile(object) == 0'); vrfy(isfile(rand) == 0, '6157: isfile(rand) == 0'); vrfy(isfile(random) == 0, '6158: isfile(random) == 0'); vrfy(isfile(real) == 0, '6159: isfile(real) == 0'); vrfy(isfile(prime) == 0, '6160: isfile(prime) == 0'); vrfy(isfile(square) == 0, '6161: isfile(square) == 0'); vrfy(isfile(string) == 0, '6162: isfile(string) == 0'); vrfy(isfile(com) == 0, '6163: isfile(com) == 0'); vrfy(isfile(files(0)) == 1, '6164: isfile(files(0)) == 1'); vrfy(isfile(files(1)) == 1, '6165: isfile(files(1)) == 1'); vrfy(isfile(files(2)) == 1, '6166: isfile(files(2)) == 1'); vrfy(isfile(files(3)) == 1, '6167: isfile(files(3)) == 1'); print '6168: test unused'; print '6169: test unused'; /* * test ishash */ vrfy(ishash(loc) == 0, '6170: ishash(loc) == 0'); vrfy(ishash(a) == 0, '6171: ishash(a) == 0'); vrfy(ishash(ofd) == 0, '6172: ishash(ofd) == 0'); vrfy(ishash(cfd) == 0, '6173: ishash(cfd) == 0'); vrfy(ishash(blk) == 0, '6174: ishash(blk) == 0'); vrfy(ishash(nblk) == 0, '6175: ishash(nblk) == 0'); vrfy(ishash(cfg) == 0, '6176: ishash(cfg) == 0'); vrfy(ishash(serr) == 0, '6177: ishash(serr) == 0'); vrfy(ishash(nerr) == 0, '6178: ishash(nerr) == 0'); vrfy(ishash(odd) == 0, '6179: ishash(odd) == 0'); vrfy(ishash(even) == 0, '6180: ishash(even) == 0'); vrfy(ishash(hash) == 1, '6181: ishash(hash) == 1'); vrfy(ishash(id) == 0, '6182: ishash(id) == 0'); vrfy(ishash(list) == 0, '6183: ishash(list) == 0'); vrfy(ishash(matrix) == 0, '6184: ishash(matrix) == 0'); vrfy(ishash(nul) == 0, '6185: ishash(nul) == 0'); vrfy(ishash(object) == 0, '6186: ishash(object) == 0'); vrfy(ishash(rand) == 0, '6187: ishash(rand) == 0'); vrfy(ishash(random) == 0, '6188: ishash(random) == 0'); vrfy(ishash(real) == 0, '6189: ishash(real) == 0'); vrfy(ishash(prime) == 0, '6190: ishash(prime) == 0'); vrfy(ishash(square) == 0, '6191: ishash(square) == 0'); vrfy(ishash(string) == 0, '6192: ishash(string) == 0'); vrfy(ishash(com) == 0, '6193: ishash(com) == 0'); print '6194: test unused'; print '6195: test unused'; print '6196: test unused'; print '6197: test unused'; print '6198: test unused'; print '6199: test unused'; /* * test isident */ vrfy(isident(loc) == 0, '6200: isident(loc) == 0'); vrfy(isident(a) == 0, '6201: isident(a) == 0'); vrfy(isident(ofd) == 0, '6202: isident(ofd) == 0'); vrfy(isident(cfd) == 0, '6203: isident(cfd) == 0'); vrfy(isident(blk) == 0, '6204: isident(blk) == 0'); vrfy(isident(nblk) == 0, '6205: isident(nblk) == 0'); vrfy(isident(cfg) == 0, '6206: isident(cfg) == 0'); vrfy(isident(serr) == 0, '6207: isident(serr) == 0'); vrfy(isident(nerr) == 0, '6208: isident(nerr) == 0'); vrfy(isident(odd) == 0, '6209: isident(odd) == 0'); vrfy(isident(even) == 0, '6210: isident(even) == 0'); vrfy(isident(hash) == 0, '6211: isident(hash) == 0'); vrfy(isident(id) == 1, '6212: isident(id) == 1'); vrfy(isident(list) == 0, '6213: isident(list) == 0'); vrfy(isident(matrix) == 0, '6214: isident(matrix) == 0'); vrfy(isident(nul) == 0, '6215: isident(nul) == 0'); vrfy(isident(object) == 0, '6216: isident(object) == 0'); vrfy(isident(rand) == 0, '6217: isident(rand) == 0'); vrfy(isident(random) == 0, '6218: isident(random) == 0'); vrfy(isident(real) == 0, '6219: isident(real) == 0'); vrfy(isident(prime) == 0, '6220: isident(prime) == 0'); vrfy(isident(square) == 0, '6221: isident(square) == 0'); vrfy(isident(string) == 0, '6222: isident(string) == 0'); vrfy(isident(com) == 0, '6223: isident(com) == 0'); print '6224: test unused'; print '6225: test unused'; print '6226: test unused'; print '6227: test unused'; print '6228: test unused'; print '6229: test unused'; /* * test isint */ vrfy(isint(loc) == 1, '6230: isint(loc) == 1'); vrfy(isint(a) == 0, '6231: isint(a) == 0'); vrfy(isint(ofd) == 0, '6232: isint(ofd) == 0'); vrfy(isint(cfd) == 0, '6233: isint(cfd) == 0'); vrfy(isint(blk) == 0, '6234: isint(blk) == 0'); vrfy(isint(nblk) == 0, '6235: isint(nblk) == 0'); vrfy(isint(cfg) == 0, '6236: isint(cfg) == 0'); vrfy(isint(serr) == 0, '6237: isint(serr) == 0'); vrfy(isint(nerr) == 0, '6238: isint(nerr) == 0'); vrfy(isint(odd) == 1, '6239: isint(odd) == 1'); vrfy(isint(even) == 1, '6240: isint(even) == 1'); vrfy(isint(hash) == 0, '6241: isint(hash) == 0'); vrfy(isint(id) == 0, '6242: isint(id) == 0'); vrfy(isint(list) == 0, '6243: isint(list) == 0'); vrfy(isint(matrix) == 0, '6244: isint(matrix) == 0'); vrfy(isint(nul) == 0, '6245: isint(nul) == 0'); vrfy(isint(object) == 0, '6246: isint(object) == 0'); vrfy(isint(rand) == 0, '6247: isint(rand) == 0'); vrfy(isint(random) == 0, '6248: isint(random) == 0'); vrfy(isint(real) == 0, '6249: isint(real) == 0'); vrfy(isint(prime) == 1, '6250: isint(prime) == 1'); vrfy(isint(square) == 1, '6251: isint(square) == 1'); vrfy(isint(string) == 0, '6252: isint(string) == 0'); vrfy(isint(com) == 0, '6253: isint(com) == 0'); print '6254: test unused'; print '6255: test unused'; print '6255: test unused'; print '6256: test unused'; print '6257: test unused'; print '6258: test unused'; print '6259: test unused'; /* * test islist */ vrfy(islist(loc) == 0, '6260: islist(loc) == 0'); vrfy(islist(a) == 0, '6261: islist(a) == 0'); vrfy(islist(ofd) == 0, '6262: islist(ofd) == 0'); vrfy(islist(cfd) == 0, '6263: islist(cfd) == 0'); vrfy(islist(blk) == 0, '6264: islist(blk) == 0'); vrfy(islist(nblk) == 0, '6265: islist(nblk) == 0'); vrfy(islist(cfg) == 0, '6266: islist(cfg) == 0'); vrfy(islist(serr) == 0, '6267: islist(serr) == 0'); vrfy(islist(nerr) == 0, '6268: islist(nerr) == 0'); vrfy(islist(odd) == 0, '6269: islist(odd) == 0'); vrfy(islist(even) == 0, '6270: islist(even) == 0'); vrfy(islist(hash) == 0, '6271: islist(hash) == 0'); vrfy(islist(id) == 0, '6272: islist(id) == 0'); vrfy(islist(list) == 1, '6273: islist(list) == 1'); vrfy(islist(matrix) == 0, '6274: islist(matrix) == 0'); vrfy(islist(nul) == 0, '6275: islist(nul) == 0'); vrfy(islist(object) == 0, '6276: islist(object) == 0'); vrfy(islist(rand) == 0, '6277: islist(rand) == 0'); vrfy(islist(random) == 0, '6278: islist(random) == 0'); vrfy(islist(real) == 0, '6279: islist(real) == 0'); vrfy(islist(prime) == 0, '6280: islist(prime) == 0'); vrfy(islist(square) == 0, '6281: islist(square) == 0'); vrfy(islist(string) == 0, '6282: islist(string) == 0'); vrfy(islist(com) == 0, '6283: islist(com) == 0'); print '6284: test unused'; print '6255: test unused'; print '6285: test unused'; print '6286: test unused'; print '6287: test unused'; print '6288: test unused'; print '6289: test unused'; /* * test ismat */ vrfy(ismat(loc) == 0, '6290: ismat(loc) == 0'); vrfy(ismat(a) == 0, '6291: ismat(a) == 0'); vrfy(ismat(ofd) == 0, '6292: ismat(ofd) == 0'); vrfy(ismat(cfd) == 0, '6293: ismat(cfd) == 0'); vrfy(ismat(blk) == 0, '6294: ismat(blk) == 0'); vrfy(ismat(nblk) == 0, '6295: ismat(nblk) == 0'); vrfy(ismat(cfg) == 0, '6296: ismat(cfg) == 0'); vrfy(ismat(serr) == 0, '6297: ismat(serr) == 0'); vrfy(ismat(nerr) == 0, '6298: ismat(nerr) == 0'); vrfy(ismat(odd) == 0, '6299: ismat(odd) == 0'); vrfy(ismat(even) == 0, '6300: ismat(even) == 0'); vrfy(ismat(hash) == 0, '6301: ismat(hash) == 0'); vrfy(ismat(id) == 1, '6302: ismat(id) == 1'); vrfy(ismat(list) == 0, '6303: ismat(list) == 0'); vrfy(ismat(matrix) == 1, '6304: ismat(matrix) == 1'); vrfy(ismat(nul) == 0, '6305: ismat(nul) == 0'); vrfy(ismat(object) == 0, '6306: ismat(object) == 0'); vrfy(ismat(rand) == 0, '6307: ismat(rand) == 0'); vrfy(ismat(random) == 0, '6308: ismat(random) == 0'); vrfy(ismat(real) == 0, '6309: ismat(real) == 0'); vrfy(ismat(prime) == 0, '6310: ismat(prime) == 0'); vrfy(ismat(square) == 0, '6311: ismat(square) == 0'); vrfy(ismat(string) == 0, '6312: ismat(string) == 0'); vrfy(ismat(com) == 0, '6313: ismat(com) == 0'); print '6314: test unused'; print '6215: test unused'; print '6315: test unused'; print '6316: test unused'; print '6317: test unused'; print '6318: test unused'; print '6319: test unused'; /* * test ismult */ vrfy(ismult(odd,even) == 0, '6320: ismult(odd,even) == 0'); vrfy(ismult(even,odd) == 1, '6321: ismult(even,odd) == 1'); vrfy(ismult(odd,odd) == 1, '6322: ismult(odd,odd) == 1'); vrfy(ismult(even,prime) == 0, '6323: ismult(even,prime) == 0'); vrfy(ismult(square,prime) == 1, '6324: ismult(square,prime) == 1'); vrfy(ismult(real,prime) == 0, '6325: ismult(real,prime) == 0'); vrfy(ismult(real,real*34) == 0, '6326: ismult(real,real*34) == 0'); vrfy(ismult(real*34,real) == 1, '6327: ismult(real*34,real) == 1'); print '6328: test unused'; print '6329: test unused'; /* * test isnull */ vrfy(isnull(loc) == 0, '6330: isnull(loc) == 0'); vrfy(isnull(a) == 0, '6331: isnull(a) == 0'); vrfy(isnull(ofd) == 0, '6332: isnull(ofd) == 0'); vrfy(isnull(cfd) == 0, '6333: isnull(cfd) == 0'); vrfy(isnull(blk) == 0, '6334: isnull(blk) == 0'); vrfy(isnull(nblk) == 0, '6335: isnull(nblk) == 0'); vrfy(isnull(cfg) == 0, '6336: isnull(cfg) == 0'); vrfy(isnull(serr) == 0, '6337: isnull(serr) == 0'); vrfy(isnull(nerr) == 0, '6338: isnull(nerr) == 0'); vrfy(isnull(odd) == 0, '6339: isnull(odd) == 0'); vrfy(isnull(even) == 0, '6340: isnull(even) == 0'); vrfy(isnull(hash) == 0, '6341: isnull(hash) == 0'); vrfy(isnull(id) == 0, '6342: isnull(id) == 0'); vrfy(isnull(list) == 0, '6343: isnull(list) == 0'); vrfy(isnull(matrix) == 0, '6344: isnull(matrix) == 0'); vrfy(isnull(nul) == 1, '6345: isnull(nul) == 1'); vrfy(isnull(object) == 0, '6346: isnull(object) == 0'); vrfy(isnull(rand) == 0, '6347: isnull(rand) == 0'); vrfy(isnull(random) == 0, '6348: isnull(random) == 0'); vrfy(isnull(real) == 0, '6349: isnull(real) == 0'); vrfy(isnull(prime) == 0, '6350: isnull(prime) == 0'); vrfy(isnull(square) == 0, '6351: isnull(square) == 0'); vrfy(isnull(string) == 0, '6352: isnull(string) == 0'); vrfy(isnull(com) == 0, '6353: isnull(com) == 0'); print '6354: test unused'; print '6355: test unused'; print '6355: test unused'; print '6356: test unused'; print '6357: test unused'; print '6358: test unused'; print '6359: test unused'; /* * test isnum */ vrfy(isnum(loc) == 1, '6360: isnum(loc) == 1'); vrfy(isnum(a) == 0, '6361: isnum(a) == 0'); vrfy(isnum(ofd) == 0, '6362: isnum(ofd) == 0'); vrfy(isnum(cfd) == 0, '6363: isnum(cfd) == 0'); vrfy(isnum(blk) == 0, '6364: isnum(blk) == 0'); vrfy(isnum(nblk) == 0, '6365: isnum(nblk) == 0'); vrfy(isnum(cfg) == 0, '6366: isnum(cfg) == 0'); vrfy(isnum(serr) == 0, '6367: isnum(serr) == 0'); vrfy(isnum(nerr) == 0, '6368: isnum(nerr) == 0'); vrfy(isnum(odd) == 1, '6369: isnum(odd) == 1'); vrfy(isnum(even) == 1, '6370: isnum(even) == 1'); vrfy(isnum(hash) == 0, '6371: isnum(hash) == 0'); vrfy(isnum(id) == 0, '6372: isnum(id) == 0'); vrfy(isnum(list) == 0, '6373: isnum(list) == 0'); vrfy(isnum(matrix) == 0, '6374: isnum(matrix) == 0'); vrfy(isnum(nul) == 0, '6375: isnum(nul) == 0'); vrfy(isnum(object) == 0, '6376: isnum(object) == 0'); vrfy(isnum(rand) == 0, '6377: isnum(rand) == 0'); vrfy(isnum(random) == 0, '6378: isnum(random) == 0'); vrfy(isnum(real) == 1, '6379: isnum(real) == 1'); vrfy(isnum(prime) == 1, '6380: isnum(prime) == 1'); vrfy(isnum(square) == 1, '6381: isnum(square) == 1'); vrfy(isnum(string) == 0, '6382: isnum(string) == 0'); vrfy(isnum(com) == 1, '6379: isnum(com) == 1'); print '6384: test unused'; print '6385: test unused'; print '6385: test unused'; print '6386: test unused'; print '6387: test unused'; print '6388: test unused'; print '6389: test unused'; /* * test isobj */ vrfy(isobj(loc) == 0, '6390: isobj(loc) == 0'); vrfy(isobj(a) == 0, '6391: isobj(a) == 0'); vrfy(isobj(ofd) == 0, '6392: isobj(ofd) == 0'); vrfy(isobj(cfd) == 0, '6393: isobj(cfd) == 0'); vrfy(isobj(blk) == 0, '6394: isobj(blk) == 0'); vrfy(isobj(nblk) == 0, '6395: isobj(nblk) == 0'); vrfy(isobj(cfg) == 0, '6396: isobj(cfg) == 0'); vrfy(isobj(serr) == 0, '6397: isobj(serr) == 0'); vrfy(isobj(nerr) == 0, '6398: isobj(nerr) == 0'); vrfy(isobj(odd) == 0, '6399: isobj(odd) == 0'); vrfy(isobj(even) == 0, '6400: isobj(even) == 0'); vrfy(isobj(hash) == 0, '6401: isobj(hash) == 0'); vrfy(isobj(id) == 0, '6402: isobj(id) == 0'); vrfy(isobj(list) == 0, '6403: isobj(list) == 0'); vrfy(isobj(matrix) == 0, '6404: isobj(matrix) == 0'); vrfy(isobj(nul) == 0, '6405: isobj(nul) == 0'); vrfy(isobj(object) == 1, '6406: isobj(object) == 1'); vrfy(isobj(rand) == 0, '6407: isobj(rand) == 0'); vrfy(isobj(random) == 0, '6408: isobj(random) == 0'); vrfy(isobj(real) == 0, '6409: isobj(real) == 0'); vrfy(isobj(prime) == 0, '6410: isobj(prime) == 0'); vrfy(isobj(square) == 0, '6411: isobj(square) == 0'); vrfy(isobj(string) == 0, '6412: isobj(string) == 0'); vrfy(isobj(com) == 0, '6413: isobj(com) == 0'); print '6414: test unused'; print '6415: test unused'; print '6415: test unused'; print '6416: test unused'; print '6417: test unused'; print '6418: test unused'; print '6419: test unused'; /* * test isobjtype */ vrfy(isobjtype("loc") == 0, '6420: isobjtype("loc") == 0'); vrfy(isobjtype("a") == 0, '6421: isobjtype("a") == 0'); vrfy(isobjtype("ofd") == 0, '6422: isobjtype("ofd") == 0'); vrfy(isobjtype("xy5800") == 1, '6423: isobjtype("xy5800") == 1'); vrfy(isobjtype("xy5900") == 1, '6424: isobjtype("xy5900") == 1'); print '6425: test unused'; print '6426: test unused'; print '6427: test unused'; print '6428: test unused'; print '6429: test unused'; /* * test isodd */ vrfy(isodd(loc) == 0, '6430: isodd(loc) == 0'); vrfy(isodd(a) == 0, '6431: isodd(a) == 0'); vrfy(isodd(ofd) == 0, '6432: isodd(ofd) == 0'); vrfy(isodd(cfd) == 0, '6433: isodd(cfd) == 0'); vrfy(isodd(blk) == 0, '6434: isodd(blk) == 0'); vrfy(isodd(nblk) == 0, '6435: isodd(nblk) == 0'); vrfy(isodd(cfg) == 0, '6436: isodd(cfg) == 0'); vrfy(isodd(serr) == 0, '6437: isodd(serr) == 0'); vrfy(isodd(nerr) == 0, '6438: isodd(nerr) == 0'); vrfy(isodd(odd) == 1, '6439: isodd(odd) == 1'); vrfy(isodd(even) == 0, '6440: isodd(even) == 0'); vrfy(isodd(hash) == 0, '6441: isodd(hash) == 0'); vrfy(isodd(id) == 0, '6442: isodd(id) == 0'); vrfy(isodd(list) == 0, '6443: isodd(list) == 0'); vrfy(isodd(matrix) == 0, '6444: isodd(matrix) == 0'); vrfy(isodd(nul) == 0, '6445: isodd(nul) == 0'); vrfy(isodd(object) == 0, '6446: isodd(object) == 0'); vrfy(isodd(rand) == 0, '6447: isodd(rand) == 0'); vrfy(isodd(random) == 0, '6448: isodd(random) == 0'); vrfy(isodd(real) == 0, '6449: isodd(real) == 0'); vrfy(isodd(prime) == 1, '6450: isodd(prime) == 1'); vrfy(isodd(square) == 1, '6451: isodd(square) == 1'); vrfy(isodd(string) == 0, '6452: isodd(string) == 0'); vrfy(isodd(com) == 0, '6453: isodd(com) == 0'); print '6454: test unused'; print '6455: test unused'; print '6455: test unused'; print '6456: test unused'; print '6457: test unused'; print '6458: test unused'; print '6459: test unused'; /* * test isprime */ vrfy(isprime(loc) == 0, '6460: isprime(loc) == 0'); vrfy(isprime(odd) == 1, '6461: isprime(odd) == 1'); vrfy(isprime(even) == 0, '6462: isprime(even) == 0'); vrfy(isprime(prime) == 1, '6463: isprime(prime) == 1'); vrfy(isprime(square) == 0, '6464: isprime(square) == 0'); print '6465: test unused'; print '6466: test unused'; print '6468: test unused'; print '6468: test unused'; print '6469: test unused'; /* * test isrand */ vrfy(isrand(loc) == 0, '6470: isrand(loc) == 0'); vrfy(isrand(a) == 0, '6471: isrand(a) == 0'); vrfy(isrand(ofd) == 0, '6472: isrand(ofd) == 0'); vrfy(isrand(cfd) == 0, '6473: isrand(cfd) == 0'); vrfy(isrand(blk) == 0, '6474: isrand(blk) == 0'); vrfy(isrand(nblk) == 0, '6475: isrand(nblk) == 0'); vrfy(isrand(cfg) == 0, '6476: isrand(cfg) == 0'); vrfy(isrand(serr) == 0, '6477: isrand(serr) == 0'); vrfy(isrand(nerr) == 0, '6478: isrand(nerr) == 0'); vrfy(isrand(odd) == 0, '6479: isrand(odd) == 0'); vrfy(isrand(even) == 0, '6480: isrand(even) == 0'); vrfy(isrand(hash) == 0, '6481: isrand(hash) == 0'); vrfy(isrand(id) == 0, '6482: isrand(id) == 0'); vrfy(isrand(list) == 0, '6483: isrand(list) == 0'); vrfy(isrand(matrix) == 0, '6484: isrand(matrix) == 0'); vrfy(isrand(nul) == 0, '6485: isrand(nul) == 0'); vrfy(isrand(object) == 0, '6486: isrand(object) == 0'); vrfy(isrand(rand) == 1, '6487: isrand(rand) == 1'); vrfy(isrand(random) == 0, '6488: isrand(random) == 0'); vrfy(isrand(real) == 0, '6489: isrand(real) == 0'); vrfy(isrand(prime) == 0, '6490: isrand(prime) == 0'); vrfy(isrand(square) == 0, '6491: isrand(square) == 0'); vrfy(isrand(string) == 0, '6492: isrand(string) == 0'); vrfy(isrand(com) == 0, '6493: isrand(com) == 0'); print '6494: test unused'; print '6495: test unused'; print '6495: test unused'; print '6496: test unused'; print '6497: test unused'; print '6498: test unused'; print '6499: test unused'; /* * test israndom */ vrfy(israndom(loc) == 0, '6500: israndom(loc) == 0'); vrfy(israndom(a) == 0, '6501: israndom(a) == 0'); vrfy(israndom(ofd) == 0, '6502: israndom(ofd) == 0'); vrfy(israndom(cfd) == 0, '6503: israndom(cfd) == 0'); vrfy(israndom(blk) == 0, '6504: israndom(blk) == 0'); vrfy(israndom(nblk) == 0, '6505: israndom(nblk) == 0'); vrfy(israndom(cfg) == 0, '6506: israndom(cfg) == 0'); vrfy(israndom(serr) == 0, '6507: israndom(serr) == 0'); vrfy(israndom(nerr) == 0, '6508: israndom(nerr) == 0'); vrfy(israndom(odd) == 0, '6509: israndom(odd) == 0'); vrfy(israndom(even) == 0, '6510: israndom(even) == 0'); vrfy(israndom(hash) == 0, '6511: israndom(hash) == 0'); vrfy(israndom(id) == 0, '6512: israndom(id) == 0'); vrfy(israndom(list) == 0, '6513: israndom(list) == 0'); vrfy(israndom(matrix) == 0, '6514: israndom(matrix) == 0'); vrfy(israndom(nul) == 0, '6515: israndom(nul) == 0'); vrfy(israndom(object) == 0, '6516: israndom(object) == 0'); vrfy(israndom(rand) == 0, '6517: israndom(rand) == 0'); vrfy(israndom(random) == 1, '6518: israndom(random) == 1'); vrfy(israndom(real) == 0, '6519: israndom(real) == 0'); vrfy(israndom(prime) == 0, '6520: israndom(prime) == 0'); vrfy(israndom(square) == 0, '6521: israndom(square) == 0'); vrfy(israndom(string) == 0, '6522: israndom(string) == 0'); vrfy(israndom(com) == 0, '6523: israndom(com) == 0'); print '6524: test unused'; print '6525: test unused'; print '6526: test unused'; print '6527: test unused'; print '6528: test unused'; print '6529: test unused'; /* * test isreal */ vrfy(isreal(loc) == 1, '6530: isreal(loc) == 1'); vrfy(isreal(a) == 0, '6531: isreal(a) == 0'); vrfy(isreal(ofd) == 0, '6532: isreal(ofd) == 0'); vrfy(isreal(cfd) == 0, '6533: isreal(cfd) == 0'); vrfy(isreal(blk) == 0, '6534: isreal(blk) == 0'); vrfy(isreal(nblk) == 0, '6535: isreal(nblk) == 0'); vrfy(isreal(cfg) == 0, '6536: isreal(cfg) == 0'); vrfy(isreal(serr) == 0, '6537: isreal(serr) == 0'); vrfy(isreal(nerr) == 0, '6538: isreal(nerr) == 0'); vrfy(isreal(odd) == 1, '6539: isreal(odd) == 1'); vrfy(isreal(even) == 1, '6540: isreal(even) == 1'); vrfy(isreal(hash) == 0, '6541: isreal(hash) == 0'); vrfy(isreal(id) == 0, '6542: isreal(id) == 0'); vrfy(isreal(list) == 0, '6543: isreal(list) == 0'); vrfy(isreal(matrix) == 0, '6544: isreal(matrix) == 0'); vrfy(isreal(nul) == 0, '6545: isreal(nul) == 0'); vrfy(isreal(object) == 0, '6546: isreal(object) == 0'); vrfy(isreal(rand) == 0, '6547: isreal(rand) == 0'); vrfy(isreal(random) == 0, '6548: isreal(random) == 0'); vrfy(isreal(real) == 1, '6549: isreal(real) == 1'); vrfy(isreal(prime) == 1, '6550: isreal(prime) == 1'); vrfy(isreal(square) == 1, '6551: isreal(square) == 1'); vrfy(isreal(string) == 0, '6552: isreal(string) == 0'); vrfy(isreal(com) == 0, '6553: isreal(com) == 0'); print '6554: test unused'; print '6555: test unused'; print '6555: test unused'; print '6556: test unused'; print '6557: test unused'; print '6558: test unused'; print '6559: test unused'; /* * test isrel */ vrfy(isrel(odd,even) == 0, '6560: isrel(odd,even) == 0'); vrfy(isrel(even,odd) == 0, '6561: isrel(even,odd) == 0'); vrfy(isrel(odd,odd) == 0, '6562: isrel(odd,odd) == 0'); vrfy(isrel(even,prime) == 1, '6563: isrel(even,prime) == 1'); vrfy(isrel(square,prime) == 0, '6564: isrel(square,prime) == 0'); vrfy(isrel(prime,square) == 0, '6565: isrel(prime,square) == 0'); vrfy(isrel(even,square) == 1, '6566: isrel(even,square) == 1'); vrfy(isrel(prime,even) == 1, '6567: isrel(prime,even) == 1'); print '6568: test unused'; print '6569: test unused'; /* * test bit (this was isset and thus was included here, however * we leave it here for now rather than renumber * the tests below) */ vrfy(bit(odd,0) == 1, '6570: bit(odd,0) == 1'); vrfy(bit(odd,1) == 0, '6571: bit(odd,1) == 0'); vrfy(bit(odd,2) == 0, '6572: bit(odd,2) == 0'); vrfy(bit(odd,3) == 1, '6573: bit(odd,3) == 1'); vrfy(bit(real,4) == 1, '6574: bit(real,4) == 1'); vrfy(bit(real,5) == 0, '6575: bit(real,5) == 0'); vrfy(bit(real,6) == 1, '6576: bit(real,6) == 1'); vrfy(bit(real,7) == 0, '6577: bit(real,7) == 0'); print '6578: test unused'; print '6579: test unused'; /* * test issimple */ vrfy(issimple(loc) == 1, '6580: issimple(loc) == 1'); vrfy(issimple(a) == 0, '6581: issimple(a) == 0'); vrfy(issimple(ofd) == 0, '6582: issimple(ofd) == 0'); vrfy(issimple(cfd) == 0, '6583: issimple(cfd) == 0'); vrfy(issimple(blk) == 0, '6584: issimple(blk) == 0'); vrfy(issimple(nblk) == 0, '6585: issimple(nblk) == 0'); vrfy(issimple(cfg) == 0, '6586: issimple(cfg) == 0'); vrfy(issimple(serr) == 0, '6587: issimple(serr) == 0'); vrfy(issimple(nerr) == 0, '6588: issimple(nerr) == 0'); vrfy(issimple(odd) == 1, '6589: issimple(odd) == 1'); vrfy(issimple(even) == 1, '6590: issimple(even) == 1'); vrfy(issimple(hash) == 0, '6591: issimple(hash) == 0'); vrfy(issimple(id) == 0, '6592: issimple(id) == 0'); vrfy(issimple(list) == 0, '6593: issimple(list) == 0'); vrfy(issimple(matrix) == 0, '6594: issimple(matrix) == 0'); vrfy(issimple(nul) == 1, '6595: issimple(nul) == 1'); vrfy(issimple(object) == 0, '6596: issimple(object) == 0'); vrfy(issimple(rand) == 0, '6597: issimple(rand) == 0'); vrfy(issimple(random) == 0, '6598: issimple(random) == 0'); vrfy(issimple(real) == 1, '6599: issimple(real) == 1'); vrfy(issimple(prime) == 1, '6600: issimple(prime) == 1'); vrfy(issimple(square) == 1, '6601: issimple(square) == 1'); vrfy(issimple(string) == 1, '6602: issimple(string) == 1'); vrfy(issimple(com) == 1, '6603: issimple(com) == 1'); print '6604: test unused'; print '6605: test unused'; print '6606: test unused'; print '6607: test unused'; print '6608: test unused'; print '6609: test unused'; /* * test issq */ vrfy(issq(loc) == 1, '6610: issq(loc) == 1'); vrfy(issq(odd) == 0, '6611: issq(odd) == 0'); vrfy(issq(even) == 0, '6612: issq(even) == 0'); vrfy(issq(prime) == 0, '6613: issq(prime) == 0'); vrfy(issq(square) == 1, '6614: issq(square) == 1'); print '6615: test unused'; print '6616: test unused'; print '6618: test unused'; print '6618: test unused'; print '6619: test unused'; /* * test isstr */ vrfy(isstr(loc) == 0, '6620: isstr(loc) == 0'); vrfy(isstr(a) == 0, '6621: isstr(a) == 0'); vrfy(isstr(ofd) == 0, '6622: isstr(ofd) == 0'); vrfy(isstr(cfd) == 0, '6623: isstr(cfd) == 0'); vrfy(isstr(blk) == 0, '6624: isstr(blk) == 0'); vrfy(isstr(nblk) == 0, '6625: isstr(nblk) == 0'); vrfy(isstr(cfg) == 0, '6626: isstr(cfg) == 0'); vrfy(isstr(serr) == 0, '6627: isstr(serr) == 0'); vrfy(isstr(nerr) == 0, '6628: isstr(nerr) == 0'); vrfy(isstr(odd) == 0, '6629: isstr(odd) == 0'); vrfy(isstr(even) == 0, '6630: isstr(even) == 0'); vrfy(isstr(hash) == 0, '6631: isstr(hash) == 0'); vrfy(isstr(id) == 0, '6632: isstr(id) == 0'); vrfy(isstr(list) == 0, '6633: isstr(list) == 0'); vrfy(isstr(matrix) == 0, '6634: isstr(matrix) == 0'); vrfy(isstr(nul) == 0, '6635: isstr(nul) == 0'); vrfy(isstr(object) == 0, '6636: isstr(object) == 0'); vrfy(isstr(rand) == 0, '6637: isstr(rand) == 0'); vrfy(isstr(random) == 0, '6638: isstr(random) == 0'); vrfy(isstr(real) == 0, '6639: isstr(real) == 0'); vrfy(isstr(prime) == 0, '6640: isstr(prime) == 0'); vrfy(isstr(square) == 0, '6641: isstr(square) == 0'); vrfy(isstr(string) == 1, '6642: isstr(string) == 1'); vrfy(isstr(com) == 0, '6643: isstr(com) == 0'); print '6644: test unused'; print '6645: test unused'; print '6645: test unused'; print '6646: test unused'; print '6647: test unused'; print '6648: test unused'; print '6649: test unused'; /* * test istype */ vrfy(istype(odd,even) == 1, '6650: istype(odd,even) == 1'); vrfy(istype(even,odd) == 1, '6651: istype(even,odd) == 1'); vrfy(istype(odd,odd) == 1, '6652: istype(odd,odd) == 1'); vrfy(istype(even,prime) == 1, '6653: istype(even,prime) == 1'); vrfy(istype(square,prime) == 1, '6654: istype(square,prime) == 1'); vrfy(istype(prime,square) == 1, '6655: istype(prime,square) == 1'); vrfy(istype(even,square) == 1, '6656: istype(even,square) == 1'); vrfy(istype(prime,even) == 1, '6657: istype(prime,even) == 1'); vrfy(istype(prime,com) == 0, '6658: istype(prime,com) == 0'); vrfy(istype(matrix,com) == 0, '6659: istype(matrix,com) == 0'); vrfy(istype(matrix,list) == 0, '6660: istype(matrix,list) == 0'); vrfy(istype(matrix,odd) == 0, '6661: istype(matrix,odd) == 0'); vrfy(istype(a,odd) == 0, '6662: istype(a,odd) == 0'); /* * cleanup */ blkfree("blk5900"); print '6663: blkfree("blk5900")'; fclose(ofd); print '6664: fclose(ofd)'; print '6665: Ending test_is'; } print '168: test_is()'; /* * test_blk - test block of octets */ define test_blk() { local A, B, C, A1, A2, B1; print '6700: Beginning test_blk'; A = blk(20); print '6701: A = blk(20);'; vrfy(size(A) == 20, '6702: size(A) == 20'); vrfy(sizeof(A) == 256, '6703: sizeof(A) == 256'); B = A; print '6704: B = A;'; vrfy(size(B) == 20, '6705: size(B) == 20'); vrfy(A == B, '6706: A == B'); A[5] = 21; print '6707: A[5] = 21;'; vrfy(A[5] == 21, '6708: A[5] == 21'); A[6] = 'abc'; print '6709: A[6] = "abc";'; vrfy(A[6] == ord('a'), '6710: A[6] == ord("a")'); A[7] = 260; print '6711: A[7] = 260;'; vrfy(A[7] == 4, '6712: A[7] == 4'); A[8] = 3+4i; print '6713: A[8] = 3+4i;'; vrfy(A[8] == 3, '6714: A[8] == 3'); vrfy(A != B, '6715: A != B'); /* Equality of blocks of same data-length is unaffected by maxsizes */ C = blk(A, ,128); print '6716: C = blk(A, ,128);'; vrfy(size(C) == size(A), '6717: size(C) == size(A)'); vrfy(sizeof(C) == 128, '6718: sizeof(C) == 128'); vrfy(C == A, '6719: C == A'); /* Blocks of different lengths test as unequal */ C = blk(A,30); print '6720: C = blk(A,30);'; vrfy(size(C) == 30, '6721: size(C) == 30'); vrfy(C != A, '6722: C != A;'); /* Reducing length to that of original data restores equality */ C = blk(C,20); print '6723: C = blk(C,20);'; vrfy(C == A, '6724: C == A'); /* Reading block beyond data length extends length */ A[29] = 7; print '6725: A[29] = 7;'; vrfy(A[29] == 7, '6726: A[29] == 7'); vrfy(size(A) == 30, '6727: size(A) == 30'); /* Reducing length clears memory beyond new length */ A = blk(A, 20); print '6728: A = blk(A, 20);'; vrfy(A[29] == 0, '6729: A[29] == 0'); /* Reducing length to zero and initializing a few early values */ A = blk(A,0) = {1,,3,,5}; print '6730: A = blk(A,0) = {1,,3,5};'; vrfy(A[4] == 5, '6731: A[4] == 5'); vrfy(size(A) == 5, '6732: size(A) == 5'); /* Assignment of copy with initialization */ B = A; print '6733: B = A;'; C=blk(A)={,,,,,,,,,,0xbb}; print '6734: C=blk(A)={,,,,,,,,,,0xbb};'; /* A has not been changed */ vrfy(A == B, '6735: A == B'); vrfy(C[10] == 0xbb, '6736: C[10] == 0xbb'); /* Testing named blocks */ A1 = blk("blk6700"); print '6737: A1 = blk("blk6700");'; A2 = blk("blk6700"); print '6738: A2 = blk("blk6700");'; vrfy(A1 == A2, '6739: A1 == A2'); vrfy(size(A1) == 0, '6740: size(A1) == 0'); vrfy(sizeof(A1) == 256, '6741: sizeof(A1) == 256'); print '6742: test disabled: test(A1) == 0'; print '6743: test disabled: str(A1) == "blk6700"'; vrfy(blocks() == 1, '6744: blocks() == 1'); vrfy(blocks(1) == A1, '6745: blocks(1) == A1'); /* A second named block */ B1 = blk("+++6700", 15, 10) = {1,2,3,4,5}; print '6746: B1 = blk("+++6700", , 10);'; vrfy(size(B1) == 15, '6747: size(B1) == 15'); vrfy(sizeof(B1) == 20, '6748: sizeof(B1) == 20'); vrfy(test(B1) == 1, '6749: test(B1) == 1'); print '6750: test disabled: str(B1) == "+++6700"'; vrfy(blocks() == 2, '6751: blocks() == 2'); vrfy(blocks(2) == B1, '6752: blocks(2) == B1'); vrfy(B1 != A1, '6753: B1 != A1'); /* Referencing octets beyond datalen increases datalen */ A1[15] = 29; print '6754: A1[15] = 29;'; vrfy(A1[15] == 29, '6755: A1[15] == 29'); vrfy(A2[15] == 29, '6756: A2[15] == 29'); vrfy(size(A1) == 16, '6757: size(A1) == 16'); vrfy(test(A1) == 1, '6758: test(A1) == 1'); A1[99] = 11; print '6759: A1[99] = 11;'; vrfy(size(A1) == 100, '6760: size(A1) == 100'); vrfy(A1[99] == 11, '6761: A1[99] == 11'); /* increasing chunksize */ null(blk(A1, , 1000)); print '6762: null(blk(A1, , 1000));'; vrfy(size(A1) == 100, '6763: size(A1) == 100'); vrfy(sizeof(A1) == 1000, '6764: sizeof(A1) == 1000'); vrfy(A1[99] == 11, '6765: A1[99] == 11'); /* reducing data-length */ A1 = blk(A1, 10); print '6766: A1 = blk(A1, 10);'; vrfy(size(A1) == 10, '6767: size(A1) == 10'); /* all octets now zero */ vrfy(test(A1) == 0, '6768: test(A1) == 0'); vrfy(A1[99] == 0, '6769: A1[99] == 0'); /* freeing memory */ blkfree(A1); print '6770: blkfree(A1);'; /* freeing named block memory reduces number of unfreed blocks */ vrfy(blocks() == 1, '6771: blocks() == 1'); /* 'removed' block still exists but has zero size and maxsize */ vrfy(blocks(1) == A1, '6772: blocks(1) == A1'); vrfy(size(A1) == 0, '6773: size(A1) == 0'); vrfy(sizeof(A1) == 0, '6774: sizeof(A1) == 0'); vrfy(test(A1) == 0, '6775: test(A1) == 0'); print '6776: test disabled: str(A1) == "blk6700"'; /* Equality of named blocks not affected by freeing of memory */ vrfy(A1 == A2, '6777: A1 == A2'); /* Executing blk('blk6700') reallocates memory for A1 */ null(blk('blk6700')); print '6778: null(blk("blk6700"));'; vrfy(size(A1) == 0, '6779: size(A1) == 0'); vrfy(sizeof(A1) == 1000, '6780: sizeof(A1) == 1000'); /* A2 still refers to same block as A1 */ A1[100] = 0xff; print '6781: A1[100] = 0xff;'; vrfy(A2[100] == 0xff, '6782: A2[100] == 0xff'); /* A possibly confusing initialization and assignment */ mat A1[2] = {A1, B1}; print '6783: mat A1[2] = {A1, B1};'; vrfy(A1[0] == A2, '6784: A1[0] == A2'); vrfy(A1[1] == B1, '6785: A1[1] == B1'); vrfy(A1[0][100] == 0xff, '6786: A1[0][100] == 0xff'); print '6800: reserved for future expansion of test_blk'; print '6899: Ending test_blk'; } print '169: parsed test_blk()'; /* * test_blkcpy - test the new copy builtin function */ define test_blkcpy() { local A, B, C, A1, A2, B1, fs, S, M1, M2, L1, L2, x; print '6800: Beginning test_blkcpy'; A = blk() = {1,2,3,4,5}; print '6801: A = blk() = {1,2,3,4,5};'; B = blk(); print '6802: B = blk();'; blkcpy(B, A); print '6803: blkcpy(B, A);'; vrfy(A == B, '6804: A == B'); blkcpy(B, A, ,10); print '6805: blkcpy(B, A, ,10)'; vrfy(size(B) == 15, '6806: size(B) == 15'); blkcpy(B, A, , 15, 3); print '6807: blkcpy(A, 3, B, 15);'; vrfy(size(B) == 17, '6808: size(B) == 17'); vrfy(B[16] == 5, '6809: B[16] == 5'); /* create named block A1 and blkcpy A into B[0]... and B[100]... */ x = rm("-f", "blk6800"); print '6810: x = rm("-f", "blk6800")'; A1 = blk("blk6800"); print '6811: A1 = blk("blk6800");'; vrfy(size(A1) == 0, '6812: size(A1) == 0'); blkcpy(A1, A); print '6813: blkcpy(A1, A);'; vrfy(size(A1) == 5, '6814: size(A1) == 5'); blkcpy(A1, A, ,100); print '6815: blkcpy(A1, A, ,100);'; vrfy(size(A1) == 105, '6816: size(A1) == 105'); /* create named block B1 and blkcpy first 5 octets of A1 to B[100]... */ B1 = blk("beta"); print '6817: B1 = blk("beta")'; vrfy(size(B1) == 0, '6818: size(B1) == 0'); blkcpy(B1, A1, 5, 100, 0); print '6819: blkcpy(B1, A1, 5, 100, 0)'; vrfy(size(B1) == 105, '6820: size(B1) == 105'); /* blkcpy the last 5 octets of B1 to a new block C */ blkcpy(C = blk(), B1, 5, ,100); print '6821: blkcpy(C = blk(), B1, 5, ,100);'; vrfy(C == A, '6822: C == A'); /* blkcpy to and from a file */ fs = fopen("junk6800", "w+"); print '6823: fs = fopen("junk6800", "w+");'; blkcpy(fs, A); print '6824: blkcpy(fs, A);'; vrfy(size(fs) == 5, '6825: size(f) == 5'); blkcpy(B = blk(), fs); print '6826: blkcpy(B = blk(), fs);'; vrfy(B == A, '6827: B == A'); blkcpy(fs, A, ,100); print '6828: blkcpy(fs, A, ,100);'; vrfy(size(fs) == 105, '6829: size(f) == 105'); blkcpy(C = blk(), fs, 2, ,100); print '6830: blkcpy(C = blk(), fs, 2, ,100)'; vrfy(C == (blk() = {1,2}), '6831: C == (blk() = {1,2}'); /* blkcpy string to a block */ A = blk(); print '6832: A = blk();'; /* Note that "blk6800" is not here considered to name a block */ blkcpy(A, "blk6800 "); print '6833: blkcpy(A, "blk6800");'; vrfy(size(A) == 9, '6834: size(A) == 9'); blkcpy(A, "beta", , 7); print '6835: blkcpy(A, "beta", , 7);'; vrfy(size(A) == 12, '6836: size(A) == 12'); /* read strings from A */ S = strprintf("%s", A[0]); print '6837: S = strprintf("%s", A[0]);'; vrfy(S == "blk6800beta", '6838: S == "blk6800beta"'); S = strprintf("%s", A[8]); print '6839: S = strprintf("%s", A[8]);'; vrfy(S == "eta", '6840: S == "eta"'); mat M1[2,2] = {1,2,3,4}; print '6841: mat M1[2,2] = {1,2,3,4};'; mat M2[4]; print '6842: mat M2[4];'; blkcpy(M2, M1); print '6843: blkcpy(M2, M1)'; vrfy(M2 == (mat[4]={1,2,3,4}), '6844: M2 == (mat[4]={1,2,3,4}'); blkcpy(M2, M2, 2, 2, 0); print '6845: blkcpy(M2, M2, 2, 2, 0);'; vrfy(M2 == (mat[4]={1,2,1,2}), '6846: M2 == (mat[4]={1,2,1,2}'); /* blkcpy between blocks and matrices */ B = blk(); print '6847: B = blk()'; blkcpy(B, M1); print '6848: blkcpy(B, M1)'; vrfy(B == (blk() = {1,2,3,4}), '6849: B == (blk() = {1,2,3,4}'); blkcpy(M2, B, 2, ,2); print '6850: blkcpy(B,2,2,M2);'; vrfy(M2 == (mat[4]={3,4,1,2}), '6851: M2 == (mat[4]={3,4,1,2})'); /* blkcpy between matrices and lists */ L1 = makelist(4); print '6852: L1 = makelist(4);'; blkcpy(L1, M2); print '6853: blkcpy(L1, M2);'; blkcpy(M2, L1, 2, ,2); print '6854: blkcpy(M2, L1, 2, ,2);'; vrfy(M2 == (mat[4]={1,2,1,2}), '6855: M2 == (mat[4]={1,2,1,2}'); /* blkcpy lists to lists */ L2 = makelist(4); print '6856: L2 = makelist(4);'; blkcpy(L2, L1); print '6857: blkcpy(L2, L1);'; vrfy(L1 == L2, '6858: L1 == L2'); blkcpy(L2, L1, 2, 2, 0); print '6859: blkcpy(L2, L1, 2, 2, 0)'; vrfy(L2 == list(3,4,3,4), '6860: L2 == list(3,4,3,4)'); /* blkcpy between structures and substructures */ M2[0] = L2; print '6861: M2[0] = L2;'; blkcpy(M2, M2[0]); print '6862: blkcpy(M2, M2[0]);'; vrfy(M2 == (mat[4]={3,4,3,4}), '6863: M2 == (mat[4]={3,4,3,4})'); M2[2] = list(1,2,3,4); print '6864: M2[2] = list(1,2,3,4);'; blkcpy(M2[2], M2); print '6865: blkcpy(M2[2], M2);'; vrfy(M2[2][[2]][[2]] == 3, '6866: M2[2][[2]][[2]] == 3'); /* cleanup */ fclose(fs); print '6867: fclose(fs)'; x = rm("junk6800"); print '6868: x = rm("junk6800")'; print '6868: Ending test_blkcpy'; } print '170: parsed test_blkcpy()'; /* * test_name - test the name builtin */ define test_name() { local f, A, x; print '6900: Beginning test_name'; x = rm("-f", "junk6900"); print '6901: x = rm("-f", "junk6900")'; f = fopen("junk6900", "w"); print '6902: f = fopen("junk6900", "w")'; vrfy(name(f) == "junk6900", '6903: name(f) == "junk6900"'); /* file stream loses name when file is closed */ fclose(f); print '6904: fclose(f)'; vrfy(name(f) == null(), '6905: name(f) == null()'); A = blk("blk6900"); print '6906: A = blk("blk6900")'; vrfy(name(A) == "blk6900", '6907: name(A) == "blk6900"'); /* name of block is not lost when its data memory is freed */ blkfree("blk6900"); print '6908: blkfree("blk6900");'; vrfy(name(A) == "blk6900", '6909: name(A) == "blk6900"'); /* values other than named blocks and files have no name */ vrfy(name(27) == null(), '6910: name(27) == null()'); /* cleanup */ x = rm("junk6900"); print '6911: x = rm("junk6900")'; print '6912: Ending test_name'; } print '171: parsed test_name()'; /* * test_blkprintf - test blk printf */ define test_blkprintf() { local A, B; print '7000: Beginning test_blkprintf'; A = blk("alpha"); print '7001: A = blk("alpha")'; B = blk(); print '7002: B = blk();'; copy("abc yz", A); print '7003: copy("abc yz", A);'; copy("defg", B); print '7004: copy("defg", B);'; vrfy(strprintf("%s", A) == "abc yz", '7005: strprintf("%s", A) == "abc yz"'); vrfy(strprintf("%s", A[2]) == "c yz", '7006: strprintf("%s", A[2]) == "c yz"'); vrfy(strprintf("%s", A[7]) == "", '7007: strprintf("%s", A[7]) == ""'); vrfy(strprintf("%c", A) == "a", '7008: strprintf("%c", A == "a"'); vrfy(strprintf("%c", A[4]) == "y", '7009: strprintf("%c", A[4]) == "y"'); vrfy(strprintf("%s", B) == "defg", '7010: strprintf("%s", B) == "defg"'); vrfy(strprintf("%s", B[1]) == "efg", '7011: strprintf("%s", B[1]) == "efg"'); vrfy(strprintf("%s", B[7]) == "", '7012: strprintf("%s", B[7]) == ""'); vrfy(strprintf("%c", B) == "d", '7013: strprintf("%c", B == "d"'); vrfy(strprintf("%c", B[2]) == "f", '7014: strprintf("%c", B[2]) == "f"'); print '7015: Ending test_blkprintf'; } print '172: parsed test_blkprintf()'; /* * test_sha - test the sha hash */ define test_sha() { local a, b, c, d, e, f, x, y, z, L, M, B1, B2, B; print '7100: Beginning test_sha'; y = sha(); print '7101: y = sha();'; z = sha(); print '7102: z = sha();'; vrfy(y == z, '7103: y == z'); vrfy(sha("") == y, '7104: sha("") == y'); y = sha(y,1); print '7105: y = sha(y,1);'; vrfy(y == sha(1), '7106: y == sha(1)'); vrfy(sha(y,2) == sha(1,2), '7107: sha(y,2) == sha(1,2)'); vrfy(sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef, '7108: sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef'); vrfy(sha(sha("a"))==0x37f297772fae4cb1ba39b6cf9cf0381180bd62f2, '7109: sha(sha("a"))==0x37f297772fae4cb1ba39b6cf9cf0381180bd62f2'); vrfy(sha(sha("ab"))==0x488373d362684af3d3f7a6a408b59dfe85419e09, '7110: sha(sha("ab"))==0x488373d362684af3d3f7a6a408b59dfe85419e09'); vrfy(sha(sha("abc"))==0x0164b8a914cd2a5e74c4f7ff082c4d97f1edf880, '7111: sha(sha("abc"))==0x0164b8a914cd2a5e74c4f7ff082c4d97f1edf880'); vrfy(sha(sha("abcd"))==0x082c73b06f71185d840fb4b28eb3abade67714bc, '7112: sha(sha("abcd"))==0x082c73b06f71185d840fb4b28eb3abade67714bc'); vrfy(sha(sha("abcde"))==0xd624e34951bb800f0acae773001df8cffe781ba8, '7113: sha(sha("abcde"))==0xd624e34951bb800f0acae773001df8cffe781ba8'); vrfy(sha(sha("abcdef"))==0x2a589f7750598dc0ea0a608719e04327f609279a, '7114: sha(sha("abcdef"))==0x2a589f7750598dc0ea0a608719e04327f609279a'); vrfy(sha(sha("abcdefg"))==0x5bdf01f9298e9d19d3f8d15520fd74eed600b497, '7115: sha(sha("abcdefg"))==0x5bdf01f9298e9d19d3f8d15520fd74eed600b497'); vrfy(sha(sha("abcdefgh"))==0x734ba8b31975d0dbae4d6e249f4e8da270796c94, '7116: sha(sha("abcdefgh"))==0x734ba8b31975d0dbae4d6e249f4e8da270796c94'); vrfy(sha(sha(1)) == 0x864c8d09e828c7c31d62693736a5a9302c282777, '7117: sha(sha(1)) == 0x864c8d09e828c7c31d62693736a5a9302c282777'); vrfy(sha(sha(2)) == 0x2c0b59c512cb20fad6bb0883b69c9f5a46545808, '7118: sha(sha(2)) == 0x2c0b59c512cb20fad6bb0883b69c9f5a46545808'); vrfy(sha(sha(22/7))==0x7ddb7f8a7e9d70757f157744fddea7a6c6a6bcc6, '7119: sha(sha(22/7)==0x7ddb7f8a7e9d70757f157744fddea7a6c6a6bcc6'); vrfy(sha(sha(isqrt(2e1000))) == 0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0, '7120: sha(sha(isqrt(2e1000)==0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0'); vrfy(sha("x", "y", "z") == sha("xyz"), '7121: sha("x", "y", "z") == sha("xyz")'); vrfy(sha(sha("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == 0x21e42319a26787046c2b28b7ae70f1b54bf0ba2a, '7122: sha(sha("this is", 7^19-8, ..., "hash")) == 0x21e4...'); z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi()); print '7123: z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi());'; vrfy(sha(z) == 0x36dcca3e51865c30a2cf738023cda446f1368340, '7124: sha(z) == 0x36dcca3e51865c30a2cf738023cda446f1368340'); y = sha(); print '7125: y = sha()'; y = sha(y, list(1,2,3), "curds and whey"); print '7126: y = sha(y, list(1,2,3), "curds and whey")'; y = sha(y, 2^21701-1); print '7127: y = sha(y, 2^21701-1)'; y = sha(y, pi()); print '7128: y = sha(y, pi())'; vrfy(y == z, '7129: y == z'); B = blk() = {"a", "b", "c"}; print '7130: B = blk() = {"a", "b", "c"};'; vrfy(sha(B) == sha("abc"), '7131: sha(B) == sha("abc")'); B1 = blk() = {1,2,3,4}; print '7132: B1 = blk() = {1,2,3,4};'; B2 = blk() = {5,6,7,8}; print '7133: B2 = blk() = {5,6,7,8};'; B = blk() = {1,2,3,4,5,6,7,8}; print '7134: B = blk() = {1,2,3,4,5,6,7,8};'; vrfy(sha(B1, B2) == sha(B), '7135: sha(B1, B2) == sha(B)'); vrfy(sha(B[1], B[3], B[5]) == sha("\02\04\06"), '7136: sha(B[1], B[3], B[5]) == sha("\02\04\06")'); L = list(1,2,3); print '7137: L = list(1,2,3)'; mat M[3] = {4,5,6}; print '7138: mat M[3] = {4,5,6}'; vrfy(sha(sha(L), M, B) == sha(L, M, B), '7139: sha(sha(L), M, B) == sha(L, M, B)'); vrfy(sha(sha(L,M), B) == sha(L, M, B), '7140: sha(sha(L, M), B) == sha(L, M, B)'); print '7141: Ending test_sha'; } print '173: parsed test_sha()'; /* * test_sha1 - test the sha1 hash */ define test_sha1() { local a, b, c, d, e, f, x, y, z, L, M, B; print '7200: Beginning test_sha1'; y = sha1(); print '7201: y = sha1();'; z = sha1(); print '7202: z = sha1();'; vrfy(y == z, '7203: y == z'); z = sha1(1); print '7204: z = sha1(1);'; vrfy(sha1(y,1) == z, '7205: sha1(y,1) == z'); vrfy(sha1(z,2) == sha1(1,2), '7206: sha1(z,2) == sha1(1,2)'); vrfy(sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709, '7207: sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709'); vrfy(sha1("x", "y", "z") == sha1("xyz"), '7208: sha1("x", "y", "z") == sha1("xyz")'); vrfy(sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == 0xc3e1b562bf45b3bcfc055ac65b5b39cdeb6a6c55, '7209: sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == ...'); z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi()); print '7210: z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi());'; vrfy(sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f, '7211: sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f'); y = sha1(); print '7212: y = sha1();'; y = sha1(y, list(1,2,3), "curds and whey"); print '7213: y = sha1(y, list(1,2,3), "curds and whey");'; y = sha1(y, 2^21701-1); print '7214: y = sha1(y, 2^21701-1);'; y = sha1(y, pi()); print '7215: y = sha1(y, pi());'; vrfy(y == z, '7216: y == z'); vrfy(sha1(sha1("a"))==0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8, '7217: sha1(sha1("a"))==0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8'); vrfy(sha1(sha1("ab"))==0xda23614e02469a0d7c7bd1bdab5c9c474b1904dc, '7218: sha1(sha1("ab"))==0xda23614e02469a0d7c7bd1bdab5c9c474b1904dc'); vrfy(sha1(sha1("abc"))==0xa9993e364706816aba3e25717850c26c9cd0d89d, '7219: sha1(sha1("abc"))==0xa9993e364706816aba3e25717850c26c9cd0d89d' ); vrfy(sha1(sha1("abcd"))==0x81fe8bfe87576c3ecb22426f8e57847382917acf, '7220: sha1(sha1("abcd"))==0x81fe8bfe87576c3ecb22426f8e57847382917acf'); vrfy(sha1(sha1("abcde"))==0x03de6c570bfe24bfc328ccd7ca46b76eadaf4334, '7221: sha1(sha1("abcde"))==0x03de6c570bfe24bfc328ccd7ca46b76eadaf4334'); vrfy(sha1(sha1("abcdef"))== 0x1f8ac10f23c5b5bc1167bda84b833e5c057a77d2, '7222: sha1(sha1("abcdef"))==0x1f8ac10f23c5b5bc1167bda84b833e5c057a77d2'); vrfy(sha1(sha1("abcdefg"))==0x2fb5e13419fc89246865e7a324f476ec624e8740, '7223: sha1(sha1("abcdefg"))==0x2fb5e13419fc89246865e7a324f476ec624e8740'); vrfy(sha1(sha1("abcdefgh"))==0x425af12a0743502b322e93a015bcf868e324d56a, '7224: sha1(sha1("abcdefgh"))==0x425af12a0743502b322e93a015bcf868e324d56a'); vrfy(sha1(sha1(1))==0x53dd4e1734ad47d45e41c23e4ce42d7f1f98c1e8, '7225: sha1(sha1(1))==0x53dd4e1734ad47d45e41c23e4ce42d7f1f98c1e8'); vrfy(sha1(sha1(22/7))==0xf8e2510f85f7b9bf088b321188e9f70620f44246, '7226: sha1(sha1(22/7))==0xf8e2510f85f7b9bf088b321188e9f70620f44246'); vrfy(sha1(sha1(isqrt(2e1000)))== 0x6852a1365c51050c3d039e3c5d9cf29c12283ef4, '7227: sha1(sha1(isqrt(2e1000)))==0x6852a1365c51050c3d039e3c5d9cf29c12283ef4' ); L = list(1,2,3); print '7228: L = list(1,2,3)'; mat M[3] = {4,5,6}; print '7229: mat M[3] = {4,5,6}'; B = blk() = {7,8,9}; print '7230: B = blk() = {7,8,9}'; vrfy(sha1(sha1(L), M, B) == sha1(L, M, B), '7231: sha1(sha1(L), M, B) == sha1(L, M, B)'); vrfy(sha1(sha1(L,M), B) == sha1(L, M, B), '7232: sha1(sha1(L, M), B) == sha1(L, M, B)'); print '7233: Ending test_sha1'; } print '174: parsed test_sha1()'; /* * test_md5 - test the md5 hash */ define test_md5() { local a, b, c, d, e, f, x, y, z, L, M, B; print '7300: Beginning test_md5'; y = md5(); print '7301: y = md5();'; z = md5(); print '7302: z = md5();'; vrfy(y == z, '7303: y == z'); y = md5(y,1); print '7304: y = md5(y,1);'; z = md5(1); print '7305: z = md5(1);'; vrfy(y == z, '7306: y == z'); vrfy(md5(z,2) == md5(1,2), '7307: md5(z,2) == md5(1,2)'); vrfy(md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e, '7308: md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e'); vrfy(md5("x", "y", "z") == md5("xyz"), '7309: md5("x", "y", "z") == md5("xyz")'); vrfy(md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == 0x39a5a8e24a2eb65a51af462c8bdd5e3, '7310: md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == ...'); z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi()); print '7311: z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi());'; vrfy(md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5, '7312: md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5'); y = md5(); print '7313: y = md5();'; y = md5(y, list(1,2,3), "curds and whey"); print '7314: y = md5(y, list(1,2,3), "curds and whey")'; y = md5(y, 2^21701-1); print '7315: y = md5(y, 2^21701-1);'; y = md5(y, pi()); print '7316: y = md5(y, pi());'; vrfy(y == z, '7317: y == z'); vrfy(md5(md5("a")) == 0x0cc175b9c0f1b6a831c399e269772661, '7318: md5(md5("a")) == 0x0cc175b9c0f1b6a831c399e269772661'); vrfy(md5(md5("ab")) == 0x187ef4436122d1cc2f40dc2b92f0eba0, '7319: md5(md5("ab")) == 0x187ef4436122d1cc2f40dc2b92f0eba0'); vrfy(md5(md5("abc")) == 0x900150983cd24fb0d6963f7d28e17f72, '7320: md5(md5("abc")) == 0x900150983cd24fb0d6963f7d28e17f72'); vrfy(md5(md5("abcd")) == 0xe2fc714c4727ee9395f324cd2e7f331f, '7321: md5(md5("abcd")) == 0xe2fc714c4727ee9395f324cd2e7f331f'); vrfy(md5(md5("abcde")) == 0xab56b4d92b40713acc5af89985d4b786, '7322: md5(md5("abcde")) == 0xab56b4d92b40713acc5af89985d4b786'); vrfy(md5(md5("abcdef")) == 0xe80b5017098950fc58aad83c8c14978e, '7323: md5(md5("abcdef")) == 0xe80b5017098950fc58aad83c8c14978e'); vrfy(md5(md5("abcdefg")) == 0x7ac66c0f148de9519b8bd264312c4d64, '7324: md5(md5("abcdefg")) == 0x7ac66c0f148de9519b8bd264312c4d64'); vrfy(md5(md5("abcdefgh")) == 0xe8dc4081b13434b45189a720b77b6818, '7325: md5(md5("abcdefgh")) == 0xe8dc4081b13434b45189a720b77b6818'); vrfy(md5(md5(1)) == 0x44fe7987067ac45311c88772038f60d1, '7326: md5(md5(1)) == 0x44fe7987067ac45311c88772038f60d1'); vrfy(md5(md5(22/7)) == 0x9274b951e1dfb9cba22af1c127daa8e7, '7327: md5(md5(22/7) == 0x9274b951e1dfb9cba22af1c127daa8e7'); vrfy(md5(md5(isqrt(2e1000))) == 0xe56ac4b8cad869e738a04fedc97058f3, '7328: md5(md5(isqrt(2e1000))) == 0xe56ac4b8cad869e738a04fedc97058f3'); L = list(1,2,3); print '7329: L = list(1,2,3)'; mat M[3] = {4,5,6}; print '7330: mat M[3] = {4,5,6}'; B = blk() = {7,8,9}; print '7331: B = blk() = {7,8,9}'; vrfy(md5(md5(L), M, B) == md5(L, M, B), '7332: md5(md5(L), M, B) == md5(L, M, B)'); vrfy(md5(md5(L,M), B) == md5(L, M, B), '7333: md5(md5(L, M), B) == md5(L, M, B)'); print '7334: Ending test_md5'; } print '175: parsed test_md5()'; /* * The 7400's contain tests for saveval and dot. These tests are * done inline near the bottom. */ /* * test_ptr - test pointers */ define g7500a(a,b) = a = b; print '176: define g7500a(a,b) = a = b'; define g7500b(a,b) = a + b; print '177: define g7500b(a,b) = a + b'; define g7500c(a,b) = *(a + b); print '178: define g7500c(a,b) = *(a + b)'; define g7500d(a) = &a; print '179: define g7500d(a) = &a'; define g7500e(a,b) = *a = b; print '180: define g7500e(a,b) = *a = b' define test_ptr() { local a, b, c, A, B, B1, B2, M, L, p, q, p0, q0; print '7500: Beginning test_ptr'; vrfy(isoctet(27) == 0, '7501: isoctet(27) == 0'); vrfy(isptr(27) == 0, '7502: isptr(27) == 0'); /* testing octet pointers */ B = blk() = {1,2,3,4,5,6}; print '7503: B = blk() = {1,2,3,4,5,6};'; vrfy(isoctet(B[0]) == 1, '7504: isoctet(B[0]) == 1'); vrfy(isnum(B[0]) == 0, '7505: isnum(B[0]) == 0'); vrfy(isptr(B[0]) == 0, '7506: isptr(B[0]) == 0'); vrfy(isoctet(*B[0]) == 0, '7507: isoctet(*B[0]) == 0'); vrfy(isnum(*B[0]) == 1, '7508: isnum(*B[0]) == 1'); vrfy(isoctet(&B[0]) == 0, '7509: isoctet(&B[0]) == 0'); vrfy(isptr(&B[0]) == 1, '7510: isptr(&B[0]) == 1'); vrfy(*B[3] == B[3], '7511: *B[3]== B[3]'); vrfy(*&B[3] == B[3], '7512: *&B[3] == B[3]'); vrfy(&B[0] + 3 == &B[3], '7513: &B[0] + 3 == &B[3]'); vrfy(&B[3] - &B[0] == 3, '7514: &B[3] - &B[0] == 3'); vrfy(&B[3] - 3 == &B[0], '7515: &B[3 - 3 == &B[1]'); vrfy(&B[3] > &B[0], '7516: &B[3] > &B[0]'); swap(B[0], B[5]); print '7517: swap(B[0], B[5]);'; vrfy(B[0] == 6 && B[5] == 1, '7518: B[0] == 6 && B[5] == 1'); /* testing octet-pointer-valued variables */ p = &B[0], q = &B[5]; print '7519: p = &B[0], q = &B[5]'; vrfy(isoctet(p) == 0, '7520: isoctet(p) == 0'); vrfy(isptr(p) == 1, '7521: isptr(p) == 1'); vrfy(isoctet(*p) == 1, '7522: isoctet(*p) == 1'); vrfy(isptr(*p) == 0, '7523: isptr(*p) == 0'); vrfy(p == &B[0], '7524: p == &B[0]'); vrfy(q != p, '7525: q != p'); vrfy(q > p, '7526: q > p'); vrfy(*p == B[0], '7527: *p == B[0]'); vrfy(&B[1] == p + 1, '7528: &B[1] == p + 1'); vrfy(q == p + 5, '7529: q == p + 5'); *p = 1, *q = 6; print '7530: *p = 1, *q = 6'; vrfy(B[0] == 1 && B[5] == 6, '7531: B[0] == 1 && B[5] == 6'); a = *p, b = *q; print '7532: a = *p, b = *q'; vrfy(a == 1 && b == 6, '7533: a == 1 && b == 6'); *(p + 3) = 7; print '7534: *(p + 3) = 7;'; vrfy(B[3] == 7, '7535: B[3] == 7'); *(q - 2) = 8; print '7536: *(q - 2) = 8;'; vrfy(B[3] == 8, '7537: B[3] == 8'); p0 = p++; print '7538: p0 = p++;'; vrfy(p0 == &B[0] && p == &B[1], '7539: p0 == &B[0] && p == &B[1]'); q0 = --q; print '7540: q0 = --q'; vrfy(q0 == &B[4] && q == q0, '7541: q0 == &B[4] && q == q0'); a = *p++, b = *q--; print '7542: a = *p++, b = *q--;'; vrfy(a == 2 && b == 5, '7543: a == 2 && b == 5'); vrfy(p - &B[0] == 2 && q == &B[0] + 3, '7544: p - &B[0] == 2 && q == &B[0] + 3'); a = *--q, b = *----q; print '7545: a = *--q, b = *----q;'; vrfy(q == &B[0], '7546: q == &B[0]'); vrfy(a == 3 && b == 1, '7547: a == 3 && b == 1'); a = (*p)++; print '7548: a = (*p)++;'; vrfy(a == 3 && B[2] == 4, '7549: a == 3 && B[2] == 4'); a = ++(*++p)++; print '7550: a = ++(*++p)++;'; vrfy(a == 9 && B[3] == 10, '7551: a == 9 && B[3] == 10'); /* testing octets, & and * in arguments of user-defined functions */ A = blk() = {1,2,3}; print '7552: A = blk() = {1,2,3};'; vrfy(g7500a(A[0],5) == 5, '7553: g7500a(A[0],5) == 5'); vrfy(A[0] == 5, '7554: A[0] == 5'); vrfy(g7500a(`A[0],5) == 5, '7555: g7500a(`A[0],5) == 5'); vrfy(A[0] == 5, '7556: A[0] == 5'); vrfy(g7500b(&A[0],3) == &A[3], '7557: g7500b(&A[0],3) == &A[3]'); vrfy(g7500c(&A[0],2) == 3, '7558: g7500c(&A[0], 2) == 3'); vrfy(g7500d(`A[0]) == &A[0], '7559: g7500d(`A[0]) == &A[0]'); p = &A[0]; print '7560: p = &A[0];'; vrfy(g7500a(*p, 6) == 6, '7561: g7500a(*p, 6) == 6'); vrfy(*p == 6, '7562: *p == 6'); vrfy(g7500a(`*p,6) == 6, '7563: g7500a(`*p,6) == 6'); vrfy(*p == 6, '7564: *p == 6'); vrfy(g7500b(p,3) == p + 3, '7565: g7500b(p,3) == p + 3'); vrfy(g7500c(p,2) == 3, '7566: g7500c(p,2) == 3'); vrfy(g7500d(`*p) == p, '7567: g7500d(`*p) == p'); vrfy(g7500e(p,4) == 4, '7568: g7500e(p,4) == 4'); vrfy(A[0] == 4, '7569: A[0] == 4'); vrfy(g7500e(p+2,5) == 5, '7570: g7500e(p+2,5) == 5'); vrfy(A[2] == 5, '7571: A[2] == 5'); /* testing pointers to values */ A = 27, p = &A; print '7572: A = 27, p = &A;'; vrfy(isptr(A) == 0, '7573: isptr(A) == 0'); vrfy(isptr(&A) == 2, '7574: isptr(&A) == 2'); vrfy(isptr(p) == 2, '7575: isptr(p) == 2'); vrfy(*p == 27, '7576: *p == 27'); vrfy(p == &A, '7577: p == &A'); *p = 45; print '7578: *p = 45;'; vrfy(A == 45, '7579: A == 45'); q = p; print '7580: q = p;'; vrfy(q == &A, '7581: q == &A'); q = &p; print '7582: q = &p'; vrfy(*q == p, '7583: *q == p'); vrfy(**q == A, '7584: **q == A'); vrfy(***q == A, '7585: ***q == A'); M = mat[4] = {1,2,3,4}; print '7586: M = mat[4] = {1,2,3,4};'; p = &M[0], *p = 5; print '7587: p = &M[0], *p = 5;'; vrfy(M[0] == 5, '7588: M[0] == 5'); *++p = 6; print '7589: *++p = 6;'; vrfy(M[1] == 6, '7590: M[1] == 6'); q = p++; print '7591: q = p++;'; vrfy(q == &M[1], '7592: q == &M[1]'); vrfy(p == &M[2], '7593: p == &M[2]'); quomod(17,5,*q,*p); print '7594: quomod(17,5,*p,*q);'; vrfy(M[1] == 3 && M[2] == 2, '7595: M[1] == 3 && M[2] == 2'); swap(*p, *q); print '7596: swap(*p, *q);'; vrfy(M[1] == 2 && M[2] == 3, '7597: M[1] == 2 && M[2] == 3'); A = *M = {7,8}; print '7598: A = *M = {7,8};'; vrfy(M == (mat[4] = {5,2,3,4}), '7599: M == (mat[4] = {5,2,3,4})'); vrfy(A == (mat[4] = {7,8,3,4}), '7600: A == (mat[4] = {7,8,3,4})'); /* Values which point to themselves */ A = &A; print '7601: A = &A;'; vrfy(&A == A && *A == A, '7602: &A == A && *A == A'); A = &B, B = &A; print '7603: A = &B, B = &A;'; vrfy(**A == A && ***A == B, '7604: **A == A && ***A == B'); /* Testing functions that return pointers */ M[3] = 7; print '7605: M[3] = 7;'; vrfy(*g7500b(&M[1], 2) == 7, '7606: *g7500b(&M[1], 2) == 7'); *g7500b(&M[1], 2) = 8; print '7607: *g7500b(&M[1], 2) = 8;'; vrfy(M[3] == 8, '7608: M[3] == 8'); M[3] = list(9,10); print '7609: M[3] = list(9,10);'; vrfy((*g7500b(&M[1], 2))[[1]] == 10, '7610: (*g7500b(&M[1], 2))[[1]] == 10'); /* Testing number and string pointers */ a = 24, b = 4 * 6, c = 4!; print '7611: a = 24, b = 4 * 6, c= 4!;'; vrfy(isptr(&*a) == 4, '7612: isptr(&*a) == 4'); vrfy(&*a == &24, '7613: &*a == &24'); vrfy(&*a == &*b, '7614: &*a == &*b'); vrfy(&*a != &*c, '7615: &*a != &*c'); a = b = "abc", c = strcat("a", "bc"); print '7616: a = b = "abc", c = strcat("a", "bc");'; vrfy(isptr(&*a) == 3, '7617: isptr(&*a) == 3'); vrfy(&*a == &"abc", '7618: &*a == &"abc"'); vrfy(&*a == &*b, '7619: &*a == &*b'); vrfy(&*a != &*c, '7620: &*a != &*c'); a = c; print '7621: a = c;'; vrfy(&*a == &*c, '7622: &*a == &*c'); /* Verifying null-ness of freed numbers */ c = 4!, p = &*c, free(c); print '7623: c = 4!, p = &*c, free(c)'; vrfy(isnull(*p), '7624: isnull(*p)'); print '7625: Ending test_ptr'; } print '181: parsed test_ptr()'; /* * test_newstring - test new string operations */ define test_newstring() { local A, B, C, D, S, p, q; print '7700: Beginning test_newstring'; A = "abcdef", B = "xyz"; print '7701: A = "abcdef", B = "xyz";'; vrfy(A + B == "abcdefxyz", '7702: A + B == "abcdefxyz"'); vrfy(-A == "fedcba", '7703: -A == "fedcba"'); vrfy(A - B == "abcdefzyx", '7704: A - B == "abcdefzyx"'); vrfy(2 * B == "xyzxyz", '7705: 2 * B == "xyzxyz"'); vrfy(-2 * B == "zyxzyx", '7706: -2 * B == "zyxzyx"'); vrfy(B * 3 == "xyzxyzxyz", '7707: B * 3 == "xyzxyzxyz"'); vrfy(2.5 * B == "xyzxyzx", '7708: 2.5 * B == "xyzxyzx"'); vrfy(0 * B == "", '7709: 0 * B == ""'); vrfy(3 * "12" == "121212", '7710: 2 * "12" == "121212"'); vrfy(A/2 == "abc", '7711: A/2 == "abc"'); vrfy(A | B == "y\173\173def", '7712: A | B == "y\\173\\173def"'); vrfy(A & B == "``b", '7713: A & B == "``b"'); vrfy(A \ B == "\1\2\1def", '7714: A \\ B == "\\1\\2\\1def"'); vrfy(A ~ B == "\31\e\31def", '7715: A ~ B == "\\31\\e\\31def"'); vrfy(~B == "\207\206\205", '7716: ~B == "\\207\\206\\205"'); C = "abcdef"; print '7717: C = "abcdef";'; vrfy(&*A == &*C, '7718: &*A == &*C'); D = "abc\0ef"; print '7719: D = "abc\0ef;"'; vrfy(size(D) == 6, '7720: size(D) == 6'); vrfy(strlen(D) == 3, '7721: strlen(D) == 3'); vrfy(strcat(D,B) == "abcxyz", '7722: strcat(D,B) == "abcxyz"'); vrfy(bit(A,0) == 1, '7723: bit(A,0) == 1'); vrfy(!bit(A,12), '7724: !bit(A,12)'); vrfy(bit(A,13), '7725: bit(A,13)'); vrfy(lowbit(A) == 0, '7726: lowbit(A) == 0'); vrfy(highbit(A) == 46, '7727: highbit(A) == 46'); vrfy(#A == 21, '7728: #A == 21'); vrfy(A[2] == "c", '7729: A[2] == "c"'); vrfy(char(A[2]) == "c", '7730: char(A[2]) == "c"'); vrfy(A[2] == 99, '7731: A[2] == 99'); vrfy(ord(A[2]) == 99, '7731: ord(A[2]) == 99'); vrfy(A[2] == A[0] + 2, '7732: A[2] == A[0] + 2'); vrfy(3 * A[2] == 297, '7733: 3 * A[2] == 297'); vrfy(3 * char(A[2]) == "ccc", '7734: 3 * char(A[2]) == "ccc"'); vrfy(head(A,3) == "abc", '7735: head(A,3) == "abc"'); vrfy(head(A,-3) == "cba", '7736: head(A,-3) == "cba"'); vrfy(tail(A,3) == "def", '7737: tail(A,3) == "def"'); vrfy(tail(A,-3) == "fed", '7738: tail(A,-3) == "fed"'); vrfy(segment(A,2) == "c", '7739: segment(A,2) == "c"'); vrfy(segment(A,2,4) == "cde", '7740: segment(A,2,4) == "cde"'); vrfy(segment(A,4,2) == "edc", '7741: segment(A,4,2) == "edc"'); vrfy(search(A, "c") == 2, '7742: search(A, "c") == 2'); vrfy(search(A, "x") == null(), '7743: search(A, "x") == null()'); vrfy(search("abbcbc", "bc") == 2, '7744: search("abbcbc", "bc") == 2'); vrfy(search("abbcbc", "bc", 2) == 2, '7745: search("abbcbc", "bc", 2) == 2'); vrfy(search("abbcbc", "bc", 3) == 4, '7746: search("abbcbc", "bc", 3) == 4'); vrfy(search("abbcbc", "bc", -3) == 4, '7747: search("abbcbc", "bc", -3) == 4'); vrfy(search("abbcbc", "bc", -4) == 2, '7748: search("abbcbc", "bc", -4) == 2'); vrfy(search("abbcbc", "bc", , 3) == null(), '7749: search("abbcbc", "bc", , 3) == null()'); vrfy(search("abbcbc", "bc", , 4) == 2, '7750: search("abbcbc", "bc", , 4) == 2'); vrfy(rsearch("abbcbc", "bc") == 4, '7751: rsearch("abbcbc", "bc") == 4'); p = &A[0]; print '7752: p = &A[0];'; vrfy(-*p == -97, '7753: -*p == -97'); vrfy(~*p == char(158), '7754: ~*p == char(158)'); vrfy(/-#~*p == -1/5, '7755: /-#~*p == -1/5'); A[0] = "A"; print '7756: A[0] = "A";'; vrfy(A == "Abcdef", '7757: A == "Abcdef"'); A[1] = 173; print '7758: A[1] = 173;'; vrfy(A == "A\255cdef", '7759: A == "A\\255cdef"'); setbit(A, 18); print '7760: setbit(A,10);'; vrfy(A == "A\255gdef", '7761: A == "A\\255gdef"'); setbit(A, 16, 0); print '7762: setbit(A, 16, 0);'; vrfy(A == "A\255fdef", '7763: A == "A\255fdef"'); q = "curds" " and " "whey"; print '7764: q = "curds" " and " "whey"'; vrfy(q == "curds and whey", '7765: q == "curds and whey"'); q = "chongo" ' was ' "here"; print '7766: q = "chongo" \' was \' "here"'; vrfy(q == "chongo was here", '7767: q == "chongo was here"'); print '7768: Ending test_newstring'; } print '182: parsed test_newstring()'; /* * test_newcomb - test combinatoric and permutation functions */ define test_newcomb() { print '7800: Beginning test_newcomb'; vrfy(comb(2, 5) == 0, '7801: comb(2, 5) == 0'); vrfy(comb(2, -2) == 0, '7802: comb(2, -2) == 0'); vrfy(comb(1/2, 4) == -5/128, '7803: comb(1/2, 4) == -5/128'); vrfy(comb(1/2, 5) == 7/256, '7804: comb(1/2, 5) == 7/256'); vrfy(perm(2, -1) == 1/3, '7805: perm(2, -1) == 1/3'); vrfy(perm(2, -2) == 1/12, '7806: perm(2, -2) == 1/12'); vrfy(perm(2, -3) == 1/60, '7807: perm(2, -3) == 1/60'); vrfy(perm(1/2, 4) == -15/16, '7808: perm(1/2, 4) == -15/16'); vrfy(perm(1/2, 5) == 105/32, '7809: perm(1/2, 5) == 105/32'); vrfy(perm(1/2,-1) == 2/3, '7810: perm(1/2, -1) == 2/3'); vrfy(perm(1/2,-2) == 4/15, '7811: perm(1/2, -2) == 4/15'); print '7812: Ending test_newcomb'; } print '183: parsed test_newcomb()'; /* * The following functions f, g should be equal when b-a is an * integer, and n is any integer other than -1. */ define f7900(a,b,n) { local s, x; if (a > b) return -f7900(b, a, n); for (s = 0, x = a; x < b; x++) s += perm(x, n); return s; } print '184: define f7900(a,b,n) {... }'; /**/ define g7900(a,b,n) = (perm(b, n + 1) - perm(a, n + 1))/(n + 1); print '185: define g7900(a,b,n) = ...'; /* * test_bigcomb - test big combinations and permutations */ define test_bigcomb() { local a, b, n, i, v1, v2; print '7900: Starting test_bigcomb'; a = 1234/4321; print '7901: a = 1234/4321'; b = 3456/6543; print '7902: b = 3456/6543'; n = 47; print '7903: n = 47'; v1 = perm(a + b, n); print '7904: v1 = perm(a + b, n)'; v2 = 0; print '7905: v2 = 0'; for (i = 0; i <= n; i++) v2 += comb(n, i) * perm(a, i) * perm(b, n - i); print '7906: for (i=0;i<=n;i++) v2 += comb(n,i)*perm(a,i)*perm(b,n-i)'; vrfy(v1 == v2, '7910: v1 == v2'); vrfy(f7900(-10,10,5) == g7900(-10,10,5), '7911: f7900(-10,10,5) == g7900(10,10,5)'); vrfy(f7900(5,15,-4) == g7900(5,15,-4), '7912: f7900(5,15,-4) == g7900(5,15,-4)'); vrfy(f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2), '7913: f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2)'); print '7914: Ending test_bigcomb'; } print '186: parsed test_bigcomb()'; /* * natnumset - test natural numbers not exceeding a fixed bound */ read -once natnumset; print '187: read -once natnumset;'; /**/ define test_natnumset() { local A, B, C, D, P, P1, L1, L2; print '8000: Starting test_natnumset'; A = set(17, 2, 0, 24, 2); print '8101: A = set(17, 2, 0, 24, 2);'; B = set(41, 17, 11, 2, 19, 17); print '8102: B = set(41, 17, 11, 2, 19, 17);'; vrfy(A | B == set(0,2,11,17,19,24,41), '8103: A | B == set(0,2,11,17,19,24,41)'); vrfy(A & B == set(2,17), '8104: A & B == set(2,17)'); vrfy(A \ B == set(0,24), '8105: A \\ B == set(0, 24)'); vrfy(B \ A == set(11,19,41), '8106: B \\ A == set(11,19,41)'); vrfy(A ~ B == set(0,11,19,24,41), '8107: A ~ B == set(0,11,19,24,41)'); vrfy(#A == 4, '8108: #A == 4'); vrfy(#~A == 97, '8109: #~A == 97'); vrfy(A + 5 == set(5,7,22,29), '8110: A + 5 == set(5,7,22,29)'); vrfy(A - 5 == set(12,19), '8111: A - 5 == set(12,19)'); vrfy(30 - A == set(6,13,28,30), '8112: 30 - A == set(6,13,28,30)'); vrfy(2 * A == set(0,4,34,48), '8113: 2 * A == set(0,4,34,48)'); vrfy(10 * A == set(0,20), '8114: 10 * A == set(0,20)'); vrfy(A + A == set(0,2,4,17,19,24,26,34,41,48), '8115: A + A == set(0,2,4,17,19,24,26,34,41,48)'); vrfy(A - A == set(0,2,7,15,17,22,24), '8116: A - A == set(0,2,7,15,17,22,24)'); vrfy(set(2,3,5,7)^2 == set(4,9,25,49), '8117: set(2,3,5,7)^2 == set(4,9,25,49)'); vrfy(interval(8,12) == set(8,9,10,11,12), '8118: interval(8,12) == set(8,9,10,11,12)'); vrfy(min(A) == 0, '8119: min(A) == 0'); vrfy(max(A) == 24, '8120: max(A) == 24'); P = primes(); print '8121: P = primes();'; vrfy(#P == 25, '8122: #P == 25'); vrfy(+P == 1060, '8123: +P == 1060'); vrfy(isin(P,31), '8124: isin(P,31)'); vrfy(!isin(P,51), '8125: !isin(P,51)'); P1 = primes(20,40); print '8126: P1 = primes(20,40)'; vrfy(P1 == set(23,29,31,37), '8127: P1 == set(23,29,31,37)'); vrfy(P1 < P, '8128: P1 < P'); vrfy(P1 & (set(3) % 4) == set(23,31), '8129: P1 & (set(3) % 4) == set(23,31)'); L1 = list(3,2,1); print '8130: L1 = list(3,2,1);'; C = set(2,3,5,7); print '8131: C = set(2,3,5,7);'; vrfy(polyvals(L1, C) == set(11,18,38,66), '8132: polyvals(L1, C) == set(11,18,38,66)'); L2 = list(0,list(0,1),1); print '8133: L2 = list(0,list(0,1),1);'; D = set(4,6); print '8134: D = set(4,6);'; vrfy(polyvals2(L2,C,D) == set(12,16,21,27,45,55,77,91), '8135: polyvals(L2,C,D) == set(12,16,21,27,45,55,77,91)'); print '8136: Ending test_natnumset'; } print '188: parsed test_natnumset()'; /* * test_somenew - test some new features */ define func8200(x,y) {if (x>0) return calclevel()+func8200(x-1,y)-y; return 0;} print '189: define func8200(x,y)'; define test_somenew() { local a, s, y; print '8200: Starting test_somenew'; vrfy(char(-1) == char(255), '8201: char(-1) == char(255)'); vrfy(char(258) == char(2), '8202: char(258) == char(2)'); vrfy(size(char(0)) == 1, '8203: size(char(0)) == 1'); vrfy(strlen(char(0)) == 0, '8204: strlen(char(0)) == 0'); vrfy(char(0) != "", '8205: char(0) != ""'); vrfy(strcmp(char(0),"") == 0, '8206: strcmp(char(0),"") == 0'); vrfy(str("abc") == "abc", '8207: str("abc") == "abc"'); vrfy(2^-3^2 == 1/512, '8208: 2^-3^2 == 1/512'); vrfy(/2 == .5, '8209: /2 == .5'); vrfy(/-2 == -.5, '8210: /-2 == -.5'); vrfy(1+/2 == 1.5, '8211: 1+/2 == 1.5'); ecnt += 6; print '8212: ecnt += 6'; vrfy(0^-2 == 1/0, '8213: 0^-2 == 1/0'); vrfy(inverse(0) == 1/0, '8214: inverse(0) == 1/0'); vrfy(1/(1/0) == 0, '8215: 1/(1/0) == 0'); vrfy(inverse(1/0) == 0, '8216: inverse(1/0) == 0'); a = isqrt(2e1000); s = "xyz"; print '8217: a = isqrt(2e1000); s = "xyz";'; vrfy(hash(a,s) == 2708885378, '8218: hash(a,s) == 2708885378'); vrfy(hash("curds n whey") == 2376141927, '8219: hash("curds n whey") == 2376141927'); y = calclevel(); print '8220: y = calclevel()'; vrfy(func8200(0,y) == 0, '8221: func8200(0,y) == 0'); vrfy(func8200(1,y) == 1, '8222: func8200(1,y) == 1'); vrfy(func8200(10,y) == 55, '8223: func8200(10,y) == 55'); vrfy(func8200(100,y) == 5050, '8224: func8200(100,y) == 5050'); vrfy(inputlevel() == 1, '8225: inputlevel() == 1'); print '8226: Ending test_somenew'; } print '190: parsed test_somenew()'; /* * test_quit - test the QUIT functionality */ define test_quit() { local x8400 = 23209; /* watch for lost memory */ static s8400 = 21701; /* watch for lost memory */ print '8400: Starting test_quit'; quit; prob('quit did not end the test_quit() function'); /* 8400 serise continued after return, do not print end here */ } print '191: parsed test_quit()'; /* * Reserved for top level test use */ print '200: Reserved for top level test use'; /* * Report the number of errors found. */ define count_errors() { if (prob == 0) { print "9997: passed all tests /\\../\\"; } else { print "****", prob, "error(s) found \\/++\\/"; } } print '298: parsed count_errors()'; print '299: Ending main part of regression test suite read'; print; return test_booleans(); print; return test_variables(); print; return test_arithmetic(); print; return test_config(); print; return test_bignums(); print; return test_functions(); print; return _test_underscore(); print; return test_assoc(); print; return test_list(); print; return test_rand(); print; return test_mode(); print; print '1700: Beginning read test'; value = 0; vrfy(value == 0, '1701: value == 0'); read "test1700"; print '1702: read "test1700";'; vrfy(value == 1, '1703: value == 1'); read -once "test1700"; print '1704: read -once "test1700";'; vrfy(value == 1, '1705: value == 1'); read "test1700.cal"; print '1706: read "test1700.cal";'; vrfy(value == 2, '1707: value == 2'); read -once "test1700.cal"; print '1708: read -once "test1700.cal";'; vrfy(value == 2, '1709: value == 2'); read "test1700.cal"; print '1710: read "test1700.cal";'; vrfy(value == 3, '1711: value == 3'); {++value;} read "test1700.cal"; print '1712: {++value;} read "test1700.cal";'; vrfy(value == 5, '1713: value == 5'); {++value;} read -once "test1700.cal"; print '1714: {++value;} read -once "test1700.cal";'; vrfy(value == 6, '1715: value == 6'); print '1716: Ending read test'; print; return test_obj(); print; return test_prime(); print; return test_lucas(); print; return test_newop(); print; return test_xx_incdec(); print; return test_round(); print; return test_2600(); print; return test_2700(); print; return test_matrix(); print; return test_strings(); print; return test_matobj(); print; return test_poly(); print; return test_det(); print; return test_trig(); print; return test_frem(); print; return test_error(); print; return test_param(); print; return test_noarg(); print; return test_ptest(); print; return test_redc(); print; return test_fileops(); print; return test_matdcl(); print; return test_objmat(); print; return test_fileop(); print; return test_charset(); print; return test_strprintf(); print; return test_listsearch(); print; return test_filesearch(); print; return test_newdecl(); print; return test_globstat(); print; return test_random(); print; return test_newsyn(); vrfy(s5500 == 78, '5548: s5500 == 78'); print; return test_commaeq(); print; return test_size(); print; /* * 5800 assignment tests */ return test_assign(5800, 1); define xy5800_assign(a,b) { }; print '5812: define xy5800_assign(a,b) { }'; return test_assign(5820, 0); undefine xy5800_assign; print '5832: undefine xy5800_assign'; return test_assign(5840, 1); define xy5800_assign(a, b) = a.y = b; print '5852: define xy5800_assign(a, b) = a.y = b'; X5800 = 9; print '5853: X5800 = 9'; vrfy(X5800 == (obj xy5800 = {3,9}), '5854: X5800 == (obj xy5800 = {3,9})'); asserr = newerror("Incompatible types for ="); print '5855: asserr = newerror("Incompatible types for =")'; define xy5800_assign(a, b) { if (istype(b, obj xy5800)) { a.x = b.x; a.y = b.y; } else if (isreal(b)) { a.x = b; a.y = 0; } else { error(asserr); } } print '5856: xy5800_assign(a, b) { ... };'; ecnt += 2; print '5857: ecnt += 2'; X5800 = 2 + 3i; print '5858: X5800 = 2 + 3i'; vrfy(X5800 == (obj xy5800 = {3,9}), '5859: X5800 == (obj xy5800 = {3,9})'); vrfy(errno() > 0, '5860: errno() > 0'); vrfy(strerror() == "Incompatible types for =", '5861: strerror() == "Incompatible types for ="'); X5800 = 2; print '5862: X5800 = 2'; vrfy(X5800 == (obj xy5800 = {2,0}), '5863: X5800 == (obj xy5800 = {2,0})'); X5800 = obj xy5800 = {1,2}; print '5864: X5800 = obj xy5800 = {1,2}'; vrfy(X5800 == (obj xy5800 = {1,2}), '5865: X5800 == (obj xy5800 = {1,2})'); print '5866: End of 5800 sequence'; print; return test_is(); print; return test_blk(); print; return test_blkcpy(); print; return test_name(); print; return test_blkprintf(); print; return test_sha(); print; return test_sha1(); print; return test_md5(); print; print '7400: Beginning test_savedot'; print '7401: saveval(1);'; saveval(1); print '7402: a7400 = 2;'; a7400 = 2; vrfy(. == 2, '7403: . == 2;'); vrfy((. += 3, . == 5), '7404: (. += 3, . == 5)'); vrfy(. == 5, '7405: . == 5;'); print '7406: a7400 = 5; b7400 = 6;'; a7400 = 5; b7400 = 6; vrfy(. == 6, '7407: . == 6'); print '7408: a7400 = 7; b7400 = 8; null()'; a7400 = 7; b7400 = 8; null(); vrfy(. == 6, '7409: . == 6'); print '7410: saveval(0);'; saveval(0); print '7411: a7400 = 9;'; a7400 = 9; vrfy(. == 6, '7412: . == 6'); print '7413: a7400 = 2; saveval(1); b7400 = 3; saveval(0); c7400 = 4;'; a7400 = 2; saveval(1); b7400 = 3; saveval(0); c7400 = 4; vrfy(. == 3, '7414: . == 3'); print '7415: free(.);'; free(.); vrfy(isnull(.), '7416: isnull(.)'); print '7417: a7400 = 4;'; a7400 = 4; vrfy(isnull(.), '7418: isnull(.)'); print '7419: saveval(1);'; saveval(1); print '7420: obj pair7400 {one,two} = {1,2};'; obj pair7400 {one,two} = {1,2}; vrfy(. .one == 1, '7421: . .one == 1'); print '7422: Ending test_savedot'; print; return test_ptr(); print; return test_newstring(); print; return test_newcomb(); print; return test_bigcomb(); print; return test_natnumset(); print; return test_somenew(); /* * misc define tests */ print; print '8300: Starting define tests'; define f8300(x) = x^2; define g8300(x) = 1 - x; print '8301: define f8300(x) = x^2; define g8300(x) = 1 - x;'; vrfy(f8300(10) == 100, '8302: f8300(10) == 100'); vrfy(g8300(10) == -9, '8303: g8300(10) == -9'); define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1; print '8304: define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1;'; vrfy(h8300(10) == 1000, '8305: h8300(10) == 1000'); vrfy(i8300(10) == 9, '8306: i8300(10) == 9'); vrfy(j8300(10) == 11, '8307: j8300(10) == 11'); {static k8300 = 5} define l8300(x) = k8300 + x; print '8308: {static k8300 = 5} define l8300(x) = k8300 + x;'; vrfy(l8300(10) == 15, '8309: l8300(10) == 15'); print '8310: Ending define tests'; /* * quit tests */ print; return test_quit(); read -once test8400; print '8404: read -once test8400'; vrfy(test8400() == 64434, '8405: test8400() == 64434'); print '8406: Ending test_quit'; /* * read various calc libs * * We read most of the calc libs shipped with the distribution. * There are a few lib files that are not read: * * beer.cal - prints a bunch of things when loaded * hello.cal - designed to go into an infinite loop * lucal.cal - already read by this file * lucas_chk.cal - already read by this file * lucas_tbl.cal - duplicatres code already read by another file * regress.cal - this file * surd.cal - already read by this file * test9999.cal - files of this form are already read by this file * xx_print.cal - prints a bunch of things when loaded * * We want to do this 2nd to last; ahead of any final cleanup and behind * all of real actions of regress.cal. */ print; print '9800: Starting read of selected calc libs'; read -once bernoulli; print '9801: read -once bernoulli'; read -once bigprime; print '9802: read -once bigprime'; read -once chrem; print '9803: read -once chrem'; read -once deg; print '9804: read -once deg'; read -once ellip; print '9805: read -once ellip'; read -once mersenne; print '9806: read -once mersenne'; read -once mfactor; print '9807: read -once mfactor'; read -once mod; print '9808: read -once mod'; read -once natnumset; print '9809: read -once natnumset'; read -once pell; print '9810: read -once pell'; read -once pi; print '9811: read -once pi'; read -once pix; print '9812: read -once pix'; read -once pollard; print '9813: read -once pollard'; read -once poly; print '9814: read -once poly'; read -once prompt; print '9815: read -once prompt'; read -once psqrt; print '9816: read -once psqrt'; read -once quat; print '9817: read -once quat'; read -once randbitrun; print '9818: read -once randbitrun'; read -once randmprime; print '9819: read -once randmprime'; read -once randombitrun; print '9820: read -once randombitrun'; read -once randomrun; print '9821: read -once randomrun'; read -once randrun; print '9822: read -once randrun'; read -once seedrandom; print '9823: read -once seedrandom'; read -once solve; print '9824: read -once solve'; read -once sumsq; print '9825: read -once sumsq'; read -once unitfrac; print '9826: read -once unitfrac'; read -once varargs; print '9827: read -once varargs'; read -once qtime; print '9828: read -once qtime'; print '9829: Ending read of selected calc libs'; /* * cleanup and report the results */ print; freeredc(); print '9995: freeredc()'; freestatics(); print '9996: freestatics()'; return count_errors(); freeglobals(); print '9998: freeglobals()'; print '9999: Ending regression tests';