/* * regress - calc regression and correctness test suite * * Copyright (C) 1999-2017,2021,2023 David I. Bell and Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License * as published by the Free Software Foundation. * * Calc is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General * Public License for more details. * * A copy of version 2.1 of the GNU Lesser General Public License is * distributed with calc under the filename COPYING-LGPL. You should have * received a copy with calc; if not, write to Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Under source code control: 1990/02/15 01:50:36 * File existed as early as: before 1990 * * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ */ /* * IMPORTANT NOTE: When adding new tests, look for comments with: * * * *********************************************** * * * NOTE: ==> Room for new tests ....-.... <== here * * * *********************************************** * * * Select test numbers using a new block of a multiple of 100 test numbers. * * Test the correct execution of the calculator by reading this resource file. * Errors are reported with '****' messages, or worse. :-) * * NOTE: Unlike most calc resource 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. */ /* * test 000-002: Start of the regression test suite */ 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'; /* * test 003: define regression test global variables and error counts */ global prob; /* libregress.cal problem counter */ prob = 0; /* clear problem counter */ errcount(0),; /* clear error count */ errmax(-1),; /* prevent errcount from aborting */ global ecnt; /* expected value of errcount() */ ecnt = 0; /* clear expected errcount() value */ initcfg = config("all", "newstd"); /* set config to startup default */ defcfg = config("all"); /* capture the default config */ config("resource_debug", 0),; /* disable resource startup messages */ config("calc_debug", 0),; /* disable internal debugging */ config("verbose_quit", 0),; /* disable quit messages */ startcfg = config("all"); /* save state for later use */ print '003: parsed global definitions'; /* * test 004: define vrfy * * This function verifies that a regress test is true and passed. * * 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:', str; ++prob; } else { print str; } return; } print '004: parsed vrfy()'; /* * test 005: define prob * * This function is used as a regress test error notification and error count. */ define prob(str) { print '****' , str; ++prob; } print '005: parsed prob()'; /* * test 006: define test_booleans for test 30d + 31d + 32d * * This function tests boolean operations and IF statements. * * 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 '006: parsed test_booleans()'; /* * test 007-008: define test_variables, test_variables for test 35d + 36d + 37d + 38d * * This function tests return of a global value. */ define getglobalvar() { global globalvar; return globalvar; } print '007: parsed getglobalvar()'; /* * This function tests variables, simple assignments, AND and OR operators, short-circuit eval. */ define test_variables() { local x1, x2, x3; global g1, g2; local t; 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 009: define test_arithmetic for test 4dd * * This function tests simple arithmetic operations and expressions. */ define test_arithmetic() { local x; 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 == 7'); 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'); vrfy(0^(0-0) == 1, '450: 0^(0-0) == 1'); vrfy(0^(2-2) == 1, '451: 0^(2-2) == 1'); vrfy(2^0 == 1, '452: 2^0 == 1'); vrfy(2^(0-0) == 1, '453: 2^(0-0) == 1'); vrfy(2^(2-2) == 1, '454: 2^(2-2) == 1'); vrfy((2^23209-1)^0 == 1, '455: (2^23209-1)^0 == 1'); vrfy((2^23209-1)^(0-0) == 1, '456: (2^23209-1)^(0-0) == 1'); vrfy((2^23209-1)^(2-2) == 1, '457: (2^23209-1)^(2-2) == 1'); vrfy((2^23209-1)^((2^23209-1)-(2^23209-1)) == 1, '458: (2^23209-1)^((2^23209-1)-(2^23209-1)) == 1'); vrfy(0^2 == 0, '459: 0^2 == 0'); vrfy(0^3 == 0, '460: 0^3 == 0'); vrfy(0^12 == 0, '461: 0^12 == 0'); vrfy(0^13 == 0, '462: 0^13 == 0'); x = 0; vrfy(x == 0, '463: x == 0'); vrfy(0^2 == 0, '464: 0^2 == 0'); vrfy(0^3 == 0, '465: 0^3 == 0'); vrfy(0^12 == 0, '466: 0^12 == 0'); vrfy(x^13 == 0, '467: x^13 == 0'); print '462: Ending test_arithmetic'; } print '009: parsed test_arithmetic()'; /* * test 010: define test_config for test 5dd * * This function tests 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")'; vrfy(callcfg == startcfg, '502: callcfg == startcfg'); callcfg = config("all", "oldstd"); print '503: callcfg = config("all","oldstd")'; vrfy(callcfg == startcfg, '504: callcfg == startcfg'); oldcfg = config("all"); print '505: oldcfg = config("all");'; vrfy(config("all") == oldcfg, '506: config("all") == oldcfg'); vrfy(oldcfg==config("all","newstd"), '507: oldcfg==config("all","newstd")'); vrfy(defcfg == config("all"), '508: defcfg == config("all")'); /* vrfy the state of the default config */ 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") == 28, '514: config("mul2") == 28'); vrfy(config("sq2") == 28, '515: config("sq2") == 28'); vrfy(config("pow2") == 20, '516: config("pow2") == 20'); vrfy(config("redc2") == 25, '517: config("redc2") == 25'); vrfy(config("tilde"), '518: config("tilde")'); vrfy(config("tab"), '519: config("tab")'); 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") == 24, '527: config("outround") == 24'); vrfy(config("round") == 24, '528: config("round") == 24'); vrfy(config("leadzero") == 1, '529: config("leadzero") == 1'); 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 "oldstd" config by individual changes */ print '534: test unused'; vrfy(config("outround", 2) == 24, '535: config("outround", 2) == 24'); vrfy(config("leadzero","n") == 1, '536: config("leadzero","n") == 1'); print '537: test unused'; vrfy(config("prompt", "> ") == "; ", '538: config("prompt", "> ") == "; "'); vrfy(config("more", ">> ") == ";; ", '539: config("more", ">> ") == ";; "'); vrfy(config("all") == oldcfg, '540: config("all") == oldcfg'); /* restore the configuration at the start of this function */ vrfy(config("all",callcfg) == oldcfg, '541: config("all",callcfg) == oldcfg'); /* display and fullzero tests */ vrfy(config("display",2) == 20, '542: config("display",2) == 20'); vrfy(config("leadzero",0) == 1, '543: config("leadzero",0) == 1'); vrfy(config("fullzero",1) == 0, '544: config("fullzero",1) == 0'); vrfy(strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00", '545: strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00"'); vrfy(config("display",20) == 2, '546: config("display",20) == 2'); vrfy(config("leadzero",1) == 0, '547: config("leadzero",1) == 0'); 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) == startcfg, '550: config("all",callcfg) == startcfg'); vrfy(config("all") == callcfg, '551: config("all") == callcfg'); vrfy(config("all") == startcfg, '552: config("all") == startcfg'); /* check read-only config values */ vrfy(strlen(config("program")) > 0, '553: strlen(config("program")) > 0'); vrfy(strlen(config("basename")) > 0, '554: strlen(config("basename")) > 0'); vrfy(strlen(config("version")) > 0, '555: strlen(config("version")) > 0'); /* mode2 is off by default */ vrfy(config("mode2") == "off", '556: config("mode2") == "off"'); /* hz is numeric */ vrfy(isint(config("hz")), '557: isint(config("hz"))'); /* compile_custom is simple */ vrfy(issimple(config("compile_custom")), '558: issimple(config("compile_custom"))'); /* allow_custom is simple */ vrfy(issimple(config("allow_custom")), '559: issimple(config("allow_custom"))'); /* allow_custom is simple */ vrfy(issimple(config("allow_custom")), '559: issimple(config("allow_custom"))'); /* baseb is numeric */ vrfy(isint(config("baseb")), '560: isint(config("baseb"))'); /* redecl_warn is simple */ vrfy(issimple(config("redecl_warn")), '561: issimple(config("redecl_warn"))'); /* dupvar_warn is simple */ vrfy(issimple(config("dupvar_warn")), '562: issimple(config("rdupvar_warn"))'); /* test space modes */ vrfy(config("tilde_space") == 0, '563: config("tilde_space") == 0'); vrfy(config("fraction_space") == 0, '564: config("fraction_space") == 0'); vrfy(config("complex_space") == 0, '565: config("complex_space") == 0'); print '566: Ending test_config'; } print '010: parsed test_config()'; /* * test 011-016: define muldivcheck, squarecheck, fraccheck, powercheck, algcheck, test_bignums for test 6dd * * This function tests multiplication and division on three numbers in various ways. */ 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()'; /* * This function tests 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()'; /* * This function tests the use the raising of numbers to large powers to check multiplication and exponentiation. */ define powercheck(a, p1, p2, str) { local a1, a2, a3; local b1, b2, b3; a1 = (a^p1)^p2; a2 = (a^p2)^p1; a3 = a^(p1*p2); b1 = (a**p1)**p2; b2 = (a**p2)**p1; b3 = 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;} if (b1 != b2) {print '**** (b^p1)^p2 != (b^p2)^p1:', str; ++prob;} if (b1 != b3) {print '**** (b^p1)^p2 != b^(p1*p2):', str; ++prob;} print str; } print '013: parsed powercheck()'; /* * This function tests fraction reductions for arguments that are 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()'; /* * This function tests 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()'; /* * This function tests 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 017: define test_functions for test 7dd + 8dd + 9dd + 10dd + 11dd + 12dd * * This function tests many of the built-in functions. * * See test_functions() (test 700 - 1238) for other built-in function tests. * See test_functions2() (test 9000 - 9063) for other built-in function tests. * See test_functions3() (test 9100 - 9214) for other built-in function tests. */ define test_functions() { local a, b; local pi; local h, n, r, m, v; local n2, m2, v2; local t; 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'); if (config("windows") || config("cygwin")) { print '949: test skipped for windows or cygwin systems'; print '950: test skipped for windows or cygwin systems'; } else { 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)'); /* * catalan testing */ vrfy(catalan(2) == 2, '1113: catalan(2) == 2'); vrfy(catalan(3) == 5, '1114: catalan(3) == 5'); vrfy(catalan(4) == 14, '1115: catalan(4) == 14'); vrfy(catalan(20) == 6564120420, '1116: catalan(20) == 6564120420'); /* * bernoulli builtin function testing */ vrfy(bernoulli(0) == 1, '1117: bernoulli(0) == 1'); vrfy(bernoulli(1) == -1/2, '1118: bernoulli(1) == -1/2'); vrfy(bernoulli(2) == 1/6, '1119: bernoulli(2) == 1/6'); vrfy(bernoulli(3) == 0, '1120: bernoulli(3) == 0'); vrfy(bernoulli(4) == -1/30, '1121: bernoulli(4) == -1/30'); vrfy(bernoulli(5) == 0, '1122: bernoulli(5) == 0'); vrfy(bernoulli(6) == 1/42, '1123: bernoulli(6) == 1/42'); vrfy(bernoulli(32) == -7709321041217/510, '1124: bernoulli(32) == -7709321041217/510'); /* * euler function testing */ vrfy(euler(0) == 1, '1125: euler(0) == 1'); vrfy(euler(1) == 0, '1126: euler(1) == 0'); vrfy(euler(2) == -1, '1127: euler(2) == -1'); vrfy(euler(3) == 0, '1128: euler(3) == 0'); vrfy(freeeuler() == null(), '1129: freeeuler() == null()'); vrfy(euler(4) == 5, '1130: euler(4) == 5'); vrfy(euler(5) == 0, '1131: euler(5) == 0'); vrfy(euler(6) == -61, '1132: euler(6) == -61'); vrfy(euler(32) == 177519391579539289436664789665, '1130: euler(32) == 177519391579539289436664789665'); vrfy(freeeuler() == null(), '1133: freeeuler() == null()'); /* * digit with non-10 base */ a = 123456.789; print '1134: a = 123456.789'; vrfy(digit(a, 6, 100) == 0, '1135: digit(a, 6, 100) == 0'); vrfy(digit(a, 5, 100) == 0, '1136: digit(a, 5, 100) == 0'); vrfy(digit(a, 4, 100) == 0, '1137: digit(a, 4, 100) == 0'); vrfy(digit(a, 3, 100) == 0, '1138: digit(a, 3, 100) == 0'); vrfy(digit(a, 2, 100) == 12, '1139: digit(a, 2, 100) == 12'); vrfy(digit(a, 1, 100) == 34, '1140: digit(a, 1, 100) == 34'); vrfy(digit(a, 0, 100) == 56, '1141: digit(a, 0, 100) == 56'); vrfy(digit(a, -1, 100) == 78, '1142: digit(a, -1, 100) == 78'); vrfy(digit(a, -2, 100) == 90, '1143: digit(a, -2, 100) == 90'); vrfy(digit(a, -3, 100) == 0, '1144: digit(a, -3, 100) == 0'); vrfy(digit(a, -4, 100) == 0, '1145: digit(a, -4, 100) == 0'); vrfy(digit(a, -5, 100) == 0, '1146: digit(a, -5, 100) == 0'); vrfy(digit(a, -6, 100) == 0, '1146: digit(a, -6, 100) == 0'); /* * digits with a non-10 base */ vrfy(digits(a, 100) == 3, '1147: digits(a, 100) == 3'); vrfy(digits(2^256-1, 256) == 32,'1148: digits(2^256-1, 256) == 32'); /* * places with a non-10 base */ vrfy(places(0.0123, 2) == -1, '1149: places(0.0123, 2) == -1'); vrfy(places(0.625, 2) == 3, '1150: places(0.625, 2) == 3'); vrfy(places(0.625, 8) == 1, '1151: places(0.625, 8) == 1'); vrfy(places(171/2^712, 2) == 712, '1152: places(171/2^7120.625, 2) == 712'); vrfy(places(171/2^712, 64) == 119, '1152: places(171/2^7120.625, 64) == 119'); /* * verify sleep */ vrfy(sleep(1/5) == null(), '1153: sleep(1/5) == null()'); vrfy(sleep(1/100) == null(), '1154: sleep(1/100) == null()'); /* * verify calcpath */ vrfy(isstr(calcpath()), '1155: isstr(calcpath())'); /* * ssq use of lists */ vrfy(ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204, '1156: ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204'); /* * quomod 5th argument rounding tests */ vrfy(quomod(10,-3,a,b,0) == 1, '1157: vrfy(quomod(10,-3,a,b,0) == 1'); vrfy(a == -4, '1158: a == -4'); vrfy(b == -2, '1159: b == -2'); vrfy(quomod(-10,-3,a,b,1) == 1, '1160: vrfy(quomod(-10,-3,a,b,1) == 1'); vrfy(a == 4, '1161: a == 4'); vrfy(b == 2, '1162: b == 2'); vrfy(quomod(10,3,a,b,2) == 1, '1163: vrfy(quomod(10,3,a,b,2) == 1'); vrfy(a == 3, '1164: a == 3'); vrfy(b == 1, '1165: b == 1'); vrfy(quomod(-10,3,a,b,3) == 1, '1166: vrfy(quomod(-10,3,a,b,3) == 1'); vrfy(a == -4, '1167: a == -4'); vrfy(b == 2, '1168: b == 2'); vrfy(quomod(10,-3,a,b,4) == 1, '1169: vrfy(quomod(10,-3,a,b,4) == 1'); vrfy(a == -3, '1170: a == -3'); vrfy(b == 1, '1171: b == 1'); vrfy(quomod(-10,-3,a,b,5) == 1, '1172: vrfy(quomod(-10,-3,a,b,5) == 1'); vrfy(a == 3, '1173: a == 3'); vrfy(b == -1, '1174: b == -1'); vrfy(quomod(10,3,a,b,6) == 1, '1175: vrfy(quomod(10,3,a,b,6) == 1'); vrfy(a == 3, '1176: a == 3'); vrfy(b == 1, '1177: b == 1'); vrfy(quomod(-10,3,a,b,7) == 1, '1178: vrfy(quomod(-10,3,a,b,7) == 1'); vrfy(a == -4, '1179: a == -4'); vrfy(b == 2, '1180: b == 2'); vrfy(quomod(10,-3,a,b,8) == 1, '1181: vrfy(quomod(10,-3,a,b,8) == 1'); vrfy(a == -4, '1182: a == -4'); vrfy(b == -2, '1183: b == -2'); vrfy(quomod(-10,-3,a,b,9) == 1, '1184: vrfy(quomod(-10,-3,a,b,9) == 1'); vrfy(a == 3, '1185: a == 3'); vrfy(b == -1, '1186: b == -1'); vrfy(quomod(10,3,a,b,10) == 1, '1187: vrfy(quomod(10,3,a,b,10) == 1'); vrfy(a == 4, '1188: a == 4'); vrfy(b == -2, '1189: b == -2'); vrfy(quomod(-10,3,a,b,11) == 1, '1190: vrfy(quomod(-10,3,a,b,11) == 1'); vrfy(a == -4, '1191: a == -4'); vrfy(b == 2, '1192: b == 2'); vrfy(quomod(10,-3,a,b,12) == 1, '1193: vrfy(quomod(10,-3,a,b,12) == 1'); vrfy(a == -3, '1194: a == -3'); vrfy(b == 1, '1195: b == 1'); vrfy(quomod(-10,-3,a,b,13) == 1, '1196: vrfy(quomod(-10,-3,a,b,13) == 1'); vrfy(a == 4, '1197: a == 4'); vrfy(b == 2, '1198: b == 2'); vrfy(quomod(10,3,a,b,14) == 1, '1199: vrfy(quomod(10,3,a,b,14) == 1'); vrfy(a == 4, '1200: a == 4'); vrfy(b == -2, '1201: b == -2'); vrfy(quomod(-10,3,a,b,15) == 1, '1202: vrfy(quomod(-10,3,a,b,15) == 1'); vrfy(a == -4, '1203: a == -4'); vrfy(b == 2, '1204: b == 2'); /* runtime(), systime(), usertime() return numeric values */ vrfy(isnum(runtime()), '1205: isnum(runtime())'); vrfy(isnum(systime()), '1206: isnum(systime())'); vrfy(isnum(usertime()), '1207: isnum(usertime())'); /* more jacobi tests */ vrfy(jacobi(987897,987) == 0, '1208: jacobi(987897,987) == 0'); vrfy(jacobi(897,987) == 0, '1209: jacobi(897,987) == 0'); vrfy(jacobi(987,897) == 0, '1210: jacobi(987,897) == 0'); vrfy(jacobi(90,897) == 0, '1211: jacobi(90,897) == 0'); vrfy(jacobi(45,897) == 0, '1212: jacobi(45,897) == 0'); vrfy(jacobi(897,45) == 0, '1213: jacobi(897,45) == 0'); vrfy(jacobi(42,45) == 0, '1214: jacobi(42,45) == 0'); vrfy(jacobi(21,45) == 0, '1215: jacobi(21,45) == 0'); vrfy(jacobi(45,21) == 0, '1216: jacobi(45,21) == 0'); vrfy(jacobi(3,21) == 0, '1217: jacobi(3,21) == 0'); vrfy(jacobi(0,21) == 0, '1218: jacobi(0,21) == 0'); vrfy(jacobi(0,20003) == 0, '1219: jacobi(0,20003) == 0'); vrfy(jacobi(1,20003) == 1, '1220: jacobi(1,20003) == 1'); vrfy(jacobi(1236,20003) == 1, '1221: jacobi(1236,20003) == 1'); vrfy(jacobi(618,20003) == -1, '1222: jacobi(618,20003) == -1'); vrfy(jacobi(309,20003) == 1, '1223: jacobi(309,20003) == 1'); vrfy(jacobi(227,309) == 1, '1224: jacobi(227,309) == 1'); vrfy(jacobi(82,227) == 1, '1225: jacobi(82,227) == 1'); vrfy(jacobi(41,227) == -1, '1226: jacobi(41,227) == -1'); vrfy(jacobi(22,41) == -1, '1227: jacobi(22,41) == -1'); vrfy(jacobi(11,41) == -1, '1228: jacobi(11,41) == -1'); vrfy(jacobi(8,11) == -1, '1229: jacobi(8,11) == -1'); vrfy(jacobi(4,11) == 1, '1230: jacobi(4,11) == 1'); vrfy(jacobi(2,11) == -1, '1231: jacobi(2,11) == -1'); vrfy(jacobi(1,11) == 1, '1232: jacobi(1,11) == 1'); vrfy(jacobi(0,11) == 0, '1233: jacobi(0,11) == 0'); vrfy(jacobi(0,0) == 0, '1234: jacobi(0,0) == 0'); vrfy(jacobi(-1,0) == 0, '1235: jacobi(-1,0) == 0'); vrfy(jacobi(-1,-1) == 0, '1236: jacobi(-1,-1) == 0'); vrfy(jacobi(0,-1) == 0, '1237: jacobi(0,-1) == 0'); /* * NOTE: Function tests are continued in test_functionss() * starting at test 9000. */ print '1293: Ending test_functions'; } print '017: parsed test_functions()'; /* * test 018-020: define _test_underscore and variables for test 45dd * * This function tests use of _'s in identifiers. */ _ = 49; print '018: _ = 49'; __ = 63; print "019: __ = 63"; define _test_underscore() { local _a = 27; local __a = 23209; print "4500: Beginning _test_underscore"; vrfy(_a == 27, '4501: _a == 27'); vrfy(_ == 49, '4502: _ == 49'); vrfy(__ == 63, '4503: __ == 63'); vrfy(__a == 23209, '4504: __a == 23209'); print "4505: Ending _test_underscore"; } print '020: parsed _test_underscore()'; /* ********************************************************************* */ /* NOTE: ==> Room for special start of regression tests 021-022 here <== */ /* ********************************************************************* */ /* * test 023: define test_assoc for test 13dd * * This function tests 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 024: define test_list for test 14dd * * This function tests 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 025: define test_rand for test 15dd * * This function tests the subtractive 100 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 subtractive 100 shuffle generator */ tmp = srand(0); print '1505: tmp = srand(0)'; vrfy(rand() == 0x1fe5b46fba7e069d, \ '1506: rand() == 0x1fe5b46fba7e069d'); vrfy(rand() == 0x308d32d9bdf2dc6f, \ '1507: rand() == 0x308d32d9bdf2dc6f'); tmp = srand(init); print '1508: tmp = srand(init)'; vrfy(rand() == 0x1fe5b46fba7e069d, \ '1509: rand() == 0x1fe5b46fba7e069d'); vrfy(rand() == 0x308d32d9bdf2dc6f, \ '1510: rand() == 0x308d32d9bdf2dc6f'); /* test range interface */ tmp = srand(0); print '1511: tmp = srand(0)'; vrfy(rand(12345678901234567890) == 0x1fe5b46fba7e069d, \ '1512: rand(12345678901234567890) == 0x1fe5b46fba7e069d'); vrfy(rand(216091) == 0xc234, '1513: rand(216091) == 0xc234'); vrfy(rand(100) == 0x59, '1514: rand(100) == 0x59'); vrfy(rand(-46,46) == 0x2d, '1515: rand(-46,46) == 0x2d'); tmp = srand(0); print '1516: tmp = srand(0)'; vrfy(rand(2^64) == 0x1fe5b46fba7e069d, \ '1517: rand(2^64) == 0x1fe5b46fba7e069d'); vrfy(rand(0,2^64) == 0x308d32d9bdf2dc6f, \ '1518: rand(0,2^64) == 0x308d32d9bdf2dc6f'); /* 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)'; print '1522: test disabled'; 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) == 0x1fe5b46fba7e069d, \ '1529: randbit(64) == 0x1fe5b46fba7e069d'); vrfy(randbit(128) == 0x308d32d9bdf2dc6f45d3e3b3361b79e4, \ '1530: randbit(128) == 0x308d32d9bdf2dc6f45d3e3b3361b79e4'); vrfy(randbit(64) == 0xd4ef1e3336022d81, \ '1531: randbit(64) == 0xd4ef1e3336022d81'); vrfy(randbit(128) == 0x66b086e6c34e42124a1fc5d4e5c6f598, \ '1532: randbit(128) == 0x66b086e6c34e42124a1fc5d4e5c6f598'); tmp = srand(0); print '1533: tmp = srand(0)'; vrfy(randbit(32) == 0x1fe5b46f, '1534: randbit(32) == 0x1fe5b46f'); vrfy(randbit(32) == 0xba7e069d, '1535: randbit(32) == 0xba7e069d'); vrfy(randbit(1) == 0x0, '1536: randbit(1) == 0x0'); vrfy(randbit(5) == 0xc, '1537: randbit(5) == 0xc'); vrfy(randbit(33) == 0x46996cde, '1538: randbit(33) == 0x46996cde'); vrfy(randbit(25) == 0x1f2dc6f, '1539: randbit(25) == 0x1f2dc6f'); vrfy(randbit(2) == 0x1, '1540: randbit(2) == 0x1'); vrfy(randbit(13) == 0x2e9, '1541: randbit(13) == 0x2e9'); vrfy(randbit(18) == 0x3c766, '1542: randbit(18) == 0x3c766'); vrfy(randbit(8) == 0x6c, '1543: randbit(8) == 0x6c'); vrfy(randbit(9) == 0x6d, '1544: randbit(9) == 0x6d'); vrfy(randbit(70) == 0x39e4d4ef1e3336022d, \ '1545: randbit(70) == 0x39e4d4ef1e3336022d'); print '1546: test unused'; vrfy(randbit(8) == 0x81, '1547: randbit(8) == 0x81'); vrfy(randbit(65) == 0xcd610dcd869c8424, \ '1548: randbit(65) == 0xcd610dcd869c8424'); vrfy(randbit(63) == 0x4a1fc5d4e5c6f598, \ '1549: randbit(63) == 0x4a1fc5d4e5c6f598'); /* 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) == 0xbf989a4c504a541d, \ '1554: randbit(64) == 0xbf989a4c504a541d'); /* test randbit skip interface */ tmp = srand(0); print '1555: tmp = srand(0)'; vrfy(randbit(20) == 0x1fe5b, '1556: randbit(20) == 0x1fe5b'); vrfy(randbit(20) == 0x46fba, '1557: randbit(20) == 0x46fba'); vrfy(randbit(20) == 0x7e069, '1558: randbit(20) == 0x7e069'); vrfy(randbit(20) == 0xd308d, '1559: randbit(20) == 0xd308d'); tmp = srand(0); print '1560: tmp = srand(0)'; vrfy(randbit(-20) == 20, '1561: randbit(-20) == 20'); vrfy(randbit(20) == 290746, '1562: randbit(20) == 290746'); vrfy(randbit(-20) == 20, '1563: randbit(-20) == 20'); vrfy(randbit(20) == 864397, '1564: randbit(20) == 864397'); /* test randbit without and arg */ tmp = srand(0); print '1565: tmp = srand(0)'; vrfy(randbit() == 0, '1566: randbit() == 0'); vrfy(randbit() == 0, '1567: randbit() == 0'); vrfy(randbit() == 0, '1568: randbit() == 0'); vrfy(randbit() == 1, '1569: randbit() == 1'); /* test seed() as best as we can */ vrfy(seed() >= 0, '1570: seed() >= 0'); vrfy(seed() < 2^64, '1571: seed() < 2^64'); vrfy(isrand(srand(seed())), '1572: isrand(srand(seed()))'); print '1573: Ending rand test'; } print '025: parsed test_rand()'; /* * test 026: define test_mode for test 16dd * * This function tests config mode and base. */ 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 == "fraction", '1605: tmp == "fraction"'); vrfy(base() == -10, '1606: base() == -10'); tmp = config("mode", "real"); print '1607: tmp = config("mode", "real")'; vrfy(tmp == "integer", '1608: tmp == "integer"'); 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 == "scientific", '1614: tmp == "scientific"'); 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", "eng"); print '1622: tmp = config("mode", "eng")'; vrfy(tmp == "binary", '1623: tmp == "binary"'); vrfy(base() == 1000, '1624: base() == 1000'); tmp = config("mode", "real"); print '1625: tmp = config("mode", "real")'; vrfy(tmp == "engineering", '1626: tmp == "engineering"'); tmp = base(1/3); print '1627: tmp = base(1/3)'; vrfy(config("mode") == "fraction", '1628: config("mode") == "fraction"'); tmp = base(-10); print '1629: tmp = base(-10)'; vrfy(config("mode") == "integer", '1630: config("mode") == "integer"'); tmp = base(10); print '1631: tmp = base(10)'; vrfy(config("mode") == "real", '1632: config("mode") == "real"'); tmp = base(1e20); print '1633: tmp = base(1e20)'; vrfy(config("mode") == "scientific", '1634: config("mode") == "scientific"'); tmp = base(16); print '1635: tmp = base(16)'; vrfy(config("mode") == "hexadecimal", \ '1636: config("mode") == "hexadecimal"'); tmp = base(8); print '1637: tmp = base(8)'; vrfy(config("mode") == "octal", '1638: config("mode") == "octal"'); tmp = base(2); print '1639: tmp = base(2)'; vrfy(config("mode") == "binary",'1640: config("mode") == "binary"'); tmp = base(1000); print '1641: tmp = base(1000)'; vrfy(config("mode") == "engineering", '1642: config("mode") == "engineering"'); tmp = base(1/3); print '1643: tmp = base(1/3)'; vrfy(str(0x80000000) == "2147483648", \ '1644: str(0x8000000) == \"2147483648\"'); vrfy(str(0xffffffff) == "4294967295", \ '1645: str(0xffffffff) == \"4294967295\"'); vrfy(str(3e9) == "3000000000", \ '1646: str(3e9) == \"3000000000\"'); vrfy(str(1/3) == "1/3", \ '1647: str(1/3) == \"1/3\"'); vrfy(str(2e8) == "200000000", \ '1648: str(2e8) == \"200000000"'); vrfy(str(200e6) == "200000000", \ '1649: str(200e6) == \"200000000"'); vrfy(str(0b100111) == "39", \ '1650: str(0b100111) == \"39"'); vrfy(str(07543) == "3939", \ '1651: str(07543) == \"3939"'); vrfy(str(7543) == "7543", \ '1652: str(7543) == \"7543"'); tmp = base(8); print '1653: tmp = base(8)'; vrfy(str(0x80000000) == "020000000000", \ '1654: str(0x8000000) == \"020000000000\"'); vrfy(str(0xffffffff) == "037777777777", \ '1655: str(0xffffffff) == \"037777777777\"'); vrfy(str(3e9) == "026264057000", \ '1656: str(3e9) == \"026264057000\"'); vrfy(str(1/3) == "1/3", \ '1657: str(1/3) == \"1/3\"'); vrfy(str(2e8) == "01372741000", \ '1658: str(2e8) == \"01372741000"'); vrfy(str(200e6) == "01372741000", \ '1659: str(200e6) == \"01372741000"'); vrfy(str(0b100111) == "047", \ '1660: str(0b100111) == \"047"'); vrfy(str(07543) == "07543", \ '1661: str(07543) == \"07543"'); vrfy(str(7543) == "016567", \ '1662: str(7543) == \"016567"'); tmp = base(16); print '1663: tmp = base(16)'; vrfy(str(0x80000000) == "0x80000000", \ '1664: str(0x8000000) == \"0x80000000\"'); vrfy(str(0xffffffff) == "0xffffffff", \ '1665: str(0xffffffff) == \"0xffffffff\"'); vrfy(str(3e9) == "0xb2d05e00", \ '1666: str(3e9) == \"0xb2d05e00\"'); vrfy(str(1/3) == "1/3", \ '1667: str(1/3) == \"1/3\"'); vrfy(str(2e8) == "0xbebc200", \ '1668: str(2e8) == \"0xbebc200"'); vrfy(str(200e6) == "0xbebc200", \ '1669: str(200e6) == \"0xbebc200"'); vrfy(str(0b100111) == "0x27", \ '1670: str(0b100111) == \"0x27"'); vrfy(str(07543) == "0xf63", \ '1671: str(07543) == \"0xf63"'); vrfy(str(7543) == "0x1d77", \ '1672: str(7543) == \"0x1d77"'); tmp = base(2); print '1673: tmp = base(2)'; vrfy(str(0x80000000) == "0b10000000000000000000000000000000", \ '1674: str(0x8000000) == \"0b10000000000000000000000000000000\"'); vrfy(str(0xffffffff) == "0b11111111111111111111111111111111", \ '1675: str(0xffffffff) == \"0b11111111111111111111111111111111\"'); vrfy(str(3e9) == "0b10110010110100000101111000000000", \ '1676: str(3e9) == \"0b10110010110100000101111000000000\"'); vrfy(str(1/3) == "1/0b11", \ '1677: str(1/3) == \"1/0b11\"'); vrfy(str(2e8) == "0b1011111010111100001000000000", \ '1678: str(2e8) == \"0b1011111010111100001000000000"'); vrfy(str(200e6) == "0b1011111010111100001000000000", \ '1679: str(200e6) == \"0b1011111010111100001000000000"'); vrfy(str(0b100111) == "0b100111", \ '1680: str(0b100111) == \"0b100111"'); vrfy(str(07543) == "0b111101100011", \ '1681: str(07543) == \"0b111101100011"'); vrfy(str(7543) == "0b1110101110111", \ '1682: str(7543) == \"0b1110101110111"'); tmp = base(1e20); print '1683: tmp = base(1e20)'; vrfy(str(0x80000000) == "2.147483648e9", \ '1684: str(0x8000000) == \"2.147483648e9\"'); vrfy(str(0xffffffff) == "4.294967295e9", \ '1685: str(0xffffffff) == \"4.294967295e9\"'); vrfy(str(3e9) == "3e9", \ '1686: str(3e9) == \"3e9\"'); vrfy(str(1/3) == "~3.33333333333333333333e-1", \ '1687: str(1/3) == \"~3.33333333333333333333e-1\"'); vrfy(str(2e8) == "2e8", \ '1688: str(2e8) == \"2e8"'); vrfy(str(200e6) == "2e8", \ '1689: str(200e6) == \"2e8"'); vrfy(str(0b100111) == "3.9e1", \ '1690: str(0b100111) == \"3.9e1"'); vrfy(str(07543) == "3.939e3", \ '1691: str(07543) == \"3.939e3"'); vrfy(str(7543) == "7.543e3", \ '1692: str(7543) == \"7.543e3"'); tmp = base(1000); print '1693: tmp = base(1000)'; vrfy(str(0x80000000) == "2.147483648e9", \ '1694: str(0x8000000) == \"2.147483648e9"'); vrfy(str(0xffffffff) == "4.294967295e9", \ '1695: str(0xffffffff) == \"4.294967295e9\"'); vrfy(str(3e9) == "3e9", \ '1696: str(3e9) == \"3e9\"'); vrfy(str(1/3) == "~333.33333333333333333333e-3", \ '1697: str(1/3) == \"~333.33333333333333333333e-3\"'); vrfy(str(2e8) == "200e6", \ '1698: str(2e8) == \"200e6"'); vrfy(str(200e6) == "200e6", \ '1699: str(200e6) == \"200e6"'); vrfy(str(0b100111) == "39", \ '1700: str(0b100111) == \"39"'); vrfy(str(07543) == "3.939e3", \ '1701: str(07543) == \"3.939e3"'); vrfy(str(7543) == "7.543e3", \ '1702: str(7543) == \"7.543e3"'); tmp = base(-10); print '1703: tmp = base(-10)'; vrfy(str(0x80000000) == "2147483648", \ '1704: str(0x8000000) == \"2147483648\"'); vrfy(str(0xffffffff) == "4294967295", \ '1705: str(0xffffffff) == \"4294967295\"'); vrfy(str(3e9) == "3000000000", \ '1706: str(3e9) == \"3000000000\"'); vrfy(str(1/3) == "~0", \ '1707: str(1/3) == \"~0\"'); vrfy(str(2e8) == "200000000", \ '1708: str(2e8) == \"200000000"'); vrfy(str(200e6) == "200000000", \ '1709: str(200e6) == \"200000000"'); vrfy(str(0b100111) == "39", \ '1710: str(0b100111) == \"39"'); vrfy(str(07543) == "3939", \ '1711: str(07543) == \"3939"'); vrfy(str(7543) == "7543", \ '1712: str(7543) == \"7543"'); tmp = base(10); print '1713: tmp = base(10)'; vrfy(str(0x80000000) == "2147483648", \ '1714: str(0x8000000) == \"2147483648\"'); vrfy(str(0xffffffff) == "4294967295", \ '1715: str(0xffffffff) == \"4294967295\"'); vrfy(str(3e9) == "3000000000", \ '1716: str(3e9) == \"3000000000\"'); vrfy(str(1/3) == "~0.33333333333333333333", \ '1717: str(1/3) == \"~0.33333333333333333333"'); vrfy(str(2e8) == "200000000", \ '1718: str(2e8) == \"200000000"'); vrfy(str(200e6) == "200000000", \ '1719: str(200e6) == \"200000000"'); vrfy(str(0b100111) == "39", \ '1720: str(0b100111) == \"39"'); vrfy(str(07543) == "3939", \ '1721: str(07543) == \"3939"'); vrfy(str(7543) == "7543", \ '1722: str(7543) == \"7543"'); /* test base2() functionality */ vrfy(base2() == 0, '1723: base2() == 0'); vrfy(base2(0) == 0, '1724: base2(0) == 0'); vrfy(base2() == 0, '1725: base2() == 0'); vrfy(base2(16) == 0, '1726: base2(16) == 0'); vrfy(base2() == 16, '1727: base2() == 16'); vrfy(str(3e9) == "3000000000 /* 0xb2d05e00 */", '1728: str(3e9) == "3000000000 /* 0xb2d05e00 */"'); vrfy(base2(1/3) == 16, '1728: base2(16) == 16'); vrfy(base2() == 1/3, '1729: base2() == 1/3'); vrfy(str(23209) == "23209 /* 23209 */", '1730: str(23209) == "23209 /* 23209 */"'); vrfy(str(3/2) == "1.5 /* 3/2 */", '1731: str(3/2) == "1.5 /* 3/2 */"'); vrfy(base2(8) == 1/3, '1732: base2(8) == 1/3'); vrfy(base2() == 8, '1733: base2() == 8'); vrfy(str(23209) == "23209 /* 055251 */", '1734: str(23209) == "23209 /* 055251 */"'); vrfy(str(3/2) == "1.5 /* 3/2 */", '1735: str(3/2) == "1.5 /* 3/2 */"'); vrfy(base2(2) == 8, '1736: base2(2) == 8'); vrfy(base2() == 2, '1737: base2() == 2'); vrfy(str(23209) == "23209 /* 0b101101010101001 */", '1738: str(23209) == "23209 /* 0b101101010101001 */"'); vrfy(str(3/2) == "1.5 /* 0b11/0b10 */", '1739: str(3/2) == "1.5 /* 0b11/0b10 */"'); vrfy(base2(1e20) == 2, '1740: base2(1e20) == 2'); vrfy(base2() == 1e20, '1741: base2() == 1e20'); vrfy(str(23209) == "23209 /* 2.3209e4 */", '1742: str(23209) == "23209 /* 2.3209e4 */"'); vrfy(str(3/2) == "1.5 /* 1.5 */", '1743: str(3/2) == "1.5 /* 1.5 */"'); vrfy(base2(-10) == 1e20, '1744: base2(-10) == 1e20'); vrfy(base2() == -10, '1745: base2() == -10'); vrfy(str(23209) == "23209 /* 23209 */", '1746: str(23209) == "23209 /* 23209 */"'); vrfy(str(3/2) == "1.5 /* ~2 */", '1747: str(3/2) == "1.5 /* ~2 */"'); vrfy(base2(1000) == -10, '1748: base2(1000) == -1000'); vrfy(base2() == 1000, '1749: base2() == 1000'); vrfy(str(23209) == "23209 /* 23.209e3 */", '1750: str(23209) == "23209 /* 23.209e3 */"'); vrfy(str(3/2) == "1.5 /* 1.5 */", '1751: str(3/2) == "1.5 /* 1.5 */"'); vrfy(base2(10) == 1000, '1752: base2(10) == 1000'); vrfy(base2() == 10, '1753: base2() == 10'); vrfy(str(23209) == "23209 /* 23209 */", '1754: str(23209) == "23209 /* 23209 */"'); vrfy(str(3/2) == "1.5 /* 1.5 */", '1755: str(3/2) == "1.5 /* 1.5 */"'); vrfy(base2(0) == 10, '1756: base2(0) == 10'); vrfy(base2() == 0, '1757: base2() == 0'); vrfy(str(23209) == "23209", '1758: str(23209) == "23209"'); vrfy(str(3/2) == "1.5", '1759: str(3/2) == "1.5"'); vrfy(base() == 10, '1760: base() == 10'); vrfy(base2() == 0, '1761: base2() == 0'); print '1762: Ending mode/base test'; } print '026: parsed test_mode()'; /* * test 027-028: define test_obj and read surd for test 18dd * * This function tests objects. */ read -once "surd"; print '027: read -once surd'; /**/ define test_obj() { static obj surd a; static obj surd b; local PP; 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'); obj pt {x,y}, PP = obj pair {A,B} = {obj pt, obj pt}; print '1830: obj pt {x,y}, PP = obj pair {A,B} = {obj pt, obj pt}'; print '1831: Ending object test'; } print '028: parsed test_obj()'; /* * test 029: define test_prime for test 19dd + 20dd * * This function tests prime related functionality. */ 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 030-031: define test_lucas and read lucas_chk for test 21dd * * This function performs the Lucas primality test suite. */ read -once "lucas_chk"; /* obtain our needed Lucas resource file */ 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 032: define test_newop for test 22dd * * This function tests 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 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 operator functionality test'; } print '032: parsed test_newop()'; /* * test 033-034: define test_xx_incdec and read test2300.obj_incdec for test 23dd * * This function tests object increment/decrement. */ read -once "test2300.obj_incdec"; print '033: read -once test2300.obj_incdec'; /**/ define test_xx_incdec() { local A, B; local n; 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'); n = 1; print '2315: n = 1'; vrfy(n + n + n + n++ == 4, '2316: n + n + n + n++ == 4'); vrfy(n == 2, '2317: n == 2'); n = 1; print '2318: n = 1'; vrfy(n + n + n++ == 3, '2319: n + n + n++ == 3'); vrfy(n == 2, '2320: n == 2'); n = 1; print '2321: n = 1'; vrfy(n + n++ == 2, '2322: n + n++ == 3'); vrfy(n == 2, '2323: n == 2'); print '2315: Ending object increment/decrement test'; } print '034: parsed test_xx_incdec()'; /* * test 035: define test_round for test 24dd + 25dd * * This function tests 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 036-037: define test_2600 and read test2600.numfunc for test 26dd * * This function tests certain numeric functions extensively. * * Test multiplication, sqrt(), exp(), ln(), power(), gcd(), complex * power, complex exp, complex log. */ read -once "test2600.numfunc"; print '036: read -once test2600.numfunc'; define test_2600() { local tnum; /* test number */ local i; /* * NOTE: The various functions test in this are often accurate to * eps (epsilon) or better, which defaults to about 20 decimal * digits. We test a number of functions to 10 digits using * round(..., 10) because we do not want to have to put lots * of digits in the verify identities. */ 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)'; i = epsilon(1e-100),; print tnum++: ': i = epsilon(1e-100),;'; vrfy(ln(exp(6)) == 6, strcat(str(tnum++), ': ln(exp(6)) == 6')); vrfy(ln(exp(4)^4) == 16, strcat(str(tnum++), ': ln(exp(4)^4) == 16')); vrfy(ln(exp(6.5)^8) == 52, strcat(str(tnum++), ': ln(exp(6.5)^8) == 52')); vrfy(ln(exp(5)^16) == 80, strcat(str(tnum++), ': ln(exp(5)^16) == 80')); vrfy(ln(exp(4.5)^4) == 18, strcat(str(tnum++), ': ln(exp(4.5)^4) == 18')); vrfy(ln(exp(4)^8) == 32, strcat(str(tnum++), ': ln(exp(4)^8) == 32')); vrfy(ln(exp(60/11)^11) == 60, strcat(str(tnum++), ': ln(exp(60/11)^11) == 60')); vrfy(ln(exp(6)^15) == 90, strcat(str(tnum++), ': ln(exp(6)^11) == 90')); vrfy(ln(exp(80/17)^17) == 80, strcat(str(tnum++), ': ln(exp(80/17)^17) == 80')); vrfy(ln(exp(6)^15) == 90, strcat(str(tnum++), ': ln(exp(6)^15) == 90')); vrfy(ln(exp(5)^18) == 90, strcat(str(tnum++), ': ln(exp(5)^18) == 90')); vrfy(log(1e6) == 6, strcat(str(tnum++), ': log(1e6)) == 6')); vrfy(log(1) == 0, strcat(str(tnum++), ': log(1)) == 0')); vrfy(log(100) == 2, strcat(str(tnum++), ': log(100)) == 2')); vrfy(log(1e66) == 66, strcat(str(tnum++), ': log(1e66)) == 66')); vrfy(log(1e127) == 127, strcat(str(tnum++), ': log(1e127)) == 127')); vrfy(round(log(17^47),10) == 57.8310993048, strcat(str(tnum++), ': round(log(17^47),10) == 57.8310993048')); vrfy(round(log(127),10) == 2.103803721, strcat(str(tnum++), ': round(log(127),10) == 2.103803721')); vrfy(round(log(0.25,0.00001),5) == -0.60206, strcat(str(tnum++), ': round(log(0.25,0.00001),5) == -0.60206')); vrfy(round(log(0.25,1e-10),10) == -0.6020599913, strcat(str(tnum++), ': round(log(0.25,1e-10),10) == -0.6020599913')); vrfy(round( log(1.2+1.2i,1e-5),5) == 0.2297+0.34109i, strcat(str(tnum++), ': round(log(1.2+1.2i,1e-5),5) == 0.2297+0.34109i')); vrfy(round( log(1.2+1.2i,1e-10),10) == 0.2296962439+0.3410940885i, strcat(str(tnum++), ': round(log(1.2+1.2i,1e-10),10) == ', '0.2296962439+0.3410940885i')); vrfy(log2(0.5) == -1, strcat(str(tnum++), ': log2(0.5) == -1')); vrfy(log2(0.5) == -1, strcat(str(tnum++), ': log2(0.5) == -1')); vrfy(log2(0.5) == log2(0.5), strcat(str(tnum++), ': log2(0.5) == log2(0.5)')); vrfy(0^0 == 1, strcat(str(tnum++), ': 0^0 == 1')); vrfy(1^0 == 1, strcat(str(tnum++), ': 1^0 == 1')); vrfy(1^1 == 1, strcat(str(tnum++), ': 1^1 == 1')); vrfy(2^0 == 1, strcat(str(tnum++), ': 2^0 == 1')); vrfy(log2(1) == 0, strcat(str(tnum++), ': log2(1) == 0')); vrfy(log2(1.0) == 0, strcat(str(tnum++), ': log2(1.0) == 0')); vrfy(log2(2) == 1, strcat(str(tnum++), ': log2(2) == 1')); vrfy(log2(4) == 2, strcat(str(tnum++), ': log2(4) == 2')); vrfy(log2(1024) == 10, strcat(str(tnum++), ': log2(1024) == 10')); vrfy(log2(2^500) == 500, strcat(str(tnum++), ': log2(2^500) == 500')); vrfy(log2(1/2^23209) == -23209, strcat(str(tnum++), ': log2(1/2^23209) == -23209')); vrfy(round(log2(127),10) == 6.9886846868, strcat(str(tnum++), ': round(log2(127),10) == 6.9886846868')); vrfy(round(log2(23209),10) == 14.5023967426, strcat(str(tnum++), ': round(log2(23209),10) == 14.5023967426')); vrfy(round(log2(2^17-19),10) == 16.9997908539, strcat(str(tnum++), ': round(log2(2^17-19),10) == 16.9997908539')); vrfy(round(log2(-127),10) == 6.9886846868+4.5323601418i, strcat(str(tnum++), ': round(log2(-127),10) == 6.9886846868+4.5323601418i')); vrfy(round(log2(2+3i),10) == 1.8502198591+1.4178716307i, strcat(str(tnum++), ': round(log2(2+3i),10) == 1.8502198591+1.4178716307i')); vrfy(round(log2(-2+3i),10) == 1.8502198591+3.1144885111i, strcat(str(tnum++), ': round(log2(-2+3i),10) == 1.8502198591+3.1144885111i')); vrfy(round(log2(2-3i),10) == 1.8502198591-1.4178716307i, strcat(str(tnum++), ': round(log2(2-3i),10) == 1.8502198591-1.4178716307i')); vrfy(round(log2(-2-3i),10) == 1.8502198591-3.1144885111i, strcat(str(tnum++), ': round(log2(-2-3i),10) == 1.8502198591-3.1144885111i')); vrfy(round(log2(17+0.3i),10) == 4.0876874474+0.0254566819i, strcat(str(tnum++), ': round(log2(17+0.3i),10) == 4.0876874474+0.0254566819i')); vrfy(logn(2, 2) == 1, strcat(str(tnum++), ': logn(2, 2) == 1')); vrfy(logn(4, 2) == 2, strcat(str(tnum++), ': logn(4, 2) == 2')); vrfy(logn(1024, 2) == 10, strcat(str(tnum++), ': logn(1024, 2) == 10')); vrfy(logn(2^500, 2) == 500, strcat(str(tnum++), ': logn(2^500, 2) == 500')); vrfy(logn(1/2^23209, 2) == -23209, strcat(str(tnum++), ': logn(1/2^23209, 2) == -23209')); vrfy(round(logn(127, 1/13),10) == -1.8886092516, strcat(str(tnum++), ': round(logn(127, 1/13),10) == -1.8886092516')); vrfy(round(logn(23209, sqrt(3)),10) == 18.299987206, strcat(str(tnum++), ': round(logn(23209, sqrt(3)),10) == 18.299987206')); vrfy(round(logn(2, 42),10) == 0.1854490234, strcat(str(tnum++), ': round(logn(2, 42),10) == 0.1854490234')); vrfy(round(logn(1024, 42),10) == 1.8544902342, strcat(str(tnum++), ': round(logn(1024, 42),10) == 1.8544902342')); vrfy(round(logn(2^500, 42),10) == 92.7245117077, strcat(str(tnum++), ': round(logn(2^500, 42),10) == 92.7245117077')); vrfy(round(logn(1/2^23209, 42),10) == -4304.0863844473, strcat(str(tnum++), ': round(logn(1/2^23209, 42),10) == -4304.0863844473')); vrfy(logn(-1, 1i) == 2, strcat(str(tnum++), ': logn(-1, 1i) == 2')); vrfy(round(logn(22+3i, 3i),10) == 0.984899142-1.2848465788i, strcat(str(tnum++), ': round(logn(22+3i, 3i),10) == 0.984899142-1.2848465788i')); vrfy(round(logn(22.2+3.3i, -4-3.3i),10) == 0.5456929478+0.9025545623i, strcat(str(tnum++), ': round(logn(22.2+3.3i, -4-3.3i),10) == 0.5456929478+0.9025545623i')); vrfy(round(logn(-127, 7),10) == 2.4894197139+1.6144592571i, strcat(str(tnum++), ': round(logn(-127, 7),10) == 2.4894197139+1.6144592571i')); vrfy(round(logn(-127, 7i),10) == 2.2963271277-0.2392040372i, strcat(str(tnum++), ': round(logn(-127, 7i),10) == 2.2963271277-0.2392040372i')); epsilon(i),; print tnum++: ': epsilon(i),;'; print tnum: ': Ending extensive numeric function test'; } print '037: parsed test_2600()'; /* * test 038-039: define test_2700 and read test2700.isqrt for test 27dd * * This function tests complex sqrt. */ read -once "test2700.isqrt"; print '038: read -once test2700.isqrt'; 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 040-430: define test_matrix and variables for test 28dd + 29dd * * This function tests 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 044: define test_strings for test 30dd * * This function tests 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 045-046: define test_matobj and read test3100.matobj for test 31dd * * This function tests determinants of a matrix containing objects. */ read -once "test3100.matobj"; print '045: read -once test3100.matobj'; /**/ 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(3)'; B[1,0] = res(5); print '3108: B[1,0] = res(5)'; B[1,1] = res(7); print '3109: B[1,1] = res(7)'; 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 047: define test_poly for test 32dd * * This function tests 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 048-049: define test3300.det for test 33dd * * This function tests more determinant functionality. */ read -once "test3300.det"; print '048: read -once test3300.det'; /**/ 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 050-051: define test_trig and read test3400.trig for test 34dd * * * This function tests common trig functions. */ read -once "test3400.trig"; print '050: read -once test3400.trig'; /**/ define test_trig() { local tnum; /* test number */ local pi; /* pi to 1e-20 precision */ local i; /* * NOTE: The various functions test in this are often accurate to * eps (epsilon) or better, which defaults to about 20 decimal * digits. We test a number of functions to 10 digits using * round(..., 10) because we do not want to have to put lots * of digits in the verify identities. */ print '3400: Beginning test_trig'; /* test 3401-3407 */ tnum = test3400(1, 3401); vrfy(tnum++ == 3407, '3407: tnum == 3407'); pi = pi(1e-20); /* test trigonometric sine */ vrfy(sin(0, 1e-10) == 0, strcat(str(tnum++), ': sin(0, 1e-10) == 0')); vrfy(round(sin(1, 1e-10), 10) == 0.8414709848, strcat(str(tnum++), ': round(sin(1, 1e-10), 10) == 0.8414709848')); vrfy(round(sin(2 + 3i, 1e-10), 10) == 9.1544991469-4.16890696i, strcat(str(tnum++), ': round(sin(2 + 3i, 1e-10), 10) == 9.1544991469-4.16890696i')); vrfy(sin(pi/6, 1e-10) == 0.5, strcat(str(tnum++), ': sin(pi/6, 1e-10) == 0.5')); vrfy(sin(pi/2, 1e-10) == 1, strcat(str(tnum++), ': sin(pi/2, 1e-10) == 1')); vrfy(sin(pi, 1e-10) == 0, strcat(str(tnum++), ': sin(pi, 1e-10) == 1')); vrfy(round(sin(1/2, 1e-10), 10) == 0.4794255386, strcat(str(tnum++), ': round(sin(1/2, 1e-10), 10) == 0.4794255386')); vrfy(round(sin(5/7, 1e-10), 10) == 0.6550778972, strcat(str(tnum++), ': round(sin(5/7, 1e-10), 10) == 0.6550778972')); vrfy(round(sin(42/7, 1e-10), 10) == -0.2794154982, strcat(str(tnum++), ': round(sin(42/7, 1e-10), 10) == -0.2794154982')); /* test trigonometric cosine */ vrfy(cos(0, 1e-10) == 1, strcat(str(tnum++), ': cos(0, 1e-10) == 1')); vrfy(round(cos(1, 1e-10), 10) == 0.5403023059, strcat(str(tnum++), ': round(cos(0.2, 1e-10), 10) == 0.5403023059')); vrfy(cos(pi/3, 1e-10) == 0.5, strcat(str(tnum++), ': cos(pi/3, 1e-10) == 0.5')); vrfy(cos(pi/2, 1e-10) == 0, strcat(str(tnum++), ': cos(pi/2, 1e-10) == 0')); vrfy(cos(pi, 1e-10) == -1, strcat(str(tnum++), ': cos(pi, 1e-10) == -1')); vrfy(round(cos(2 + 3i, 1e-10), 10) == -4.189625691-9.1092278938i, strcat(str(tnum++), ': round(cos(2 + 3i, 1e-10), 10) == -4.189625691-9.1092278938i')); vrfy(round(cos(1/2, 1e-10), 10) == 0.8775825619, strcat(str(tnum++), ': round(cos(1/2, 1e-10), 10) == 0.8775825619')); vrfy(round(cos(5/7, 1e-10), 10) == 0.7555613467, strcat(str(tnum++), ': round(cos(5/7, 1e-10), 10) == 0.7555613467')); vrfy(round(cos(42/7, 1e-10), 10) == 0.9601702866, strcat(str(tnum++), ': round(cos(42/7, 1e-10), 10) == 0.9601702866')); /* test trigonometric tangent */ vrfy(tan(0, 1e-10) == 0, strcat(str(tnum++), ': tan(0, 1e-10) == 0')); vrfy(round(tan(1, 1e-10), 10) == 1.5574077247, strcat(str(tnum++), ': round(tan(0.2, 1e-10), 10) == 1.5574077247')); vrfy(round(tan(pi/6, 1e-10), 10) == 0.5773502692, strcat(str(tnum++), ': round(tan(pi/6, 1e-10), 10) == 0.5773502692')); vrfy(round(tan(pi/3, 1e-10), 10) == 1.7320508076, strcat(str(tnum++), ': round(tan(pi/3, 1e-10), 10) == 1.7320508076')); vrfy(tan(pi, 1e-10) == 0, strcat(str(tnum++), ': tan(pi, 1e-10) == 0')); vrfy(round(tan(1/2, 1e-10), 10) == 0.5463024898, strcat(str(tnum++), ': round(tan(1/2, 1e-10), 10) == 0.5463024898')); vrfy(round(tan(5/7, 1e-10), 10) == 0.8670082185, strcat(str(tnum++), ': round(tan(5/7, 1e-10), 10) == 0.8670082185')); vrfy(round(tan(42/7, 1e-10), 10) == -0.2910061914, strcat(str(tnum++), ': round(tan(42/7, 1e-10), 10) == -0.2910061914')); /* test trigonometric cotangent */ vrfy(round(cot(1, 1e-10), 10) == 0.6420926159, strcat(str(tnum++), ': round(cot(0.2, 1e-10), 10) == 0.6420926159')); vrfy(round(cot(pi/12, 1e-10), 10) == 3.7320508076, strcat(str(tnum++), ': round(cot(pi/12, 1e-10), 10) == 3.7320508076')); vrfy(round(cot(pi/6, 1e-10), 10) == 1.7320508076, strcat(str(tnum++), ': round(cot(pi/6, 1e-10), 10) == 1.7320508076')); vrfy(round(cot(pi/3, 1e-10), 10) == 0.5773502692, strcat(str(tnum++), ': round(cot(pi/3, 1e-10), 10) == 0.5773502692')); vrfy(cot(pi/2, 1e-10) == 0, strcat(str(tnum++), ': cot(pi/2, 1e-10) == 0')); vrfy(round(cot(1/2, 1e-10), 10) == 1.8304877217, strcat(str(tnum++), ': round(cot(1/2, 1e-10), 10) == 1.8304877217')); vrfy(round(cot(5/7, 1e-10), 10) == 1.1533916042, strcat(str(tnum++), ': round(cot(5/7, 1e-10), 10) == 1.1533916042')); vrfy(round(cot(42/7, 1e-10), 10) == -3.4363530042, strcat(str(tnum++), ': round(cot(42/7, 1e-10), 10) == -3.4363530042')); /* test trigonometric cosecant */ vrfy(round(csc(1, 1e-10), 10) == 1.1883951058, strcat(str(tnum++), ': round(csc(0.2, 1e-10), 10) == 1.1883951058')); vrfy(csc(pi/6, 1e-10) == 2, strcat(str(tnum++), ': csc(pi/6, 1e-10) == 2')); vrfy(round(csc(pi/3, 1e-10), 10) == 1.1547005384, strcat(str(tnum++), ': round(csc(pi/3, 1e-10), 10) == 1.1547005384')); vrfy(round(csc(4*pi/3, 1e-10), 10) == -1.1547005384, strcat(str(tnum++), ': round(csc(4*pi/3, 1e-10), 10) == -1.1547005384')); vrfy(round(csc(1/2, 1e-10), 10) == 2.0858296429, strcat(str(tnum++), ': round(csc(1/2, 1e-10), 10) == 2.0858296429')); vrfy(round(csc(5/7, 1e-10), 10) == 1.5265360109, strcat(str(tnum++), ': round(csc(5/7, 1e-10), 10) == 1.5265360109')); vrfy(round(csc(42/7, 1e-10), 10) == -3.5788995473, strcat(str(tnum++), ': round(csc(42/7, 1e-10), 10) == -3.5788995473')); /* test trigonometric secant */ vrfy(sec(0, 1e-10) == 1, strcat(str(tnum++), ': sec(0, 1e-10) == 1')); vrfy(round(sec(1, 1e-10), 10) == 1.8508157177, strcat(str(tnum++), ': round(sec(0.2, 1e-10), 10) == 1.8508157177')); vrfy(round(sec(pi/6, 1e-10), 10) == 1.1547005384, strcat(str(tnum++), ': round(sec(pi/6, 1e-10), 10) == 1.1547005384')); vrfy(sec(pi/3, 1e-10) == 2, strcat(str(tnum++), ': sec(pi/2, 1e-10) == 2')); vrfy(sec(pi, 1e-10) == -1, strcat(str(tnum++), ': sec(pi, 1e-10) == -1')); vrfy(round(sec(1/2, 1e-10), 10) == 1.1394939273, strcat(str(tnum++), ': round(sec(1/2, 1e-10), 10) == 1.1394939273')); vrfy(round(sec(5/7, 1e-10), 10) == 1.3235192673, strcat(str(tnum++), ': round(sec(5/7, 1e-10), 10) == 1.3235192673')); vrfy(round(sec(42/7, 1e-10), 10) == 1.0414819266, strcat(str(tnum++), ': round(sec(42/7, 1e-10), 10) == 1.0414819266')); /* test versed trigonometric sine */ vrfy(versin(0, 1e-10) == 0, strcat(str(tnum++), ': versin(0, 1e-10) == 0')); vrfy(round(versin(0.2, 1e-10), 10) == 0.0199334222, strcat(str(tnum++), ': round(versin(0.2, 1e-10), 10) == 0.0199334222')); vrfy(round(versin(3/7, 1e-10), 10) == 0.0904396483, strcat(str(tnum++), ': round(versin(3/7, 1e-10), 10) == 0.0904396483')); vrfy(round(versin(-31, 1e-10), 10) == 0.0852576422, strcat(str(tnum++), ': round(versin(-31, 1e-10), 10) == 0.0852576422')); vrfy(versin(pi/3, 1e-10) == 0.5, strcat(str(tnum++), ': versin(pi/3, 1e-10) == 0.5')); vrfy(versin(pi/2, 1e-10) == 1, strcat(str(tnum++), ': versin(pi/2, 1e-10) == 1')); vrfy(versin(pi, 1e-10) == 2, strcat(str(tnum++), ': versin(pi, 1e-10) == 2')); vrfy(versin(3*pi/2, 1e-10) == 1, strcat(str(tnum++), ': versin(3*pi/2, 1e-10) == 1')); vrfy(round(versin(1, 1e-10), 10) == 0.4596976941, strcat(str(tnum++), ': round(versin(1, 1e-10), 10) == 0.4596976941')); vrfy(round(versin(2 + 3i, 1e-10), 10) == 5.189625691+9.1092278938i, strcat(str(tnum++), ': round(versin(2 + 3i, 1e-10), 10) == 5.189625691+9.1092278938i')); /* test inverse versed trigonometric sine */ vrfy(aversin(0) == 0, strcat(str(tnum++), ': aversin(0) == 0')); vrfy(round(aversin(0.5, 1e-10), 10) == 1.0471975512, strcat(str(tnum++), ': round(aversin(0.5, 1e-10), 10) == 1.0471975512')); vrfy(round(aversin(-5, 1e-10), 10) == 2.4778887303i, strcat(str(tnum++), ': round(aversin(-5, 1e-10), 10) == 2.4778887303i')); vrfy(round(aversin(2 + 3i, 1e-10), 10) == 1.8783999763+1.8641615439i, strcat(str(tnum++), ': round(aversin(2 + 3i, 1e-10), 10) == 1.8783999763+1.8641615439i')); /* test coversed trigonometric sine */ vrfy(coversin(0, 1e-10) == 1, strcat(str(tnum++), ': coversin(0, 1e-10) == 1')); vrfy(round(coversin(0.2, 1e-10), 10) == 0.8013306692, strcat(str(tnum++), ': round(coversin(0.2, 1e-10), 10) == 0.8013306692')); vrfy(round(coversin(3/7, 1e-10), 10) == 0.584428145, strcat(str(tnum++), ': round(coversin(3/7, 1e-10), 10) == 0.584428145')); vrfy(round(coversin(-31, 1e-10), 10) == 0.5959623547, strcat(str(tnum++), ': round(coversin(-31, 1e-10), 10) == 0.5959623547')); vrfy(coversin(pi/6, 1e-10) == 0.5, strcat(str(tnum++), ': coversin(pi/6, 1e-10) == 0.5')); vrfy(coversin(pi/2, 1e-10) == 0, strcat(str(tnum++), ': coversin(pi/2, 1e-10) == 0')); vrfy(coversin(pi, 1e-10) == 1, strcat(str(tnum++), ': coversin(pi, 1e-10) == 1')); vrfy(coversin(3*pi/2, 1e-10) == 2, strcat(str(tnum++), ': coversin(3*pi/2, 1e-10) == 2')); vrfy(round(coversin(1, 1e-10), 10) == 0.1585290152, strcat(str(tnum++), ': round(coversin(1, 1e-10), 10) == 0.1585290152')); vrfy(round(coversin(2 + 3i, 1e-10), 10) == -8.1544991469+4.16890696i, strcat(str(tnum++), ': round(coversin(2 + 3i, 1e-10), 10) == -8.1544991469+4.16890696i')); /* test inverse coversed trigonometric sine */ vrfy(round(acoversin(0, 1e-10), 10) == 1.5707963268, strcat(str(tnum++), ': round(acoversin(0.5, 1e-10), 10) == 1.5707963268')); vrfy(round(acoversin(0.5, 1e-10), 10) == 0.5235987756, strcat(str(tnum++), ': round(acoversin(0.5, 1e-10), 10) == 0.5235987756')); vrfy(acoversin(1) == 0, strcat(str(tnum++), ': acoversin(1) == 0')); vrfy(round(acoversin(-5, 1e-10), 10) == 1.5707963268-2.4778887303i, strcat(str(tnum++), ': round(acoversin(-5, 1e-10), 10) == 1.5707963268-2.4778887303i')); vrfy(round(acoversin(2 + 3i, 1e-10), 10) == -0.3076036495-1.8641615442i, strcat(str(tnum++), ': round(acoversin(2 + 3i, 1e-10), 10) == -0.3076036495-1.8641615442i')); /* test versed trigonometric cosine */ vrfy(vercos(0, 1e-10) == 2, strcat(str(tnum++), ': vercos(0, 1e-10) == 2')); vrfy(round(vercos(0.2, 1e-10), 10) == 1.9800665778, strcat(str(tnum++), ': round(vercos(0.2, 1e-10), 10) == 1.9800665778')); vrfy(round(vercos(3/7, 1e-10), 10) == 1.9095603517, strcat(str(tnum++), ': round(vercos(3/7, 1e-10), 10) == 1.9095603517')); vrfy(round(vercos(-31, 1e-10), 10) == 1.9147423578, strcat(str(tnum++), ': round(vercos(-31, 1e-10), 10) == 1.9147423578')); vrfy(vercos(pi/3, 1e-10) == 1.5, strcat(str(tnum++), ': vercos(pi/3, 1e-10) == 1.5')); vrfy(vercos(pi/2, 1e-10) == 1, strcat(str(tnum++), ': vercos(pi/2, 1e-10) == 1')); vrfy(vercos(pi, 1e-10) == 0, strcat(str(tnum++), ': vercos(pi, 1e-10) == 0')); vrfy(vercos(3*pi/2, 1e-10) == 1, strcat(str(tnum++), ': vercos(3*pi/2, 1e-10) == 1')); vrfy(round(vercos(1, 1e-10), 10) == 1.5403023059, strcat(str(tnum++), ': round(vercos(1, 1e-10), 10) == 1.5403023059')); vrfy(round(vercos(2 + 3i, 1e-10), 10) == -3.189625691-9.1092278938i, strcat(str(tnum++), ': round(vercos(2 + 3i, 1e-10), 10) == -3.189625691-9.1092278938i')); /* test inverse versed trigonometric cosine */ vrfy(round(avercos(0, 1e-10), 10) == 3.1415926536, strcat(str(tnum++), ': round(avercos(0, 1e-10), 10) == 3.1415926536')); vrfy(round(avercos(0.5, 1e-10), 10) == 2.0943951024, strcat(str(tnum++), ': round(avercos(0.5, 1e-10), 10) == 2.0943951024')); vrfy(avercos(2) == 0, strcat(str(tnum++), ': avercos(2) == 0')); vrfy(round(avercos(-5, 1e-10), 10) == 3.1415926536-2.4778887303i, strcat(str(tnum++), ': round(avercos(-5, 1e-10), 10) == 3.1415926536-2.4778887303i')); vrfy(round(avercos(2 + 3i, 1e-10), 10) == 1.2631926773-1.8641615442i, strcat(str(tnum++), ': round(avercos(2 + 3i, 1e-10), 10) == 1.2631926773-1.8641615442i')); /* test coversed trigonometric cosine */ vrfy(covercos(0, 1e-10) == 1, strcat(str(tnum++), ': covercos(0, 1e-10) == 1')); vrfy(round(covercos(0.2, 1e-10), 10) == 1.1986693308, strcat(str(tnum++), ': round(covercos(0.2, 1e-10), 10) == 1.1986693308')); vrfy(round(covercos(3/7, 1e-10), 10) == 1.415571855, strcat(str(tnum++), ': round(covercos(3/7, 1e-10), 10) == 1.415571855')); vrfy(round(covercos(-31, 1e-10), 10) == 1.4040376453, strcat(str(tnum++), ': round(covercos(-31, 1e-10), 10) == 1.4040376453')); vrfy(covercos(pi/6, 1e-10) == 1.5, strcat(str(tnum++), ': covercos(pi/6, 1e-10) == 1.5')); vrfy(covercos(pi/2, 1e-10) == 2, strcat(str(tnum++), ': covercos(pi/2, 1e-10) == 2')); vrfy(covercos(pi, 1e-10) == 1, strcat(str(tnum++), ': covercos(pi, 1e-10) == 1')); vrfy(covercos(3*pi/2, 1e-10) == 0, strcat(str(tnum++), ': covercos(3*pi/2, 1e-10) == 0')); vrfy(round(covercos(1, 1e-10), 10) == 1.8414709848, strcat(str(tnum++), ': round(covercos(1, 1e-10), 10) == 1.8414709848')); vrfy(round(covercos(2 + 3i, 1e-10), 10) == 10.1544991469-4.16890696i, strcat(str(tnum++), ': round(covercos(2 + 3i, 1e-10), 10) == 10.1544991469-4.16890696i')); /* test inverse coversed trigonometric cosine */ vrfy(round(acovercos(0, 1e-10), 10) == 1.5707963268, strcat(str(tnum++), ': round(acovercos(0, 1e-10), 10) == 1.5707963268')); vrfy(round(acovercos(0.5, 1e-10), 10) == 0.5235987756, strcat(str(tnum++), ': round(acovercos(0.5, 1e-10), 10) == 0.5235987756')); vrfy(acovercos(1) == 0, strcat(str(tnum++), ': acovercos(1) == 0')); vrfy(round(acovercos(-5, 1e-10), 10) == -1.5707963268+2.4778887303i, strcat(str(tnum++), ': round(acovercos(-5, 1e-10), 10) == -1.5707963268+2.4778887303i')); vrfy(round(acovercos(2 + 3i, 1e-10), 10) == 0.3076036495+1.8641615442i, strcat(str(tnum++), ': round(acovercos(2 + 3i, 1e-10), 10) == 0.3076036495+1.8641615442i')); /* test half versed trigonometric sine */ vrfy(haversin(0, 1e-10) == 0, strcat(str(tnum++), ': haversin(0, 1e-10) == 0')); vrfy(round(haversin(0.2, 1e-10), 10) == 0.0099667111, strcat(str(tnum++), ': round(haversin(0.2, 1e-10), 10) == 0.0099667111')); vrfy(round(haversin(3/7, 1e-10), 10) == 0.0452198242, strcat(str(tnum++), ': round(haversin(3/7, 1e-10), 10) == 0.0452198242')); vrfy(round(haversin(-31, 1e-10), 10) == 0.0426288211, strcat(str(tnum++), ': round(haversin(-31, 1e-10), 10) == 0.0426288211')); vrfy(haversin(pi/3, 1e-10) == 0.25, strcat(str(tnum++), ': haversin(pi/3, 1e-10) == 0.25')); vrfy(haversin(pi/2, 1e-10) == 0.5, strcat(str(tnum++), ': haversin(pi/2, 1e-10) == 0.5')); vrfy(haversin(pi, 1e-10) == 1, strcat(str(tnum++), ': haversin(pi, 1e-10) == 1')); vrfy(haversin(3*pi/2, 1e-10) == 0.5, strcat(str(tnum++), ': haversin(3*pi/2, 1e-10) == 0.5')); vrfy(round(haversin(1, 1e-10), 10) == 0.229848847, strcat(str(tnum++), ': round(haversin(1, 1e-10), 10) == 0.229848847')); vrfy(round(haversin(2 + 3i, 1e-10), 10) == 2.5948128455+4.5546139469i, strcat(str(tnum++), ': round(haversin(2 + 3i, 1e-10), 10) == 2.5948128455+4.5546139469i')); /* test inverse half versed trigonometric sine */ vrfy(ahaversin(0, 1e-10) == 0, strcat(str(tnum++), ': ahaversin(0, 1e-10) == 0')); vrfy(round(ahaversin(0.5, 1e-10), 10) == 1.5707963268, strcat(str(tnum++), ': round(ahaversin(0.5, 1e-10), 10) == 1.5707963268')); vrfy(round(ahaversin(1, 1e-10), 10) == 3.1415926536, strcat(str(tnum++), ': round(ahaversin(1, 1e-10), 10) == 3.1415926536')); vrfy(round(ahaversin(-5, 1e-10), 10) == 3.0889699048i, strcat(str(tnum++), ': round(ahaversin(-5, 1e-10), 10) == 3.0889699048i')); vrfy(round(ahaversin(2 + 3i, 1e-10), 10) == 2.03004373+2.5998241933i, strcat(str(tnum++), ': round(ahaversin(2 + 3i, 1e-10), 10) == 2.03004373+2.5998241933i')); /* test half coversed trigonometric sine */ vrfy(hacoversin(0, 1e-10) == 0.5, strcat(str(tnum++), ': hacoversin(0, 1e-10) == 0.5')); vrfy(round(hacoversin(0.2, 1e-10), 10) == 0.4006653346, strcat(str(tnum++), ': round(hacoversin(0.2, 1e-10), 10) == 0.4006653346')); vrfy(round(hacoversin(3/7, 1e-10), 10) == 0.2922140725, strcat(str(tnum++), ': round(hacoversin(3/7, 1e-10), 10) == 0.2922140725')); vrfy(round(hacoversin(-31, 1e-10), 10) == 0.2979811774, strcat(str(tnum++), ': round(hacoversin(-31, 1e-10), 10) == 0.2979811774')); vrfy(hacoversin(pi/6, 1e-10) == 0.25, strcat(str(tnum++), ': hacoversin(pi/6, 1e-10) == 0.25')); vrfy(hacoversin(pi/2, 1e-10) == 0, strcat(str(tnum++), ': hacoversin(pi/2, 1e-10) == 0')); vrfy(hacoversin(pi, 1e-10) == 0.5, strcat(str(tnum++), ': hacoversin(pi, 1e-10) == 0.5')); vrfy(hacoversin(3*pi/2, 1e-10) == 1, strcat(str(tnum++), ': hacoversin(3*pi/2, 1e-10) == 1')); vrfy(round(hacoversin(1, 1e-10), 10) == 0.0792645076, strcat(str(tnum++), ': round(hacoversin(1, 1e-10), 10) == 0.0792645076')); vrfy(round(hacoversin(2 + 3i, 1e-10), 10) == -4.0772495734+2.08445348i, strcat(str(tnum++), ': round(hacoversin(2 + 3i, 1e-10), 10) == -4.0772495734+2.08445348i')); /* test inverse half coversed trigonometric sine */ vrfy(ahacoversin(1, 1e-10) == 0, strcat(str(tnum++), ': ahacoversin(1, 1e-10) == 0')); vrfy(round(ahacoversin(0.5, 1e-10), 10) == 0.5235987756, strcat(str(tnum++), ': round(ahacoversin(0.5, 1e-10), 10) == 0.5235987756')); vrfy(round(ahacoversin(0, 1e-10), 10) == 1.5707963268, strcat(str(tnum++), ': round(ahacoversin(0, 1e-10), 10) == 1.5707963268')); vrfy(round(ahacoversin(-5, 1e-10), 10) == 1.5707963268-3.0889699048i, strcat(str(tnum++), ': round(ahacoversin(-5, 1e-10), 10) == 1.5707963268-3.0889699048i')); vrfy(round(ahacoversin(2 + 3i, 1e-10), 10) == -0.4592474035-2.5998241938i, strcat(str(tnum++), ': round(ahacoversin(2 + 3i, 1e-10), 10) == -0.4592474035-2.5998241938i')); /* test half versed trigonometric cosine */ vrfy(havercos(0, 1e-10) == 1, strcat(str(tnum++), ': havercos(0, 1e-10) == 1')); vrfy(round(havercos(0.2, 1e-10), 10) == 0.9900332889, strcat(str(tnum++), ': round(havercos(0.2, 1e-10), 10) == 0.9900332889')); vrfy(round(havercos(3/7, 1e-10), 10) == 0.9547801758, strcat(str(tnum++), ': round(havercos(3/7, 1e-10), 10) == 0.9547801758')); vrfy(round(havercos(-31, 1e-10), 10) == 0.9573711789, strcat(str(tnum++), ': round(havercos(-31, 1e-10), 10) == 0.9573711789')); vrfy(havercos(pi/3, 1e-10) == 0.75, strcat(str(tnum++), ': havercos(pi/3, 1e-10) == 0.75')); vrfy(havercos(pi/2, 1e-10) == 0.5, strcat(str(tnum++), ': havercos(pi/2, 1e-10) == 0.5')); vrfy(havercos(pi, 1e-10) == 0, strcat(str(tnum++), ': havercos(pi, 1e-10) == 0')); vrfy(havercos(3*pi/2, 1e-10) == 0.5, strcat(str(tnum++), ': havercos(3*pi/2, 1e-10) == 0.5')); vrfy(round(havercos(1, 1e-10), 10) == 0.770151153, strcat(str(tnum++), ': round(havercos(1, 1e-10), 10) == 0.770151153')); vrfy(round(havercos(2 + 3i, 1e-10), 10) == -1.5948128455-4.5546139469i, strcat(str(tnum++), ': round(havercos(2 + 3i, 1e-10), 10) == -1.5948128455-4.5546139469i')); /* test inverse half versed trigonometric cosine */ vrfy(ahavercos(0, 1e-10) == 0, strcat(str(tnum++), ': ahavercos(0, 1e-10) == 0')); vrfy(round(ahavercos(0.5, 1e-10), 10) == 1.5707963268, strcat(str(tnum++), ': round(ahavercos(0.5, 1e-10), 10) == 1.5707963268')); vrfy(round(ahavercos(1, 1e-10), 10) == 3.1415926536, strcat(str(tnum++), ': round(ahavercos(1, 1e-10), 10) == 3.1415926536')); vrfy(round(ahavercos(-5, 1e-10), 10) == 3.0889699048i, strcat(str(tnum++), ': round(ahavercos(-5, 1e-10), 10) == 3.0889699048i')); vrfy(round(ahavercos(2 + 3i, 1e-10), 10) == 2.03004373+2.5998241933i, strcat(str(tnum++), ': round(ahavercos(2 + 3i, 1e-10), 10) == 2.03004373+2.5998241933i')); /* test half coversed trigonometric cosine */ vrfy(hacovercos(0, 1e-10) == 0.5, strcat(str(tnum++), ': hacovercos(0, 1e-10) == 0.5')); vrfy(round(hacovercos(0.2, 1e-10), 10) == 0.5993346654, strcat(str(tnum++), ': round(hacovercos(0.2, 1e-10), 10) == 0.5993346654')); vrfy(round(hacovercos(3/7, 1e-10), 10) == 0.7077859275, strcat(str(tnum++), ': round(hacovercos(3/7, 1e-10), 10) == 0.7077859275')); vrfy(round(hacovercos(-31, 1e-10), 10) == 0.7020188226, strcat(str(tnum++), ': round(hacovercos(-31, 1e-10), 10) == 0.7020188226')); vrfy(hacovercos(pi/6, 1e-10) == 0.75, strcat(str(tnum++), ': hacovercos(pi/6, 1e-10) == 0.75')); vrfy(hacovercos(pi/2, 1e-10) == 1, strcat(str(tnum++), ': hacovercos(pi/2, 1e-10) == 1')); vrfy(hacovercos(pi, 1e-10) == 0.5, strcat(str(tnum++), ': hacovercos(pi, 1e-10) == 0.5')); vrfy(hacovercos(3*pi/2, 1e-10) == 0, strcat(str(tnum++), ': hacovercos(3*pi/2, 1e-10) == 0')); vrfy(round(hacovercos(1, 1e-10), 10) == 0.9207354924, strcat(str(tnum++), ': round(hacovercos(1, 1e-10), 10) == 0.9207354924')); vrfy(round(hacovercos(2 + 3i, 1e-10), 10) == 5.0772495734-2.08445348i, strcat(str(tnum++), ': round(hacovercos(2 + 3i, 1e-10), 10) == 5.0772495734-2.08445348i')); /* test inverse half coversed trigonometric cosine */ vrfy(ahacovercos(0, 1e-10) == 0, strcat(str(tnum++), ': ahacovercos(0, 1e-10) == 0')); vrfy(round(ahacovercos(0.5, 1e-10), 10) == 1.0471975512, strcat(str(tnum++), ': round(ahacovercos(0.5, 1e-10), 10) == 1.0471975512')); vrfy(round(ahacovercos(1, 1e-10), 10) == 1.5707963268, strcat(str(tnum++), ': round(ahacovercos(1, 1e-10), 10) == 1.5707963268')); vrfy(round(ahacovercos(-5, 1e-10), 10) == 1.5707963268-3.0889699048i, strcat(str(tnum++), ': round(ahacovercos(-5, 1e-10), 10) == 1.5707963268-3.0889699048i')); vrfy(round(ahacovercos(2 + 3i, 1e-10), 10) == -0.4592474035-2.5998241938i, strcat(str(tnum++), ': round(ahacovercos(2 + 3i, 1e-10), 10) == -0.4592474035-2.5998241938i')); /* test exterior trigonometric secant */ vrfy(exsec(0, 1e-10) == 0, strcat(str(tnum++), ': exsec(0, 1e-10) == 0')); vrfy(round(exsec(0.2, 1e-10), 10) == 0.0203388449, strcat(str(tnum++), ': round(exsec(0.2, 1e-10), 10) == 0.0203388449')); vrfy(round(exsec(3/7, 1e-10), 10) == 0.0994322676, strcat(str(tnum++), ': round(exsec(3/7, 1e-10), 10) == 0.0994322676')); vrfy(round(exsec(-31, 1e-10), 10) == 0.0932039951, strcat(str(tnum++), ': round(exsec(-31, 1e-10), 10) == 0.0932039951')); vrfy(exsec(pi/3, 1e-10) == 1, strcat(str(tnum++), ': exsec(pi/3, 1e-10) == 1')); vrfy(exsec(2*pi/3, 1e-10) == -3, strcat(str(tnum++), ': exsec(2*pi/3, 1e-10) == -3')); vrfy(exsec(pi, 1e-10) == -2, strcat(str(tnum++), ': exsec(pi, 1e-10) == -2')); vrfy(exsec(2*pi, 1e-10) == 0, strcat(str(tnum++), ': exsec(2*pi, 1e-10) == 0')); vrfy(round(exsec(1, 1e-10), 10) == 0.8508157177, strcat(str(tnum++), ': round(exsec(1, 1e-10), 10) == 0.8508157177')); vrfy(round(exsec(2 + 3i, 1e-10), 10) == -1.0416749644+0.0906111372i, strcat(str(tnum++), ': round(exsec(2 + 3i, 1e-10), 10) == -1.0416749644+0.0906111372i')); /* test inverse exterior trigonometric secant */ vrfy(aexsec(0, 1e-10) == 0, strcat(str(tnum++), ': aexsec(0, 1e-10) == 0')); vrfy(round(aexsec(0.2, 1e-10), 10) == 0.5856855435, strcat(str(tnum++), ': round(aexsec(0.2, 1e-10), 10) == 0.5856855435')); vrfy(round(aexsec(3/7, 1e-10), 10) == 0.7953988302, strcat(str(tnum++), ': round(aexsec(3/7, 1e-10), 10) == 0.7953988302')); vrfy(round(aexsec(-31, 1e-10), 10) == 1.6041358361, strcat(str(tnum++), ': round(aexsec(-31, 1e-10), 10) == 1.6041358361')); vrfy(round(aexsec(1, 1e-10), 10) == 1.0471975512, strcat(str(tnum++), ': round(aexsec(1, 1e-10), 10) == 1.0471975512')); vrfy(round(aexsec(2 + 3i, 1e-10), 10) == 1.4057101283+0.1681700706i, strcat(str(tnum++), ': round(aexsec(2 + 3i, 1e-10), 10) == 1.4057101283+0.1681700706i')); /* test exterior trigonometric cosecant */ vrfy(round(excsc(0.2, 1e-10), 10) == 4.0334895477, strcat(str(tnum++), ': round(excsc(0.2, 1e-10), 10) == 4.0334895477')); vrfy(round(excsc(3/7, 1e-10), 10) == 1.4063227285, strcat(str(tnum++), ': round(excsc(3/7, 1e-10), 10) == 1.4063227285')); vrfy(round(excsc(-31, 1e-10), 10) == 1.475016899, strcat(str(tnum++), ': round(excsc(-31, 1e-10), 10) == 1.475016899')); vrfy(excsc(pi/6, 1e-10) == 1, strcat(str(tnum++), ': excsc(pi/6, 1e-10) == 1')); vrfy(excsc(pi/2, 1e-10) == 0, strcat(str(tnum++), ': excsc(pi/2, 1e-10) == 0')); vrfy(excsc(3*pi/2, 1e-10) == -2, strcat(str(tnum++), ': excsc(3*pi/2, 1e-10) == -2')); vrfy(round(excsc(1, 1e-10), 10) == 0.1883951058, strcat(str(tnum++), ': round(excsc(1, 1e-10), 10) == 0.1883951058')); vrfy(round(excsc(2 + 3i, 1e-10), 10) == -0.9095267902+0.0412009863i, strcat(str(tnum++), ': round(excsc(2 + 3i, 1e-10), 10) == -0.9095267902+0.0412009863i')); /* test inverse exterior trigonometric cosecant */ vrfy(round(aexcsc(0, 1e-10), 10) == 1.5707963268, strcat(str(tnum++), ': round(aexcsc(0, 1e-10), 10) == 1.5707963268')); vrfy(round(aexcsc(0.2, 1e-10), 10) == 0.9851107833, strcat(str(tnum++), ': round(aexcsc(0.2, 1e-10), 10) == 0.9851107833')); vrfy(round(aexcsc(3/7, 1e-10), 10) == 0.7753974966, strcat(str(tnum++), ': round(aexcsc(3/7, 1e-10), 10) == 0.7753974966')); vrfy(round(aexcsc(-31, 1e-10), 10) == -0.0333395093, strcat(str(tnum++), ': round(aexcsc(-31, 1e-10), 10) == -0.0333395093')); vrfy(round(aexcsc(1, 1e-10), 10) == 0.5235987756, strcat(str(tnum++), ': round(aexcsc(1, 1e-10), 10) == 0.5235987756')); vrfy(round(aexcsc(2 + 3i, 1e-10), 10) == 0.1650861985-0.1681700706i, strcat(str(tnum++), ': round(aexcsc(2 + 3i, 1e-10), 10) == 0.1650861985-0.1681700706i')); /* test trigonometric chord of a unit circle */ vrfy(crd(0, 1e-10) == 0, strcat(str(tnum++), ': crd(0, 1e-10) == 0')); vrfy(round(crd(0.2, 1e-10), 10) == 0.1996668332, strcat(str(tnum++), ': round(crd(0.2, 1e-10), 10) == 0.1996668332')); vrfy(round(crd(3/7, 1e-10), 10) == 0.4252990674, strcat(str(tnum++), ': round(crd(3/7, 1e-10), 10) == 0.4252990674')); vrfy(round(crd(-31, 1e-10), 10) == -0.4129349638, strcat(str(tnum++), ': round(crd(-31, 1e-10), 10) == -0.4129349638')); vrfy(crd(pi/3, 1e-10) == 1, strcat(str(tnum++), ': crd(pi/3, 1e-10) == 1')); vrfy(crd(pi, 1e-10) == 2, strcat(str(tnum++), ': crd(pi, 1e-10) == 2')); vrfy(crd(5*pi/3, 1e-10) == 1, strcat(str(tnum++), ': crd(5*pi/3, 1e-10) == 1')); vrfy(round(crd(1, 1e-10), 10) == 0.9588510772, strcat(str(tnum++), ': round(crd(1, 1e-10), 10) == 0.9588510772')); vrfy(round(crd(2 + 3i, 1e-10), 10) == 3.9589688712+2.3009091988i, strcat(str(tnum++), ': round(crd(2 + 3i, 1e-10), 10) == 3.9589688712+2.3009091988i')); /* test inverse trigonometric chord of a unit circle */ vrfy(acrd(0, 1e-10) == 0, strcat(str(tnum++), ': acrd(0, 1e-10) == 0')); vrfy(round(acrd(0.2, 1e-10), 10) == 0.2003348424, strcat(str(tnum++), ': round(acrd(0.2, 1e-10), 10) == 0.2003348424')); vrfy(round(acrd(3/7, 1e-10), 10) == 0.4319209974, strcat(str(tnum++), ': round(acrd(3/7, 1e-10), 10) == 0.4319209974')); vrfy(round(acrd(-31, 1e-10), 10) == -3.1415926536+6.8658899902i, strcat(str(tnum++), ': round(acrd(-31, 1e-10), 10) == -3.1415926536+6.8658899902i')); vrfy(round(acrd(1, 1e-10), 10) == 1.0471975512, strcat(str(tnum++), ': round(acrd(1, 1e-10), 10) == 1.0471975512')); vrfy(round(acrd(2 + 3i, 1e-10), 10) == 1.0471975512+2.6339157938i, strcat(str(tnum++), ': round(acrd(2 + 3i, 1e-10), 10) == 1.0471975512+2.6339157938i')); /* test cosine plus sine */ vrfy(cas(0, 1e-10) == 1, strcat(str(tnum++), ': cas(0, 1e-10) == 1')); vrfy(round(cas(0.2, 1e-10), 10) == 1.1787359086, strcat(str(tnum++), ': round(cas(0.2, 1e-10), 10) == 1.1787359086')); vrfy(round(cas(3/7, 1e-10), 10) == 1.3251322067, strcat(str(tnum++), ': round(cas(3/7, 1e-10), 10) == 1.3251322067')); vrfy(round(cas(-31, 1e-10), 10) == 1.3187800031, strcat(str(tnum++), ': round(cas(-31, 1e-10), 10) == 1.3187800031')); vrfy(cas(pi/2, 1e-10) == 1, strcat(str(tnum++), ': cas(pi/2, 1e-10) == 1')); vrfy(cas(pi, 1e-10) == -1, strcat(str(tnum++), ': cas(pi, 1e-10) == -1')); vrfy(cas(3*pi/2, 1e-10) == -1, strcat(str(tnum++), ': cas(3*pi/2, 1e-10) == -1')); vrfy(round(cas(1, 1e-10), 10) == 1.3817732907, strcat(str(tnum++), ': round(cas(1, 1e-10), 10) == 1.3817732907')); vrfy(round(cas(2 + 3i, 1e-10), 10) == 4.9648734559-13.2781348538i, strcat(str(tnum++), ': round(cas(2 + 3i, 1e-10), 10) == 4.9648734559-13.2781348538i')); /* test Euler's formula */ vrfy(cis(0, 1e-10) == 1, strcat(str(tnum++), ': cis(0, 1e-10) == 1')); vrfy(cis(pi/2, 1e-10) == 1i, strcat(str(tnum++), ': cis(pi/2, 1e-10) == 1i')); vrfy(round(cis(0.2, 1e-10), 10) == 0.9800665778+0.1986693308i, strcat(str(tnum++), ': round(cis(0.2, 1e-10), 10) == 0.9800665778+0.1986693308i')); vrfy(round(cis(3/7, 1e-10), 10) == 0.9095603517+0.415571855i, strcat(str(tnum++), ': round(cis(3/7, 1e-10), 10) == 0.9095603517+0.415571855i')); vrfy(round(cis(-31, 1e-10), 10) == 0.9147423578+0.4040376453i, strcat(str(tnum++), ': round(cis(-31, 1e-10), 10) == 0.9147423578+0.4040376453i')); vrfy(round(cis(1, 1e-10), 10) == 0.5403023059+0.8414709848i, strcat(str(tnum++), ': round(cis(1, 1e-10), 10) == 0.5403023059+0.8414709848i')); vrfy(round(cis(2 + 3i, 1e-10), 10) == -0.020718731+0.0452712532i, strcat(str(tnum++), ': round(cis(2 + 3i, 1e-10), 10) == -0.020718731+0.0452712532i')); print strcat(str(tnum++), ': Ending test_trig'); } print '051: parsed test_trig()'; /* * test 052-054: define test_frem and read test9300.frem for test 93dd * * This function tests of functions frem, fcnt, gcdrem. * * After defining test_frem we print errcount() and ecnt. * * NOTE: We moved test3500 to test9300. We parse this code here, * however we execute this code as a 9300 test. */ read -once "test9300.frem"; print '052: read -once test9300.frem'; /**/ define test_frem() { local tnum; /* test number */ print '9300: Beginning test_frem'; tnum = test9300(1, 9301, 200, 61); print tnum: ': Ending test_frem'; } print '053: parsed test_frem()'; print '054: errcount():', errcount() : ', ecnt:', ecnt; /* * test 055-065: define test_param and variables and related parameter functions for test 38dd * * This function tests 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 066: define test_noarg for test 39dd * * This function tests missing argument 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 067-068: define test_ptest and read test4000.ptest for test 40dd * * This function tests more the functions such as ptest, nextcand, prevcand. */ read -once "test4000.ptest"; print '067: read -once test4000.ptest'; /**/ 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 069-070: define test_redc and read test4100.redc for test 41dd * * This function test REDC operations. */ read -once "test4100.redc"; print '069: read -once test4100.redc'; /**/ 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 071: define test_fileops for test 42dd * * This function tests various file operations. */ define test_fileops() { local a, b, c, f, m, n, p, r, s, x, y, z; local L = "Landon"; local C = "Curt"; local N = "Noll"; local LCN = "Landon\nCurt\nNoll\n"; local long = "0123456789abcdef0123456789abcdef"; 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))'); /* * fpathopen tests */ vrfy(!iserror(p=fpathopen("junk4200","r",".")), '4260: !iserror(p=fparhopen("junk4200","r","."))'); vrfy(!iserror(fclose(p)), '4261: !iserror(fclose(p))'); vrfy(!iserror(r=fpathopen("regress.cal","r")), '4262: !iserror(r=fparhopen("regress.cal","r","."))'); vrfy(!iserror(fclose(r)), '4263: !iserror(fclose(r))'); /* * verify non-stack overflow on long filenames */ long = long + long + long + long; print '4264: long = long + long + long + long;'; long = long + long + long + long; print '4265: long = long + long + long + long;'; vrfy(strlen(long) == 512, '4266: strlen(long) == 512'); /* bump ecnt up by 1 */ ++ecnt; print '4267: ++ecnt;'; vrfy(isfile(p=fopen(long,"r")) == 0, '4268: isfile(p=fopen(long,"r")) == 0'); /* * test fgetfile() and fgetline() */ vrfy(!iserror(p=fopen("tmp4200","w")), '4269: !iserror(p=fopen("tmp4200","w"))'); vrfy(!iserror(fputs(p,"chongo\n")), '4270: !iserror(fputs(p,"chongo\n"))'); vrfy(!iserror(fputs(p,"w\0a\0s\n")), '4271: !iserror(fputs(p,"w\0a\0s\n"))'); vrfy(!iserror(fputs(p,"here\n")), '4272: !iserror(fputs(p,"here\n"))'); vrfy(!iserror(fclose(p)), '4273: !iserror(fclose(p))'); vrfy(!iserror(p=fopen("tmp4200","r")), '4274: !iserror(p=fopen("tmp4200","r"))'); vrfy(!iserror(s=fgetline(p)), '4275: !iserror(s=fgetline(p))'); vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0'); vrfy(!iserror(s=fgetfile(p)), '4277: !iserror(s=fgetfile(p))'); vrfy(strcmp(s,"w\0a\0s\nhere\n") == 0, '4278: strcmp(s,"w\0a\0s\nhere\n") == 0'); vrfy(!iserror(fclose(p)), '4279: !iserror(fclose(p))'); /* * cleanup */ x = rm("junk4200"); print '4280: x = rm("junk4200")'; x = rm("tmp4200"); print '4281: x = rm("tmp4200")'; x = config("display", 20); print '4282: x = config("display", 20)'; print '4283: Ending test_fileops'; } print '071: parsed test_fileops()'; /* * test 072-075: define test_matdcl and variables for test 43dd * * This function tests 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("E_ADD"), '4342: mat_Y3 == error("E_ADD")'); 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 076: define test_objmat for test 44dd * * This function tests 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 '076: parsed test_objmat()'; /* * test 077-078: define test_fileop and variables and read test4600.fileop for test 46dd * * This function tests file operations. */ read -once "test4600.fileop"; print '077: read -once test4600.fileop'; /**/ 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 079-086: 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 087: define test_charset * * This function tests 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)'); /* NOTE: We skip non-ASCII to avoid problems with old awk that cannot handle them */ /* 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_charset()'; /* * test 088: define test_strprintf for test 48dd * * This function tests 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("tilde_space", 1); print '4806: c = config("tilde_space", 1)'; c = config("leadzero", 0); print '4807: c = config("leadzero", 0)'; c = config("fullzero", 0); print '4808: c = config("fullzero", 0)'; /* tests with tilde == 0 */ vrfy(strprintf("%d%d", 27, 29) == "2729", '4809: strprintf("%d%d", 27, 29) == "2729"'); vrfy(strprintf("%5d%3d", 27, 29) == " 27 29", '4810: strprintf("%5d%3d", 27, 29) == " 27 29"; '); vrfy(strprintf("%-5d%-3d", 27, 29) == "27 29 ", '4811: strprintf("%-5d%-3d", 27, 29) == "27 29 "'); vrfy(strprintf("%f", 1.375) == "1.38", '4812: strprintf("%f", 1.375) == "1.38"'); vrfy(strprintf("%f", 1.385) == "1.38", '4813: strprintf("%f", 1.385) == "1.38"'); vrfy(strprintf("%f", .375) == ".38", '4814: strprintf("%f", .375) == ".38"'); vrfy(strprintf("%f", .385) == ".38", '4815: strprintf("%f", .385) == ".38"'); /* tests with tilde == 1 */ c = config("tilde", 1); print '4816: c = config("tilde", 1)'; vrfy(strprintf("%f", 1.375) == "~ 1.38", '4817: strprintf("%f", 1.375) == "~ 1.38"'); vrfy(strprintf("%f", 27/29) == "~ .93", '4818: strprintf("%f", 27/29) == "~ .93"'); vrfy(strprintf("%r", 27/29) == "27/29", '4819: strprintf("%r", 27/29) == "27/29"'); vrfy(strprintf("%o", 27/29) == "033/035", '4820: strprintf("%o", 27/29) == "033/035"'); vrfy(strprintf("%x", 27/29) == "0x1b/0x1d", '4821: strprintf("%x", 27/29) == "0x1b/0x1d"'); vrfy(strprintf("%b", 27/29) == "0b11011/0b11101", '4822: strprintf("%b", 27/29) == "0b11011/0b11101"'); vrfy(strprintf("%e", 12345) == "~ 1.23e4", '4823: strprintf("%e", 12345) == "~ 1.23e4"'); vrfy(strprintf("%g", .385) == "~ .38", '4824: strprintf("%g", .385) == "~ .38"'); vrfy(strprintf("%g", 385) == "~ 3.8e2", '4825: strprintf("%g", 385) == "~ 3.8e2"'); /* tests with tilde == 1 and tilde_space == 0 */ c = config("tilde_space", 0); print '4826: c = config("tilde_space", 0)'; vrfy(strprintf("%f", 1.375) == "~1.38", '4827: strprintf("%f", 1.375) == "~1.38"'); vrfy(strprintf("%f", 27/29) == "~.93", '4828: strprintf("%f", 27/29) == "~.93"'); vrfy(strprintf("%e", 12345) == "~1.23e4", '4829: strprintf("%e", 12345) == "~1.23e4"'); vrfy(strprintf("%g", .385) == "~.38", '4830: strprintf("%g", .385) == "~.38"'); vrfy(strprintf("%g", 385) == "~3.8e2", '4831: strprintf("%g", 385) == "~3.8e2"'); /* tests with tilde_space == 0 */ c = config("tilde_space", 1); print '4832: c = config("tilde_space", 1)'; vrfy(strprintf("%f", 1.375) == "~ 1.38", '4833: strprintf("%f", 1.375) == "~ 1.38"'); vrfy(strprintf("%f", 27/29) == "~ .93", '4834: strprintf("%f", 27/29) == "~ .93"'); vrfy(strprintf("%e", 12345) == "~ 1.23e4", '4835: strprintf("%e", 12345) == "~ 1.23e4"'); vrfy(strprintf("%g", .385) == "~ .38", '4836: strprintf("%g", .385) == "~ .38"'); vrfy(strprintf("%g", 385) == "~ 3.8e2", '4837: strprintf("%g", 385) == "~ 3.8e2"'); /* mode tests with tilde == 0 */ c = config("tilde", 0); print '4838: c = config("tilde", 0)'; vrfy(strprintf("%e", 12345) == "1.23e4", '4839: strprintf("%e", 12345) == "1.23e4"'); vrfy(strprintf("%.3e", 12345) == "1.234e4", '4840: strprintf("%.3e", 12345) == "1.234e4"'); vrfy(strprintf("%e", .00012345) == "1.23e-4", '4841: strprintf("%e", .00012345) == "1.23e-4"'); vrfy(strprintf("%d %d", 27) == "27 ", '4842: strprintf("%d %d", 27) == "27 "'); vrfy(strprintf("%d", 27, 29) == "27", '4843: strprintf("%d", 27, 29) == "27"'); vrfy(strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93", '4844: strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93"'); vrfy(strprintf("%s", "abc") == "abc", '4845: strprintf("%s", "abc") == "abc"'); vrfy(strprintf("%f", "abc") == "abc", '4846: strprintf("%f", "abc") == "abc"'); vrfy(strprintf("%e", "abc") == "abc", '4847: strprintf("%e", "abc") == "abc"'); vrfy(strprintf("%5s", "abc") == " abc", '4848: strprintf("%5s", "abc") == " abc"'); vrfy(strprintf("%-5s", "abc") == "abc ", '4849: strprintf("%-5s", "abc") == "abc "'); vrfy(strprintf("%g", .385) == ".38", '4850: strprintf("%g", .385) == ".38"'); vrfy(strprintf("%g", 385) == "3.8e2", '4851: strprintf("%g", 385) == "3.8e2"'); c = config("fraction_space", 1); print '4852: c = config("fraction_space", 1)'; vrfy(strprintf("%r = %f", 27/29, 27/29) == "27 / 29 = .93", '4853: strprintf("%r = %f", 27/29, 27/29) == "27 / 29 = .93"'); /* restore config */ c = config("all", callcfg); print '4854: c = config("all", callcfg)'; print '4855: Ending test_strprintf'; } print '088: parsed test_strprintf()'; /* * test 089-123: global and static assignment tests */ global a = 10, b, c d = 20, e; 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 124: define test_listsearch for test 49dd * * This function tests 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_listsearch'; } print '124: parsed test_listsearch()'; /* * test 125: define test_filesearch for test 55dd * * This function tests searching in files. * * This function is designed to trigger 22 errors, so we bump the * errmax by 22 during the function call in test 55dd. */ 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("E_SEARCH_2"), '5009: search(f, 45) == error("E_SEARCH_2")'); vrfy(search(f, "a", 1/2) == error("E_SEARCH_3"), '5010: search(f, "a", 1/2) == error(E_SEARCH_3")'); vrfy(search(f, "a", 0, "b") == error("E_SEARCH_4"), '5011: search(f, "a", 0, "b") == error("E_SEARCH_4")'); vrfy(search(f, "a", 0) == error("E_SEARCH_6"), '5012: search(f, "a") == error("E_SEARCH_6")'); vrfy(rsearch(f, 45) == error("E_RSEARCH_2"), '5013: rsearch(f, 45) == error("E_RSEARCH_2")'); vrfy(rsearch(f, "a", "b") == error("E_RSEARCH_3"), '5014: rsearch(f, "a", "b") == error("E_RSEARCH_3")'); vrfy(rsearch(f, "a", 0, "b") == error("E_RSEARCH_4"), '5015: rsearch(f, "a", 0, "b") == error("E_RSEARCH_4")'); vrfy(rsearch(f, "a", 0) == error("E_RSEARCH_6"), '5016: rsearch(f,"a",0) == error("E_RSEARCH_6")'); /* 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 126-127: define test_newdecl and read test5100.newdecl for test 51dd * * This function tests the code generator declaration scope and order. */ read -once "test5100.newdecl"; print '126: read -once test5100.newdecl'; /**/ 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 128-129: define test_globstat and read test5200.globstat for test 52dd * * This function tests the fix of an old global/static bug. */ read -once "test5200.globstat"; print '128: read -once test5200.globstat'; /**/ 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 130-132: define test_newop2 and test label stuff * * This function tests 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 133-136: define test_newop3 and test more label stuff * * This function tests more 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 137: define test_random for test 53dd + 54dd * * This function test the 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 subtractive 100 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()))'); /* verify random(10,11) double bug fix */ vrfy(random(10,11) == 10, '5467: random(10,11) == 10'); vrfy(random(10,11) == 10, '5468: random(10,11) == 10'); vrfy(random(10,11) == 10, '5469: random(10,11) == 10'); vrfy(random(0,1) == 0, '5470: random(0,1) == 0'); vrfy(random(0,1) == 0, '5471: random(0,1) == 0'); print '5472: Ending test_random'; } print '137: parsed test_random()'; /* * test 138-151: define test_newsyn and variables for test 55dd * * This function tests 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'); /**/ { 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 152-155: define test_commaeq and variables for test 56dd * * This fucntion will test = and , operator functionality. */ 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}, mat B[2] = {1,2}; print '5625: mat A[3] = {1,2,3}, mat 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 156: test_size - test sizes of calc variables * * 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)'); /* * reciprocals 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 sizeof's 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 158-160: define test_assign and variables for test 58dd * * This function tests assignment of constants and variables. */ 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}, obj xy5800 B={3,4}; print base+5: ': obj xy5800 A={1,2}, obj xy5800 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 161-168: define test_is for test 59dd + 60dd + 61dd + 62dd + 63dd + 64dd + 65dd + 66dd * * This function tests is related 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; /* sha1 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-integer value */ local prime; /* odd prime */ local square; /* square of an odd prime */ local string; /* string */ local com; /* complex value */ local rndint; /* a random integer */ local rndexp; /* a random exponent */ local rndval; /* rndint ^ rndexp */ local i; /* integer value */ local ok; /* 1 ==> issq() tests were OK, 0 ==> failure */ print '5900: Beginning test_is'; /* * setup values */ a = assoc(); print '5901: a = assoc()'; if (config("windows")) { ofd = fopen("NUL:", "rb"); print '5902: ofd = fopen("NUL:", "rb")'; cfd = fopen("NUL:", "rb"); print '5903: cfd = fopen("NUL:", "rb")'; } else { ofd = fopen("/dev/null","rb"); print '5902: ofd = fopen("/dev/null","rb")'; cfd = fopen("/dev/null","rb"); print '5903: cfd = fopen("/dev/null","rb")'; } 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("E_1"); print '5909: serr = error("E_1")'; nerr = newerror("curds"); print '5910: nerr = newerror("curds")'; odd = 23209; print '5911: odd = 23209'; even = odd*10; print '5912: even = odd*10'; hash = sha1(); print '5913: hash = sha1()'; 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 = prime^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) == 2, '6181: ishash(hash) == 2'); 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'); /* * perform more extensive issq() testing */ ok = 1; for (i=0; i < 256; ++i) { /* rndval will be a square - even powers>0 of x>1 */ rndexp = random(1, 16) * 2; rndint = random(2, 4294967296); if (issq(rndint)) { ++rndint; } rndval = rndint ^ rndexp; if (issq(rndval) == 0) { prob(strprintf("issq(%d^%d) returned 0", rndint, rndexp)); ok = 0; } } if (ok) { print '6663: issq() on 256 squares'; } else { print '****: failure(s): 6663: faiissq() on 256 squares'; } for (i=0; i < 256; ++i) { /* rndval will not be a square - 1 + even powers>0 of x>1 */ rndexp = random(1, 16) * 2; rndint = random(2, 4294967296); rndval = rndint ^ rndexp; if (issq(rndval+1) != 0) { prob(strprintf("issq(%d^%d)+1 returned non-zero", rndint, rndexp)); ok = 0; } } if (ok) { print '6664: issq() on 256 squares+1'; } else { print '****: failure(s): 6664: issq() on 256 squares+1'; } print '6664: issq() on 256 squares+1'; for (i=0; i < 256; ++i) { /* rndval will not be a square - odd powers>0 of x>1 */ rndexp = (random(1, 16) * 2) + 1; rndint = random(2, 4294967296); if (issq(rndint)) { ++rndint; } rndval = rndint ^ rndexp; if (issq(rndval) != 0) { prob(strprintf("issq(%d^%d) returned non-zero", rndint, rndexp)); ok = 0; } } if (ok) { print '6665: issq() on 256 non-squares'; } else { print '****: failure(s): 6665: issq() on 256 non-squares'; } /* * cleanup */ blkfree("blk5900"); print '6666: blkfree("blk5900")'; fclose(ofd); print '6667: fclose(ofd)'; print '6668: Ending test_is'; } print '168: test_is()'; /* * test 169: test_blk - test blk (block of octets) facility * * This function tests the blk (block of octets) facility. */ 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", 15 , 10) = {1,2,3,4,5};'; 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 '6787: Ending test_blk'; } print '169: parsed test_blk()'; /* * test 170: define test_blkcpy for tess 68dd * * This function tests the 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 171: define test_name for test 69dd * * This function tests 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 172: test_blkprintf - define test_blkprintf for test 70dd * * This function tests 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()'; /* **************************************************************** */ /* NOTE: ==> Room for special start of regression test 173 here <== */ /* **************************************************************** */ /* * test 174: test_sha1 - define test_sha1 for test 72dd * * * This function tests 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 composite",3i+4.5,"hash")) == 0x68aa4fe0a9b6d1662f8d2dbdeee8879239185d09, '7209: sha1(sha1("this is",7^19-8,"a composite",3i+4.5,"hash")) ' + '== ...'); z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100)); print '7210: z = sha1(list(1,2,3), "curds and whey",', '2^21701-1, pi(1e-100));'; vrfy(sha1(z) == 0x158cc87deeb9dd478ca14e3ab359205b0fb15b83, '7211: sha1(z) == 0x158cc87deeb9dd478ca14e3ab359205b0fb15b83'); 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(1e-100)); print '7215: y = sha1(y, pi(1e-100));'; 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()'; /* **************************************************************** */ /* NOTE: ==> Room for special start of regression test 175 here <== */ /* **************************************************************** */ /* * test 176-180: test_ptr - define test functions for pointers for test_ptr and test 75dd + 76dd */ 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' /* * test 181: define test_ptr for test 75dd + 76dd * * This function tests pointers as well as "inline" defined functions. */ define test_ptr() { local a, b, c, A, B, B1, B2, M, L, p, q, r, 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'); q = &M[1], *q = 6; print '7589: q = &M[1], *q = 6;'; vrfy(M[1] == 6, '7588: M[1] == 6'); vrfy(M[0] == 5, '7588: M[0] == 5'); vrfy(q == &M[1], '7592: q == &M[1]'); vrfy(p == &M[0], '7593: p == &M[0]'); quomod(17,5,*q,*p); print '7594: quomod(17,5,*p,*q);'; vrfy(M[1] == 3 && M[0] == 2, '7595: M[1] == 3 && M[0] == 2'); swap(*p, *q); print '7596: swap(*p, *q);'; vrfy(M[1] == 2 && M[0] == 3, '7597: M[1] == 2 && M[0] == 3'); A = *M = {7,8}; print '7598: A = *M = {7,8};'; vrfy(M == (mat[4] = {3,2,3,4}), '7599: M == (mat[4] = {3,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'); /* verify arithmetic value address operation restrictions */ M = mat[10] = {0,1,2,3,4,5,6,7,8,9}; print '7605: M = mat[10] = {0,1,2,3,4,5,6,7,8,9};'; /* NOTE: The next set of tests will trigger 10 errors by design */ ecnt += 10; print '7606: ecnt += 10'; p = &M[3]; print '7607: p = &M[3]'; ++p; print '7608: ++p'; vrfy(p == error("E_INVALID_ADDR_OP"), '7609: p == error("E_INVALID_ADDR_OP")'); p = &M[4]; print '7610: p = &M[4]'; p++; print '7611: p++'; vrfy(p == error("E_INVALID_ADDR_OP"), '7612: p == error("E_INVALID_ADDR_OP")'); p = &M[5]; print '7613: p = &M[5]'; q = &M[8]; print '7614: q = &M[8]'; vrfy(q+5 == error("E_INVALID_ADDR_OP"), '7615: q+5 == error("E_INVALID_ADDR_OP")'); vrfy(q-7 == error("E_INVALID_ADDR_OP"), '7616: q-7 == error("E_INVALID_ADDR_OP")'); vrfy(p+q == error("E_INVALID_ADDR_OP"), '7617: p+q == error("E_INVALID_ADDR_OP")'); r = p-q; print '7618: r = p-q;'; /* Testing number and string pointers */ a = 24, b = 4 * 6, c = 4!; print '7619: a = 24, b = 4 * 6, c= 4!;'; vrfy(isptr(&*a) == 4, '7620: isptr(&*a) == 4'); vrfy(&*a == &24, '7621: &*a == &24'); vrfy(&*a == &*b, '7622: &*a == &*b'); vrfy(&*a != &*c, '7623: &*a != &*c'); a = b = "abc", c = strcat("a", "bc"); print '7624: a = b = "abc", c = strcat("a", "bc");'; vrfy(isptr(&*a) == 3, '7625: isptr(&*a) == 3'); vrfy(&*a == &"abc", '7626: &*a == &"abc"'); vrfy(&*a == &*b, '7627: &*a == &*b'); vrfy(&*a != &*c, '7628: &*a != &*c'); a = c; print '7629: a = c;'; vrfy(&*a == &*c, '7630: &*a == &*c'); /* Verifying null-ness of freed numbers */ c = 4!, p = &*c, free(c); print '7631: c = 4!, p = &*c, free(c)'; vrfy(isnull(*p), '7632: isnull(*p)'); print '7633: Ending test_ptr'; } print '181: parsed test_ptr()'; /* * test 182: define test_newstring for test 77dd * * This function tests 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);'; /* NOTE: We skip non-ASCII to avoid problems with old awk that cannot handle them */ /* 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 183: define test_newcomb for test 78dd * * This function tests 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()'; /* * test 184-185: define f7900 functions for test 79dd * * 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: parsed f7900()'; /**/ define g7900(a,b,n) = (perm(b, n + 1) - perm(a, n + 1))/(n + 1); print '185: define g7900(a,b,n) = ...'; /* * test 186: test_bigcomb - define test_bigcomb for test 79dd * * This function tests 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()'; /* * test 187-188: define test_natnumset and read natnumset for test 81dd * * The test_natnumset is used to 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 '8100: 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 189-190: define test_somenew for test 82dd * * This function tests 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(str(char(0)) == "", '8206: str(char(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 191: define test_exponentiation for test 88dd * * This function tests new exponentiation functionality. */ define test_exponentiation() { local a; print '8800: Starting test_exponentiation'; /* unexpected help file cases */ vrfy(2^3 == 8, '8801: 2^3 == 8'); vrfy(2.5 ^ 3.5 == power(2.5, 3.5), '8802: 2.5 ^ 3.5 == power(2.5, 3.5)'); vrfy(2.5 ^ 2.718i == power(2.5, 2.718i), '8803: 2.5 ^ 2.718i == power(2.5, 2.718i)'); vrfy(3i^4 == 81, '8804: 3i^4 == 81'); vrfy(0.5i ^ 0.25 == power(0.5i, 0.25), '8804: 0.5i ^ 0.25 == power(0.5i, 0.25)'); vrfy(3.13145i^0.30103i == power(3.13145i, 0.30103i), '8806: 3.13145i^0.30103i == power(3.13145i, 0.30103i)'); /* deal with some corner error cases */ ecnt += 12; print '8807: ecnt += 2'; vrfy((1/0) ^ -1 == 0, '8808: (1/0) ^ -1 == 0'); vrfy((1/0) ^ -2 == 0, '8809: (1/0) ^ -2 == 0'); vrfy((1/0) ^ 0 == error("E_DIVBYZERO"), '8810: (1/0) ^ 0 == error("E_DIVBYZERO")'); vrfy((1/0) ^ 3 == error("E_DIVBYZERO"), '8811: (1/0) ^ 3 == error("E_DIVBYZERO")'); vrfy(0 ^ -2 == error("E_DIVBYZERO"), '8812: 0 ^ -2 == error("E_DIVBYZERO")'); vrfy((1/0) ^ 1i == error("E_DIVBYZERO"),'8813: (1/0) ^ 1i == error("E_DIVBYZERO")'); vrfy((1/0) ^ 0i == error("E_DIVBYZERO"),'8814: (1/0) ^ 0i == error("E_DIVBYZERO")'); /* real ^ real */ vrfy(5^6 == 15625, '8815: 5^6 == 15625'); vrfy(10^31 == 1e31, '8816: 10^31 == 1e31'); vrfy(10 ^ (127/31) == power(10, 127/31), '8817: 10 ^ (127/31) == power(10, 127/31)'); vrfy((10^31) ^ 10 == 1e310, '8818: (10^31) ^ 10 == 1e310'); /* complex ^ real */ vrfy(10i ^ 10 == -1e10, '8819: 10i ^ 10 == -1e10'); vrfy((-10i) ^ 10 == -1e10, '8820: (-10i) ^ 10 == -1e10'); vrfy((1+1i) ^ 4 == -4, '8821: (1+1i) ^ 4 == -4'); vrfy((1+1i) ^ 65536 == 2^32768, '8822: (1+1i) ^ 65536 == 2^32768'); vrfy((1+1i) ^ (2^20) == 2^(2^19), '8823: (1+1i) ^ (2^20) == 2^(2^19)'); vrfy((31+17i) ^ pi() == power(31+17i, pi()), '8824: (31+17i) ^ pi() == power(31+17i, pi()'); vrfy((5+7i) ^ exp(5) == power(5+7i, exp(5)), '8825: (5+7i) ^ exp(5) == power(5+7i, exp(5))'); /* real ^ complex */ vrfy(10 ^ 1i == power(10, 1i), '8826: 10 ^ 1i == power(10, 1i)'); vrfy(10 ^ (2+3i) == power(10, 2+3i), '8827: 10 ^ (2+3i) == power(10, 2+3i)'); vrfy(pi() ^ (2+3i) == power(pi(), 2+3i), '8828: pi() ^ (2+3i) == power(pi(), 2+3i)'); vrfy(exp(64) ^ (2+3i) == power(exp(64), 2+3i), '8828: exp(64) ^ (2+3i) == power(exp(64), 2+3i)'); vrfy(pi() ^ (257+127i) == power(pi(), 257+127i), '8829: pi() ^ (257+127i) == power(pi(), 257+127i)'); vrfy(pi() ^ asin(-2) == power(pi(), asin(-2)), '8830: pi() ^ asin(-2) == power(pi(), asin(-2)'); /* complex ^ complex */ vrfy((3+4i) ^ (2+3i) == power(3+4i, 2+3i), '8831: (3+4i) ^ (2+3i) == power(3+4i, 2+3i)'); vrfy(ln(-10) ^ (2+3i) == power(ln(-10), 2+3i), '8832: ln(-10) ^ (2+3i) == power(ln(-10), 2+3i)'); vrfy((pi()*1i) ^ asin(-2) == power(pi()*1i, asin(-2)), '8833: (pi()*1i) ^ asin(-2) == power(pi()*1i, asin(-2))'); vrfy((exp(1)+pi()*1i) ^ asin(-2) == power(exp(1)+pi()*1i, asin(-2)), '8834: (exp(1)+pi()*1i) ^ asin(-2) == power(exp(1)+pi()*1i, asin(-2))'); print '8835: Ending test_exponentiation'; } print '191: parsed test_exponentiation()'; /* * test 192: define test_quit for test 84dd * * This function tests 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 series continued after return, do not print end here */ } print '192: parsed test_quit()'; /* ********************************************************************* */ /* NOTE: ==> Room for special start of regression tests 193-298 here <== */ /* ********************************************************************* */ /* * test 299: End of main part of regression test suite read */ print '299: Ending main part of regression test suite read'; /* * test 30d + 31d + 32d: test boolean operations and IF statements */ print; return test_booleans(); /* * test 35d + 36d + 37d + 38d: test global variables, simple assignments, AND and OR operators, short-circuit eval */ print; return test_variables(); /* * test 4dd: test simple arithmetic operations and expressions */ print; return test_arithmetic(); /* * test 5dd: test config control */ print; return test_config(); /* * test 6dd: test multiplication and division on three numbers in various ways */ print; return test_bignums(); /* * test 7dd + 8dd + 9dd + 10dd + 11dd + 12dd: test many of the built-in functions * * See test_functions() (test 700 - 1238) for other built-in function tests. * See test_functions2() (test 9000 - 9063) for other built-in function tests. * See test_functions3() (test 9100 - 9214) for other built-in function tests. */ print; return test_functions(); /* * test 13dd: test associations */ print; return test_assoc(); /* * test 14dd: test lists */ print; return test_list(); /* * test 15dd: test the subtractive 100 shuffle pseudo-random number generator */ print; return test_rand(); /* * test 16dd + 17dd: test config mode and base */ print; return test_mode(); /* * test 18dd: test objects */ print; return test_obj(); /* * test 19dd + 20dd: test prime related functionality */ print; return test_prime(); /* * test 21dd: perfor the Lucas primality test suite */ print; return test_lucas(); /* * test 22dd: test operator functionality */ print; return test_newop(); /* * test 23dd: test object increment/decrement */ print; return test_xx_incdec(); /* * test 24dd + 25dd: test rounding config modes */ print; return test_round(); /* * test 26dd: test certain numeric functions extensively */ print; return test_2600(); /* * test 27dd: test complex sqrt */ print; return test_2700(); /* * test 28dd + 29dd: test matrix operations */ print; return test_matrix(); /* * test 30dd: test string constants and comparisons */ print; return test_strings(); /* * test 31dd: test determinants of a matrix containing objects */ print; return test_matobj(); /* * test 32dd: test the polynomial function */ print; return test_poly(); /* * test 33dd: test more determinant functionality */ print; return test_det(); /* * test 34dd + 35dd + 36dd: test common trig functions */ print; return test_trig(); /* *********************************************** */ /* NOTE: ==> Room for new tests 3700-3799 here <== */ /* *********************************************** */ /* * test 38dd: test param functionality */ print; return test_param(); /* * test 39dd: test missing argument functionality */ print; return test_noarg(); /* * test 40dd: test more the functions such as ptest, nextcand, prevcand */ print; return test_ptest(); /* * test 41dd: test REDC operations */ print; return test_redc(); /* * test 42dd: test various file operations */ print; return test_fileops(); /* * test 43dd: test matrix declaration syntax */ print; return test_matdcl(); /* * test 44dd: test combined obj and mat operations */ print; return test_objmat(); /* * test 45dd: test use of _'s in identifiers */ print; return _test_underscore(); /* * test 46dd: test file operations */ print; return test_fileop(); /* * test 47dd: test the ASCII character set and \'s */ print; return test_charset(); /* * test 48dd: test strprintf calls */ print; return test_strprintf(); /* * test 49dd: test searching in lists */ print; return test_listsearch(); /* * test 50dd: test searching in files */ print; return test_filesearch(); /* * test 51dd: test code generator declaration scope and order */ print; return test_newdecl(); /* * test 52dd: test the fix of an old global/static bug */ print; return test_globstat(); /* * test 53dd + 54dd: test Blum-Blum-Shub pseudo-random number generator */ print; return test_random(); /* * test 55dd: test command completion syntax and scope rules */ print; return test_newsyn(); vrfy(s5500 == 78, '5548: s5500 == 78'); /* * test 56dd: test = and , operator functionality */ print; return test_commaeq(); /* * test 57dd: test sizes of calc variables */ print; return test_size(); /* * test 58dd: assignment tests */ print; 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})'); define f5800(a5800 = mat[2] = {3,4}) = 5 * a5800; print '5866: define f5800(a5800 = mat[2] = {3,4}) = 5 * a5800;' vrfy(f5800() == (mat[] = {15,20}),'5867: f5800() == (mat[] = {15,20})'); print '5868: End of 5800 sequence'; /* * test 59dd + 60dd + 61dd + 62dd + 63dd + 64dd + 65dd + 66dd: test is related functions */ print; return test_is(); /* * test 67dd: test blk (block of octets) facility */ print; return test_blk(); /* * test 68dd: test the copy builtin function */ print; return test_blkcpy(); /* * test 69dd: test the name builtin */ print; return test_name(); /* * test 70dd: Test blk printf */ print; return test_blkprintf(); /* *********************************************** */ /* NOTE: ==> Room for new tests 7100-7199 here <== */ /* *********************************************** */ /* * test 72dd: test SHA1 hash */ print; return test_sha1(); /* *********************************************** */ /* NOTE: ==> Room for new tests 7300-7399 here <== */ /* *********************************************** */ /* * test 74dd: savedot tests */ 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'; /* * test 75dd + 76dd: test pointers well as "inline" defined functions */ print; return test_ptr(); /* * test 77dd: test new string operations */ print; return test_newstring(); /* * test 78dd: test combinatoric and permutation functions */ print; return test_newcomb(); /* * test 79dd: test big combinations and permutations */ print; return test_bigcomb(); /* * test 80dd: test read of calc resource files */ print; print '8000: Beginning read test'; value = 0; vrfy(value == 0, '8001: value == 0'); read "test8000.read"; print '8002: read "test8000.read";'; vrfy(value == 1, '8003: value == 1'); read -once "test8000.read"; print '8004: read -once "test8000.read";'; vrfy(value == 1, '8005: value == 1'); read "test8000.read.cal"; print '8006: read "test8000.read.cal";'; vrfy(value == 2, '8007: value == 2'); read -once "test8000.read.cal" print '8008: read -once "test8000.read.cal";'; vrfy(value == 2, '8009: value == 2'); read "test8000.read.cal"; print '8010: read "test8000.read.cal";'; vrfy(value == 3, '8011: value == 3'); {++value;} read "test8000.read.cal"; print '8012: {++value;} read "test8000.read.cal";'; vrfy(value == 5, '8013: value == 5'); {++value;} read -once "test8000.read.cal"; print '8014: {++value;} read -once "test8000.read.cal";'; vrfy(value == 6, '8015: value == 6'); print '8016: Ending read test'; /* * test 81dd: test natural numbers not exceeding a fixed bound */ print; return test_natnumset(); /* * test 82dd: test new exponentiation functionality */ print; return test_somenew(); /* * test 83dd: 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'); static a8300 = 1, b8300; vrfy(a8300 == 1, '8310: a8300 == 1'); print '8311: Ending define tests'; /* * test 84dd: quit tests and read test8400.quit */ print; return test_quit(); read -once test8400.quit; print '8404: read -once test8400.quit'; vrfy(test8400() == 64434, '8405: test8400() == 64434'); print '8406: Ending test_quit'; /* * test 85dd: pseudo-random tests on the // and % with various rounding modes and read test8500.divmod */ print; print '8500: Starting test of divmod' read -once "test8500.divmod"; /* * test 86dd: test up to 1024 args being passed to a builtin function and read test8600.maxargs */ print; print '8600: Starting test of up to 1024 args' read -once "test8600.maxargs"; /* * test 87dd: read dotest, test8700.dotest * * We use the dotest driver to evaluate set8700.line data files. */ print; print '8700: Starting dotest runs' print '8701: read -once "dotest"'; read -once "dotest"; print '8702: read -once "test8700.dotest"'; read -once "test8700.dotest"; vrfy(dotest("set8700.line", 8703) == 0, '8703: dotest("set8700.line", 8703) == 0'); /* * test 88dd: new exponentiation functionality */ print; return test_exponentiation(); /* * test 89dd: test calc resource functions by Christoph Zurnieden and read test8900.special */ print; print '8900: Starting test of calc resource functions by Christoph Zurnieden'; print '8901: read -once "test8900.special"'; read -once "test8900.special"; print '8902: about to run test8900(1,,8903)'; testnum = test8900(1,,8903); print "8941: ecnt ==", ecnt; print '8942: ecnt = 224;' ecnt = 224; /* * test 90dd: Test more of the built-in functions. * * See test_functions() (test 700 - 1238) for other built-in function tests. * See test_functions2() (test 9000 - 9063) for other built-in function tests. * See test_functions3() (test 9100 - 9214) for other built-in function tests. */ define test_functions2() { print '9001: Beginning test_functions2'; /* ctype function tests */ vrfy(isalnum("A") == 1, '9002: isalnum("A") == 1'); vrfy(isalnum("a") == 1, '9003: isalnum("a") == 1'); vrfy(isalnum("2") == 1, '9004: isalnum("2") == 1'); vrfy(isalnum("\t") == 0, '9005: isalnum("\\t") == 0'); vrfy(isalpha("A") == 1, '9006: isalpha("A") == 1'); vrfy(isalpha("a") == 1, '9007: isalpha("a") == 1'); vrfy(isalpha("2") == 0, '9008: isalpha("2") == 0'); vrfy(isalpha("\t") == 0, '9009: isalpha("\\t") == 0'); vrfy(iscntrl("A") == 0, '9010: iscntrl("A") == 0'); vrfy(iscntrl("a") == 0, '9011: iscntrl("a") == 0'); vrfy(iscntrl("2") == 0, '9012: iscntrl("2") == 0'); vrfy(iscntrl("\t") == 1, '9013: iscntrl("\\t") == 1'); vrfy(isdigit("A") == 0, '9014: isdigit("A") == 0'); vrfy(isdigit("a") == 0, '9015: isdigit("a") == 0'); vrfy(isdigit("2") == 1, '9016: isdigit("2") == 1'); vrfy(isdigit("\t") == 0, '9017: isdigit("\\t") == 0'); vrfy(isgraph("A") == 1, '9018: isgraph("A") == 1'); vrfy(isgraph("a") == 1, '9019: isgraph("a") == 1'); vrfy(isgraph("2") == 1, '9020: isgraph("2") == 1'); vrfy(isgraph("\t") == 0, '9021: isgraph("\\t") == 0'); vrfy(islower("A") == 0, '9022: islower("A") == 0'); vrfy(islower("a") == 1, '9023: islower("a") == 1'); vrfy(islower("1") == 0, '9024: islower("1") == 0'); vrfy(isprint("A") == 1, '9025: isprint("A") == 1'); vrfy(isprint("a") == 1, '9026: isprint("a") == 1'); vrfy(isprint(" ") == 1, '9027: isprint(" ") == 1'); vrfy(isprint("\t") == 0, '9028: isprint("\\t") == 0'); vrfy(ispunct("A") == 0, '9029: ispunct("A") == 0'); vrfy(ispunct("a") == 0, '9030: ispunct("a") == 0'); vrfy(ispunct(" ") == 0, '9031: ispunct(" ") == 0'); vrfy(ispunct("?") == 1, '9032: ispunct("?") == 1'); vrfy(isspace("A") == 0, '9033: isspace("A") == 0'); vrfy(isspace("Krik") == 0, '9034: isspace("Krik") == 0'); vrfy(isspace(" ") == 1, '9035: isspace(" ") == 1'); vrfy(isspace("?") == 0, '9036: isspace("?") == 0'); vrfy(isupper("A") == 1, '9037: isupper("A") == 1'); vrfy(isupper("a") == 0, '9038: isupper("a") == 0'); vrfy(isupper("1") == 0, '9039: isupper("1") == 0'); vrfy(isxdigit("A") == 1, '9040: isxdigit("A") == 1'); vrfy(isxdigit("f") == 1, '9041: isxdigit("f") == 1'); vrfy(isxdigit("2") == 1, '9042: isxdigit("2") == 1'); vrfy(isxdigit("x") == 0, '9043: isxdigit("x") == 0'); vrfy(strcasecmp("ab", "aBc") == -1, '9044: strcasecmp("ab", "aBc") == -1'); vrfy(strcasecmp("abc", "aBb") == 1, '9045: strcasecmp("abc", "aBb") == 1'); vrfy(strcasecmp("abc", "abc") == 0, '9046: strcasecmp("abc", "abc") == 0'); vrfy(strcasecmp("abc", "aBc") == 0, '9047: strcasecmp("abc", "aBc") == 0'); vrfy(strcasecmp("abc", "aBd") == -1, '9048: strcasecmp("abc", "aBd") == -1'); vrfy(strcasecmp("abc\0", "aBc") == 1, '9049: strcasecmp("a8c\\0", "aBc") == 1'); vrfy(strcasecmp("a\0b", "A\0c") == -1, '9050: strcasecmp("a\\0b", "A\\0c") == -1'); vrfy(strncasecmp("abc", "xyz", 0) == 0, '9051: strncasecmp("abc", "xyz", 0) == 0'); vrfy(strncasecmp("abc", "xyz", 1) == -1, '9052: strncasecmp("abc", "xyz", 1) == -1'); vrfy(strncasecmp("abc", "", 1) == 1, '9053: strncasecmp("abc", "", 1) == 1'); vrfy(strncasecmp("a", "b", 2) == -1, '9054: strncasecmp("a", "b", 2) == -1'); vrfy(strncasecmp("ab", "Ac", 2) == -1, '9055: strncasecmp("ab", "Ac", 2) == -1'); vrfy(strncasecmp("\0ac", "\0b", 2) == -1, '9056: strncasecmp("\\0ac", "\\0b", 2) == -1'); vrfy(strncasecmp("ab", "aBc", 2) == 0, '9057: strncasecmp("ab", "aBc", 2) == 0'); vrfy(strncasecmp("abc", "abd", 2) == 0, '9058: strncasecmp("abc", "abd", 2) == 0'); local s1 = " gnu lesser general public license"; print '9059: local s1 = " gnu lesser general public license";'; vrfy(strcmp(strtolower(" GNU Lesser General Public License"), s1) == 0, '9060: strcmp(strtolower(" GNU Lesser General Public License"),' + ' s1) == 0'); local s2 = " GNU LESSER GENERAL PUBLIC LICENSE"; print '9061: local s2 = " GNU LESSER GENERAL PUBLIC LICENSE";'; vrfy(strcmp(strtoupper(" GNU Lesser General Public License"), s2) == 0, '9062: strcmp(strtoupper(" GNU Lesser General Public License"),' + ' s2) == 0'); print '9063: Ending test_functions2'; } print; print '9000: parsed test_functions2()'; return test_functions2(); /* * test 91dd + 92dd: Test even more of the built-in functions. * * See test_functions() (test 700 - 1238) for other built-in function tests. * See test_functions2() (test 9000 - 9063) for other built-in function tests. * See test_functions3() (test 9100 - 9214) for other built-in function tests. */ define test_functions3() { local d, m, s, g, h; print '9101: Beginning test_functions3'; /* d2r & r2d */ vrfy(d2r(180) == pi(), '9102: d2r(180) == pi()'); vrfy(d2r(180, 1e-100) == pi(1e-100), '9103: d2r(180, 1e-100) == pi(1e-100)'); vrfy(r2d(pi()/2) == 90, '9104: r2d(pi()/2) == 90'); vrfy(r2d(pi(1e-15)/2) == 14137166941154068500000/157079632679489661923, '9105: r2d(pi(1e-15)/2) == ' + '14137166941154068500000/157079632679489661923'); vrfy(r2d(d2r(40)) == 40, '9106: r2d(d2r(40)) == 40'); vrfy(r2d(d2r(40,1e-90),1e-90) == 40, '9107: r2d(d2r(40,1e-90),1e-90) == 40'); vrfy(d2r(180i) == 1i*pi(), '9108: d2r(1808) == 1i*pi()'); vrfy(d2r(180i+90) == 1i*pi() + pi()/2, '9109: d2r(180i+90) == 1i*pi() + pi()/2'); vrfy(r2d(d2r(40+40i)) == 40+40i, '9110: r2d(d2r(40+40i)) == 40+40i'); vrfy(r2d(d2r(40+40i,1e-60),1e-60) == 40+40i, '9111: r2d(d2r(40+40i,1e-60),1e-60) == 40+40i'); /* g2r & r2g */ vrfy(g2r(200) == pi(), '9112: g2r(200) == pi()'); vrfy(g2r(200, 1e-100) == pi(1e-100), '9113: g2r(180, 1e-100) == pi(1e-100)'); vrfy(r2g(pi()/2) == 100, '9114: r2g(pi()/2) == 100'); vrfy(r2g(pi(1e-15)/2) == 15707963267948965000000/157079632679489661923, '9115: r2g(pi(1e-15)/2) == ' + '15707963267948965000000/157079632679489661923'); vrfy(r2g(g2r(40)) == 40, '9116: r2g(g2r(40)) == 40'); vrfy(r2g(g2r(40,1e-90),1e-90) == 40, '9117: r2g(g2r(40,1e-90),1e-90) == 40'); vrfy(g2r(200i) == 1i*pi(), '9118: g2r(200i) == 1i*pi()'); vrfy(g2r(200i+150) == pi()*0.75 + 1i*pi(), '9119: g2r(200i+150) == pi()*0.75 + 1i*pi()'); vrfy(r2g(g2r(40+40i)) == 40+40i, '9120: r2g(g2r(40+40i)) == 40+40i'); vrfy(r2g(g2r(40+40i,1e-60),1e-60) == 40+40i, '9121: r2g(g2r(40+40i,1e-60),1e-60) == 40+40i'); /* g2d & d2g */ vrfy(g2d(200) == 180, '9122: g2d(200) == 180'); vrfy(g2d(200, 1e-100) == 180, '9123: g2d(180, 1e-100) == 180'); vrfy(d2g(81) == 90, '9124: d2g(81) == 90'); vrfy(d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000, '9125: d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000'); vrfy(d2g(g2d(40)) == 40, '9126: d2g(g2d(40)) == 40'); vrfy(d2g(g2d(40,1e-90),1e-90) == 40, '9127: d2g(g2d(40,1e-90),1e-90) == 40'); vrfy(g2d(200i) == 180i, '9128: g2d(200i) == 180i'); vrfy(g2d(200i+47) == 42.3 + 180i, '9129: g2d(200i+47) == 42.3 + 180i'); vrfy(d2g(g2d(40+40i)) == 40+40i, '9130: d2g(g2d(40+40i)) == 40+40i'); vrfy(d2g(g2d(40+40i,1e-90),1e-90) == 40+40i, '9131: d2g(g2d(40+40i,1e-90),1e-90) == 40+40i'); /* d2dms */ vrfy(d2dms(12.3456,d,m,s) == 12.3456, '9132: d2dms(12.3456,d,m,s) == 12.3456'); vrfy(d == 12, '9133: d == 12'); vrfy(m == 20, '9133: m == 20'); vrfy(s == 44.16, '9134: s == 44.16'); vrfy(d2dms(1234.5678,d,m,s) == 154.5678, '9135: d2dms(1234.5678,d,m,s) == 154.5678'); vrfy(d == 154, '9136: d == 154'); vrfy(m == 34, '9137: m == 34'); vrfy(s == 4.08, '9138: s == 4.08'); vrfy(d2dms(-1234.5678,d,m,s) == 205.4322, '9139: d2dms(-1234.5678,d,m,s) == 205.4322'); vrfy(d == 205, '9140: d == 205'); vrfy(m == 25, '9141: m == 25'); vrfy(s == 55.92, '9142: s == 55.92'); vrfy(d2dms(360.321,d,m,s,1) == -359.679, '9143: d2dms(360.321,d,m,s,1) == -359.679'); vrfy(d == -359, '9144: d == -359'); vrfy(m == -40, '9145: m == -40'); vrfy(s == -44.4, '9146: s == -44.4'); /* d2dm */ vrfy(d2dm(12.3456,d,m) == 12.3456, '9147: d2dm(12.3456,d,m) == 12.3456'); vrfy(d == 12, '9148: d == 12'); vrfy(m == 20.736, '9149: m == 20.736'); vrfy(d2dm(1234.5678,d,m) == 154.5678, '9150: d2dm(1234.5678,d,m) == 154.5678'); vrfy(d == 154, '9151: d == 154'); vrfy(m == 34.068, '9152: m == 34.068'); vrfy(d2dm(-1234.5678,d,m) == 205.4322, '9153: d2dm(-1234.5678,d,m) == 205.4322'); vrfy(d == 205, '9154: d == 205'); vrfy(m == 25.932, '9155: m == 25.932'); vrfy(d2dm(360.321,d,m,1) == -359.679, '9156: d2dm(360.321,d,m,1) == -359.679'); vrfy(d == -359, '9167: d == -359'); vrfy(m == -40.74, '9158: m == -40.74'); /* g2gms */ vrfy(g2gms(12.3456,g,m,s) == 12.3456, '9159: g2gms(12.3456,g,m,s) == 12.3456'); vrfy(g == 12, '9133: g == 12'); vrfy(m == 20, '9160: m == 20'); vrfy(s == 44.16, '9161: s == 44.16'); vrfy(g2gms(1234.5678,g,m,s) == 34.5678, '9162: g2gms(1234.5678,g,m,s) == 34.5678'); vrfy(g == 34, '9163: g == 34'); vrfy(m == 34, '9164: m == 34'); vrfy(s == 4.08, '9165: s == 4.08'); vrfy(g2gms(-1234.5678,g,m,s) == 365.4322, '9166: g2gms(-1234.5678,g,m,s) == 365.4322'); vrfy(g == 365, '9167: g == 365'); vrfy(m == 25, '9168: m == 25'); vrfy(s == 55.92, '9169: s == 55.92'); vrfy(g2gms(400.321,g,m,s,1) == -399.679, '9170: g2gms(400.321,g,m,s,1) == -399.679'); vrfy(g == -399, '9171: g == -399'); vrfy(m == -40, '9172: m == -40'); vrfy(s == -44.4, '9173: s == -44.4'); /* g2gm */ vrfy(g2gm(12.3456,g,m) == 12.3456, '9174: g2gm(12.3456,g,m) == 12.3456'); vrfy(g == 12, '9175: g == 12'); vrfy(m == 20.736, '9176: m == 20.736'); vrfy(g2gm(1234.5678,g,m) == 34.5678, '9177: g2gm(1234.5678,g,m) == 34.5678'); vrfy(g == 34, '9178: g == 34'); vrfy(m == 34.068, '9179: m == 34.068'); vrfy(g2gm(-1234.5678,g,m) == 365.4322, '9180: g2gm(-1234.5678,g,m) == 365.4322'); vrfy(g == 365, '9181: g == 365'); vrfy(m == 25.932, '9182: m == 25.932'); vrfy(g2gm(400.321,g,m,1) == -399.679, '9183: g2gm(400.321,g,m,1) == -399.679'); vrfy(g == -399, '9184: g == -399'); vrfy(m == -40.74, '9185: m == -40.74'); /* h2hms */ vrfy(h2hms(12.3456,h,m,s) == 12.3456, '9186: h2hms(12.3456,h,m,s) == 12.3456'); vrfy(h == 12, '9187: h == 12'); vrfy(m == 20, '9188: m == 20'); vrfy(s == 44.16, '9189: s == 44.16'); vrfy(h2hms(1234.5678,h,m,s) == 10.5678, '9190: h2hms(1234.5678,h,m,s) == 10.5678'); vrfy(h == 10, '9191: h == 10'); vrfy(m == 34, '9192: m == 34'); vrfy(s == 4.08, '9193: s == 4.08'); vrfy(h2hms(-1234.5678,h,m,s) == 13.4322, '9194: h2hms(-1234.5678,h,m,s) == 13.4322'); vrfy(h == 13, '9195: h == 13'); vrfy(m == 25, '9196: m == 25'); vrfy(s == 55.92, '9197: s == 55.92'); vrfy(h2hms(24.321,h,m,s,1) == -23.679, '9198: h2hms(24.321,h,m,s,1) == -23.679'); vrfy(h == -23, '9199: h == -23'); vrfy(m == -40, '9200: m == -40'); vrfy(s == -44.4, '9201: s == -44.4'); /* h2hm */ vrfy(h2hm(12.3456,h,m) == 12.3456, '9202: h2hm(12.3456,h,m) == 12.3456'); vrfy(h == 12, '9203: h == 12'); vrfy(m == 20.736, '9204: m == 20.736'); vrfy(h2hm(1234.5678,h,m) == 10.5678, '9205: h2hm(1234.5678,h,m) == 10.5678'); vrfy(h == 10, '9206: h == 10'); vrfy(m == 34.068, '9207: m == 34.068'); vrfy(h2hm(-1234.5678,h,m) == 13.4322, '9208: h2hm(-1234.5678,h,m) == 13.4322'); vrfy(h == 13, '9209: h == 13'); vrfy(m == 25.932, '9210: m == 25.932'); vrfy(h2hm(24.321,h,m,1) == -23.679, '9211: h2hm(24.321,h,m,1) == -23.679'); vrfy(h == -23, '9212: h == -23'); vrfy(m == -40.74, '9213: m == -40.74'); /* dm2d */ vrfy(dm2d(203, 325.5594) == 208.42599, '9214: dm2d(203, 325.5594) == 208.42599'); vrfy(dm2d(3601, -25.5594) == 0.57401, '9215: dm2d(3601, -25.5594) == 0.57401'); vrfy(dm2d(-923, -25.5594) == 156.57401, '9216: dm2d(-923, -25.5594) == 156.57401'); vrfy(dm2d(203, 325.5594, 1) == -151.57401, '9217: dm2d(203, 325.5594, 1) == -151.57401'); vrfy(d2dm(dm2d(12, 20.16),d,m) == 12.336, '9218: d2dm(dm2d(12, 20.16),d,m) == 12.336'); vrfy(d == 12, '9219: d == 12'); vrfy(m == 20.16, '9220: m == 20.16'); /* dms2d */ vrfy(dms2d(12, 20, 44.16) == 12.3456, '9221: dms2d(12, 20, 44.16) == 12.3456'); vrfy(dms2d(123.456, -345.68, 4.08) == 117.6958, '9222: dms2d(123.456, -345.68, 4.08) == 117.6958'); vrfy(dms2d(-65, -40, -44.4) == 294.321, '9223: dms2d(-65, -40, -44.4) == 294.321'); vrfy(dms2d(12, 20, 44.16, 1) == -347.6544, '9224: dms2d(12, 20, 44.16, 1) == -347.6544'); vrfy(d2dms(dms2d(13, 20, 44.16),d,m,s) == 13.3456, '9225: d2dms(dms2d(13, 20, 44.16),d,m,s) == 13.3456'); vrfy(d == 13, '9226: d == 13'); vrfy(m == 20, '9227: m == 20'); vrfy(s == 44.16, '9228: s == 44.16'); /* gm2g */ vrfy(gm2g(203, 325.5594) == 208.42599, '9229: gm2g(203, 325.5594) == 208.42599'); vrfy(gm2g(3601, -25.5594) == 0.57401, '9230: gm2g(3601, -25.5594) == 0.57401'); vrfy(gm2g(-923, -25.5594) == 276.57401, '9231: gm2g(-923, -25.5594) == 276.57401'); vrfy(gm2g(203, 325.5594, 1) == -191.57401, '9232: gm2g(203, 325.5594, 1) == -191.57401'); vrfy(g2gm(gm2g(12, 20.16),g,m) == 12.336, '9233: g2gm(gm2g(12, 20.16),g,m) == 12.336'); vrfy(g == 12, '9234: g == 12'); vrfy(m == 20.16, '9235: m == 20.16'); /* gms2g */ vrfy(gms2g(12, 20, 44.16) == 12.3456, '9236: gms2g(12, 20, 44.16) == 12.3456'); vrfy(gms2g(123.456, -345.68, 4.08) == 117.6958, '9237: gms2g(123.456, -345.68, 4.08) == 117.6958'); vrfy(gms2g(-65, -40, -44.4) == 334.321, '9238: gms2g(-65, -40, -44.4) == 334.321'); vrfy(gms2g(12, 20, 44.16, 1) == -387.6544, '9239: gms2g(12, 20, 44.16, 1) == -387.6544'); vrfy(g2gms(gms2g(14, 20, 44.16),g,m,s) == 14.3456, '9240: g2gms(gms2g(14, 20, 44.16),g,m,s) == 14.3456'); vrfy(g == 14, '9241: g == 14'); vrfy(m == 20, '9242: m == 20'); vrfy(s == 44.16, '9243: s == 44.16'); /* hm2h */ vrfy(hm2h(203, 325.5594) == 16.42599, '9244: hm2h(203, 325.5594) == 16.42599'); vrfy(hm2h(241, -25.5594) == 0.57401, '9245: hm2h(241, -25.5594) == 0.57401'); vrfy(hm2h(-923, -25.5594) == 12.57401, '9246: hm2h(-923, -25.5594) == 12.57401'); vrfy(hm2h(203, 325.5594, 1) == -7.57401, '9247: hm2h(203, 325.5594, 1) == -7.57401'); vrfy(h2hm(hm2h(12, 20.16),h,m) == 12.336, '9248: h2hm(hm2h(12, 20.16),h,m) == 12.336'); vrfy(h == 12, '9249: h == 12'); vrfy(m == 20.16, '9250: m == 20.16'); /* hms2h */ vrfy(hms2h(12, 20, 44.16) == 12.3456, '9251: hms2h(12, 20, 44.16) == 12.3456'); vrfy(hms2h(123.456, -345.68, 4.08) == 21.6958, '9252: hms2h(123.456, -345.68, 4.08) == 21.6958'); vrfy(hms2h(-65, -40, -44.4) == 6.321, '9253: hms2h(-65, -40, -44.4) == 6.321'); vrfy(hms2h(12, 20, 44.16, 1) == -11.6544, '9254: hms2h(12, 20, 44.16, 1) == -11.6544'); vrfy(h2hms(hms2h(15, 20, 44.16),h,m,s) == 15.3456, '9255: h2hms(hms2h(15, 20, 44.16),h,m,s) == 15.3456'); vrfy(h == 15, '9256: h == 15'); vrfy(m == 20, '9257: m == 20'); vrfy(s == 44.16, '9258: s == 44.16'); print '9259: Ending test_functions3'; } print; print '9100: parsed test_functions3()'; return test_functions3(); /* * test 93dd: test_frem - tests of the functions frem, fcnt, gcdrem * * NOTE: We moved test3500 to test9300. We parse this code here, * however we execute this code as a 9300 test. */ print; return test_frem(); /* * test 94dd + 95dd: read various calc resource files * * We read most of the standard calc resource files. There are a few * resource files that are not read because their are infinite loops, * or print lots of stuff when loaded, or were read by test8900.special.cal, * or were already read by regressl.cal. * * We want to do this 2nd to last; ahead of any final cleanup and behind * all of real actions of regress.cal. */ print; print '9400: Starting read of selected calc resource files'; read -once alg_config; print '9401: read -once alg_config'; print '9402: skipping read -once beer because it is an infinite loop'; read -once bernoulli; print '9403: read -once bernoulli'; print '9404: skipping read -once bernpoly - will be read via test8900.special'; read -once bigprime; print '9405: read -once bigprime'; print '9406: skipping read -once brentsolve - will be read via test8900.special'; read -once chi; print '9407: read -once chi'; read -once chrem; print '9408: read -once chrem'; read -once comma; print '9409: read -once comma'; print '9410: skipping read -once constants - will be read via test8900.special'; read -once deg; print '9411: read -once deg'; read -once dms; print '9412: read -once dms'; print '9413: skipping read -once dotest - will be read via test8700.dotest'; read -once ellip; print '9414: read -once ellip'; print '9415: skipping read -once factorial - will be read via test8900.special'; print '9416: skipping read -once factorial2 - will be read via test8900.special'; read -once fnv_tool; print '9417: read -once fnv_tool'; read -once gvec; print '9418: read -once gvec'; print '9419: skipping read -once hello.cal because it is an infinite loop'; read -once hms; print '9420: read -once hms'; print '9421: skipping read -once infinities - will be read via test8900.special'; read -once intfile; print '9422: read -once intfile'; print '9423: skipping read -once intnum - will be read via test8900.special'; print '9424: skipping read -once lambertw - will be read via test8900.special'; read -once linear; print '9425: read -once linear'; read -once lnseries; print '9426: read -once lnseries'; print '9427: skipping read -once lucas - will be read via regress'; print '9428: skipping read -once lucas_chk - will be read via regress'; read -once mersenne; print '9429: read -once mersenne'; read -once mfactor; print '9430: read -once mfactor'; read -once mod; print '9431: read -once mod'; read -once natnumset; print '9432: read -once natnumset'; read -once palindrome; print '9433: read -once palindrome'; read -once pell; print '9434: read -once pell'; read -once pi; print '9435: read -once pi'; read -once pix; print '9436: read -once pix'; read -once pollard; print '9437: read -once pollard'; read -once poly; print '9438: read -once poly'; read -once prompt; print '9439: read -once prompt'; read -once psqrt; print '9440: read -once psqrt'; read -once qtime; print '9441: read -once qtime'; read -once quat; print '9442: read -once quat'; read -once randbitrun; print '9443: read -once randbitrun'; read -once randmprime; print '9444: read -once randmprime'; read -once randombitrun; print '9445: read -once randombitrun'; read -once randomrun; print '9446: read -once randomrun'; read -once randrun; print '9447: read -once randrun'; print '9448: skipping read -once regress - will be read via regress'; read -once repeat; print '9449: read -once repeat'; read -once screen; print '9450: read -once screen'; read -once seedrandom; print '9451: read -once seedrandom'; read -once smallfactors; print '9452: read -once smallfactors'; read -once solve; print '9453: read -once solve'; print '9454: skipping read -once specialfunctions - will be read via test8900.special'; read -once splitbits; print '9455: read -once splitbits'; print '9456: skipping read -once statistics - will be read via test8900.special'; read -once strings; print '9457: read -once strings'; read -once sumsq; print '9458: read -once sumsq'; read -once sumtimes; print '9459: read -once sumtimes'; print '9460: skipping read -once surd - will be read via regress'; print '9461: skipping read -once test2300.obj_incdec - will be read via regress'; print '9462: skipping read -once test2600.numfunc - will be read via regress'; print '9463: skipping read -once test2700.isqrt - will be read via regress'; print '9464: skipping read -once test3100.matobj - will be read via regress'; print '9465: skipping read -once test3300.det - will be read via regress'; print '9466: skipping read -once test3400.trig - will be read via regress'; print '9467: skipping read -once test4000.ptest - will be read via regress'; print '9468: skipping read -once test4100.redc - will be read via regress'; print '9469: skipping read -once test4600 - will be read via regress'; print '9470: skipping read -once test5100.newdecl - will be read via regress'; print '9471: skipping read -once test5200.globstat - will be read via regress'; print '9472: skipping read -once test8000.read - will be read via regress'; print '9473: skipping read -once test8400.quit - will be read via regress'; print '9474: skipping read -once test8500.divmod - will be read via regress'; print '9475: skipping read -once test8600.maxargs - will be read via regress'; print '9476: skipping read -once test8700.dotest - will be read via regress'; print '9477: skipping read -once test8900.special - will be read via regress'; print '9478: skipping read -once test9300.frem - will be read via regress'; print '9479: skipping read -once toomcook - will be read via test8900.special'; read -once unitfrac; print '9480: read -once unitfrac'; read -once varargs; print '9481: read -once varargs'; read -once write2file; print '9482: read -once write2file'; print '9483: skipping read -once xx_print.cal because it is a printing demo'; print '9484: skipping read -once zeta2 - will be read via test8900.special'; print '9485: Ending read of selected calc resource files'; /* * test 95dd: read test9500.trigeq, test of trigonometric identities */ print; print '9500: Starting trigonometric identities test set'; epsilon(1e-20),; print '9501: epsilon(1e-20)'; read -once test9500.trigeq; print '9502: read -once test9500.trigeq'; vrfy(verify_tan(9503) == 0, '9503: verify_tan(9503) == 0'); vrfy(verify_cot(9504) == 0, '9504: verify_cot(9504) == 0'); vrfy(verify_sec(9505) == 0, '9505: verify_sec(9505) == 0'); vrfy(verify_csc(9506) == 0, '9506: verify_csc(9506) == 0'); vrfy(verify_versin(9507) == 0, '9507: verify_versin(9507) == 0'); vrfy(verify_coversin(9508) == 0, '9508: verify_coversin(9508) == 0'); vrfy(verify_vercos(9509) == 0, '9509: verify_vercos(9509) == 0'); vrfy(verify_covercos(9510) == 0, '9510: verify_covercos(9510) == 0'); vrfy(verify_haversin(9511) == 0, '9511: verify_haversin(9511) == 0'); vrfy(verify_hacoversin(9512) == 0, '9512: verify_hacoversin(9512) == 0'); vrfy(verify_havercos(9513) == 0, '9513: verify_havercos(9513) == 0'); vrfy(verify_hacovercos(9514) == 0, '9514: verify_hacovercos(9514) == 0'); vrfy(verify_exsec(9515) == 0, '9515: verify_exsec(9515) == 0'); vrfy(verify_excsc(9516) == 0, '9516: verify_excsc(9516) == 0'); vrfy(verify_crd(9517) == 0, '9517: verify_crd(9517) == 0'); vrfy(verify_cas(9518) == 0, '9518: verify_cas(9518) == 0'); vrfy(verify_cis(9519) == 0, '9519: verify_cis(9519) == 0'); print '9520: Ending trigonometric identities test set'; /* * test 96dd: dupvar_warn and redecl_warn testing */ print; print '9600: Starting test of dupvar_warn and redecl_warn config parameters'; vrfy(config("redecl_warn",0), '9601: config("redecl_warn",0)'); vrfy(config("dupvar_warn",0), '9602: config("dupvar_warn",0)'); vrfy(u_glob == 6, '9603: u_glob == 6'); global u_glob = 555; print '9604: declare u_glob'; vrfy(u_glob == 555, '9605: u_glob == 555'); define func_8650(u_glob) { local u_glob; return u_glob; } print '9606: u_glob as both local and parameter'; define func_8650a(u_glob) { static u_glob; return u_glob; } print '9607: u_glob as both static and parameter'; vrfy(config("redecl_warn",1)==0, '9608: config("redecl_warn",1)==0'); vrfy(config("dupvar_warn",1)==0, '9609: config("dupvar_warn",1)==0'); print '9610: Ending test of dupvar_warn and redecl_warn config parameters'; /* * test 9699: define test_error for test 97dd + 98dd * * This function tests 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, e9999; local a, b, c, n, x; /* used by newerror() */ print '9700: Beginning test_error'; print '9701: ecnt:', ecnt; strx = "x"; print '9702: strx = "x"'; e99 = error(99); print '9703: e99 = error(99)'; vrfy(1/0 == error("E_DIVBYZERO"), '9704: 1/0 == error("E_DIVBYZERO")'); vrfy(0/0 == error("E_ZERODIVZERO"), '9705: 0/0 == error("E_ZERODIVZERO")'); vrfy(2 + "x" == error("E_ADD"), '9706: 2 + "x" == error("E_ADD")'); vrfy("x" - 2 == error("E_SUB"), '9707: "x" - 2 == error("E_SUB")'); vrfy("x" * "y" == error("E_MUL"), '9708: "x" * "y" == error("E_MUL")'); vrfy("x" / "y" == error("E_DIV"), '9709: "x" / "y" == error("E_DIV")'); vrfy(-list(1) == error("E_NEG"), '9710: -list(1) == error("E_NEG")'); vrfy("x"^2 == error("E_SQUARE"), '9711: "x"^2 == error("E_SQUARE")'); vrfy(inverse("x")==error("E_INV"), '9712: inverse("x") == error("E_INV")'); vrfy(++strx == error("E_INCV"), '9713: ++strx == error("E_INCV")'); vrfy(strx == error("E_INCV"), '9714: strx == error("E_INCV")'); strx = "x"; print '9715: strx = "x"'; vrfy(strx++ == "x", '9716: strx++ == "x"'); vrfy(strx == error("E_INCV"), '9717: strx == error("E_INCV")'); strx = "x"; print '9718: strx = "x"'; vrfy(--strx == error("E_DECV"), '9719: strx == error("E_DECV")'); vrfy(int("x") == error("E_INT"), '9720: int("x") == error("E_INT")'); vrfy(frac("x") == error("E_FRAC"), '9721: frac("x") == error("E_FRAC")'); vrfy(conj("x") == error("E_CONJ"), '9722: conj("x") == error("E_CONJ")'); vrfy(appr("x",.1) == error("E_APPR_1"), '9723: appr("x",.1) == error("E_APPR_1")'); vrfy(appr(1.27,.1i) == error("E_APPR_2"), '9724: appr(1.27,.1i) == error("E_APPR_2")'); vrfy(appr(1.27,.1,.1) == error("E_APPR_3"), '9725: appr(1.27,.1,.1) == error("E_APPR_3")'); vrfy(round("x") == error("E_ROUND_1"), '9726: round("x") == error("E_ROUND_1")'); vrfy(round(1.25,.1) == error("E_ROUND_2"), '9727: round(1.25,.1) == error("E_ROUND_2")'); vrfy(round(1.25,"x") == error("E_ROUND_2"), '9728: round(1.25,"x") == error("E_ROUND_2")'); vrfy(round(1.25,1,.1) == error("E_ROUND_3"), '9729: round(1.25,1,.1) == error("E_ROUND_3")'); vrfy(bround("x") == error("E_BROUND_1"), '9730: bround("x") == error("E_BROUND_1")'); vrfy(bround(1.25,.1) == error("E_BROUND_2"), '9731: bround(1.25,.1) == error("E_BROUND_2")'); vrfy(bround(1.25,"x") == error("E_BROUND_2"), '9732: bround(1.25,"x") == error("E_BROUND_2")'); vrfy(bround(1.25,1,.1) == error("E_BROUND_3"), '9733: bround(1.25,1,.1) == error("E_BROUND_3")'); vrfy(sqrt("x") == error("E_SQRT_1"), '9734: sqrt("x") == error("E_SQRT_1")'); vrfy(sqrt(2,"x") == error("E_SQRT_2"), '9735: sqrt(2,"x") == error("E_SQRT_2")'); vrfy(sqrt(2,0) == error("E_SQRT_2"), '9736: sqrt(2,0) == error("E_SQRT_2")'); vrfy(sqrt(2,.1,.1) == error("E_SQRT_3"), '9737: sqrt(2,.1,.1) == error("E_SQRT_3")'); vrfy(root("x",3) == error("E_ROOT_1"), '9738: root("x",3) == error("E_ROOT_1")'); vrfy(root(3,"x") == error("E_ROOT_2"), '9739: root(3,"x") == error("E_ROOT_2")'); vrfy(root(3,-2) == error("E_ROOT_2"), '9740: root(3,-2) == error("E_ROOT_2")'); vrfy(root(3,0) == error("E_ROOT_2"), '9741: root(3,0) == error("E_ROOT_2")'); vrfy(root(3,.1) == error("E_ROOT_2"), '9742: root(3,.1) == error("E_ROOT_2")'); vrfy(root(3,2,"x") == error("E_ROOT_3"), '9743: root(3,2,"x") == error("E_ROOT_3")'); vrfy(root(3,2,0) == error("E_ROOT_3"), '9744: root(3,2,0) == error("E_ROOT_3")'); vrfy(norm("x") == error("E_NORM"), '9745: norm("x") == error("E_NORM")'); vrfy(list() << 2 == error("E_SHIFT_1"), '9746: list() << 2 == error("E_SHIFT_1")'); vrfy(1.5 << 2 == error("E_SHIFT_1"), '9747: 1.5 << 2 == error("E_SHIFT_1")'); vrfy(3 << "x" == error("E_SHIFT_2"), '9748: 3 << "x" == error("E_SHIFT_2")'); vrfy(3 << 1.5 == error("E_SHIFT_2"), '9749: 3 << 1.5 == error("E_SHIFT_2")'); vrfy(3 << 2^31 == error("E_SHIFT_2"), '9750: 3 << 2^31 == error("E_SHIFT_2")'); vrfy(scale("x",2) == error("E_SCALE_1"), '9751: scale("x",2) == error("E_SCALE_1")'); vrfy(scale(3,"x") == error("E_SCALE_2"), '9752: scale(3,"x") == error("E_SCALE_2")'); vrfy(scale(3,1.5) == error("E_SCALE_2"), '9753: scale(3,1.5) == error("E_SCALE_2")'); vrfy(scale(3,2^31) == error("E_SCALE_2"), '9754: scale(3,2^31) == error("E_SCALE_2")'); vrfy("x" ^ 3 == error("E_POWI_1"), '9755: "x" ^ 3 == error("E_POWI_1")'); vrfy(2 ^ "x" == error("E_POWI_2"), '9756: 2 ^ "x" == error("E_POWI_2")'); vrfy(2 ^ "2" == error("E_POWI_2"), '9757: 2 ^ "2" == error("E_POWI_2")'); vrfy(power("x",2.1) == error("E_POWER_1"), '9758: power("x",2.1) == error("E_POWER_1")'); vrfy(power(2,"x") == error("E_POWER_2"), '9759: power(2,"x") == error("E_POWER_2")'); vrfy(power(2,2.1,"x") == error("E_POWER_3"), '9760: power(2,2.1,"x") == error("E_POWER_3")'); vrfy(quo("x",3) == error("E_QUO_1"), '9761: quo("x",3) == error("E_QUO_1")'); vrfy(quo(8,"x") == error("E_QUO_2"), '9762: quo(8,"x") == error("E_QUO_2")'); vrfy(quo(8,3,"x") == error("E_QUO_3"), '9763: quo(8,3,"x") == error("E_QUO_3")'); vrfy(quo(8,3,2.1) == error("E_QUO_3"), '9764: quo(8,3,2.1) == error("E_QUO_3")'); vrfy(mod("x",3) == error("E_MOD_1"), '9765: mod("x",3) == error("E_MOD_1")'); vrfy(mod(8,"x") == error("E_MOD_2"), '9766: mod(8,"x") == error("E_MOD_2")'); vrfy(mod(8,3,"x") == error("E_MOD_3"), '9767: mod(8,3,"x") == error("E_MOD_3")'); vrfy(mod(8,3,2.1) == error("E_MOD_3"), '9768: mod(8,3,2.1) == error("E_MOD_3")'); vrfy(sgn("x") == error("E_SGN"), '9769: sgn("x") == error("E_SGN")'); vrfy(abs("x") == error("E_ABS_1"), '9770: abs("x") == error("E_ABS_1")'); vrfy(abs(2+3i,"x") == error("E_ABS_2"), '9771: abs(2+3i,"x") == error("E_ABS_2")'); vrfy(abs(2+3i,0) == error("E_ABS_2"), '9772: abs(2+3i,0) == error("E_ABS_2")'); list1 = list(2,3,"x",4,5); print '9773: list1 = list(2,3,"x",4,5)'; vrfy(avg(list1) == error("E_ADD"), '9774: avg(list1) == error("E_ADD")'); vrfy(iserror(e99)==99, '9775: iserror(e99) == 99'); vrfy(e99 + 2 == e99, '9776: e99 + 2 == e99'); vrfy(e99 - 2 == e99, '9777: e99 - 2 == e99'); vrfy(e99 * 2 == e99, '9778: e99 * 2 == e99'); vrfy(e99 / 2 == e99, '9779: e99 / 2 == e99'); vrfy(e99 // 2 == e99, '9780: e99 // 2 == e99'); vrfy(e99 % 2 == e99, '9781: e99 % 2 == e99'); vrfy(e99 ^ 2 == e99, '9782: e99 ^ 2 == e99'); vrfy(2 + e99 == e99, '9783: 2 + e99 == e99'); vrfy(2 - e99 == e99, '9784: 2 - e99 == e99'); vrfy(2 * e99 == e99, '9785: 2 * e99 == e99'); vrfy(2 / e99 == e99, '9786: 2 / e99 == e99'); vrfy(2 // e99 == e99, '9787: 2 // e99 == e99'); vrfy(2 % e99 == e99, '9788: 2 % e99 == e99'); vrfy(2 ^ e99 == e99, '9789: 2 ^ e99 == e99'); vrfy(- e99 == e99, '9790: -e99 == e99'); vrfy(inverse(e99) == e99, '9791: inverse(e99) == e99'); vrfy(++e99 == e99, '9792: ++e99 == e99'); vrfy(--e99 == e99, '9793: --e99 == e99'); vrfy(int(e99) == e99, '9794: int(e99) == e99'); vrfy(frac(e99) == e99, '9795: frac(e99) == e99'); vrfy(conj(e99) == e99, '9796: conj(e99) == e99'); vrfy(norm(e99) == e99, '9797: norm(e99) == e99'); vrfy(sgn(e99) == e99, '9798: sgn(e99) == e99'); vrfy(appr(e99,1,0) == e99, '9799: appr(e99,1,0) == e99'); vrfy(round(e99) == e99, '9800: round(e99) == e99'); vrfy(bround(e99) == e99, '9801: bround(e99) == e99'); vrfy(sqrt(e99) == e99, '9802: sqrt(e99) == e99'); print '9803: a = newerror("alpha")'; a = newerror("alpha"); print '9804: b = newerror("beta")'; b = newerror("beta"); print '9805: c = newerror("alpha")'; c = newerror("alpha"); vrfy(a == c, '9806: a == c'); vrfy(strerror(a) == "alpha", '9807: strerror(a) == "alpha"'); print '9808: n = iserror(a)'; n = iserror(a); vrfy(a == error(n), '9809: a == error(n)'); vrfy(newerror() == newerror("???"), '9810: newerror() == newerror("???")'); vrfy(newerror("") == newerror(), '9811: newerror("") == newerror()'); e9999 = error("E_9999"); print '9812: e9999 = error("E_9999")'; vrfy(errno() == 9999, '9813: errno() == 9999'); vrfy(error() == e9999, '9814: error() == e9999'); /* test 3715 removed due to non-portable strerror() output */ x = newerror("Alpha"); print '9816: x = newerror("Alpha")'; n = iserror(x); print '9817: n = iserror(x)'; vrfy(errno() == n, '9818: errno() == n'); vrfy(error() == x, '9819: error() == x'); vrfy(strerror() == "Alpha", '9820: strerror() == "Alpha"'); vrfy(errno("E_9999") == n, '9821: errno("E_9999") == n'); vrfy(errno() == 9999, '9822: errno() == 9999'); vrfy(error() == e9999, '9823: error() == e9999'); /* test 3724 removed due to non-portable strerror() output */ a = 1/0; print '9825: a = 1/0'; vrfy(strerror() == "Division by zero", '9826: strerror() == "Division by zero"'); n = 8191; print '9827: n = 8191'; print '9828: test removed due to non-portable strerror() output'; vrfy(tan(2e9i) == error("E_TAN_5"), '9829: tan(2e9i) == error("E_TAN_5")'); vrfy(cot(2e9i) == error("E_COT_6"), '9830: cot(2e9i) == error("E_COT_6")'); vrfy(sec(2e9i) == error("E_SEC_5"), '9831: sec(2e9i) == error("E_SEC_5")'); vrfy(csc(2e9i) == error("E_CSC_6"), '9832: csc(2e9i) == error("E_CSC_6")'); /* errmax and errcount should be bumped up the 148 errors above */ print '9833: errcount():', errcount(); print '9833: ecnt:', ecnt; vrfy(errcount() == ecnt, '9835: errcount() == ecnt'); print '9836: Ending test_error'; } print; print '9699: parsed test_error()'; /* * test 97dd + 98dd: test the error builtin */ print; return test_error(); /* * test 99dd: define vrfy_errsym and test E_STRING in error, errno, strerror, errsym */ print; print '9900: Prep to test of error("E_STRING") errno("E_STRING"), strerror("E_STRING") and errsym("E_STRING")'; /* * vrfy_errsym - verify errsym builtin function for valid errnum codes and errsym "E_STRING" strings */ define vrfy_errsym(testnum, errnum, e_string) { local res_errnum; /* errnum result of errsym(e_string) */ local res_errsym; /* errnum result of errsym(errnum) */ /* * firewall */ if (!isint(testnum) || testnum <= 0) { print '**** Non-true result (' : testnum : \ '): invalid vrfy_errsym testnum (must be int > 0) 1st arg:', testnum; ++prob; return; } if (!isint(errnum) || errnum < 0) { print '**** Non-true result (' : testnum : \ '): invalid vrfy_errsym errnum (must be int >= 0) 2nd arg:', errnum; ++prob; return; } if (!isstr(e_string) || strlen(e_string) < 3 || strncmp(e_string, "E_", 2) != 0) { print '**** Non-true result (' : testnum : \ '): invalid vrfy_errsym e_string (must be string starting with E_) 3rd arg:', e_string; ++prob; return; } /* * try errsym("E_STRING") */ res_errnum = errsym(e_string); if (!isint(res_errnum)) { print '**** Non-true result (' : testnum : \ '): errsym("' : e_string : '") returned non-integer:', res_errnum; ++prob; return; } /* * try errsym(errnum) */ res_errsym = errsym(errnum); if (!isstr(res_errsym)) { print '**** Non-true result (' : testnum : \ '): errsym(' : errnum : ') returned non-string:', res_errsym; ++prob; return; } /* * compare errnum and res_errnum */ if (errnum != res_errnum) { print '**** Non-true result (' : testnum : \ '): vrfy_errsym errnum 2nd arg:', errnum, '!= errsym("' : e_string : '"):', res_errnum; ++prob; return; } /* * compare errsym and res_errsym */ if (strcmp(e_string, res_errsym) != 0) { print '**** Non-true result (' : testnum : \ '): vrfy_errsym errsym 3rd arg: "' : e_string : '" != errsym(' : errnum : '): "' : res_errsym : '"'; ++prob; return; } /* * report success */ print testnum : ': vrfy_errsym(' : testnum : ',', errnum : ', "' : e_string : '") passed'; return; } print '9901: parsed vrfy_errsym()'; ++ecnt,; print '9902: ++ecnt'; res = error("E_ADD"); print '9903: res = error("E_ADD")'; vrfy(iserror(res) == errsym("E_ADD"), '9904: iserror(res) == errsym("E_ADD")'); vrfy(errno("E_ADD") == errsym("E_ADD"), '9905: errno("E_ADD") == errsym("E_ADD")'); vrfy(errno() == errsym("E_ADD"), '9906: errno() == errsym("E_ADD")'); vrfy(strerror("E_ADD") == "Bad arguments for +", '9907: strerror("E_ADD") == "Bad arguments for +"'); vrfy(errsym("E__NONE") == 0, '9909: errsym("E__NONE") == 0'); vrfy_errsym( 9910, 0, "E_0"); vrfy(errsym("E__BASE") == 10000, '9911: errsym("E__BASE") == 10000'); vrfy_errsym( 9912, 10000, "E__BASE"); vrfy(errsym("E__HIGHEST") > errsym("E__BASE"), '9913: errsym("E__HIGHEST") > errsym("E__BASE")'); vrfy(errsym("E__USERDEF") > errsym("E__HIGHEST"), '9914: errsym("E__USERDEF") > errsym("E__HIGHEST")'); vrfy(errsym("E__USERDEF") == 20000, '9915: errsym("E__USERDEF") == 20000'); vrfy_errsym( 9916, 20000, "E_20000"); vrfy(errsym("E__USERMAX") > errsym("E__USERDEF"), '9917: errsym("E__USERMAX") > errsym("E__USERDEF")'); vrfy(errsym("E__USERMAX") == 32767, '9918: errsym("E__USERMAX") == 32767'); vrfy_errsym( 9919, 32767, "E_32767"); vrfy_errsym( 9920, 1, "E_1"); vrfy_errsym( 9921, 7, "E_7"); vrfy_errsym( 9922, 10, "E_10"); vrfy_errsym( 9923, 31, "E_31"); vrfy_errsym( 9924, 100, "E_100"); vrfy_errsym( 9925, 127, "E_127"); vrfy_errsym( 9926, 1000, "E_1000"); vrfy_errsym( 9927, 2203, "E_2203"); vrfy_errsym( 9928, 19937, "E_19937"); vrfy_errsym( 9929, 23209, "E_23209"); print '9930: ending test of error("E_STRING") errno("E_STRING"), strerror("E_STRING") and errsym("E_STRING")'; /* * test 10ddd: verify E_STRING values for calc computation error codes * * We verify that the errnum calc computation error codes and * their E_STRING values match. If someone messes up the error_table[] table * that would impact user code, one or more of the tests (test 10ddd) will fail. */ print; print '10000: verify E_STRING values for calc computation error codes'; vrfy_errsym(10001, 10001, "E_DIVBYZERO"); vrfy_errsym(10002, 10002, "E_ZERODIVZERO"); vrfy_errsym(10003, 10003, "E_ADD"); vrfy_errsym(10004, 10004, "E_SUB"); vrfy_errsym(10005, 10005, "E_MUL"); vrfy_errsym(10006, 10006, "E_DIV"); vrfy_errsym(10007, 10007, "E_NEG"); vrfy_errsym(10008, 10008, "E_SQUARE"); vrfy_errsym(10009, 10009, "E_INV"); vrfy_errsym(10010, 10010, "E_INCV"); vrfy_errsym(10011, 10011, "E_DECV"); vrfy_errsym(10012, 10012, "E_INT"); vrfy_errsym(10013, 10013, "E_FRAC"); vrfy_errsym(10014, 10014, "E_CONJ"); vrfy_errsym(10015, 10015, "E_APPR_1"); vrfy_errsym(10016, 10016, "E_APPR_2"); vrfy_errsym(10017, 10017, "E_APPR_3"); vrfy_errsym(10018, 10018, "E_ROUND_1"); vrfy_errsym(10019, 10019, "E_ROUND_2"); vrfy_errsym(10020, 10020, "E_ROUND_3"); vrfy_errsym(10021, 10021, "E_BROUND_1"); vrfy_errsym(10022, 10022, "E_BROUND_2"); vrfy_errsym(10023, 10023, "E_BROUND_3"); vrfy_errsym(10024, 10024, "E_SQRT_1"); vrfy_errsym(10025, 10025, "E_SQRT_2"); vrfy_errsym(10026, 10026, "E_SQRT_3"); vrfy_errsym(10027, 10027, "E_ROOT_1"); vrfy_errsym(10028, 10028, "E_ROOT_2"); vrfy_errsym(10029, 10029, "E_ROOT_3"); vrfy_errsym(10030, 10030, "E_NORM"); vrfy_errsym(10031, 10031, "E_SHIFT_1"); vrfy_errsym(10032, 10032, "E_SHIFT_2"); vrfy_errsym(10033, 10033, "E_SCALE_1"); vrfy_errsym(10034, 10034, "E_SCALE_2"); vrfy_errsym(10035, 10035, "E_POWI_1"); vrfy_errsym(10036, 10036, "E_POWI_2"); vrfy_errsym(10037, 10037, "E_POWER_1"); vrfy_errsym(10038, 10038, "E_POWER_2"); vrfy_errsym(10039, 10039, "E_POWER_3"); vrfy_errsym(10040, 10040, "E_QUO_1"); vrfy_errsym(10041, 10041, "E_QUO_2"); vrfy_errsym(10042, 10042, "E_QUO_3"); vrfy_errsym(10043, 10043, "E_MOD_1"); vrfy_errsym(10044, 10044, "E_MOD_2"); vrfy_errsym(10045, 10045, "E_MOD_3"); vrfy_errsym(10046, 10046, "E_SGN"); vrfy_errsym(10047, 10047, "E_ABS_1"); vrfy_errsym(10048, 10048, "E_ABS_2"); vrfy_errsym(10049, 10049, "E_EVAL"); vrfy_errsym(10050, 10050, "E_STR"); vrfy_errsym(10051, 10051, "E_EXP_1"); vrfy_errsym(10052, 10052, "E_EXP_2"); vrfy_errsym(10053, 10053, "E_FPUTC_1"); vrfy_errsym(10054, 10054, "E_FPUTC_2"); vrfy_errsym(10055, 10055, "E_FPUTC_3"); vrfy_errsym(10056, 10056, "E_FGETC_1"); vrfy_errsym(10057, 10057, "E_FGETC_2"); vrfy_errsym(10058, 10058, "E_FOPEN_1"); vrfy_errsym(10059, 10059, "E_FOPEN_2"); vrfy_errsym(10060, 10060, "E_FREOPEN_1"); vrfy_errsym(10061, 10061, "E_FREOPEN_2"); vrfy_errsym(10062, 10062, "E_FREOPEN_3"); vrfy_errsym(10063, 10063, "E_FCLOSE_1"); vrfy_errsym(10064, 10064, "E_FFLUSH"); vrfy_errsym(10065, 10065, "E_FPUTS_1"); vrfy_errsym(10066, 10066, "E_FPUTS_2"); vrfy_errsym(10067, 10067, "E_FPUTS_3"); vrfy_errsym(10068, 10068, "E_FGETS_1"); vrfy_errsym(10069, 10069, "E_FGETS_2"); vrfy_errsym(10070, 10070, "E_FPUTSTR_1"); vrfy_errsym(10071, 10071, "E_FPUTSTR_2"); vrfy_errsym(10072, 10072, "E_FPUTSTR_3"); vrfy_errsym(10073, 10073, "E_FGETSTR_1"); vrfy_errsym(10074, 10074, "E_FGETSTR_2"); vrfy_errsym(10075, 10075, "E_FGETLINE_1"); vrfy_errsym(10076, 10076, "E_FGETLINE_2"); vrfy_errsym(10077, 10077, "E_FGETFIELD_1"); vrfy_errsym(10078, 10078, "E_FGETFIELD_2"); vrfy_errsym(10079, 10079, "E_REWIND_1"); vrfy_errsym(10080, 10080, "E_FILES"); vrfy_errsym(10081, 10081, "E_PRINTF_1"); vrfy_errsym(10082, 10082, "E_PRINTF_2"); vrfy_errsym(10083, 10083, "E_FPRINTF_1"); vrfy_errsym(10084, 10084, "E_FPRINTF_2"); vrfy_errsym(10085, 10085, "E_FPRINTF_3"); vrfy_errsym(10086, 10086, "E_STRPRINTF_1"); vrfy_errsym(10087, 10087, "E_STRPRINTF_2"); vrfy_errsym(10088, 10088, "E_FSCAN_1"); vrfy_errsym(10089, 10089, "E_FSCAN_2"); vrfy_errsym(10090, 10090, "E_STRSCAN"); vrfy_errsym(10091, 10091, "E_FSCANF_1"); vrfy_errsym(10092, 10092, "E_FSCANF_2"); vrfy_errsym(10093, 10093, "E_FSCANF_3"); vrfy_errsym(10094, 10094, "E_FSCANF_4"); vrfy_errsym(10095, 10095, "E_STRSCANF_1"); vrfy_errsym(10096, 10096, "E_STRSCANF_2"); vrfy_errsym(10097, 10097, "E_STRSCANF_3"); vrfy_errsym(10098, 10098, "E_STRSCANF_4"); vrfy_errsym(10099, 10099, "E_SCANF_1"); vrfy_errsym(10100, 10100, "E_SCANF_2"); vrfy_errsym(10101, 10101, "E_SCANF_3"); vrfy_errsym(10102, 10102, "E_FTELL_1"); vrfy_errsym(10103, 10103, "E_FTELL_2"); vrfy_errsym(10104, 10104, "E_FSEEK_1"); vrfy_errsym(10105, 10105, "E_FSEEK_2"); vrfy_errsym(10106, 10106, "E_FSEEK_3"); vrfy_errsym(10107, 10107, "E_FSIZE_1"); vrfy_errsym(10108, 10108, "E_FSIZE_2"); vrfy_errsym(10109, 10109, "E_FEOF_1"); vrfy_errsym(10110, 10110, "E_FEOF_2"); vrfy_errsym(10111, 10111, "E_FERROR_1"); vrfy_errsym(10112, 10112, "E_FERROR_2"); vrfy_errsym(10113, 10113, "E_UNGETC_1"); vrfy_errsym(10114, 10114, "E_UNGETC_2"); vrfy_errsym(10115, 10115, "E_UNGETC_3"); vrfy_errsym(10116, 10116, "E_BIGEXP"); vrfy_errsym(10117, 10117, "E_ISATTY_1"); vrfy_errsym(10118, 10118, "E_ISATTY_2"); vrfy_errsym(10119, 10119, "E_ACCESS_1"); vrfy_errsym(10120, 10120, "E_ACCESS_2"); vrfy_errsym(10121, 10121, "E_SEARCH_1"); vrfy_errsym(10122, 10122, "E_SEARCH_2"); vrfy_errsym(10123, 10123, "E_SEARCH_3"); vrfy_errsym(10124, 10124, "E_SEARCH_4"); vrfy_errsym(10125, 10125, "E_SEARCH_5"); vrfy_errsym(10126, 10126, "E_SEARCH_6"); vrfy_errsym(10127, 10127, "E_RSEARCH_1"); vrfy_errsym(10128, 10128, "E_RSEARCH_2"); vrfy_errsym(10129, 10129, "E_RSEARCH_3"); vrfy_errsym(10130, 10130, "E_RSEARCH_4"); vrfy_errsym(10131, 10131, "E_RSEARCH_5"); vrfy_errsym(10132, 10132, "E_RSEARCH_6"); vrfy_errsym(10133, 10133, "E_MANYOPEN"); vrfy_errsym(10134, 10134, "E_REWIND_2"); vrfy_errsym(10135, 10135, "E_STRERROR_1"); vrfy_errsym(10136, 10136, "E_STRERROR_2"); vrfy_errsym(10137, 10137, "E_COS_1"); vrfy_errsym(10138, 10138, "E_COS_2"); vrfy_errsym(10139, 10139, "E_SIN_1"); vrfy_errsym(10140, 10140, "E_SIN_2"); vrfy_errsym(10141, 10141, "E_EVAL_2"); vrfy_errsym(10142, 10142, "E_ARG_1"); vrfy_errsym(10143, 10143, "E_ARG_2"); vrfy_errsym(10144, 10144, "E_POLAR_1"); vrfy_errsym(10145, 10145, "E_POLAR_2"); vrfy_errsym(10146, 10146, "E_FCNT"); vrfy_errsym(10147, 10147, "E_MATFILL_1"); vrfy_errsym(10148, 10148, "E_MATFILL_2"); vrfy_errsym(10149, 10149, "E_MATDIM"); vrfy_errsym(10150, 10150, "E_MATSUM"); vrfy_errsym(10151, 10151, "E_ISIDENT"); vrfy_errsym(10152, 10152, "E_MATTRANS_1"); vrfy_errsym(10153, 10153, "E_MATTRANS_2"); vrfy_errsym(10154, 10154, "E_DET_1"); vrfy_errsym(10155, 10155, "E_DET_2"); vrfy_errsym(10156, 10156, "E_DET_3"); vrfy_errsym(10157, 10157, "E_MATMIN_1"); vrfy_errsym(10158, 10158, "E_MATMIN_2"); vrfy_errsym(10159, 10159, "E_MATMIN_3"); vrfy_errsym(10160, 10160, "E_MATMAX_1"); vrfy_errsym(10161, 10161, "E_MATMAX_2"); vrfy_errsym(10162, 10162, "E_MATMAX_3"); vrfy_errsym(10163, 10163, "E_CP_1"); vrfy_errsym(10164, 10164, "E_CP_2"); vrfy_errsym(10165, 10165, "E_CP_3"); vrfy_errsym(10166, 10166, "E_DP_1"); vrfy_errsym(10167, 10167, "E_DP_2"); vrfy_errsym(10168, 10168, "E_DP_3"); vrfy_errsym(10169, 10169, "E_STRLEN"); vrfy_errsym(10170, 10170, "E_STRCAT"); vrfy_errsym(10171, 10171, "E_SUBSTR_1"); vrfy_errsym(10172, 10172, "E_SUBSTR_2"); vrfy_errsym(10173, 10173, "E_CHAR"); vrfy_errsym(10174, 10174, "E_ORD"); vrfy_errsym(10175, 10175, "E_INSERT_1"); vrfy_errsym(10176, 10176, "E_INSERT_2"); vrfy_errsym(10177, 10177, "E_PUSH"); vrfy_errsym(10178, 10178, "E_APPEND"); vrfy_errsym(10179, 10179, "E_DELETE_1"); vrfy_errsym(10180, 10180, "E_DELETE_2"); vrfy_errsym(10181, 10181, "E_POP"); vrfy_errsym(10182, 10182, "E_REMOVE"); vrfy_errsym(10183, 10183, "E_LN_1"); vrfy_errsym(10184, 10184, "E_LN_2"); vrfy_errsym(10185, 10185, "E_ERROR_1"); vrfy_errsym(10186, 10186, "E_ERROR_2"); vrfy_errsym(10187, 10187, "E_EVAL_3"); vrfy_errsym(10188, 10188, "E_EVAL_4"); vrfy_errsym(10189, 10189, "E_RM_1"); vrfy_errsym(10190, 10190, "E_RM_2"); vrfy_errsym(10191, 10191, "E_RDPERM"); vrfy_errsym(10192, 10192, "E_WRPERM"); vrfy_errsym(10193, 10193, "E_EXPERM"); vrfy_errsym(10194, 10194, "E_MIN"); vrfy_errsym(10195, 10195, "E_MAX"); vrfy_errsym(10196, 10196, "E_LISTMIN"); vrfy_errsym(10197, 10197, "E_LISTMAX"); vrfy_errsym(10198, 10198, "E_SIZE"); vrfy_errsym(10199, 10199, "E_NO_C_ARG"); vrfy_errsym(10200, 10200, "E_NO_CUSTOM"); vrfy_errsym(10201, 10201, "E_UNK_CUSTOM"); vrfy_errsym(10202, 10202, "E_BLK_1"); vrfy_errsym(10203, 10203, "E_BLK_2"); vrfy_errsym(10204, 10204, "E_BLK_3"); vrfy_errsym(10205, 10205, "E_BLK_4"); vrfy_errsym(10206, 10206, "E_BLKFREE_1"); vrfy_errsym(10207, 10207, "E_BLKFREE_2"); vrfy_errsym(10208, 10208, "E_BLKFREE_3"); vrfy_errsym(10209, 10209, "E_BLKFREE_4"); vrfy_errsym(10210, 10210, "E_BLKFREE_5"); vrfy_errsym(10211, 10211, "E_BLOCKS_1"); vrfy_errsym(10212, 10212, "E_BLOCKS_2"); vrfy_errsym(10213, 10213, "E_COPY_01"); vrfy_errsym(10214, 10214, "E_COPY_02"); vrfy_errsym(10215, 10215, "E_COPY_03"); vrfy_errsym(10216, 10216, "E_COPY_04"); vrfy_errsym(10217, 10217, "E_COPY_05"); vrfy_errsym(10218, 10218, "E_COPY_06"); vrfy_errsym(10219, 10219, "E_COPY_07"); vrfy_errsym(10220, 10220, "E_COPY_08"); vrfy_errsym(10221, 10221, "E_COPY_09"); vrfy_errsym(10222, 10222, "E_COPY_10"); vrfy_errsym(10223, 10223, "E_COPY_11"); vrfy_errsym(10224, 10224, "E_COPY_12"); vrfy_errsym(10225, 10225, "E_COPY_13"); vrfy_errsym(10226, 10226, "E_COPY_14"); vrfy_errsym(10227, 10227, "E_COPY_15"); vrfy_errsym(10228, 10228, "E_COPY_16"); vrfy_errsym(10229, 10229, "E_COPY_17"); vrfy_errsym(10230, 10230, "E_COPYF_1"); vrfy_errsym(10231, 10231, "E_COPYF_2"); vrfy_errsym(10232, 10232, "E_COPYF_3"); vrfy_errsym(10233, 10233, "E_COPYF_4"); vrfy_errsym(10234, 10234, "E_PROTECT_1"); vrfy_errsym(10235, 10235, "E_PROTECT_2"); vrfy_errsym(10236, 10236, "E_PROTECT_3"); vrfy_errsym(10237, 10237, "E_MATFILL_3"); vrfy_errsym(10238, 10238, "E_MATFILL_4"); vrfy_errsym(10239, 10239, "E_MATTRACE_1"); vrfy_errsym(10240, 10240, "E_MATTRACE_2"); vrfy_errsym(10241, 10241, "E_MATTRACE_3"); vrfy_errsym(10242, 10242, "E_TAN_1"); vrfy_errsym(10243, 10243, "E_TAN_2"); vrfy_errsym(10244, 10244, "E_COT_1"); vrfy_errsym(10245, 10245, "E_COT_2"); vrfy_errsym(10246, 10246, "E_SEC_1"); vrfy_errsym(10247, 10247, "E_SEC_2"); vrfy_errsym(10248, 10248, "E_CSC_1"); vrfy_errsym(10249, 10249, "E_CSC_2"); vrfy_errsym(10250, 10250, "E_SINH_1"); vrfy_errsym(10251, 10251, "E_SINH_2"); vrfy_errsym(10252, 10252, "E_COSH_1"); vrfy_errsym(10253, 10253, "E_COSH_2"); vrfy_errsym(10254, 10254, "E_TANH_1"); vrfy_errsym(10255, 10255, "E_TANH_2"); vrfy_errsym(10256, 10256, "E_COTH_1"); vrfy_errsym(10257, 10257, "E_COTH_2"); vrfy_errsym(10258, 10258, "E_SECH_1"); vrfy_errsym(10259, 10259, "E_SECH_2"); vrfy_errsym(10260, 10260, "E_CSCH_1"); vrfy_errsym(10261, 10261, "E_CSCH_2"); vrfy_errsym(10262, 10262, "E_ASIN_1"); vrfy_errsym(10263, 10263, "E_ASIN_2"); vrfy_errsym(10264, 10264, "E_ACOS_1"); vrfy_errsym(10265, 10265, "E_ACOS_2"); vrfy_errsym(10266, 10266, "E_ATAN_1"); vrfy_errsym(10267, 10267, "E_ATAN_2"); vrfy_errsym(10268, 10268, "E_ACOT_1"); vrfy_errsym(10269, 10269, "E_ACOT_2"); vrfy_errsym(10270, 10270, "E_ASEC_1"); vrfy_errsym(10271, 10271, "E_ASEC_2"); vrfy_errsym(10272, 10272, "E_ACSC_1"); vrfy_errsym(10273, 10273, "E_ACSC_2"); vrfy_errsym(10274, 10274, "E_ASINH_1"); vrfy_errsym(10275, 10275, "E_ASINH_2"); vrfy_errsym(10276, 10276, "E_ACOSH_1"); vrfy_errsym(10277, 10277, "E_ACOSH_2"); vrfy_errsym(10278, 10278, "E_ATANH_1"); vrfy_errsym(10279, 10279, "E_ATANH_2"); vrfy_errsym(10280, 10280, "E_ACOTH_1"); vrfy_errsym(10281, 10281, "E_ACOTH_2"); vrfy_errsym(10282, 10282, "E_ASECH_1"); vrfy_errsym(10283, 10283, "E_ASECH_2"); vrfy_errsym(10284, 10284, "E_ACSCH_1"); vrfy_errsym(10285, 10285, "E_ACSCH_2"); vrfy_errsym(10286, 10286, "E_GD_1"); vrfy_errsym(10287, 10287, "E_GD_2"); vrfy_errsym(10288, 10288, "E_AGD_1"); vrfy_errsym(10289, 10289, "E_AGD_2"); vrfy_errsym(10290, 10290, "E_LOGINF"); vrfy_errsym(10291, 10291, "E_STRADD"); vrfy_errsym(10292, 10292, "E_STRMUL"); vrfy_errsym(10293, 10293, "E_STRNEG"); vrfy_errsym(10294, 10294, "E_STRSUB"); vrfy_errsym(10295, 10295, "E_BIT_1"); vrfy_errsym(10296, 10296, "E_BIT_2"); vrfy_errsym(10297, 10297, "E_SETBIT_1"); vrfy_errsym(10298, 10298, "E_SETBIT_2"); vrfy_errsym(10299, 10299, "E_SETBIT_3"); vrfy_errsym(10300, 10300, "E_OR"); vrfy_errsym(10301, 10301, "E_AND"); vrfy_errsym(10302, 10302, "E_STROR"); vrfy_errsym(10303, 10303, "E_STRAND"); vrfy_errsym(10304, 10304, "E_XOR"); vrfy_errsym(10305, 10305, "E_COMP"); vrfy_errsym(10306, 10306, "E_STRDIFF"); vrfy_errsym(10307, 10307, "E_STRCOMP"); vrfy_errsym(10308, 10308, "E_SEG_1"); vrfy_errsym(10309, 10309, "E_SEG_2"); vrfy_errsym(10310, 10310, "E_SEG_3"); vrfy_errsym(10311, 10311, "E_STRSEG"); vrfy_errsym(10312, 10312, "E_HIGHBIT_1"); vrfy_errsym(10313, 10313, "E_HIGHBIT_2"); vrfy_errsym(10314, 10314, "E_LOWBIT_1"); vrfy_errsym(10315, 10315, "E_LOWBIT_2"); vrfy_errsym(10316, 10316, "E_CONTENT"); vrfy_errsym(10317, 10317, "E_HASHOP"); vrfy_errsym(10318, 10318, "E_HEAD_1"); vrfy_errsym(10319, 10319, "E_HEAD_2"); vrfy_errsym(10320, 10320, "E_STRHEAD"); vrfy_errsym(10321, 10321, "E_TAIL_1"); vrfy_errsym(10322, 10322, "E_TAIL_2"); vrfy_errsym(10323, 10323, "E_STRTAIL"); vrfy_errsym(10324, 10324, "E_STRSHIFT"); vrfy_errsym(10325, 10325, "E_STRCMP"); vrfy_errsym(10326, 10326, "E_STRNCMP"); vrfy_errsym(10327, 10327, "E_XOR_1"); vrfy_errsym(10328, 10328, "E_XOR_2"); vrfy_errsym(10329, 10329, "E_STRCPY"); vrfy_errsym(10330, 10330, "E_STRNCPY"); vrfy_errsym(10331, 10331, "E_BACKSLASH"); vrfy_errsym(10332, 10332, "E_SETMINUS"); vrfy_errsym(10333, 10333, "E_INDICES_1"); vrfy_errsym(10334, 10334, "E_INDICES_2"); vrfy_errsym(10335, 10335, "E_EXP_3"); vrfy_errsym(10336, 10336, "E_SINH_3"); vrfy_errsym(10337, 10337, "E_COSH_3"); vrfy_errsym(10338, 10338, "E_SIN_3"); vrfy_errsym(10339, 10339, "E_COS_3"); vrfy_errsym(10340, 10340, "E_GD_3"); vrfy_errsym(10341, 10341, "E_AGD_3"); vrfy_errsym(10342, 10342, "E_POWER_4"); vrfy_errsym(10343, 10343, "E_ROOT_4"); vrfy_errsym(10344, 10344, "E_DGT_1"); vrfy_errsym(10345, 10345, "E_DGT_2"); vrfy_errsym(10346, 10346, "E_DGT_3"); vrfy_errsym(10347, 10347, "E_PLCS_1"); vrfy_errsym(10348, 10348, "E_PLCS_2"); vrfy_errsym(10349, 10349, "E_DGTS_1"); vrfy_errsym(10350, 10350, "E_DGTS_2"); vrfy_errsym(10351, 10351, "E_ILOG"); vrfy_errsym(10352, 10352, "E_ILOGB"); vrfy_errsym(10353, 10353, "E_IBASE10_LOG"); vrfy_errsym(10354, 10354, "E_IBASE2_LOG"); vrfy_errsym(10355, 10355, "E_COMB_1"); vrfy_errsym(10356, 10356, "E_COMB_2"); vrfy_errsym(10357, 10357, "E_CTLN"); vrfy_errsym(10358, 10358, "E_BERN"); vrfy_errsym(10359, 10359, "E_EULER"); vrfy_errsym(10360, 10360, "E_SLEEP"); vrfy_errsym(10361, 10361, "E_TTY"); vrfy_errsym(10362, 10362, "E_ASSIGN_1"); vrfy_errsym(10363, 10363, "E_ASSIGN_2"); vrfy_errsym(10364, 10364, "E_ASSIGN_3"); vrfy_errsym(10365, 10365, "E_ASSIGN_4"); vrfy_errsym(10366, 10366, "E_ASSIGN_5"); vrfy_errsym(10367, 10367, "E_ASSIGN_6"); vrfy_errsym(10368, 10368, "E_ASSIGN_7"); vrfy_errsym(10369, 10369, "E_ASSIGN_8"); vrfy_errsym(10370, 10370, "E_ASSIGN_9"); vrfy_errsym(10371, 10371, "E_SWAP_1"); vrfy_errsym(10372, 10372, "E_SWAP_2"); vrfy_errsym(10373, 10373, "E_SWAP_3"); vrfy_errsym(10374, 10374, "E_QUOMOD_1"); vrfy_errsym(10375, 10375, "E_QUOMOD_2"); vrfy_errsym(10376, 10376, "E_QUOMOD_3"); vrfy_errsym(10377, 10377, "E_PREINC_1"); vrfy_errsym(10378, 10378, "E_PREINC_2"); vrfy_errsym(10379, 10379, "E_PREINC_3"); vrfy_errsym(10380, 10380, "E_PREDEC_1"); vrfy_errsym(10381, 10381, "E_PREDEC_2"); vrfy_errsym(10382, 10382, "E_PREDEC_3"); vrfy_errsym(10383, 10383, "E_POSTINC_1"); vrfy_errsym(10384, 10384, "E_POSTINC_2"); vrfy_errsym(10385, 10385, "E_POSTINC_3"); vrfy_errsym(10386, 10386, "E_POSTDEC_1"); vrfy_errsym(10387, 10387, "E_POSTDEC_2"); vrfy_errsym(10388, 10388, "E_POSTDEC_3"); vrfy_errsym(10389, 10389, "E_INIT_01"); vrfy_errsym(10390, 10390, "E_INIT_02"); vrfy_errsym(10391, 10391, "E_INIT_03"); vrfy_errsym(10392, 10392, "E_INIT_04"); vrfy_errsym(10393, 10393, "E_INIT_05"); vrfy_errsym(10394, 10394, "E_INIT_06"); vrfy_errsym(10395, 10395, "E_INIT_07"); vrfy_errsym(10396, 10396, "E_INIT_08"); vrfy_errsym(10397, 10397, "E_INIT_09"); vrfy_errsym(10398, 10398, "E_INIT_10"); vrfy_errsym(10399, 10399, "E_LIST_1"); vrfy_errsym(10400, 10400, "E_LIST_2"); vrfy_errsym(10401, 10401, "E_LIST_3"); vrfy_errsym(10402, 10402, "E_LIST_4"); vrfy_errsym(10403, 10403, "E_LIST_5"); vrfy_errsym(10404, 10404, "E_LIST_6"); vrfy_errsym(10405, 10405, "E_MODIFY_1"); vrfy_errsym(10406, 10406, "E_MODIFY_2"); vrfy_errsym(10407, 10407, "E_MODIFY_3"); vrfy_errsym(10408, 10408, "E_MODIFY_4"); vrfy_errsym(10409, 10409, "E_MODIFY_5"); vrfy_errsym(10410, 10410, "E_FPATHOPEN_1"); vrfy_errsym(10411, 10411, "E_FPATHOPEN_2"); vrfy_errsym(10412, 10412, "E_LOG_1"); vrfy_errsym(10413, 10413, "E_LOG_2"); vrfy_errsym(10414, 10414, "E_LOG_3"); vrfy_errsym(10415, 10415, "E_FGETFILE_1"); vrfy_errsym(10416, 10416, "E_FGETFILE_2"); vrfy_errsym(10417, 10417, "E_FGETFILE_3"); vrfy_errsym(10418, 10418, "E_ESTR"); vrfy_errsym(10419, 10419, "E_STRCASECMP"); vrfy_errsym(10420, 10420, "E_STRNCASECMP"); vrfy_errsym(10421, 10421, "E_ISUPPER"); vrfy_errsym(10422, 10422, "E_ISLOWER"); vrfy_errsym(10423, 10423, "E_ISALNUM"); vrfy_errsym(10424, 10424, "E_ISALPHA"); vrfy_errsym(10425, 10425, "E_ISASCII"); vrfy_errsym(10426, 10426, "E_ISCNTRL"); vrfy_errsym(10427, 10427, "E_ISDIGIT"); vrfy_errsym(10428, 10428, "E_ISGRAPH"); vrfy_errsym(10429, 10429, "E_ISPRINT"); vrfy_errsym(10430, 10430, "E_ISPUNCT"); vrfy_errsym(10431, 10431, "E_ISSPACE"); vrfy_errsym(10432, 10432, "E_ISXDIGIT"); vrfy_errsym(10433, 10433, "E_STRTOUPPER"); vrfy_errsym(10434, 10434, "E_STRTOLOWER"); vrfy_errsym(10435, 10435, "E_TAN_3"); vrfy_errsym(10436, 10436, "E_TAN_4"); vrfy_errsym(10437, 10437, "E_COT_3"); vrfy_errsym(10438, 10438, "E_COT_4"); vrfy_errsym(10439, 10439, "E_SEC_3"); vrfy_errsym(10440, 10440, "E_CSC_3"); vrfy_errsym(10441, 10441, "E_TANH_3"); vrfy_errsym(10442, 10442, "E_TANH_4"); vrfy_errsym(10443, 10443, "E_COTH_3"); vrfy_errsym(10444, 10444, "E_COTH_4"); vrfy_errsym(10445, 10445, "E_SECH_3"); vrfy_errsym(10446, 10446, "E_CSCH_3"); vrfy_errsym(10447, 10447, "E_ASIN_3"); vrfy_errsym(10448, 10448, "E_ACOS_3"); vrfy_errsym(10449, 10449, "E_ASINH_3"); vrfy_errsym(10450, 10450, "E_ACOSH_3"); vrfy_errsym(10451, 10451, "E_ATAN_3"); vrfy_errsym(10452, 10452, "E_ACOT_3"); vrfy_errsym(10453, 10453, "E_ASEC_3"); vrfy_errsym(10454, 10454, "E_ACSC_3"); vrfy_errsym(10455, 10455, "E_ATANH_3"); vrfy_errsym(10456, 10456, "E_ACOTH_3"); vrfy_errsym(10457, 10457, "E_ASECH_3"); vrfy_errsym(10458, 10458, "E_ACSCH_3"); vrfy_errsym(10459, 10459, "E_D2R_1"); vrfy_errsym(10460, 10460, "E_D2R_2"); vrfy_errsym(10461, 10461, "E_R2D_1"); vrfy_errsym(10462, 10462, "E_R2D_2"); vrfy_errsym(10463, 10463, "E_G2R_1"); vrfy_errsym(10464, 10464, "E_G2R_2"); vrfy_errsym(10465, 10465, "E_R2G_1"); vrfy_errsym(10466, 10466, "E_R2G_2"); vrfy_errsym(10467, 10467, "E_D2G_1"); vrfy_errsym(10468, 10468, "E_G2D_1"); vrfy_errsym(10469, 10469, "E_D2DMS_1"); vrfy_errsym(10470, 10470, "E_D2DMS_2"); vrfy_errsym(10471, 10471, "E_D2DMS_3"); vrfy_errsym(10472, 10472, "E_D2DMS_4"); vrfy_errsym(10473, 10473, "E_D2DM_1"); vrfy_errsym(10474, 10474, "E_D2DM_2"); vrfy_errsym(10475, 10475, "E_D2DM_3"); vrfy_errsym(10476, 10476, "E_D2DM_4"); vrfy_errsym(10477, 10477, "E_G2GMS_1"); vrfy_errsym(10478, 10478, "E_G2GMS_2"); vrfy_errsym(10479, 10479, "E_G2GMS_3"); vrfy_errsym(10480, 10480, "E_G2GMS_4"); vrfy_errsym(10481, 10481, "E_G2GM_1"); vrfy_errsym(10482, 10482, "E_G2GM_2"); vrfy_errsym(10483, 10483, "E_G2GM_3"); vrfy_errsym(10484, 10484, "E_G2GM_4"); vrfy_errsym(10485, 10485, "E_H2HMS_1"); vrfy_errsym(10486, 10486, "E_H2HMS_2"); vrfy_errsym(10487, 10487, "E_H2HMS_3"); vrfy_errsym(10488, 10488, "E_H2HMS_4"); vrfy_errsym(10489, 10489, "E_H2HM_1"); vrfy_errsym(10490, 10490, "E_H2HM_2"); vrfy_errsym(10491, 10491, "E_H2HM_3"); vrfy_errsym(10492, 10492, "E_H2HM_4"); vrfy_errsym(10493, 10493, "E_DMS2D_1"); vrfy_errsym(10494, 10494, "E_DMS2D_2"); vrfy_errsym(10495, 10495, "E_DM2D_1"); vrfy_errsym(10496, 10496, "E_DM2D_2"); vrfy_errsym(10497, 10497, "E_GMS2G_1"); vrfy_errsym(10498, 10498, "E_GMS2G_2"); vrfy_errsym(10499, 10499, "E_GM2G_1"); vrfy_errsym(10500, 10500, "E_GM2G_2"); vrfy_errsym(10501, 10501, "E_HMS2H_1"); vrfy_errsym(10502, 10502, "E_HMS2H_2"); vrfy_errsym(10503, 10503, "E_HM2H_1"); vrfy_errsym(10504, 10504, "E_HM2H_2"); vrfy_errsym(10505, 10505, "E_LOG2_1"); vrfy_errsym(10506, 10506, "E_LOG2_2"); vrfy_errsym(10507, 10507, "E_LOG2_3"); vrfy_errsym(10508, 10508, "E_LOGN_1"); vrfy_errsym(10509, 10509, "E_LOGN_2"); vrfy_errsym(10510, 10510, "E_LOGN_3"); vrfy_errsym(10511, 10511, "E_LOGN_4"); vrfy_errsym(10512, 10512, "E_LOGN_5"); vrfy_errsym(10513, 10513, "E_VERSIN_1"); vrfy_errsym(10514, 10514, "E_VERSIN_2"); vrfy_errsym(10515, 10515, "E_VERSIN_3"); vrfy_errsym(10516, 10516, "E_AVERSIN_1"); vrfy_errsym(10517, 10517, "E_AVERSIN_2"); vrfy_errsym(10518, 10518, "E_AVERSIN_3"); vrfy_errsym(10519, 10519, "E_COVERSIN_1"); vrfy_errsym(10520, 10520, "E_COVERSIN_2"); vrfy_errsym(10521, 10521, "E_COVERSIN_3"); vrfy_errsym(10522, 10522, "E_ACOVERSIN_1"); vrfy_errsym(10523, 10523, "E_ACOVERSIN_2"); vrfy_errsym(10524, 10524, "E_ACOVERSIN_3"); vrfy_errsym(10525, 10525, "E_VERCOS_1"); vrfy_errsym(10526, 10526, "E_VERCOS_2"); vrfy_errsym(10527, 10527, "E_VERCOS_3"); vrfy_errsym(10528, 10528, "E_AVERCOS_1"); vrfy_errsym(10529, 10529, "E_AVERCOS_2"); vrfy_errsym(10530, 10530, "E_AVERCOS_3"); vrfy_errsym(10531, 10531, "E_COVERCOS_1"); vrfy_errsym(10532, 10532, "E_COVERCOS_2"); vrfy_errsym(10533, 10533, "E_COVERCOS_3"); vrfy_errsym(10534, 10534, "E_ACOVERCOS_1"); vrfy_errsym(10535, 10535, "E_ACOVERCOS_2"); vrfy_errsym(10536, 10536, "E_ACOVERCOS_3"); vrfy_errsym(10537, 10537, "E_TAN_5"); vrfy_errsym(10538, 10538, "E_COT_5"); vrfy_errsym(10539, 10539, "E_COT_6"); vrfy_errsym(10540, 10540, "E_SEC_5"); vrfy_errsym(10541, 10541, "E_CSC_5"); vrfy_errsym(10542, 10542, "E_CSC_6"); vrfy_errsym(10543, 10543, "E_ERROR_3"); vrfy_errsym(10544, 10544, "E_ERROR_4"); vrfy_errsym(10545, 10545, "E_STRERROR_3"); vrfy_errsym(10546, 10546, "E_STRERROR_4"); vrfy_errsym(10547, 10547, "E_STRERROR_5"); vrfy_errsym(10548, 10548, "E_ERRNO_1"); vrfy_errsym(10549, 10549, "E_ERRNO_2"); vrfy_errsym(10550, 10550, "E_ERRNO_3"); vrfy_errsym(10551, 10551, "E_ERRNO_4"); vrfy_errsym(10552, 10552, "E_ERRSYM_1"); vrfy_errsym(10553, 10553, "E_ERRSYM_2"); vrfy_errsym(10554, 10554, "E_ERRSYM_3"); vrfy_errsym(10555, 10555, "E_ERRSYM_4"); vrfy_errsym(10556, 10556, "E_ERRSYM_5"); vrfy_errsym(10557, 10557, "E_HAVERSIN_1"); vrfy_errsym(10558, 10558, "E_HAVERSIN_2"); vrfy_errsym(10559, 10559, "E_HAVERSIN_3"); vrfy_errsym(10560, 10560, "E_AHAVERSIN_1"); vrfy_errsym(10561, 10561, "E_AHAVERSIN_2"); vrfy_errsym(10562, 10562, "E_AHAVERSIN_3"); vrfy_errsym(10563, 10563, "E_HACOVERSIN_1"); vrfy_errsym(10564, 10564, "E_HACOVERSIN_2"); vrfy_errsym(10565, 10565, "E_HACOVERSIN_3"); vrfy_errsym(10566, 10566, "E_AHACOVERSIN_1"); vrfy_errsym(10567, 10567, "E_AHACOVERSIN_2"); vrfy_errsym(10568, 10568, "E_AHACOVERSIN_3"); vrfy_errsym(10569, 10569, "E_HAVERCOS_1"); vrfy_errsym(10570, 10570, "E_HAVERCOS_2"); vrfy_errsym(10571, 10571, "E_HAVERCOS_3"); vrfy_errsym(10572, 10572, "E_AHAVERCOS_1"); vrfy_errsym(10573, 10573, "E_AHAVERCOS_2"); vrfy_errsym(10574, 10574, "E_AHAVERCOS_3"); vrfy_errsym(10575, 10575, "E_HACOVERCOS_1"); vrfy_errsym(10576, 10576, "E_HACOVERCOS_2"); vrfy_errsym(10577, 10577, "E_HACOVERCOS_3"); vrfy_errsym(10578, 10578, "E_AHACOVERCOS_1"); vrfy_errsym(10579, 10579, "E_AHACOVERCOS_2"); vrfy_errsym(10580, 10580, "E_AHACOVERCOS_3"); vrfy_errsym(10581, 10581, "E_EXSEC_1"); vrfy_errsym(10582, 10582, "E_EXSEC_2"); vrfy_errsym(10583, 10583, "E_EXSEC_3"); vrfy_errsym(10584, 10584, "E_AEXSEC_1"); vrfy_errsym(10585, 10585, "E_AEXSEC_2"); vrfy_errsym(10586, 10586, "E_AEXSEC_3"); vrfy_errsym(10587, 10587, "E_EXCSC_1"); vrfy_errsym(10588, 10588, "E_EXCSC_2"); vrfy_errsym(10589, 10589, "E_EXCSC_3"); vrfy_errsym(10590, 10590, "E_EXCSC_4"); vrfy_errsym(10591, 10591, "E_AEXCSC_1"); vrfy_errsym(10592, 10592, "E_AEXCSC_2"); vrfy_errsym(10593, 10593, "E_AEXCSC_3"); vrfy_errsym(10594, 10594, "E_CRD_1"); vrfy_errsym(10595, 10595, "E_CRD_2"); vrfy_errsym(10596, 10596, "E_CRD_3"); vrfy_errsym(10597, 10597, "E_ACRD_1"); vrfy_errsym(10598, 10598, "E_ACRD_2"); vrfy_errsym(10599, 10599, "E_ACRD_3"); vrfy_errsym(10600, 10600, "E_CAS_1"); vrfy_errsym(10601, 10601, "E_CAS_2"); vrfy_errsym(10602, 10602, "E_CAS_3"); vrfy_errsym(10603, 10603, "E_CIS_1"); vrfy_errsym(10604, 10604, "E_CIS_2"); vrfy_errsym(10605, 10605, "E_CIS_3"); /* ************************************************************** */ /* NOTE: Reserve thru test 10998 for calc computation error codes */ /* ************************************************************** */ print '10999: End of E_STRING values for calc computation error codes'; /* ************************************************* */ /* NOTE: ==> Room for new tests 11000-98899 here <== */ /* ************************************************* */ /* ********************************************************* */ /* NOTE: ==> Room for special end tests 99000-99992 here <== */ /* ********************************************************* */ /* NOTE: Reserve test 99ddd for end of regression test suite */ /* ********************************************************* */ /* * test 99993-99999: Final regression test suite cleanup and report test results * * NOTE: This section !!! ==> MUST BE LAST <== !!! */ print; print '99993: Final regression test suite cleanup and report test results'; define count_errors() { if (prob == 0) { print "99997: passed all tests /\\../\\"; } else { print "****", prob, "error(s) found \\/++\\/"; } } print '99994: parsed count_errors()'; freeredc(); print '99995: freeredc()'; freestatics(); print '99996: freestatics()'; /* test 99997: reports the number of errors found */ return count_errors(); freeglobals(); print '99998: freeglobals()'; print '99999: Ending regression tests'; /* !!! ==> MUST BE LAST LINE <== !!! */