1/* 2 * regress - calc regression and correctness test suite 3 * 4 * Copyright (C) 1999-2017,2021 David I. Bell and Landon Curt Noll 5 * 6 * Calc is open software; you can redistribute it and/or modify it under 7 * the terms of the version 2.1 of the GNU Lesser General Public License 8 * as published by the Free Software Foundation. 9 * 10 * Calc is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 13 * Public License for more details. 14 * 15 * A copy of version 2.1 of the GNU Lesser General Public License is 16 * distributed with calc under the filename COPYING-LGPL. You should have 17 * received a copy with calc; if not, write to Free Software Foundation, Inc. 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 * 20 * Under source code control: 1990/02/15 01:50:36 21 * File existed as early as: before 1990 22 * 23 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ 24 */ 25 26/* 27 * Test the correct execution of the calculator by reading this resource file. 28 * Errors are reported with '****' messages, or worse. :-) 29 * 30 * NOTE: Unlike most calc resource files, this one performs its work when 31 * it is read. Normally one would just define functions and 32 * values for later use. In the case of the regression test, 33 * we do not want to do this. 34 */ 35 36 37print '000: Beginning regression tests'; 38print '001: Some of these tests may take a while ...'; 39print '002: Within each section, output should be numbered sequentially'; 40 41 42global prob; /* libregress.cal problem counter */ 43prob = 0; /* clear problem counter */ 44 45errcount(0),; /* clear error count */ 46errmax(-1),; /* prevent errcount from aborting */ 47 48global ecnt; /* expected value of errcount() */ 49ecnt = 0; /* clear expected errcount() value */ 50 51initcfg = config("all", "newstd"); /* set config to startup default */ 52defcfg = config("all"); /* capture the default config */ 53config("resource_debug", 0),; /* disable resource startup messages */ 54config("calc_debug", 0),; /* disable internal debugging */ 55config("verbose_quit", 0),; /* disable quit messages */ 56startcfg = config("all"); /* save state for later use */ 57 58print '003: parsed global definitions'; 59 60 61/* 62 * vrfy - vrfy that a test is true 63 * 64 * Counts and reports errors or prints test string if successful. 65 * 66 * This function also detects when errcount() exceeds ecnt 67 * and reports when this happens. A side effect is that a 68 * new ecnt level is established. If errcount exceeds errcount 69 * but otherwise the test is successful, the string is still printed. 70 */ 71define vrfy(test, str) 72{ 73 if (errcount() > ecnt) { 74 print '**** errcount:' : errcount(), ' > ecnt:' : ecnt; 75 ecnt = errcount(); 76 ++prob; 77 } 78 if (test != 1) { 79 print '**** Non-true result (' : test : '): ' : str; 80 ++prob; 81 } else { 82 print str; 83 } 84 return; 85} 86print '004: parsed vrfy()'; 87 88 89/* 90 * prob - alternate error notification and count 91 */ 92define prob(str) 93{ 94 print '****' , str; 95 ++prob; 96} 97print '005: parsed prob(str)'; 98 99 100/* 101 * getglobalvar - used to return a global value 102 */ 103define getglobalvar() 104{ 105 global globalvar; 106 107 return globalvar; 108} 109print '006: parsed getglobalvar()'; 110 111 112/* 113 * Test boolean operations and IF tests. 114 * 115 * Some of these tests are done twice, once to print the message and 116 * once to count any errors. This means that some successful tests 117 * will display a passing message twice. Oh well, no biggie. 118 */ 119define test_booleans() 120{ 121 local x; 122 local y; 123 local t1, t2, t3; 124 125 print '300: Beginning test_booleans'; 126 127 if (0) 128 print '**** if (0)'; 129 if (0) 130 prob = prob + 1; 131 132 if (1) 133 print '301: if (1)'; 134 135 if (2) 136 print '302: if (2)'; 137 138 if (1) 139 print '303: if (1) else'; 140 else 141 print '**** if (1) else'; 142 if (1) 143 print '304: if (1) else'; 144 else 145 prob = prob + 1; 146 147 if (0) 148 print '**** if (0) else'; 149 else 150 print '305: if (0) else'; 151 if (0) 152 prob = prob + 1; 153 else 154 print '306: if (0) else'; 155 156 if (1 == 1) 157 print '307: if 1 == 1'; 158 else 159 print '**** if 1 == 1'; 160 if (1 == 1) 161 print '308: if 1 == 1'; 162 else 163 prob = prob + 1; 164 165 if (1 != 2) 166 print '309: if 1 != 2'; 167 else 168 print '**** if 1 != 2'; 169 if (1 != 2) 170 print '310: if 1 != 2'; 171 else 172 prob = prob + 1; 173 174 vrfy(1, '311: vrfy 1'); 175 vrfy(2 == 2, '312: vrfy 2 == 2'); 176 vrfy(2 != 3, '313: vrfy 2 != 3'); 177 vrfy(2 < 3, '314: vrfy 2 < 3'); 178 vrfy(2 <= 2, '315: vrfy 2 <= 2'); 179 vrfy(2 <= 3, '316: vrfy 2 <= 3'); 180 vrfy(3 > 2, '317: vrfy 3 > 2'); 181 vrfy(2 >= 2, '318: vrfy 2 >= 2'); 182 vrfy(3 >= 2, '319: vrfy 3 >= 2'); 183 vrfy(!0, '320: vrfy !0'); 184 vrfy(!1 == 0,'321: vrfy !1 == 0'); 185 vrfy((1 ? 2 ? 3 : 4 : 5) == 3, '322: (1 ? 2 ? 3 : 4 : 5) == 3'); 186 187 print '323: Ending test_booleans'; 188} 189print '007: parsed test_booleans()'; 190 191 192/* 193 * Test variables, simple assignments, AND and OR operators, short-circuit eval 194 */ 195define test_variables() 196{ 197 local x1, x2, x3; 198 global g1, g2; 199 local t; 200 local x; 201 202 print '350: Beginning test_variables'; 203 204 x1 = 5; 205 x3 = 7 * 2; 206 x2 = 9 + 1; 207 globalvar = 22; 208 g1 = 19 - 3; 209 g2 = 79; 210 vrfy(x1 == 5, '351: x1 == 5'); 211 vrfy(x2 == 10, '352: x2 == 10'); 212 vrfy(x3 == 14, '353: x3 == 14'); 213 vrfy(g1 == 16, '354: g1 == 16'); 214 vrfy(g2 == 79, '355: g2 == 79'); 215 vrfy(globalvar == 22, '356: globalvar == 22'); 216 vrfy(getglobalvar() == 22, '357: getglobalvar() == 22'); 217 x1 = x2 + x3 + g1; 218 vrfy(x1 == 40, '358: x1 == 40'); 219 g1 = x3 + g2; 220 vrfy(g1 == 93, '359: g1 == 207'); 221 x1 = 5; 222 vrfy(x1++ == 5, '360: x1++ == 5'); 223 vrfy(x1 == 6, '361: x1 == 6'); 224 vrfy(++x1 == 7, '362: ++x1 == 7'); 225 x1 += 3; 226 vrfy(x1 == 10, '363: x1 == 10'); 227 x1 -= 6; 228 vrfy(x1 == 4, '364: x1 == 4'); 229 x1 *= 3; 230 vrfy(x1 == 12, '365: x1 == 12'); 231 x1 /= 4; 232 vrfy(x1 == 3, '366: x1 == 3'); 233 x1 = x2 = x3; 234 vrfy(x2 == 14, '367: x2 == 14'); 235 vrfy(x1 == 14, '368: x1 == 14'); 236 237 if (2 && 3) { 238 print '369: if (2 && 3)'; 239 } else { 240 print '**** if (2 && 3)'; 241 ++prob; 242 } 243 244 if (2 && 0) { 245 print '**** if (2 && 0)'; 246 ++prob; 247 } else { 248 print '370: if (2 && 0)'; 249 } 250 251 if (0 && 2) { 252 print '**** if (0 && 2)'; 253 ++prob; 254 } else { 255 print '371: if (0 && 2)'; 256 } 257 258 if (0 && 0) { 259 print '**** if (0 && 0)'; 260 ++prob; 261 } else { 262 print '372: if (0 && 0)'; 263 } 264 265 if (2 || 0) { 266 print '373: if (2 || 0)'; 267 } else { 268 print '**** if (2 || 0)'; 269 ++prob; 270 } 271 272 if (0 || 2) { 273 print '374: if (0 || 2)'; 274 } else { 275 print '**** if (0 || 2)'; 276 ++prob; 277 } 278 279 if (0 || 0) { 280 print '**** if (0 || 0)'; 281 ++prob; 282 } else { 283 print '375: if (0 || 0)'; 284 } 285 286 x = 2 || 3; vrfy(x == 2, '376: (2 || 3) == 2'); 287 x = 2 || 0; vrfy(x == 2, '377: (2 || 0) == 2'); 288 x = 0 || 3; vrfy(x == 3, '378: (0 || 3) == 3'); 289 x = 0 || 0; vrfy(x == 0, '379: (0 || 0) == 0'); 290 x = 2 && 3; vrfy(x == 3, '380: (2 && 3) == 3'); 291 x = 2 && 0; vrfy(x == 0, '381: (2 && 0) == 0'); 292 x = 0 && 3; vrfy(x == 0, '382: (0 && 3) == 0'); 293 x = 2 || prob('2 || prob()'); 294 print "383: x = 2 || prob('2 || prob()'"; 295 x = 0 && prob('0 && prob()'); 296 print "384: x = 0 && prob('0 && prob()'"; 297 298 print '385: Ending test_variables'; 299} 300print '008: parsed test_variables()'; 301 302 303/* 304 * Test simple arithmetic operations and expressions. 305 */ 306define test_arithmetic() 307{ 308 print '400: Beginning test_arithmetic'; 309 310 vrfy(3+4==7, '401: 3 + 4 == 7'); 311 vrfy(4-1==3, '402: 4 - 1 == 3'); 312 vrfy(2*3==6, '403: 2 * 3 == 6'); 313 vrfy(8/4==2, '404: 8 / 4 == 2'); 314 vrfy(2^3==8, '405: 2 ^ 3 == 8'); 315 vrfy(9-4-2==3, '406: 9-4-2 == 3'); 316 vrfy(9-4+2==7, '407: 9-4+2 == 7'); 317 vrfy(-5+2==-3, '408: -5+2 == -3'); 318 vrfy(2*3+1==7, '409: 2*3+1 == 7'); 319 vrfy(1+2*3==7, '410: 1+2*3 == 7'); 320 vrfy((1+2)*3==9, '411: (1+2)*3 == 9'); 321 vrfy(2*(3+1)==8, '412: 2*(3+1) == 8'); 322 vrfy(9-(2+3)==4, '413: 9-(2+3) == 4'); 323 vrfy(9+(2-3)==8, '414: 9+(2-3) == 8'); 324 vrfy((2+3)*(4+5)==45, '415: (2+3)*(4+5) == 45'); 325 vrfy(10/(2+3)==2, '416: 10/(2+3) == 2'); 326 vrfy(12/3+4==8, '417: 12/3+4 == 8'); 327 vrfy(6+12/3==10, '418: 6+12/3 == 10'); 328 vrfy(2+3==1+4, '419: 2+3 == 1+4'); 329 vrfy(-(2+3)==-5, '420: -(2+3) == -5'); 330 vrfy(7&18==2, '421: 7&18 == 2'); 331 vrfy(3|17==19, '422: 3|17 == 19'); 332 vrfy(2&3|1==3, '423: 2&3|1 == 3'); 333 vrfy(2&(3|1)==2, '424: 2&(3|1) == 2'); 334 vrfy(3<<4==48, '425: 3<<4 == 48'); 335 vrfy(5>>1==2, '426: 5>>1 == 2'); 336 vrfy(3<<-1==1, '427: 3<<-1 == 1'); 337 vrfy(5>>-2==20, '428: 5>>-2 == 20'); 338 vrfy(1<<2<<3==65536, '429: 1<<2<<3 == 65536'); 339 vrfy((1<<2)<<3==32, '430: (1<<2)<<3 == 32'); 340 vrfy(2^3^2==512, '431: 2^3^2 == 512'); 341 vrfy((2^3)^2==64, '432: (2^3)^2 == 64'); 342 vrfy(4//3==1, '433: 4//3==1'); 343 vrfy(4//-3==-1, '434: 4//-3==-1'); 344 vrfy(0.75//-0.51==-1, '435: 0.75//-0.51==-1'); 345 vrfy(0.75//-0.50==-1, '436: 0.75//-0.50==-1'); 346 vrfy(0.75//-0.49==-1, '437: 0.75//-0.49==-1'); 347 vrfy((3/4)//(-1/4)==-3, '438: (3/4)//(-1/4)==-3'); 348 vrfy(7%3==1, '439: 7%3==1'); 349 vrfy(0-.5==-.5, '440: 0-.5==-.5'); 350 vrfy(0^0 == 1, '441: 0^0 == 1'); 351 vrfy(0^1 == 0, '442: 0^1 == 0'); 352 vrfy(1^0 == 1, '443: 1^0 == 1'); 353 vrfy(1^1 == 1, '444: 1^1 == 1'); 354 vrfy(1/(.8+.8i)==.625-.625i, '445: 1/(.8+.8i)==.625-.625i'); 355 vrfy((.6+.8i)*(3.6-4.8i)==6, '446: (.6+.8i)*(3.6-4.8i)==6'); 356 vrfy(-16^-2 == -1/256, '447: -16^-2 == -1/256'); 357 vrfy(-7^2 == -49, '448: -7^2 == -49'); 358 vrfy(-3! == -6, '449: -3! == -6'); 359 vrfy(0^(0-0) == 1, '450: 0^(0-0) == 1'); 360 vrfy(0^(2-2) == 1, '451: 0^(2-2) == 1'); 361 vrfy(2^0 == 1, '452: 2^0 == 1'); 362 vrfy(2^(0-0) == 1, '453: 2^(0-0) == 1'); 363 vrfy(2^(2-2) == 1, '454: 2^(2-2) == 1'); 364 vrfy((2^23209-1)^0 == 1, '455: (2^23209-1)^0 == 1'); 365 vrfy((2^23209-1)^(0-0) == 1, '456: (2^23209-1)^(0-0) == 1'); 366 vrfy((2^23209-1)^(2-2) == 1, '457: (2^23209-1)^(2-2) == 1'); 367 vrfy((2^23209-1)^((2^23209-1)-(2^23209-1)) == 1, 368 '458: (2^23209-1)^((2^23209-1)-(2^23209-1)) == 1'); 369 370 print '459: Ending test_arithmetic'; 371} 372print '009: parsed test_arithmetic()'; 373 374 375/* 376 * test_config - test config control 377 */ 378define test_config() 379{ 380 local callcfg; /* caller configuration value */ 381 local oldcfg; /* caller configuration value */ 382 local newcfg; /* caller configuration value */ 383 384 print '500: Beginning test_config'; 385 386 /* check the set and return of all config */ 387 callcfg = config("all"); 388 print '501: callcfg = config("all")'; 389 vrfy(callcfg == startcfg, '502: callcfg == startcfg'); 390 391 callcfg = config("all", "oldstd"); 392 print '503: callcfg = config("all","oldstd")'; 393 vrfy(callcfg == startcfg, '504: callcfg == startcfg'); 394 oldcfg = config("all"); 395 print '505: oldcfg = config("all");'; 396 vrfy(config("all") == oldcfg, '506: config("all") == oldcfg'); 397 vrfy(oldcfg==config("all","newstd"), 398 '507: oldcfg==config("all","newstd")'); 399 vrfy(defcfg == config("all"), '508: defcfg == config("all")'); 400 401 /* vrfy the state of the default config */ 402 vrfy(config("mode") == "real", 403 '509: config("mode") == "real"'); 404 vrfy(config("display") == 20, 405 '510: config("display") == 20'); 406 vrfy(config("epsilon") == 1e-20, 407 '511: config("epsilon") == 1e-20'); 408 vrfy(config("trace") == 0, 409 '512: config("trace") == 0'); 410 vrfy(config("maxprint") == 16, 411 '513: config("maxprint") == 16'); 412 vrfy(config("mul2") == 28, 413 '514: config("mul2") == 28'); 414 vrfy(config("sq2") == 28, 415 '515: config("sq2") == 28'); 416 vrfy(config("pow2") == 20, 417 '516: config("pow2") == 20'); 418 vrfy(config("redc2") == 25, 419 '517: config("redc2") == 25'); 420 vrfy(config("tilde"), 421 '518: config("tilde")'); 422 vrfy(config("tab"), 423 '519: config("tab")'); 424 vrfy(config("quomod") == 0, 425 '520: config("quomod") == 0'); 426 vrfy(config("quo") == 2, 427 '521: config("quo") == 2'); 428 vrfy(config("mod") == 0, 429 '522: config("mod") == 0'); 430 vrfy(config("sqrt") == 24, 431 '523: config("sqrt") == 24'); 432 vrfy(config("appr") == 24, 433 '524: config("appr") == 24'); 434 vrfy(config("cfappr") == 0, 435 '525: config("cfappr") == 0'); 436 vrfy(config("cfsim") == 8, 437 '526: config("cfsim") == 8'); 438 vrfy(config("outround") == 24, 439 '527: config("outround") == 24'); 440 vrfy(config("round") == 24, 441 '528: config("round") == 24'); 442 vrfy(config("leadzero") == 1, 443 '529: config("leadzero") == 1'); 444 vrfy(config("fullzero") == 0, 445 '530: config("fullzero") == 0'); 446 vrfy(config("maxscan") == 20, 447 '531: config("maxscan") == 20'); 448 vrfy(config("prompt") == "; ", 449 '532: config("prompt") == "; "'); 450 vrfy(config("more") == ";; ", 451 '533: config("more") == ";; "'); 452 453 /* convert to "oldstd" config by individual changes */ 454 print '534: test unused'; 455 vrfy(config("outround", 2) == 24, 456 '535: config("outround", 2) == 24'); 457 vrfy(config("leadzero","n") == 1, 458 '536: config("leadzero","n") == 1'); 459 print '537: test unused'; 460 vrfy(config("prompt", "> ") == "; ", 461 '538: config("prompt", "> ") == "; "'); 462 vrfy(config("more", ">> ") == ";; ", 463 '539: config("more", ">> ") == ";; "'); 464 vrfy(config("all") == oldcfg, '540: config("all") == oldcfg'); 465 466 /* restore the configuration at the start of this function */ 467 vrfy(config("all",callcfg) == oldcfg, 468 '541: config("all",callcfg) == oldcfg'); 469 470 /* display and fullzero tests */ 471 vrfy(config("display",2) == 20, 472 '542: config("display",2) == 20'); 473 vrfy(config("leadzero",0) == 1, 474 '543: config("leadzero",0) == 1'); 475 vrfy(config("fullzero",1) == 0, 476 '544: config("fullzero",1) == 0'); 477 vrfy(strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00", 478 '545: strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00"'); 479 vrfy(config("display",20) == 2, 480 '546: config("display",20) == 2'); 481 vrfy(config("leadzero",1) == 0, 482 '547: config("leadzero",1) == 0'); 483 vrfy(config("fullzero",0) == 1, 484 '548: config("fullzero",0) == 1'); 485 vrfy(strprintf("%d %d %d", 0, 1, 2) == "0 1 2", 486 '549: strprintf("%d %d %d", 0, 1, 2) == "0 1 2"'); 487 488 /* restore calling config */ 489 vrfy(config("all",callcfg) == startcfg, 490 '550: config("all",callcfg) == startcfg'); 491 vrfy(config("all") == callcfg, '551: config("all") == callcfg'); 492 vrfy(config("all") == startcfg, '552: config("all") == startcfg'); 493 494 /* check read-only config values */ 495 vrfy(strlen(config("program")) > 0, 496 '553: strlen(config("program")) > 0'); 497 vrfy(strlen(config("basename")) > 0, 498 '554: strlen(config("basename")) > 0'); 499 vrfy(strlen(config("version")) > 0, 500 '555: strlen(config("version")) > 0'); 501 502 /* mode2 is off by default */ 503 vrfy(config("mode2") == "off", 504 '556: config("mode2") == "off"'); 505 506 /* hz is numeric */ 507 vrfy(isint(config("hz")), '557: isint(config("hz"))'); 508 509 /* compile_custom is simple */ 510 vrfy(issimple(config("compile_custom")), 511 '558: issimple(config("compile_custom"))'); 512 513 /* allow_custom is simple */ 514 vrfy(issimple(config("allow_custom")), 515 '559: issimple(config("allow_custom"))'); 516 517 /* allow_custom is simple */ 518 vrfy(issimple(config("allow_custom")), 519 '559: issimple(config("allow_custom"))'); 520 521 /* baseb is numeric */ 522 vrfy(isint(config("baseb")), '560: isint(config("baseb"))'); 523 524 /* redecl_warn is simple */ 525 vrfy(issimple(config("redecl_warn")), 526 '561: issimple(config("redecl_warn"))'); 527 528 /* dupvar_warn is simple */ 529 vrfy(issimple(config("dupvar_warn")), 530 '562: issimple(config("rdupvar_warn"))'); 531 532 print '563: Ending test_config'; 533} 534print '010: parsed test_config()'; 535 536 537 538/* 539 * Do multiplication and division on three numbers in various ways 540 * and vrfy the results agree. 541 */ 542define muldivcheck(a, b, c, str) 543{ 544 local abc, acb, bac, bca, cab, cba; 545 546 abc = (a * b) * c; 547 acb = (a * c) * b; 548 bac = (b * a) * c; 549 bca = (b * c) * a; 550 cab = (c * a) * b; 551 cba = (c * b) * a; 552 553 if (abc != acb) {print '**** abc != acb:', str; ++prob;} 554 if (acb != bac) {print '**** acb != bac:', str; ++prob;} 555 if (bac != bca) {print '**** bac != bca:', str; ++prob;} 556 if (bca != cab) {print '**** bca != cab:', str; ++prob;} 557 if (cab != cba) {print '**** cab != cba:', str; ++prob;} 558 if (abc/a != b*c) {print '**** abc/a != bc:', str; ++prob;} 559 if (abc/b != a*c) {print '**** abc/b != ac:', str; ++prob;} 560 if (abc/c != a*b) {print '**** abc/c != ab:', str; ++prob;} 561 print str; 562} 563print '011: parsed muldivcheck(a, b, c, str)'; 564 565 566/* 567 * Use the identity for squaring the sum of two squares to check 568 * multiplication and squaring. 569 */ 570define squarecheck(a, b, str) 571{ 572 local a2, b2, tab, apb, apb2, t; 573 574 a2 = a^2; 575 b2 = b^2; 576 tab = a * b * 2; 577 apb = a + b; 578 apb2 = apb^2; 579 if (a2 != a*a) {print '**** a^2 != a*a:', str; ++prob;} 580 if (b2 != b*b) {print '**** b^2 != b*b:', str; ++prob;} 581 if (apb2 != apb*apb) { 582 print '**** (a+b)^2 != (a+b)*(a+b):', str; 583 ++prob; 584 } 585 if (a2+tab+b2 != apb2) { 586 print '**** (a+b)^2 != a^2 + 2ab + b^2:', str; 587 ++prob; 588 } 589 if (a2/a != a) {print '**** a^2/a != a:', str; ++prob;} 590 if (b2/b != b) {print '**** b^2/b != b:', str; ++prob;} 591 if (apb2/apb != apb) {print '**** (a+b)^2/(a+b) != a+b:', str; ++prob;} 592 if (a2*b2 != (a*b)^2) {print '**** a^2*b^2 != (ab)^2:', str; ++prob;} 593 print str; 594} 595print '012: parsed squarecheck(a, b, str)'; 596 597 598/* 599 * Use the raising of numbers to large powers to check multiplication 600 * and exponentiation. 601 */ 602define powercheck(a, p1, p2, str) 603{ 604 local a1, a2, a3; 605 local b1, b2, b3; 606 607 a1 = (a^p1)^p2; 608 a2 = (a^p2)^p1; 609 a3 = a^(p1*p2); 610 b1 = (a**p1)**p2; 611 b2 = (a**p2)**p1; 612 b3 = a**(p1*p2); 613 if (a1 != a2) {print '**** (a^p1)^p2 != (a^p2)^p1:', str; ++prob;} 614 if (a1 != a3) {print '**** (a^p1)^p2 != a^(p1*p2):', str; ++prob;} 615 if (b1 != b2) {print '**** (b^p1)^p2 != (b^p2)^p1:', str; ++prob;} 616 if (b1 != b3) {print '**** (b^p1)^p2 != b^(p1*p2):', str; ++prob;} 617 print str; 618} 619print '013: parsed powercheck(a, p1, p2, str)'; 620 621 622/* 623 * Test fraction reductions. 624 * Arguments MUST be relatively prime. 625 */ 626define fraccheck(a, b, c, str) 627{ 628 local ab, bc, ca, aoc, boc, aob; 629 630 ab = a * b; 631 bc = b * c; 632 ca = c * a; 633 aoc = ab / bc; 634 if (num(aoc) != a) {print '**** num(aoc) != a:', str; ++prob;} 635 if (den(aoc) != c) {print '**** den(aoc) != c:', str; ++prob;} 636 boc = ab / ca; 637 if (num(boc) != b) {print '**** num(boc) != b:', str; ++prob;} 638 if (den(boc) != c) {print '**** den(boc) != c:', str; ++prob;} 639 aob = ca / bc; 640 if (num(aob) != a) {print '**** num(aob) != a:', str; ++prob;} 641 if (den(aob) != b) {print '**** den(aob) != b:', str; ++prob;} 642 if (aob*boc != aoc) {print '**** aob*boc != aoc;', str; ++prob;} 643 print str; 644} 645print '014: parsed fraccheck(a, b, c, str)'; 646 647 648/* 649 * Test multiplication and squaring algorithms. 650 */ 651define algcheck(a, b, str) 652{ 653 local ss, ms, t1, t2, t3, t4, t5, t6, t7; 654 local a1, a2, a3, a4, a5, a6, a7; 655 local oldmul2, oldsq2; 656 657 oldmul2 = config("mul2", 2); 658 oldsq2 = config("sq2", 2); 659 a1 = a * b; 660 a2 = a * a; 661 a3 = b * b; 662 a4 = a^2; 663 a5 = b^2; 664 a6 = a2^2; 665 a7 = pmod(3,a-1,a); 666 for (ms = 2; ms < 20; ms++) { 667 for (ss = 2; ss < 20; ss++) { 668 config("mul2", ms); 669 config("sq2", ss); 670 t1 = a * b; 671 t2 = a * a; 672 t3 = b * b; 673 t4 = a^2; 674 t5 = b^2; 675 t6 = t2^2; 676 if (((ms + ss) % 37) == 4) 677 t7 = pmod(3,a-1,a); 678 if (t1 != a1) {print '**** t1 != a1:', str; ++prob;} 679 if (t2 != a2) {print '**** t2 != a2:', str; ++prob;} 680 if (t3 != a3) {print '**** t3 != a3:', str; ++prob;} 681 if (t4 != a4) {print '**** t4 != a4:', str; ++prob;} 682 if (t5 != a5) {print '**** t5 != a5:', str; ++prob;} 683 if (t6 != a6) {print '**** t6 != a6:', str; ++prob;} 684 if (t7 != a7) {print '**** t7 != a7:', str; ++prob;} 685 } 686 } 687 config("mul2", oldmul2); 688 config("sq2", oldsq2); 689 print str; 690} 691print '015: parsed algcheck(a, b, str)'; 692 693 694/* 695 * Test big numbers using some identities. 696 */ 697define test_bignums() 698{ 699 local a, b, c, d; 700 701 print '600: Beginning test_bignums'; 702 703 a = 64357824568234938591; 704 b = 12764632632458756817; 705 c = 43578234973856347982; 706 muldivcheck(a, b, c, '601: muldivcheck 1'); 707 a = 3^100; 708 b = 5^97; 709 c = 7^88; 710 muldivcheck(a, b, c, '602: muldivcheck 2'); 711 a = 2^160 - 1; 712 b = 2^161 - 1; 713 c = 2^162 - 1; 714 muldivcheck(a, b, c, '603: muldivcheck 3'); 715 a = 3^35 / 5^35; 716 b = 7^35 / 11^35; 717 c = 13^35 / 17^35; 718 muldivcheck(a, b, c, '604: muldivcheck 4'); 719 a = (10^97-1) / 9; 720 b = (10^53-1) / 9; 721 c = (10^37-1) / 9; 722 muldivcheck(a, b, c, '605: muldivcheck 5'); 723 a = 17^50; 724 b = 19^47; 725 squarecheck(a, b, '606: squarecheck 1'); 726 a = 2^111-1; 727 b = 2^17; 728 squarecheck(a, b, '607: squarecheck 2'); 729 a = 23^43 / 29^43; 730 b = 31^42 / 37^29; 731 squarecheck(a, b, '608: squarecheck 3'); 732 a = 4657892345743659834657238947854639; 733 b = 43784356784365893467659347867689; 734 squarecheck(a, b, '609: squarecheck 4'); 735 a = (10^80-1) / 9; 736 b = (10^50-1) / 9; 737 squarecheck(a, b, '610: squarecheck 5'); 738 a = 101^99; 739 b = 2 * a; 740 squarecheck(a, b, '611: squarecheck 6'); 741 a = (10^19-1) / 9; 742 vrfy(ptest(a, 20), '612: primetest R19'); 743 a = (10^23-1) / 9; 744 vrfy(ptest(a, 20), '613: primetest R23'); 745 a = 2^127 - 1; 746 vrfy(ptest(a, 1), '614: primetest M127'); 747 a = 2^521 - 1; 748 vrfy(ptest(a, 1), '615: primetest M521'); 749 powercheck(17, 127, 30, '616: powercheck 1'); 750 powercheck(111, 899, 6, '617: powercheck 2'); 751 powercheck(3, 87, 89, '618: powercheck 3'); 752 fraccheck(3^200, 5^173, 7^138, '619: fraccheck 1'); 753 fraccheck(11^100, 12^98, 13^121, '620: fraccheck 2'); 754 fraccheck(101^270, 103^111, 105^200, '621: fraccheck 3'); 755 a = 0xffff0000ffffffff00000000ffff0000000000000000ffff; 756 b = 0x555544440000000000000000000000000000000011112222333344440000; 757 c = 0x999911113333000011111111000022220000000000000000333300000000ffff; 758 d = 0x3333ffffffff0000000000000000ffffffffffffffff000000000000; 759 algcheck(a, a, '622: algcheck 1'); 760 algcheck(a, b, '623: algcheck 2'); 761 algcheck(a, c, '624: algcheck 3'); 762 algcheck(a, d, '625: algcheck 4'); 763 algcheck(b, b, '626: algcheck 5'); 764 algcheck(b, c, '627: algcheck 6'); 765 algcheck(b, d, '628: algcheck 7'); 766 algcheck(c, c, '629: algcheck 8'); 767 algcheck(c, d, '630: algcheck 9'); 768 algcheck(d, d, '631: algcheck 10'); 769 770 print '632: Ending test_bignums'; 771} 772print '016: parsed test_bignums()'; 773 774 775/* 776 * Test many of the built-in functions. 777 * 778 * See test_functions() (test 700 - 1238) for other built-in function tests. 779 * See test_functions2() (test 9000 - 9063) for other built-in function tests. 780 * See test_functions3() (test 9100 - 9214) for other built-in function tests. 781 */ 782define test_functions() 783{ 784 local a, b; 785 local pi; 786 local h, n, r, m, v; 787 local n2, m2, v2; 788 local t; 789 790 print '700: Beginning test_functions'; 791 792 vrfy(abs(3) == 3, '701: abs(3) == 3'); 793 vrfy(abs(-4) == 4, '702: abs(-4) == 4'); 794 vrfy(avg(7) == 7, '703: avg(7) == 7'); 795 vrfy(avg(3,5) == 4, '704: avg(3,5) == 4'); 796 vrfy(cmp(2,3) == -1, '705: cmp(2,3) == -1'); 797 vrfy(cmp(6,6) == 0, '706: cmp(6,6) == 0'); 798 vrfy(cmp(7,4) == 1, '707: cmp(7,4) == 1'); 799 vrfy(comb(9,9) == 1, '708: comb(9,9) == 1'); 800 vrfy(comb(5,2) == 10, '709: comb(5,2) == 10'); 801 vrfy(conj(4) == 4, '710: conj(4) == 4'); 802 vrfy(conj(2-3i) == 2+3i, '711: conj(2-3i) == 2+3i'); 803 vrfy(den(17) == 1, '712: den(17) == 1'); 804 vrfy(den(3/7) == 7, '713: den(3/7) == 7'); 805 vrfy(den(-2/3) == 3, '714: den(-2/3) == 3'); 806 vrfy(digits(0) == 1, '715: digits(0) == 1'); 807 vrfy(digits(9) == 1, '716: digits(9) == 1'); 808 vrfy(digits(10) == 2, '717: digits(10) == 2'); 809 vrfy(digits(-691) == 3, '718: digits(-691) == 3'); 810 vrfy(eval('2+3') == 5, "719: eval('2+3') == 5"); 811 vrfy(fcnt(11,3) == 0, '720: fcnt(11,3) == 0'); 812 vrfy(fcnt(18,3) == 2, '721: fcnt(18,3) == 2'); 813 vrfy(fib(0) == 0, '722: fib(0) == 0'); 814 vrfy(fib(1) == 1, '723: fib(1) == 1'); 815 vrfy(fib(9) == 34, '724: fib(9) == 34'); 816 vrfy(frem(12,5) == 12, '725: frem(12,5) == 12'); 817 vrfy(frem(45,3) == 5, '726: frem(45,3) == 5'); 818 vrfy(fact(0) == 1, '727: fact(0) == 1'); 819 vrfy(fact(1) == 1, '728: fact(1) == 1'); 820 vrfy(fact(5) == 120, '729: fact(5) == 120'); 821 vrfy(frac(3) == 0, '730: frac(3) == 0'); 822 vrfy(frac(2/3) == 2/3, '731: frac(2/3) == 2/3'); 823 vrfy(frac(17/3) == 2/3, '732: frac(17/3) == 2/3'); 824 vrfy(gcd(0,3) == 3, '733: gcd(0,3) == 3'); 825 vrfy(gcd(1,12) == 1, '734: gcd(1,12) == 1'); 826 vrfy(gcd(11,7) == 1, '735: gcd(11,7) == 1'); 827 vrfy(gcd(20,65) == 5, '736: gcd(20,65) == 5'); 828 vrfy(gcdrem(20,3) == 20, '737: gcdrem(20,3) == 20'); 829 vrfy(gcdrem(100,6) == 25, '738: gcdrem(100,6) == 25'); 830 vrfy(highbit(1) == 0, '739: highbit(1) == 0'); 831 vrfy(highbit(15) == 3, '740: highbit(15) == 3'); 832 vrfy(hypot(3,4) == 5, '741: hypot(3,4) == 5'); 833 vrfy(ilog(90,3) == 4, '742: ilog(90,3) == 4'); 834 vrfy(ilog10(123) == 2, '743: ilog10(123) == 2'); 835 vrfy(ilog2(17) == 4, '744: ilog2(17) == 4'); 836 vrfy(im(3) == 0, '745: im(3) == 0'); 837 vrfy(im(2+3i) == 3, '746: im(2+3i) == 3'); 838 vrfy(fact(20) == 2432902008176640000, 839 '747: fact(20) == 2432902008176640000'); 840 vrfy(fact(100) == 100*fact(99), '748: fact(100) == 100*fact(99)'); 841 vrfy(comb(100,25) == 100!/75!/25!, 842 '749: comb(100,25) == 100!/75!/25!'); 843 vrfy(perm(100,50) == 100!/50!, '750: perm(100,50) == 100!/50!'); 844 print '751: test unused'; 845 print '752: test unused'; 846 print '753: test unused'; 847 print '754: test unused'; 848 print '755: test unused'; 849 print '756: test unused'; 850 vrfy(int(5) == 5, '757: int(5) == 5'); 851 vrfy(int(19/3) == 6, '758: int(19/3) == 6'); 852 vrfy(inverse(3/2) == 2/3, '759: inverse(3/2) == 2/3'); 853 vrfy(iroot(18,2) == 4, '760: iroot(18,2) == 4'); 854 vrfy(iroot(100,3) == 4, '761: iroot(100,3) == 4'); 855 vrfy(iseven(10) == 1, '762: iseven(10) == 1'); 856 vrfy(iseven(13) == 0, '763: iseven(13) == 0'); 857 vrfy(iseven('a') == 0, "764: iseven('a') == 0"); 858 vrfy(isint(7) == 1, '765: isint(7) == 1'); 859 vrfy(isint(19/2) == 0, '766: isint(19/2) == 0'); 860 vrfy(isint('a') == 0, "767: isint('a') == 0"); 861 vrfy(islist(3) == 0, '768: islist(3) == 0'); 862 vrfy(islist(list(2,3)) == 1, '769: islist(list(2,3)) == 1'); 863 vrfy(ismat(3) == 0, '770: ismat(3) == 0'); 864 vrfy(ismult(7,3) == 0, '771: ismult(7,3) == 0'); 865 vrfy(ismult(15,5) == 1, '772: ismult(15,5) == 1'); 866 vrfy(isnull(3) == 0, '773: isnull(3) == 0'); 867 vrfy(isnull(null()) == 1, '774: isnull(null()) == 1'); 868 vrfy(isnum(2/3) == 1, '775: isnum(2/3) == 1'); 869 vrfy(isnum('xx') == 0, "776: isnum('xx') == 0"); 870 vrfy(isobj(3) == 0, '777: isobj(3) == 0'); 871 vrfy(isodd(7) == 1, '778: isodd(7) == 1'); 872 vrfy(isodd(8) == 0, '779: isodd(8) == 0'); 873 vrfy(isodd('x') == 0, "780: isodd('a') == 0"); 874 vrfy(isqrt(27) == 5, '781: isqrt(27) == 5'); 875 vrfy(isreal(3) == 1, '782: isreal(3) == 1'); 876 vrfy(isreal('x') == 0, "783: isreal('x') == 0"); 877 vrfy(isreal(2+3i) == 0, '784: isreal(2+3i) == 0'); 878 vrfy(isstr(5) == 0, '785: isstr(5) == 0'); 879 vrfy(isstr('foo') == 1, "786: isstr('foo') == 1"); 880 vrfy(isrel(10,14) == 0, '787: isrel(10,14) == 0'); 881 vrfy(isrel(15,22) == 1, '788: isrel(15,22) == 1'); 882 vrfy(issimple(6) == 1, '789: issimple(6) == 1'); 883 vrfy(issimple(3-2i) == 1, '790: issimple(3-2i) == 1'); 884 vrfy(issimple(list(5)) == 0, '791: issimple(list(5)) == 0'); 885 vrfy(issq(26) == 0, '792: issq(26) == 0'); 886 vrfy(issq(9/4) == 1, '793: issq(9/4) == 1'); 887 print '794: test unused'; 888 vrfy(istype(9,4) == 1, '795: istype(9,4) == 1'); 889 vrfy(istype(3,'xx') == 0, "796: istype(3,'xx') == 0"); 890 vrfy(jacobi(5,11) == 1, '797: jacobi(2,7) == 1'); 891 vrfy(jacobi(6,13) == -1, '798: jacobi(6,13) == -1'); 892 vrfy(lcm(3,4,5,6) == 60, '799: lcm(3,4,5,6) == 60'); 893 vrfy(lcmfact(8) == 840, '800: lcmfact(8) == 840'); 894 vrfy(lfactor(21,5) == 3, '801: lfactor(21,5) == 3'); 895 vrfy(lfactor(97,20) == 1, '802: lfactor(97,20) == 1'); 896 vrfy(lowbit(12) == 2, '803: lowbit(12) == 2'); 897 vrfy(lowbit(17) == 0, '804: lowbit(17) == 0'); 898 vrfy(ltol(1) == 0, '805: ltol(1) == 0'); 899 vrfy(max(3,-9,7,4) == 7, '806: max(3,-9,7,4) == 7'); 900 vrfy(meq(13,33,10) == 1, '807: meq(13,33,10) == 1'); 901 vrfy(meq(7,19,11) == 0, '808: meq(7,19,11) == 0'); 902 vrfy(min(9,5,12) == 5, '809: min(9,5,12) == 5'); 903 vrfy(minv(13,97) == 15, '810: minv(13,97) == 15'); 904 vrfy(mne(16,37,10) == 1, '811: mne(16,37,10) == 1'); 905 vrfy(mne(46,79,11) == 0, '812: mne(46,79,11) == 0'); 906 vrfy(norm(4) == 16, '813: norm(4) == 16'); 907 vrfy(norm(2-3i) == 13, '814: norm(2-3i) == 13'); 908 vrfy(num(7) == 7, '815: num(7) == 7'); 909 vrfy(num(11/4) == 11, '816: num(11/4) == 11'); 910 vrfy(num(-9/5) == -9, '817: num(-9/5) == -9'); 911 vrfy(char(ord('a')+2) == 'c', "818: char(ord('a')+2) == 'c'"); 912 vrfy(perm(7,3) == 210, '819: perm(7,3) == 210'); 913 vrfy(pfact(10) == 210, '820: pfact(10) == 210'); 914 vrfy(places(3/7) == -1, '821: places(3/7) == -1'); 915 vrfy(places(.347) == 3, '822: places(.347) == 3'); 916 vrfy(places(17) == 0, '823: places(17) == 0'); 917 vrfy(pmod(3,36,37) == 1, '824: pmod(3,36,37) == 1'); 918 vrfy(poly(2,3,5,2) == 19, '825: poly(2,3,5,2) == 19'); 919 vrfy(ptest(101,10) == 1, '826: ptest(101,10) == 1'); 920 vrfy(ptest(221,30) == 0, '827: ptest(221,30) == 0'); 921 vrfy(re(9) == 9, '828: re(9) == 9'); 922 vrfy(re(-7+3i) == -7, '829: re(-7+3i) == -7'); 923 vrfy(scale(3,4) == 48, '830: scale(3,4) == 48'); 924 vrfy(sgn(-4) == -1, '831: sgn(-4) == -1'); 925 vrfy(sgn(0) == 0, '832: sgn(0) == 0'); 926 vrfy(sgn(3) == 1, '833: sgn(3) == 1'); 927 vrfy(size(7) == 1, '834: size(7) == 1'); 928 vrfy(sqrt(121) == 11, '835: sqrt(121) == 11'); 929 vrfy(ssq(2,3,4) == 29, '836: ssq(2,3,4) == 29'); 930 vrfy(str(45) == '45', "837: str(45) == '45'"); 931 vrfy(strcat('a','bc','def')=='abcdef', 932 "838: strcat('a','bc','def')=='abcdef'"); 933 vrfy(strlen('') == 0, "839: strlen('') == 0"); 934 vrfy(strlen('abcd') == 4, "840: strlen('abcd') == 4"); 935 vrfy(substr('abcd',2,1) == 'b', "841: substr('abcd',2,1) == 'b'"); 936 vrfy(substr('abcd',3,4) == 'cd', "842: substr('abcd',3,4) == 'cd'"); 937 vrfy(substr('abcd',1,3) == 'abc', "843: substr('abcd',1,3) == 'abc'"); 938 vrfy(xor(17,17) == 0, '844: xor(17,17) == 0'); 939 vrfy(xor(12,5) == 9, '845: xor(12,5) == 9'); 940 vrfy(mmin(3,7) == 3, '846: mmin(3,7) == 3'); 941 vrfy(mmin(4,7) == -3, '847: mmin(4,7) == -3'); 942 vrfy(digit(123,2) == 1, '848: digit(123,2) == 1'); 943 vrfy(ismult(3/4, 1/7) == 0, '849: ismult(3/4, 1/7) == 0'); 944 vrfy(gcd(3/4, 1/7) == 1/28, '850: gcd(3/4,1/7) == 1/28'); 945 vrfy(gcd(2,3,1/2) == 1/2, '851: gcd(2,3,1/2) == 1/2'); 946 vrfy(gcd(17,7,1/7) == 1/7, '852: gcd(17,7,1/7) == 1/7'); 947 vrfy(gcd(2) == 2, '853: gcd(2) == 2'); 948 vrfy(gcd(-2) == 2, '854: gcd(-2) == 2'); 949 vrfy(floor(1.5) == 1, '855: floor(1.5) == 1'); 950 vrfy(floor(.5) == 0, '856: floor(.5) == 0'); 951 vrfy(floor(-.5) == -1, '857: floor(-.5) == -1'); 952 vrfy(floor(-1.5) == -2, '858: floor(-1.5) == -2'); 953 vrfy(ceil(1.5) == 2, '859: ceil(1.5) == 2'); 954 vrfy(ceil(.5) == 1, '860: ceil(.5) == 1'); 955 vrfy(ceil(-.5) == 0, '861: ceil(-.5) == 0'); 956 vrfy(ceil(-1.5) == -1, '862: ceil(-1.5) == -1'); 957 vrfy(frac(-7.2) == -.2, '863: frac(-7.2) == -.2'); 958 vrfy(gcd(4, 5, 1/3) == 1/3, '864: gcd(4, 5, 1/3) == 1/3'); 959 vrfy(ltol(7/25) == 24/25, '865: ltol(7/25) == 24/25'); 960 vrfy(hmean(1,2,3) == 18/11, '866: hmean(1,2,3) == 18/11'); 961 vrfy(ilog2(2^-20) == -20, '867: ilog2(2^-20) == -20'); 962 vrfy(ord("DBell") == 68, '868: ord("DBell") == 68'); 963 vrfy(cmp("a","b") == -1, '869: cmp("a","b") == -1'); 964 vrfy(cmp("abcd","abc") == 1, '870: cmp("abcd","abc") == 1'); 965 vrfy(cmp(3,4i) == 1-1i, '871: cmp(3,4i) == 1-1i'); 966 vrfy(cmp(4,4i) == 1-1i, '872: cmp(4,4i) == 1-1i'); 967 vrfy(cmp(5,4i) == 1-1i, '873: cmp(5,4i) == 1-1i'); 968 vrfy(cmp(-5,4i) == -1-1i, '874: cmp(-5,4i) == -1-1i'); 969 vrfy(cmp(-4i,5) == -1-1i, '875: cmp(-4i,5) == -1-1i'); 970 vrfy(cmp(-4i,-5) == 1-1i, '876: cmp(-4i,-5) == 1-1i'); 971 vrfy(cmp(3i,4i) == -1i, '877: cmp(3i,4i) == -1i'); 972 vrfy(cmp(4i,4i) == 0, '878: cmp(4i,4i) == 0'); 973 vrfy(cmp(5i,4i) == 1i, '879: cmp(5i,4i) == 1i'); 974 vrfy(cmp(3+4i,5) == -1+1i, '880: cmp(3+4i,5) == -1+1i'); 975 vrfy(cmp(3+4i,-5) == 1+1i, '881: cmp(3+4i,-5) == 1+1i'); 976 vrfy(cmp(3+4i,3+4i) == 0, '882: cmp(3+4i,3+4i) == 0'); 977 vrfy(cmp(3+4i,3-4i) == 1i, '883: cmp(3+4i,3-4i) == 1i'); 978 vrfy(cmp(3+4i,2+3i) == 1+1i, '884: cmp(3+4i,2+3i) == 1+1i'); 979 vrfy(cmp(3+4i,-4-5i) == 1+1i, '885: cmp(3+4i,-4-5i) == 1+1i'); 980 vrfy(comb(7,0) == 1, '886: comb(7,0) == 1'); 981 vrfy(comb(0,0) == 1, '887: comb(0,0) == 1'); 982 vrfy(perm(7,0) == 1, '888: perm(7,0) == 1'); 983 vrfy(perm(0,0) == 1, '889: perm(0,0) == 1'); 984 vrfy(isfile(files(0)) == 1, '890: isfile(files(0)) == 1'); 985 vrfy(isfile(0) == 0, '891: isfile(0) == 0'); 986 vrfy(ismult(4^67, 2^59) == 1, '892: ismult(4^67, 2^59) == 1'); 987 vrfy(ismult(13, 4/67) == 0, '893: ismult(13, 4/67) == 0'); 988 vrfy(ismult(13, 7/56) == 1, '894: ismult(13, 7/56) == 1'); 989 vrfy(isnum(2i) == 1, '895: isnum(2i) == 1'); 990 vrfy(iseven(1/3) == 0, '896: iseven(1/3) == 0'); 991 vrfy(isodd(1/3) == 0, '897: isodd(1/3) == 0'); 992 vrfy(isrel(-5, 6) == 1, '898: isrel(-5, 6) == 1'); 993 vrfy(isrel(-2, 6) == 0, '899: isrel(-2, 6) == 0'); 994 vrfy(bit(9,0) == 1, '900: bit(9,0) == 1'); 995 vrfy(bit(9,1) == 0, '901: bit(9,1) == 0'); 996 vrfy(bit(9,2) == 0, '902: bit(9,2) == 0'); 997 vrfy(bit(9,3) == 1, '903: bit(9,3) == 1'); 998 vrfy(bit(1.25, -2) == 1, '904: bit(1.25, -2) == 1'); 999 vrfy(bit(1.25, -1) == 0, '905: bit(1.25, -1) == 0'); 1000 vrfy(bit(1.25, 0) == 1, '906: bit(1.25, 0) == 1'); 1001 vrfy(bit(pi(), 1) == 1, '907: bit(pi(), 1) == 1'); 1002 vrfy(bit(pi(), -2) == 0, '908: bit(pi(), -2) == 0'); 1003 vrfy(bit(pi(), -3) == 1, '909: bit(pi(), -3) == 1'); 1004 vrfy(istype(2, 3.0) == 1, '910: istype(2, 3.0) == 1'); 1005 vrfy(istype(2, "2") == 0, '911: istype(2, "2") == 0'); 1006 vrfy(istype(2, 3i) == 0, '912: istype(2, 3i) == 0'); 1007 vrfy(istype(2i+2, 3i) == 1, '913: istype(2i+2, 3i) == 1'); 1008 a = epsilon(); 1009 print '914: a = epsilon()'; 1010 vrfy(epsilon(a) == epsilon(), '915: epsilon(a) == epsilon()'); 1011 vrfy(epsilon(a) == epsilon(), '916: epsilon(a) == epsilon()'); 1012 vrfy(epsilon(a) == epsilon(), '917: epsilon(a) == epsilon()'); 1013 vrfy(epsilon() == a, '918: epsilon() == a'); 1014 b = 1e-6; 1015 print '919: b = 1e-6'; 1016 vrfy(epsilon(b) == a, '920: epsilon(b) == a'); 1017 vrfy(epsilon(b) == epsilon(), '921: epsilon(b) == epsilon()'); 1018 vrfy(epsilon(b) == epsilon(), '922: epsilon(b) == epsilon()'); 1019 vrfy(epsilon(b) == epsilon(), '923: epsilon(b) == epsilon()'); 1020 vrfy(epsilon() == 1e-6, '924: epsilon() == 1e-6'); 1021 vrfy(epsilon(a) == b, '925: epsilon(a) == b'); 1022 vrfy(epsilon(a) == epsilon(), '926: epsilon(a) == epsilon()'); 1023 vrfy(epsilon(a) == epsilon(), '927: epsilon(a) == epsilon()'); 1024 vrfy(epsilon(a) == epsilon(), '928: epsilon(a) == epsilon()'); 1025 vrfy(epsilon(a) == a, '929: epsilon(a) == a'); 1026 vrfy(quomod(13,5,a,b) == 1, '930: quomod(13,5,a,b) == 1'); 1027 vrfy(a == 2, '931: a == 2'); 1028 vrfy(b == 3, '932: b == 3'); 1029 vrfy(quomod(15.6,5.2,a,b) == 0, '933: quomod(15.6,5.2,a,b) == 0'); 1030 vrfy(a == 3, '934: a == 3'); 1031 vrfy(b == 0, '935: b == 0'); 1032 vrfy(putenv("abcd=efg") == 0, '936: putenv("abcd=efg")'); 1033 vrfy(getenv("abcd") == "efg", '937: getenv("abcd") == "efg"'); 1034 vrfy(putenv("abcd","123")==0, '938: putenv("abcd","123")'); 1035 vrfy(getenv("abcd") == "123", '939: getenv("abcd") == "123"'); 1036 vrfy(isnull(getenv("notavar")) == 1, 1037 '940: isnull(getenv("notavar")) == 1'); 1038 a = "abcdefg"; 1039 print '941: a = "abcdefg"'; 1040 vrfy(strpos(a, "c") == 3, '942: strpos(a, "c") == 3'); 1041 vrfy(strpos(a, "def") == 4, '943: strpos(a, "def") == 4'); 1042 vrfy(strpos(a, "defg") == 4, '944: strpos(a, "defg") == 4'); 1043 vrfy(strpos(a, "defgh") == 0, '945: strpos(a, "defgh") == 0'); 1044 vrfy(strpos(a, "abc") == 1, '946: strpos(a, "abc") == 1'); 1045 vrfy(strpos(a, "xyz") == 0, '947: strpos(a, "xyz") == 0'); 1046 vrfy(strpos(a, a) == 1, '948: strpos(a, a) == 1'); 1047 if (config("windows") || config("cygwin")) { 1048 print '949: test skipped for windows or cygwin systems'; 1049 print '950: test skipped for windows or cygwin systems'; 1050 } else { 1051 vrfy(system("") == 0, '949: system("") == 0'); 1052 vrfy(system("true") == 0, '950: system("true") == 0'); 1053 } 1054 print '951: test disabled due to stdin dependency'; 1055 print '952: test removed'; 1056 print '953: test removed'; 1057 vrfy(isstr(cmdbuf()) == 1, '954: isstr(cmdbuf()) == 1'); 1058 vrfy(abs(root(4,3,0.1)-1.5874) < 0.1, 1059 '955: abs(root(4,3,0.1)-1.5874) < 0.1'); 1060 print '956: a = 2^300 + 69962309754533779525365054067'; 1061 a = 2^300 + 69962309754533779525365054067; 1062 a /= 2^211; 1063 print '957: a /= 2^211'; 1064 vrfy(appr(a, 1e-20) == 2^89, '958: appr(a, 1e-20) == 2^89'); 1065 vrfy(digits(5e149) == 150, '959: digits(5e149) == 150'); 1066 vrfy(highbit(2) == 1, '960: highbit(2) == 1'); 1067 vrfy(highbit(3) == 1, '961: highbit(3) == 1'); 1068 vrfy(highbit(4) == 2, '962: highbit(4) == 2'); 1069 vrfy(highbit(-15) == 3, '963: highbit(-15) == 3'); 1070 vrfy(highbit(2^27) == 27, '964: highbit(2^27) == 27'); 1071 a = 12.34; 1072 print '965: a = 12.34'; 1073 vrfy(digit(a,2) == 0, '966: digit(a,2) == 0'); 1074 vrfy(digit(a,1) == 1, '967: digit(a,1) == 1'); 1075 vrfy(digit(a,0) == 2, '968: digit(a,0) == 2'); 1076 vrfy(digit(a,-1) == 3, '969: digit(a,-1) == 3'); 1077 vrfy(digit(a,-2) == 4, '970: digit(a,-2) == 4'); 1078 a = 10/7; 1079 print '971: a = 10/7'; 1080 vrfy(digit(a,1) == 0, '972: digit(a,1) == 0'); 1081 vrfy(digit(a,0) == 1, '973: digit(a,0) == 1'); 1082 vrfy(digit(a,-1) == 4, '974: digit(a,-1) == 4'); 1083 vrfy(digit(a,-2) == 2, '975: digit(a,-2) == 2'); 1084 vrfy(digit(a,-3) == 8, '976: digit(a,-3) == 8'); 1085 vrfy(digits(0) == 1, '977: digits(0) == 1'); 1086 vrfy(digits(0.0123) == 1, '978: digits(0.0123) == 1'); 1087 vrfy(digits(3.7) == 1, '979: digits(3.7) == 1'); 1088 vrfy(digits(-27) == 2, '980: digits(-27) == 2'); 1089 vrfy(digits(-99.7) == 2, '981: digits(-99.7) == 2'); 1090 vrfy(ilog2(1) == 0, '982: ilog2(1) == 0'); 1091 vrfy(ilog2(2) == 1, '983: ilog2(2) == 1'); 1092 vrfy(ilog2(3) == 1, '984: ilog2(3) == 1'); 1093 vrfy(ilog2(4) == 2, '985: ilog2(4) == 2'); 1094 vrfy(ilog2(1/15) == -4, '986: ilog2(1/15) == -4'); 1095 vrfy(places(3) == 0, '987: places(3) == 0'); 1096 vrfy(places(0.0123) == 4, '988: places(0.0123) == 4'); 1097 vrfy(places(3.70) == 1, '989: places(3.70) == 1'); 1098 vrfy(places(1e-10) == 10, '990: places(1e-10) == 10'); 1099 vrfy(places(3/7) == -1, '991: places(/37) == -1'); 1100 vrfy(ilog10(7.7) == 0, '992: ilog10(7.7) == 0'); 1101 vrfy(ilog10(77.7) == 1, '993: ilog10(77.7) == 1'); 1102 vrfy(ilog10(777) == 2, '994: ilog10(777) == 2'); 1103 vrfy(ilog10(.00777) == -3, '995: ilog10(.00777) == -3'); 1104 vrfy(ilog10(1e27) == 27, '996: ilog10(1e27) == 27'); 1105 vrfy(lowbit(2) == 1, '997: lowbit(2) == 1'); 1106 vrfy(lowbit(3) == 0, '998: lowbit(3) == 0'); 1107 vrfy(lowbit(4) == 2, '999: lowbit(4) == 2'); 1108 vrfy(lowbit(-15) == 0, '1000: lowbit(-15) == 0'); 1109 vrfy(lowbit(2^27) == 27, '1001: lowbit(2^27) == 27'); 1110 vrfy(char(0102) == 'B', '1002: char(0102) == \'B\''); 1111 vrfy(char(0x6f) == 'o', '1003: char(0x6f) == \'o\''); 1112 vrfy(char(119) == 'w', '1004: char(119) == \'w\''); 1113 vrfy(char(0145) == 'e', '1005: char(0145) == \'e\''); 1114 vrfy(char(0x6e) == 'n', '1006: char(0x6e) == \'n\''); 1115 vrfy(den(-1.25) == 4, '1007: den(-1.25) == 4'); 1116 vrfy(den(121/33) == 3, '1008: den(121/33) == 3'); 1117 vrfy(gcd(9/10, 11/5, 4/25) == 0.02, 1118 '1009: gcd(9/10, 11/5, 4/25) == 0.02'); 1119 vrfy(gcd(0,0,0,0,0) == 0, '1010: gcd(0,0,0,0,0) == 0'); 1120 vrfy(hypot(3, 4, 1e-6) == 5, '1011: hypot(3, 4, 1e-6) == 5'); 1121 vrfy(hypot(2,-3,1e-6) == 3605551/1e6, 1122 '1012: hypot(2,-3,1e-6) == 3605551/1e6'); 1123 vrfy(im(-4.25 - 7i) == -7, '1013: im(-4.25 - 7i) == -7'); 1124 vrfy(lcm(12, -24, 30) == -120,'1014: lcm(12, -24, 30) == -120'); 1125 vrfy(lcm(9/10, 11/5, 4/25) == 79.2, 1126 '1015: lcm(9/10, 11/5, 4/25) == 79.2'); 1127 vrfy(lcm(2) == 2, '1016: lcm(2) == 2'); 1128 vrfy(max(2) == 2, '1017: max(2) == 2'); 1129 vrfy(min(2) == 2, '1018: min(2) == 2'); 1130 vrfy(re(-4.25 - 7i) == -4.25, '1019: re(-4.25 - 7i) == -4.25'); 1131 vrfy(size("abc") == 3, '1020: size("abc") == 3'); 1132 vrfy(str("") == "", '1021: str("") == ""'); 1133 vrfy(str(null()) == "", '1022: str(null()) == ""'); 1134 vrfy(str("Ernest Bowen") == "Ernest Bowen", 1135 '1023: str("Ernest Bowen") == "Ernest Bowen"'); 1136 vrfy(strlen("a b\tc\\d") == 7, 1137 '1024: strlen("a b\tc\\d") == 7'); 1138 vrfy(xor(2) == 2, '1025: xor(2) == 2'); 1139 vrfy(xor(5, 3, 7, 2, 9) == 10, 1140 '1026: xor(5, 3, 7, 2, 9) == 10'); 1141 vrfy(xor(0,0) == 0, '1027: xor(0,0) == 0'); 1142 vrfy(xor(0,1) == 1, '1028: xor(0,1) == 1'); 1143 vrfy(xor(1,0) == 1, '1029: xor(1,0) == 1'); 1144 vrfy(xor(1,1) == 0, '1030: xor(1,1) == 0'); 1145 vrfy(xor(5,3,-7,2,9) == -12, '1031: xor(5,3,-7,2,9) == -12'); 1146 vrfy(fib(-2) == -1, '1032: fib(-2) == -1'); 1147 vrfy(fib(-1) == 1, '1033: fib(-1) == 1'); 1148 vrfy(fib(-10) == -55, '1034: fib(-10) == -55'); 1149 vrfy(ilog(1/8, 3) == -2, '1035: ilog(1/8, 3) == -2'); 1150 vrfy(ilog(8.9, 3) == 1, '1036: ilog(8.9, 3) == 1'); 1151 vrfy(iroot(1,9) == 1, '1037: iroot(1,9) == 1'); 1152 vrfy(iroot(pi()^8,5) == 6, '1038: iroot(pi()^8,5)'); 1153 vrfy(isqrt(8.5) == 2, '1039: isqrt(8.5) == 2'); 1154 vrfy(isqrt(2e56) == 14142135623730950488016887242, 1155 '1040: isqrt(2e56) == 14142135623730950488016887242'); 1156 vrfy(near(22/7, 3.15, .01) == -1, 1157 '1041: near(22/7, 3.15, .01) == -1'); 1158 vrfy(near(22/7, 3.15, .005) == 1, 1159 '1042: near(22/7, 3.15, .005) == 1'); 1160 vrfy(norm(3.4) == 11.56, '1043: isqrt(3.4) == 11.56'); 1161 vrfy(pi(1e-5) == 3.14159, '1044: pi(1e-5) == 3.14159'); 1162 pi = pi(1e-10); 1163 print '1045: pi = pi(1e-10)'; 1164 vrfy(pi == 3.1415926536, '1046: pi == 3.1415926536'); 1165 vrfy(polar(2,pi/2,1e-5)==2i, '1047: polar(2,pi/2,1e-5)==2i'); 1166 vrfy(power(exp(1,1e-20),pi(1e-20)*1i/2,1e-20) == 1i, 1167 '1048: power(exp(1,1e-20),pi(1e-20)*1i/2,1e-20) == 1i'); 1168 vrfy(ssq(1+2i, 3-4i, 5 +6i) == -21+40i, 1169 '1049: ssq(1+2i, 3-4i, 5 +6i) == -21+40i'); 1170 vrfy(isreal(ln(1 + 1e-10i, 1e-5)), 1171 '1050: isreal(ln(1 + 1e-10i, 1e-5))'); 1172 vrfy(isreal(exp(pi(1e-10)*1i, 1e-5)), 1173 '1051: isreal(exp(pi(1e-10)*1i, 1e-5))'); 1174 vrfy(cfappr(43/30, 10, 0) == 10/7, 1175 '1052: cfappr(43/30, 10, 0) == 10/7'); 1176 vrfy(cfappr(43/30, 10, 1) == 13/9, 1177 '1053: cfappr(43/30, 10, 1) == 13/9'); 1178 vrfy(cfappr(43/30, 10, 16) == 10/7, 1179 '1054: cfappr(43/30, 10, 16) == 10/7'); 1180 vrfy(cfappr(6/5, 1/2, 16) == 1, 1181 '1055: cfappr(6/5, 1/2, 16) == 1'); 1182 vrfy(cfsim(13,8) == 0, '1056: cfsim(13,8) == 0'); 1183 vrfy(cfsim(1057,8) == 0, '1057: cfsim(1057,8) == 0'); 1184 vrfy(mod(11,5,0) == 1, '1058: mod(11,5,0) == 1'); 1185 vrfy(mod(11,5,1) == -4, '1059: mod(11,5,1) == -4'); 1186 vrfy(mod(-11,5,2) == -1, '1060: mod(-11,5,2) == -1'); 1187 vrfy(mod(-11,-5,3) == 4, '1061: mod(-11,-5,3) == 4'); 1188 vrfy(mod(12.5,5,16) == 2.5, '1062: mod(12.5,5,16) == 2.5'); 1189 vrfy(mod(12.5,5,17) == -2.5, '1063: mod(12.5,5,17) == -2.5'); 1190 vrfy(mod(12.5,5,24) == 2.5, '1064: mod(12.5,5,24) == 2.5'); 1191 vrfy(mod(-7.5,-5,24) == 2.5, '1065: mod(-7.5,-5,24) == 2.5'); 1192 vrfy(quo(11,5,0) == 2, '1066: quo(11,5,0) == 2'); 1193 vrfy(quo(11,5,1) == 3, '1067: quo(11,5,1) == 3'); 1194 vrfy(quo(-11,5,2) == -2, '1068: quo(-11,5,2) == -2'); 1195 vrfy(quo(-11,-5,3) == 3, '1069: quo(-11,-5,3) == 3'); 1196 vrfy(quo(12.5,5,16) == 2, '1070: quo(12.5,5,16) == 2'); 1197 vrfy(quo(12.5,5,17) == 3, '1071: quo(12.5,5,17) == 3'); 1198 vrfy(quo(12.5,5,24) == 2, '1072: quo(12.5,5,24) == 2'); 1199 vrfy(quo(-7.5,-5,24) == 2, '1073: quo(-7.5,-5,24) == 2'); 1200 vrfy(frac(2.5 + 3i) == .5, '1074: frac(2.5 + 3i) == .5'); 1201 vrfy(root(1i,1000,1e-2)==1, '1075: root(1i,1000,1e-2) == 1'); 1202 vrfy(scale(2+3i,2)==8+12i, '1076: scale(2+3i,2) == 8+12i'); 1203 vrfy(frem(8,4) == 2, '1077: frem(8,4) == 2'); 1204 vrfy(jacobi(80,199) == 1, '1078: jacobi(80,199) == 1'); 1205 vrfy(test(1), '1079: test(1)'); 1206 vrfy(!test(0), '1080: !test(0)'); 1207 vrfy(hnrmod(2^177-1,1,177,-1)==0, 1208 '1081: hnrmod(2^177-1,1,177,-1)==0'); 1209 vrfy(hnrmod(2^178-2,1,177,-1)==0, 1210 '1082: hnrmod(2^178-2,1,177,-1)==0'); 1211 vrfy(hnrmod(2^178-3,1,177,1)==2^177-4, 1212 '1083: hnrmod(2^178-3,1,177,1)==2^177-4'); 1213 vrfy(hnrmod(2^179-4,1,177,0)==2^177-4, 1214 '1084: hnrmod(2^179-4,1,177,0)==2^177-4'); 1215 vrfy(hnrmod(1234567^2,13,17,-1)==1155404, 1216 '1085: hnrmod(1234567^2,13,17,-1)==1155404'); 1217 vrfy(hnrmod(3276^54,45,415,1)==3276^54%(45*2^415+1), 1218 '1086: hnrmod(3276^54,45,415,1)==3276^54%(45*2^415+1)'); 1219 vrfy(hnrmod(3276^54,45,415,0)==3276^54%(45*2^415), 1220 '1087: hnrmod(3276^54,45,415,0)==3276^54%(45*2^415)'); 1221 vrfy(hnrmod(3276^54,45,415,-1)==3276^54%(45*2^415-1), 1222 '1088: hnrmod(3276^54,45,415,-1)==3276^54%(45*2^415-1)'); 1223 vrfy(hnrmod(10^40, 17, 51, 1) == 33827019788296445, 1224 '1089: hnrmod(10^40, 17, 51, 1) == 33827019788296445'); 1225 vrfy(hnrmod(3192487935759423423521,16,65,1)==241008883965895164956, 1226 '1090: hnrmod(3192487935759423423521,16,65,1)==241008883965895164956'); 1227 1228 /* 1229 * minv bug fix 1230 */ 1231 a = 2868611690182699929873981931; 1232 print '1091: a = 2868611690182699929873981931'; 1233 b = 502922899875329926125584830; 1234 print '1092: b = 502922899875329926125584830'; 1235 vrfy(minv(b,a) == 1111092570983877189739032190, 1236 '1093: minv(b,a) == 1111092570983877189739032190'); 1237 vrfy(mod(minv(b,a)*b,a) == 1, 1238 '1094: mod(minv(b,a)*b,a) == 1'); 1239 1240 /* 1241 * more functions to test 1242 */ 1243 vrfy(popcnt(32767) == 15, '1095: popcnt(32767) == 15'); 1244 vrfy(popcnt(3/2) == 3, '1096: popcnt(3/2) == 3'); 1245 vrfy(popcnt(-237/39929,1) == 17, 1246 '1097: popcnt(-237/39929,1) == 17'); 1247 vrfy(popcnt(-237/39929,0) == 7, 1248 '1098: popcnt(-237/39929,0) == 7'); 1249 vrfy(popcnt(-237/39929) == 17, 1250 '1099: popcnt(-237/39929) == 17'); 1251 vrfy(popcnt(pi(1e-20)) == 65, '1100: popcnt(pi(1e-20)) == 65'); 1252 vrfy(popcnt(pi(1e-20),0) == 69, '1101: popcnt(pi(1e-20),0) == 69'); 1253 vrfy(popcnt(17^777) == 1593, '1102: popcnt(17^777) == 1593'); 1254 1255 /* 1256 * more hnrmod testing 1257 */ 1258 vrfy(hnrmod(21<<100+5,3,100,1) == (21<<100+5)%(3<<100+1), 1259 '1103: hnrmod(21<<100+5,3,100,1) == (21<<100+5)%(3<<100+1)'); 1260 vrfy(hnrmod(21<<500+7,3,500,1) == (21<<500+7)%(3<<500+1), 1261 '1104: hnrmod(21<<500+7,3,500,1) == (21<<500+7)%(3<<500+1)'); 1262 vrfy(hnrmod(-767256,84,1,0) == (-767256)%(84<<1+0), 1263 '1105: hnrmod(-767256,84,1,0) == (-767256)%(84<<1+0)'); 1264 vrfy(hnrmod(-831150,75,1,0) == (-831150)%(75<<1+0), 1265 '1106: hnrmod(-831150,75,1,0) == (-831150)%(75<<1+0)'); 1266 vrfy(hnrmod(-767256,84,1,1) == (-767256)%(84<<1+1), 1267 '1107: hnrmod(-767256,84,1,1) == (-767256)%(84<<1+1)'); 1268 vrfy(hnrmod(-831150,75,1,1) == (-831150)%(75<<1+1), 1269 '1108: hnrmod(-831150,75,1,1) == (-831150)%(75<<1+1)'); 1270 vrfy(hnrmod(-767256,84,1,-1) == (-767256)%(84<<1-1), 1271 '1109: hnrmod(-767256,84,1,-1) == (-767256)%(84<<1-1)'); 1272 vrfy(hnrmod(-831150,75,1,-1) == (-831150)%(75<<1-1), 1273 '1110: hnrmod(-831150,75,1,-1) == (-831150)%(75<<1-1)'); 1274 vrfy(hnrmod(21<<100+5,3,100,0) == (21<<100+5)%(3<<100+0), 1275 '1111: hnrmod(21<<100+5,3,100,0) == (21<<100+5)%(3<<100+0)'); 1276 vrfy(hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1), 1277 '1112: hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1)'); 1278 1279 /* 1280 * catalan testing 1281 */ 1282 vrfy(catalan(2) == 2, '1113: catalan(2) == 2'); 1283 vrfy(catalan(3) == 5, '1114: catalan(3) == 5'); 1284 vrfy(catalan(4) == 14, '1115: catalan(4) == 14'); 1285 vrfy(catalan(20) == 6564120420, '1116: catalan(20) == 6564120420'); 1286 1287 /* 1288 * bernoulli builtin function testing 1289 */ 1290 vrfy(bernoulli(0) == 1, '1117: bernoulli(0) == 1'); 1291 vrfy(bernoulli(1) == -1/2, '1118: bernoulli(1) == -1/2'); 1292 vrfy(bernoulli(2) == 1/6, '1119: bernoulli(2) == 1/6'); 1293 vrfy(bernoulli(3) == 0, '1120: bernoulli(3) == 0'); 1294 vrfy(bernoulli(4) == -1/30, '1121: bernoulli(4) == -1/30'); 1295 vrfy(bernoulli(5) == 0, '1122: bernoulli(5) == 0'); 1296 vrfy(bernoulli(6) == 1/42, '1123: bernoulli(6) == 1/42'); 1297 vrfy(bernoulli(32) == -7709321041217/510, 1298 '1124: bernoulli(32) == -7709321041217/510'); 1299 1300 /* 1301 * euler function testing 1302 */ 1303 vrfy(euler(0) == 1, '1125: euler(0) == 1'); 1304 vrfy(euler(1) == 0, '1126: euler(1) == 0'); 1305 vrfy(euler(2) == -1, '1127: euler(2) == -1'); 1306 vrfy(euler(3) == 0, '1128: euler(3) == 0'); 1307 vrfy(freeeuler() == null(), '1129: freeeuler() == null()'); 1308 vrfy(euler(4) == 5, '1130: euler(4) == 5'); 1309 vrfy(euler(5) == 0, '1131: euler(5) == 0'); 1310 vrfy(euler(6) == -61, '1132: euler(6) == -61'); 1311 vrfy(euler(32) == 177519391579539289436664789665, 1312 '1130: euler(32) == 177519391579539289436664789665'); 1313 vrfy(freeeuler() == null(), '1133: freeeuler() == null()'); 1314 1315 /* 1316 * digit with non-10 base 1317 */ 1318 a = 123456.789; 1319 print '1134: a = 123456.789'; 1320 vrfy(digit(a, 6, 100) == 0, '1135: digit(a, 6, 100) == 0'); 1321 vrfy(digit(a, 5, 100) == 0, '1136: digit(a, 5, 100) == 0'); 1322 vrfy(digit(a, 4, 100) == 0, '1137: digit(a, 4, 100) == 0'); 1323 vrfy(digit(a, 3, 100) == 0, '1138: digit(a, 3, 100) == 0'); 1324 vrfy(digit(a, 2, 100) == 12, '1139: digit(a, 2, 100) == 12'); 1325 vrfy(digit(a, 1, 100) == 34, '1140: digit(a, 1, 100) == 34'); 1326 vrfy(digit(a, 0, 100) == 56, '1141: digit(a, 0, 100) == 56'); 1327 vrfy(digit(a, -1, 100) == 78, '1142: digit(a, -1, 100) == 78'); 1328 vrfy(digit(a, -2, 100) == 90, '1143: digit(a, -2, 100) == 90'); 1329 vrfy(digit(a, -3, 100) == 0, '1144: digit(a, -3, 100) == 0'); 1330 vrfy(digit(a, -4, 100) == 0, '1145: digit(a, -4, 100) == 0'); 1331 vrfy(digit(a, -5, 100) == 0, '1146: digit(a, -5, 100) == 0'); 1332 vrfy(digit(a, -6, 100) == 0, '1146: digit(a, -6, 100) == 0'); 1333 1334 /* 1335 * digits with a non-10 base 1336 */ 1337 vrfy(digits(a, 100) == 3, '1147: digits(a, 100) == 3'); 1338 vrfy(digits(2^256-1, 256) == 32,'1148: digits(2^256-1, 256) == 32'); 1339 1340 /* 1341 * places with a non-10 base 1342 */ 1343 vrfy(places(0.0123, 2) == -1, '1149: places(0.0123, 2) == -1'); 1344 vrfy(places(0.625, 2) == 3, '1150: places(0.625, 2) == 3'); 1345 vrfy(places(0.625, 8) == 1, '1151: places(0.625, 8) == 1'); 1346 vrfy(places(171/2^712, 2) == 712, 1347 '1152: places(171/2^7120.625, 2) == 712'); 1348 vrfy(places(171/2^712, 64) == 119, 1349 '1152: places(171/2^7120.625, 64) == 119'); 1350 1351 /* 1352 * verify sleep 1353 */ 1354 vrfy(sleep(1/5) == null(), '1153: sleep(1/5) == null()'); 1355 vrfy(sleep(1/100) == null(), '1154: sleep(1/100) == null()'); 1356 1357 /* 1358 * verify calcpath 1359 */ 1360 vrfy(isstr(calcpath()), '1155: isstr(calcpath())'); 1361 1362 /* 1363 * ssq use of lists 1364 */ 1365 vrfy(ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204, 1366 '1156: ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204'); 1367 1368 /* 1369 * quomod 5th argument rounding tests 1370 */ 1371 vrfy(quomod(10,-3,a,b,0) == 1, '1157: vrfy(quomod(10,-3,a,b,0) == 1'); 1372 vrfy(a == -4, '1158: a == -4'); 1373 vrfy(b == -2, '1159: b == -2'); 1374 vrfy(quomod(-10,-3,a,b,1) == 1, '1160: vrfy(quomod(-10,-3,a,b,1) == 1'); 1375 vrfy(a == 4, '1161: a == 4'); 1376 vrfy(b == 2, '1162: b == 2'); 1377 vrfy(quomod(10,3,a,b,2) == 1, '1163: vrfy(quomod(10,3,a,b,2) == 1'); 1378 vrfy(a == 3, '1164: a == 3'); 1379 vrfy(b == 1, '1165: b == 1'); 1380 vrfy(quomod(-10,3,a,b,3) == 1, '1166: vrfy(quomod(-10,3,a,b,3) == 1'); 1381 vrfy(a == -4, '1167: a == -4'); 1382 vrfy(b == 2, '1168: b == 2'); 1383 vrfy(quomod(10,-3,a,b,4) == 1, '1169: vrfy(quomod(10,-3,a,b,4) == 1'); 1384 vrfy(a == -3, '1170: a == -3'); 1385 vrfy(b == 1, '1171: b == 1'); 1386 vrfy(quomod(-10,-3,a,b,5) == 1, '1172: vrfy(quomod(-10,-3,a,b,5) == 1'); 1387 vrfy(a == 3, '1173: a == 3'); 1388 vrfy(b == -1, '1174: b == -1'); 1389 vrfy(quomod(10,3,a,b,6) == 1, '1175: vrfy(quomod(10,3,a,b,6) == 1'); 1390 vrfy(a == 3, '1176: a == 3'); 1391 vrfy(b == 1, '1177: b == 1'); 1392 vrfy(quomod(-10,3,a,b,7) == 1, '1178: vrfy(quomod(-10,3,a,b,7) == 1'); 1393 vrfy(a == -4, '1179: a == -4'); 1394 vrfy(b == 2, '1180: b == 2'); 1395 vrfy(quomod(10,-3,a,b,8) == 1, '1181: vrfy(quomod(10,-3,a,b,8) == 1'); 1396 vrfy(a == -4, '1182: a == -4'); 1397 vrfy(b == -2, '1183: b == -2'); 1398 vrfy(quomod(-10,-3,a,b,9) == 1, '1184: vrfy(quomod(-10,-3,a,b,9) == 1'); 1399 vrfy(a == 3, '1185: a == 3'); 1400 vrfy(b == -1, '1186: b == -1'); 1401 vrfy(quomod(10,3,a,b,10) == 1, '1187: vrfy(quomod(10,3,a,b,10) == 1'); 1402 vrfy(a == 4, '1188: a == 4'); 1403 vrfy(b == -2, '1189: b == -2'); 1404 vrfy(quomod(-10,3,a,b,11) == 1, '1190: vrfy(quomod(-10,3,a,b,11) == 1'); 1405 vrfy(a == -4, '1191: a == -4'); 1406 vrfy(b == 2, '1192: b == 2'); 1407 vrfy(quomod(10,-3,a,b,12) == 1, '1193: vrfy(quomod(10,-3,a,b,12) == 1'); 1408 vrfy(a == -3, '1194: a == -3'); 1409 vrfy(b == 1, '1195: b == 1'); 1410 vrfy(quomod(-10,-3,a,b,13) == 1, 1411 '1196: vrfy(quomod(-10,-3,a,b,13) == 1'); 1412 vrfy(a == 4, '1197: a == 4'); 1413 vrfy(b == 2, '1198: b == 2'); 1414 vrfy(quomod(10,3,a,b,14) == 1, '1199: vrfy(quomod(10,3,a,b,14) == 1'); 1415 vrfy(a == 4, '1200: a == 4'); 1416 vrfy(b == -2, '1201: b == -2'); 1417 vrfy(quomod(-10,3,a,b,15) == 1, '1202: vrfy(quomod(-10,3,a,b,15) == 1'); 1418 vrfy(a == -4, '1203: a == -4'); 1419 vrfy(b == 2, '1204: b == 2'); 1420 1421 /* runtime(), systime(), usertime() return numeric values */ 1422 vrfy(isnum(runtime()), '1205: isnum(runtime())'); 1423 vrfy(isnum(systime()), '1206: isnum(systime())'); 1424 vrfy(isnum(usertime()), '1207: isnum(usertime())'); 1425 1426 /* more jacobi tests */ 1427 vrfy(jacobi(987897,987) == 0, '1208: jacobi(987897,987) == 0'); 1428 vrfy(jacobi(897,987) == 0, '1209: jacobi(897,987) == 0'); 1429 vrfy(jacobi(987,897) == 0, '1210: jacobi(987,897) == 0'); 1430 vrfy(jacobi(90,897) == 0, '1211: jacobi(90,897) == 0'); 1431 vrfy(jacobi(45,897) == 0, '1212: jacobi(45,897) == 0'); 1432 vrfy(jacobi(897,45) == 0, '1213: jacobi(897,45) == 0'); 1433 vrfy(jacobi(42,45) == 0, '1214: jacobi(42,45) == 0'); 1434 vrfy(jacobi(21,45) == 0, '1215: jacobi(21,45) == 0'); 1435 vrfy(jacobi(45,21) == 0, '1216: jacobi(45,21) == 0'); 1436 vrfy(jacobi(3,21) == 0, '1217: jacobi(3,21) == 0'); 1437 vrfy(jacobi(0,21) == 0, '1218: jacobi(0,21) == 0'); 1438 vrfy(jacobi(0,20003) == 0, '1219: jacobi(0,20003) == 0'); 1439 vrfy(jacobi(1,20003) == 1, '1220: jacobi(1,20003) == 1'); 1440 vrfy(jacobi(1236,20003) == 1, '1221: jacobi(1236,20003) == 1'); 1441 vrfy(jacobi(618,20003) == -1, '1222: jacobi(618,20003) == -1'); 1442 vrfy(jacobi(309,20003) == 1, '1223: jacobi(309,20003) == 1'); 1443 vrfy(jacobi(227,309) == 1, '1224: jacobi(227,309) == 1'); 1444 vrfy(jacobi(82,227) == 1, '1225: jacobi(82,227) == 1'); 1445 vrfy(jacobi(41,227) == -1, '1226: jacobi(41,227) == -1'); 1446 vrfy(jacobi(22,41) == -1, '1227: jacobi(22,41) == -1'); 1447 vrfy(jacobi(11,41) == -1, '1228: jacobi(11,41) == -1'); 1448 vrfy(jacobi(8,11) == -1, '1229: jacobi(8,11) == -1'); 1449 vrfy(jacobi(4,11) == 1, '1230: jacobi(4,11) == 1'); 1450 vrfy(jacobi(2,11) == -1, '1231: jacobi(2,11) == -1'); 1451 vrfy(jacobi(1,11) == 1, '1232: jacobi(1,11) == 1'); 1452 vrfy(jacobi(0,11) == 0, '1233: jacobi(0,11) == 0'); 1453 vrfy(jacobi(0,0) == 0, '1234: jacobi(0,0) == 0'); 1454 vrfy(jacobi(-1,0) == 0, '1235: jacobi(-1,0) == 0'); 1455 vrfy(jacobi(-1,-1) == 0, '1236: jacobi(-1,-1) == 0'); 1456 vrfy(jacobi(0,-1) == 0, '1237: jacobi(0,-1) == 0'); 1457 1458 /* 1459 * NOTE: Function tests are continued in test_functionss() 1460 * starting at test 9000. 1461 */ 1462 1463 print '1293: Ending test_functions'; 1464} 1465print '017: parsed test_functions()'; 1466 1467 1468/* 1469 * _test_underscore - test use of _'s in identifiers 1470 */ 1471_ = 49; 1472print '018: _ = 49'; 1473__ = 63; 1474print "019: __ = 63"; 1475define _test_underscore() 1476{ 1477 local _a = 27; 1478 local __a = 23209; 1479 1480 print "1294: Beginning _test_underscore"; 1481 1482 vrfy(_a == 27, '1295: _a == 27'); 1483 vrfy(_ == 49, '1296: _ == 49'); 1484 vrfy(__ == 63, '1297: __ == 63'); 1485 vrfy(__a == 23209, '1298: __a == 23209'); 1486 1487 print "1299: Ending _test_underscore"; 1488} 1489print '020: parsed _test_underscore'; 1490 1491 1492/* 1493 * place holder for any print items 1494 */ 1495print "021:", "reserved for future use"; 1496print "022:": " reserved for future use"; 1497 1498 1499/* 1500 * Test associations 1501 */ 1502define test_assoc() 1503{ 1504 static a; 1505 static b; 1506 local A; 1507 1508 print '1300: Beginning associations test'; 1509 1510 a = assoc(); 1511 vrfy(size(a) == 0, '1301: size(a) == 0'); 1512 a["curds"] = 13; 1513 print '1302: a["curds"] = 13'; 1514 vrfy(a["curds"] == 13, '1303: a["curds"] == 13'); 1515 a[13] = 17; 1516 print '1304: a[13] = 17'; 1517 vrfy(a[13] == 17, '1305: a[13] == 17'); 1518 vrfy(a[a["curds"]] == 17, '1306: a[a["curds"]] == 17'); 1519 a[17] = 19; 1520 print '1307: a[17] = 19'; 1521 vrfy(a[17] == 19, '1308: a[17] == 19'); 1522 vrfy(a[a["curds"]+4] == 19, '1309: a[a["curds"]+4] == 19'); 1523 vrfy(size(a) == 3, '1310: size(a) == 3'); 1524 vrfy(a[[search(a,17)]] == 17, '1311: (a[[search(a,17)]] == 17'); 1525 vrfy(isnull(search(a,16)), '1312: isnull(search(a,16))'); 1526 a["curds","whey"] = "spider"; 1527 print '1313: a["curds","whey"] = "spider"'; 1528 vrfy(a["curds","whey"] == "spider", 1529 '1314: a["curds","whey"] == "spider"'); 1530 vrfy(a[[rsearch(a,"spider")]] == "spider", 1531 '1315: a[[rsearch(a,"spider")]] == "spider"'); 1532 b = a; 1533 print '1316: b = a'; 1534 vrfy(b[17] == 19, '1317: b[17] == 19'); 1535 vrfy(a == b, '1318: a == b'); 1536 vrfy(isassoc(a) == 1, '1319: isassoc(a) == 1'); 1537 vrfy(isassoc(1) == 0, '1320: isassoc(1) == 0'); 1538 A = assoc(); 1539 vrfy(quomod(13, 5, A[1], A[2]) == 1, 1540 '1321: quomod(13, 5, A[1], A[2]) == 1'); 1541 vrfy(A[1] == 2, '1322: A[1] == 2'); 1542 vrfy(A[2] == 3, '1323: A[2] == 3'); 1543 1544 print '1324: Ending associations test'; 1545} 1546print '023: parsed test_assoc()'; 1547 1548 1549/* 1550 * Test lists 1551 */ 1552define test_list() 1553{ 1554 static a; 1555 static b; 1556 static x = list(11,13,17,23,29); 1557 static y0 = list(1,3,7,3,9); 1558 static y1 = list(-9,-7,-3,-7,-1); 1559 static y2 = list(-9,-7,-3,3,9); 1560 static y3 = list(1,3,7,-7,-1); 1561 static y4 = list(1,3,-3,3,-1); 1562 local A,B,C,D,E; 1563 local y,z; 1564 local list1, list2; 1565 1566 print '1400: Beginning list test'; 1567 1568 a = list(2,3,5); 1569 vrfy(a == list(2,3,5), '1401: a == list(2,3,5)'); 1570 vrfy(a[[0]] == 2, '1402: a[[0]] == 2'); 1571 vrfy(a[[1]] == 3, '1403: a[[1]] == 3'); 1572 vrfy(a[[2]] == 5, '1404: a[[2]] == 5'); 1573 vrfy(size(a) == 3, '1405: size(a) == 3'); 1574 vrfy(search(a,3) == 1, '1406: search(a,3) == 1'); 1575 vrfy(isnull(search(a,3,2)), '1407: isnull(search(a,3,2))'); 1576 vrfy(rsearch(a,3,2) == 1, '1408: rsearch(a,3,2) == 1'); 1577 push(a,7); 1578 print '1409: push(a,7)'; 1579 vrfy(search(a,7) == 0, '1410: search(a,7) == 0'); 1580 vrfy(pop(a) == 7, '1411: pop(a) == 7'); 1581 vrfy(size(a) == 3, '1412: size(a) == 3'); 1582 append(a,7); 1583 print '1413: append(a,7)'; 1584 vrfy(search(a,7) == 3, '1414: search(a,7) == 3'); 1585 vrfy(size(a) == 4, '1415: size(a) == 4'); 1586 vrfy(remove(a) == 7, '1416: remove(a) == 7'); 1587 vrfy(size(a) == 3, '1417: size(a) == 3'); 1588 b = a; 1589 print '1418: b = a'; 1590 insert(a,1,7); 1591 print '1419: insert(a,1,7)'; 1592 vrfy(search(a,2) == 0, '1420: search(a,2) == 0'); 1593 vrfy(search(a,7) == 1, '1421: search(a,7) == 1'); 1594 vrfy(search(a,3) == 2, '1422: search(a,3) == 2'); 1595 vrfy(search(a,5) == 3, '1423: search(a,5) == 3'); 1596 vrfy(size(a) == 4, '1424: size(a) == 4'); 1597 vrfy(delete(a,1) == 7, '1425: remove(a) == 7'); 1598 vrfy(search(a,2) == 0, '1426: search(a,2) == 0'); 1599 vrfy(search(a,3) == 1, '1427: search(a,3) == 1'); 1600 vrfy(search(a,5) == 2, '1428: search(a,5) == 2'); 1601 vrfy(size(a) == 3, '1429: size(a) == 3'); 1602 vrfy(a == b, '1430: a == b'); 1603 A = list(1,2,3); 1604 print '1431: A = list(1,2,3)'; 1605 B = list(4,5); 1606 print '1432: B = list(4,5)'; 1607 C = join(A,B); 1608 print '1433: C = join(A,B)'; 1609 D = list(1,2,3,4,5); 1610 print '1434: D = list(1,2,3,4,5)'; 1611 vrfy(C == D, '1435: C == D'); 1612 E = list(5,4,3,2,1); 1613 print '1436: E = list(5,4,3,2,1)'; 1614 vrfy(reverse(D) == E, '1437: reverse(D) == E'); 1615 vrfy(sort(list(1,3,5,2,4))==D,'1438: sort(list(1,3,5,2,4))==D'); 1616 vrfy(head(D,2) == list(1,2), '1439: head(D,2) == list(1,2)'); 1617 vrfy(head(D,-2) == list(2,1), '1440: head(D,-2) == list(2,1)'); 1618 vrfy(head(D,5) == D, '1441: head(D,5) == D'); 1619 vrfy(head(D,6) == D, '1442: head(D,6) == D'); 1620 vrfy(head(D,-5) == E, '1443: head(D,-5) == E'); 1621 vrfy(head(D,-6) == E, '1444: head(D,-6) == E'); 1622 vrfy(tail(E,2) == list(2,1), '1445: tail(E,2) == list(2,1)'); 1623 vrfy(tail(E,-2) == list(1,2), '1446: tail(E,-2) == list(1,2)'); 1624 vrfy(tail(E,5) == E, '1447: tail(E,5) == E'); 1625 vrfy(tail(E,6) == E, '1448: tail(E,6) == E'); 1626 vrfy(tail(E,-5) == D, '1449: tail(E,-5) == D'); 1627 vrfy(tail(E,-6) == D, '1450: tail(E,-6) == D'); 1628 vrfy(segment(D,1,3) == list(2,3,4), 1629 '1451: segment(D,1,3) == list(2,3,4)'); 1630 vrfy(segment(D,3,1) == list(4,3,2), 1631 '1452: segment(D,3,1) == list(4,3,2)'); 1632 vrfy(segment(D,0,2) == head(D,3), 1633 '1453: segment(D,0,2) == head(D,3)'); 1634 vrfy(segment(D,2,0) == tail(E,3), 1635 '1454: segment(D,2,0) == tail(E,3)'); 1636 vrfy(segment(D,0,4) == head(D,5), 1637 '1455: segment(D,0,4) == head(D,5)'); 1638 vrfy(segment(D,4,0) == head(E,5), 1639 '1456: segment(D,4,0) == head(E,5)'); 1640 vrfy(segment(D,3,4) == tail(D,2), 1641 '1457: segment(D,3,4) == tail(D,2)'); 1642 vrfy(segment(D,4,3) == head(E,2), 1643 '1458: segment(D,4,3) == head(E,2)'); 1644 for (y=0; y < size(D); ++y) { 1645 for (z=y; z < size(D); ++z) { 1646 if (D != join(head(D,y), segment(D,y,z), tail(D,size(D)-z-1))) { 1647 prob(strcat("join loop failed at y=",str(y)," z=",str(z))); 1648 } 1649 } 1650 } 1651 print '1459: join loop test'; 1652 vrfy(mod(x,10,0) == y0, '1460: mod(x,10,0) == y0'); 1653 vrfy(mod(x,10,1) == y1, '1461: mod(x,10,1) == y1'); 1654 vrfy(mod(x,10,2) == y0, '1462: mod(x,10,2) == y0'); 1655 vrfy(mod(x,10,3) == y1, '1463: mod(x,10,3) == y1'); 1656 vrfy(mod(x,10,4) == y0, '1464: mod(x,10,4) == y0'); 1657 vrfy(mod(x,10,5) == y1, '1465: mod(x,10,5) == y1'); 1658 vrfy(mod(x,10,6) == y0, '1466: mod(x,10,6) == y0'); 1659 vrfy(mod(x,10,7) == y1, '1467: mod(x,10,7) == y1'); 1660 vrfy(mod(x,10,8) == y2, '1468: mod(x,10,8) == y2'); 1661 vrfy(mod(x,10,9) == y3, '1469: mod(x,10,9) == y3'); 1662 vrfy(mod(x,10,10) == y2, '1470: mod(x,10,10) == y2'); 1663 vrfy(mod(x,10,11) == y3, '1471: mod(x,10,11) == y3'); 1664 vrfy(mod(x,10,12) == y2, '1472: mod(x,10,12) == y2'); 1665 vrfy(mod(x,10,13) == y3, '1473: mod(x,10,13) == y3'); 1666 vrfy(mod(x,10,14) == y2, '1474: mod(x,10,14) == y2'); 1667 vrfy(mod(x,10,15) == y3, '1475: mod(x,10,15) == y3'); 1668 vrfy(mod(x,10,16) == y4, '1476: mod(x,10,16) == y4'); 1669 vrfy(mod(x,10,16) == y4, '1477: mod(x,10,16) == y4'); 1670 vrfy(mod(x,10,18) == y4, '1478: mod(x,10,18) == y4'); 1671 vrfy(mod(x,10,19) == y4, '1479: mod(x,10,18) == y4'); 1672 vrfy(mod(x,10,20) == y4, '1480: mod(x,10,20) == y4'); 1673 vrfy(mod(x,10,21) == y4, '1481: mod(x,10,21) == y4'); 1674 vrfy(mod(x,10,22) == y4, '1482: mod(x,10,22) == y4'); 1675 vrfy(mod(x,10,23) == y4, '1483: mod(x,10,23) == y4'); 1676 vrfy(mod(x,10,24) == y4, '1484: mod(x,10,24) == y4'); 1677 vrfy(mod(x,10,25) == y4, '1485: mod(x,10,25) == y4'); 1678 vrfy(mod(x,10,26) == y4, '1486: mod(x,10,26) == y4'); 1679 vrfy(mod(x,10,27) == y4, '1487: mod(x,10,27) == y4'); 1680 vrfy(mod(x,10,28) == y4, '1488: mod(x,10,28) == y4'); 1681 vrfy(mod(x,10,29) == y4, '1489: mod(x,10,29) == y4'); 1682 vrfy(mod(x,10,30) == y4, '1490: mod(x,10,30) == y4'); 1683 vrfy(mod(x,10,31) == y4, '1491: mod(x,10,31) == y4'); 1684 list1 = list(3,1,"x",2,null()); 1685 print '1492: list1 = list(3,1,"x",2,null())'; 1686 list2 = list(null(),1,2,3,"x"); 1687 print '1493: list2 = list(null(),1,2,3,"x")'; 1688 vrfy(sort(list1) == list2, '1494: sort(list1) == list2'); 1689 A = list(1,2,3,4); 1690 print '1495: A = list(1,2,3,4)'; 1691 B = makelist(4) = {1,2,3,4}; 1692 print '1496: B = makelist(4) = {1,2,3,4}'; 1693 vrfy(A == B, '1497: A == B'); 1694 vrfy((A = {,,5}) == list(1,2,5,4), 1695 '1498: (A = {,,5}) == list(1,2,5,4)'); 1696 1697 print '1499: Ending list test'; 1698} 1699print '024: parsed test_list()'; 1700 1701 1702/* 1703 * Test rand - a55 shuffle pseudo-random number generator 1704 */ 1705define test_rand() 1706{ 1707 local init; /* initial generator state */ 1708 local state0; /* a generator state */ 1709 local tmp; 1710 local n; 1711 1712 print '1500: Beginning rand test'; 1713 1714 /* test save and restore of the initial state */ 1715 tmp = srand(0); 1716 print '1501: tmp = srand(0)'; 1717 init = srand(); 1718 print '1502: init = srand()'; 1719 state0 = srand(0); 1720 print '1503: state0 = srand(0)'; 1721 vrfy(state0 == init, '1504: state0 == init'); 1722 1723 /* test the subtractive 100 shuffle generator */ 1724 tmp = srand(0); 1725 print '1505: tmp = srand(0)'; 1726 vrfy(rand() == 0x1fe5b46fba7e069d, \ 1727 '1506: rand() == 0x1fe5b46fba7e069d'); 1728 vrfy(rand() == 0x308d32d9bdf2dc6f, \ 1729 '1507: rand() == 0x308d32d9bdf2dc6f'); 1730 tmp = srand(init); 1731 print '1508: tmp = srand(init)'; 1732 vrfy(rand() == 0x1fe5b46fba7e069d, \ 1733 '1509: rand() == 0x1fe5b46fba7e069d'); 1734 vrfy(rand() == 0x308d32d9bdf2dc6f, \ 1735 '1510: rand() == 0x308d32d9bdf2dc6f'); 1736 1737 /* test range interface */ 1738 tmp = srand(0); 1739 print '1511: tmp = srand(0)'; 1740 vrfy(rand(12345678901234567890) == 0x1fe5b46fba7e069d, \ 1741 '1512: rand(12345678901234567890) == 0x1fe5b46fba7e069d'); 1742 vrfy(rand(216091) == 0xc234, '1513: rand(216091) == 0xc234'); 1743 vrfy(rand(100) == 0x59, '1514: rand(100) == 0x59'); 1744 vrfy(rand(-46,46) == 0x2d, '1515: rand(-46,46) == 0x2d'); 1745 tmp = srand(0); 1746 print '1516: tmp = srand(0)'; 1747 vrfy(rand(2^64) == 0x1fe5b46fba7e069d, \ 1748 '1517: rand(2^64) == 0x1fe5b46fba7e069d'); 1749 vrfy(rand(0,2^64) == 0x308d32d9bdf2dc6f, \ 1750 '1518: rand(0,2^64) == 0x308d32d9bdf2dc6f'); 1751 1752 /* test different forms of seeding the initial state */ 1753 tmp = srand(0); 1754 print '1519: tmp = srand(0)'; 1755 vrfy(srand() == init, '1520: srand() == init'); 1756 tmp = srand(0x87e6ec938ff55aa5<<64); 1757 print '1521: tmp = srand(0x87e6ec938ff55aa5<<64)'; 1758 print '1522: test disabled'; 1759 tmp = srand(state0); 1760 print '1523: tmp = srand(state0)'; 1761 vrfy(srand() == init, '1524: srand() == init'); 1762 tmp = srand(init); 1763 print '1525: tmp = srand(init)'; 1764 vrfy(srand() == init, '1526: srand() == init'); 1765 vrfy(tmp == init, '1527: tmp == init'); 1766 1767 /* test the bit length interface */ 1768 tmp = srand(0); 1769 print '1528: tmp = srand(0)'; 1770 vrfy(randbit(64) == 0x1fe5b46fba7e069d, \ 1771 '1529: randbit(64) == 0x1fe5b46fba7e069d'); 1772 vrfy(randbit(128) == 0x308d32d9bdf2dc6f45d3e3b3361b79e4, \ 1773 '1530: randbit(128) == 0x308d32d9bdf2dc6f45d3e3b3361b79e4'); 1774 vrfy(randbit(64) == 0xd4ef1e3336022d81, \ 1775 '1531: randbit(64) == 0xd4ef1e3336022d81'); 1776 vrfy(randbit(128) == 0x66b086e6c34e42124a1fc5d4e5c6f598, \ 1777 '1532: randbit(128) == 0x66b086e6c34e42124a1fc5d4e5c6f598'); 1778 tmp = srand(0); 1779 print '1533: tmp = srand(0)'; 1780 vrfy(randbit(32) == 0x1fe5b46f, '1534: randbit(32) == 0x1fe5b46f'); 1781 vrfy(randbit(32) == 0xba7e069d, '1535: randbit(32) == 0xba7e069d'); 1782 vrfy(randbit(1) == 0x0, '1536: randbit(1) == 0x0'); 1783 vrfy(randbit(5) == 0xc, '1537: randbit(5) == 0xc'); 1784 vrfy(randbit(33) == 0x46996cde, '1538: randbit(33) == 0x46996cde'); 1785 vrfy(randbit(25) == 0x1f2dc6f, '1539: randbit(25) == 0x1f2dc6f'); 1786 vrfy(randbit(2) == 0x1, '1540: randbit(2) == 0x1'); 1787 vrfy(randbit(13) == 0x2e9, '1541: randbit(13) == 0x2e9'); 1788 vrfy(randbit(18) == 0x3c766, '1542: randbit(18) == 0x3c766'); 1789 vrfy(randbit(8) == 0x6c, '1543: randbit(8) == 0x6c'); 1790 vrfy(randbit(9) == 0x6d, '1544: randbit(9) == 0x6d'); 1791 vrfy(randbit(70) == 0x39e4d4ef1e3336022d, \ 1792 '1545: randbit(70) == 0x39e4d4ef1e3336022d'); 1793 print '1546: test unused'; 1794 vrfy(randbit(8) == 0x81, '1547: randbit(8) == 0x81'); 1795 vrfy(randbit(65) == 0xcd610dcd869c8424, \ 1796 '1548: randbit(65) == 0xcd610dcd869c8424'); 1797 vrfy(randbit(63) == 0x4a1fc5d4e5c6f598, \ 1798 '1549: randbit(63) == 0x4a1fc5d4e5c6f598'); 1799 1800 /* check to be sure that the srand(1) bug was fixed */ 1801 tmp = srand(1); 1802 print '1550: tmp = srand(1)'; 1803 n = 1; 1804 print '1551: n = 1'; 1805 vrfy(num(n), '1552: num(n)'); 1806 vrfy(den(n), '1553: den(n)'); 1807 vrfy(randbit(64) == 0xbf989a4c504a541d, \ 1808 '1554: randbit(64) == 0xbf989a4c504a541d'); 1809 /* test randbit skip interface */ 1810 tmp = srand(0); 1811 print '1555: tmp = srand(0)'; 1812 vrfy(randbit(20) == 0x1fe5b, '1556: randbit(20) == 0x1fe5b'); 1813 vrfy(randbit(20) == 0x46fba, '1557: randbit(20) == 0x46fba'); 1814 vrfy(randbit(20) == 0x7e069, '1558: randbit(20) == 0x7e069'); 1815 vrfy(randbit(20) == 0xd308d, '1559: randbit(20) == 0xd308d'); 1816 tmp = srand(0); 1817 print '1560: tmp = srand(0)'; 1818 vrfy(randbit(-20) == 20, '1561: randbit(-20) == 20'); 1819 vrfy(randbit(20) == 290746, '1562: randbit(20) == 290746'); 1820 vrfy(randbit(-20) == 20, '1563: randbit(-20) == 20'); 1821 vrfy(randbit(20) == 864397, '1564: randbit(20) == 864397'); 1822 1823 /* test randbit without and arg */ 1824 tmp = srand(0); 1825 print '1565: tmp = srand(0)'; 1826 vrfy(randbit() == 0, '1566: randbit() == 0'); 1827 vrfy(randbit() == 0, '1567: randbit() == 0'); 1828 vrfy(randbit() == 0, '1568: randbit() == 0'); 1829 vrfy(randbit() == 1, '1569: randbit() == 1'); 1830 1831 /* test seed() as best as we can */ 1832 vrfy(seed() >= 0, '1570: seed() >= 0'); 1833 vrfy(seed() < 2^64, '1571: seed() < 2^64'); 1834 vrfy(isrand(srand(seed())), '1572: isrand(srand(seed()))'); 1835 1836 print '1573: Ending rand test'; 1837} 1838print '025: parsed test_rand()'; 1839 1840 1841/* 1842 * Config mode/base testing 1843 */ 1844define test_mode() 1845{ 1846 local tmp; 1847 1848 print '1600: Beginning mode/base test'; 1849 1850 tmp = config("mode", "frac"); 1851 print '1601: tmp = config("mode", "frac")'; 1852 tmp = config("mode", "frac"); 1853 print '1602: tmp = config("mode", "frac")'; 1854 vrfy(base() == 1/3, '1603: base() == 1/3'); 1855 1856 tmp = config("mode", "int"); 1857 print '1604: tmp = config("mode", "int")'; 1858 vrfy(tmp == "fraction", '1605: tmp == "fraction"'); 1859 vrfy(base() == -10, '1606: base() == -10'); 1860 1861 tmp = config("mode", "real"); 1862 print '1607: tmp = config("mode", "real")'; 1863 vrfy(tmp == "integer", '1608: tmp == "integer"'); 1864 vrfy(base() == 10, '1609: base() == 10'); 1865 1866 tmp = config("mode", "exp"); 1867 print '1610: tmp = config("mode", "exp")'; 1868 vrfy(tmp == "real", '1611: tmp == "real"'); 1869 vrfy(base() == 1e20, '1612: base() == 1e20'); 1870 1871 tmp = config("mode", "hex"); 1872 print '1613: tmp = config("mode", "hex")'; 1873 vrfy(tmp == "scientific", '1614: tmp == "scientific"'); 1874 vrfy(base() == 16, '1615: base() == 16'); 1875 1876 tmp = config("mode", "oct"); 1877 print '1616: tmp = config("mode", "oct")'; 1878 vrfy(tmp == "hexadecimal", '1617: tmp == "hexadecimal"'); 1879 vrfy(base() == 8, '1618: base() == 8'); 1880 1881 tmp = config("mode", "bin"); 1882 print '1619: tmp = config("mode", "bin")'; 1883 vrfy(tmp == "octal", '1620: tmp == "octal"'); 1884 vrfy(base() == 2, '1621: base() == 2'); 1885 1886 tmp = config("mode", "eng"); 1887 print '1622: tmp = config("mode", "eng")'; 1888 vrfy(tmp == "binary", '1623: tmp == "binary"'); 1889 vrfy(base() == 1000, '1624: base() == 1000'); 1890 1891 tmp = config("mode", "real"); 1892 print '1625: tmp = config("mode", "real")'; 1893 vrfy(tmp == "engineering", '1626: tmp == "engineering"'); 1894 1895 tmp = base(1/3); 1896 print '1627: tmp = base(1/3)'; 1897 vrfy(config("mode") == "fraction", 1898 '1628: config("mode") == "fraction"'); 1899 1900 tmp = base(-10); 1901 print '1629: tmp = base(-10)'; 1902 vrfy(config("mode") == "integer", 1903 '1630: config("mode") == "integer"'); 1904 1905 tmp = base(10); 1906 print '1631: tmp = base(10)'; 1907 vrfy(config("mode") == "real", '1632: config("mode") == "real"'); 1908 1909 tmp = base(1e20); 1910 print '1633: tmp = base(1e20)'; 1911 vrfy(config("mode") == "scientific", 1912 '1634: config("mode") == "scientific"'); 1913 1914 tmp = base(16); 1915 print '1635: tmp = base(16)'; 1916 vrfy(config("mode") == "hexadecimal", \ 1917 '1636: config("mode") == "hexadecimal"'); 1918 1919 tmp = base(8); 1920 print '1637: tmp = base(8)'; 1921 vrfy(config("mode") == "octal", '1638: config("mode") == "octal"'); 1922 1923 tmp = base(2); 1924 print '1639: tmp = base(2)'; 1925 vrfy(config("mode") == "binary",'1640: config("mode") == "binary"'); 1926 1927 tmp = base(1000); 1928 print '1641: tmp = base(1000)'; 1929 vrfy(config("mode") == "engineering", 1930 '1642: config("mode") == "engineering"'); 1931 1932 tmp = base(1/3); 1933 print '1643: tmp = base(1/3)'; 1934 vrfy(str(0x80000000) == "2147483648", \ 1935 '1644: str(0x8000000) == \"2147483648\"'); 1936 vrfy(str(0xffffffff) == "4294967295", \ 1937 '1645: str(0xffffffff) == \"4294967295\"'); 1938 vrfy(str(3e9) == "3000000000", \ 1939 '1646: str(3e9) == \"3000000000\"'); 1940 vrfy(str(1/3) == "1/3", \ 1941 '1647: str(1/3) == \"1/3\"'); 1942 vrfy(str(2e8) == "200000000", \ 1943 '1648: str(2e8) == \"200000000"'); 1944 vrfy(str(200e6) == "200000000", \ 1945 '1649: str(200e6) == \"200000000"'); 1946 vrfy(str(0b100111) == "39", \ 1947 '1650: str(0b100111) == \"39"'); 1948 vrfy(str(07543) == "3939", \ 1949 '1651: str(07543) == \"3939"'); 1950 vrfy(str(7543) == "7543", \ 1951 '1652: str(7543) == \"7543"'); 1952 1953 tmp = base(8); 1954 print '1653: tmp = base(8)'; 1955 vrfy(str(0x80000000) == "020000000000", \ 1956 '1654: str(0x8000000) == \"020000000000\"'); 1957 vrfy(str(0xffffffff) == "037777777777", \ 1958 '1655: str(0xffffffff) == \"037777777777\"'); 1959 vrfy(str(3e9) == "026264057000", \ 1960 '1656: str(3e9) == \"026264057000\"'); 1961 vrfy(str(1/3) == "1/3", \ 1962 '1657: str(1/3) == \"1/3\"'); 1963 vrfy(str(2e8) == "01372741000", \ 1964 '1658: str(2e8) == \"01372741000"'); 1965 vrfy(str(200e6) == "01372741000", \ 1966 '1659: str(200e6) == \"01372741000"'); 1967 vrfy(str(0b100111) == "047", \ 1968 '1660: str(0b100111) == \"047"'); 1969 vrfy(str(07543) == "07543", \ 1970 '1661: str(07543) == \"07543"'); 1971 vrfy(str(7543) == "016567", \ 1972 '1662: str(7543) == \"016567"'); 1973 1974 tmp = base(16); 1975 print '1663: tmp = base(16)'; 1976 vrfy(str(0x80000000) == "0x80000000", \ 1977 '1664: str(0x8000000) == \"0x80000000\"'); 1978 vrfy(str(0xffffffff) == "0xffffffff", \ 1979 '1665: str(0xffffffff) == \"0xffffffff\"'); 1980 vrfy(str(3e9) == "0xb2d05e00", \ 1981 '1666: str(3e9) == \"0xb2d05e00\"'); 1982 vrfy(str(1/3) == "1/3", \ 1983 '1667: str(1/3) == \"1/3\"'); 1984 vrfy(str(2e8) == "0xbebc200", \ 1985 '1668: str(2e8) == \"0xbebc200"'); 1986 vrfy(str(200e6) == "0xbebc200", \ 1987 '1669: str(200e6) == \"0xbebc200"'); 1988 vrfy(str(0b100111) == "0x27", \ 1989 '1670: str(0b100111) == \"0x27"'); 1990 vrfy(str(07543) == "0xf63", \ 1991 '1671: str(07543) == \"0xf63"'); 1992 vrfy(str(7543) == "0x1d77", \ 1993 '1672: str(7543) == \"0x1d77"'); 1994 1995 tmp = base(2); 1996 print '1673: tmp = base(2)'; 1997 vrfy(str(0x80000000) == "0b10000000000000000000000000000000", \ 1998 '1674: str(0x8000000) == \"0b10000000000000000000000000000000\"'); 1999 vrfy(str(0xffffffff) == "0b11111111111111111111111111111111", \ 2000 '1675: str(0xffffffff) == \"0b11111111111111111111111111111111\"'); 2001 vrfy(str(3e9) == "0b10110010110100000101111000000000", \ 2002 '1676: str(3e9) == \"0b10110010110100000101111000000000\"'); 2003 vrfy(str(1/3) == "1/0b11", \ 2004 '1677: str(1/3) == \"1/0b11\"'); 2005 vrfy(str(2e8) == "0b1011111010111100001000000000", \ 2006 '1678: str(2e8) == \"0b1011111010111100001000000000"'); 2007 vrfy(str(200e6) == "0b1011111010111100001000000000", \ 2008 '1679: str(200e6) == \"0b1011111010111100001000000000"'); 2009 vrfy(str(0b100111) == "0b100111", \ 2010 '1680: str(0b100111) == \"0b100111"'); 2011 vrfy(str(07543) == "0b111101100011", \ 2012 '1681: str(07543) == \"0b111101100011"'); 2013 vrfy(str(7543) == "0b1110101110111", \ 2014 '1682: str(7543) == \"0b1110101110111"'); 2015 2016 tmp = base(1e20); 2017 print '1683: tmp = base(1e20)'; 2018 vrfy(str(0x80000000) == "2.147483648e9", \ 2019 '1684: str(0x8000000) == \"2.147483648e9\"'); 2020 vrfy(str(0xffffffff) == "4.294967295e9", \ 2021 '1685: str(0xffffffff) == \"4.294967295e9\"'); 2022 vrfy(str(3e9) == "3e9", \ 2023 '1686: str(3e9) == \"3e9\"'); 2024 vrfy(str(1/3) == "~3.33333333333333333333e-1", \ 2025 '1687: str(1/3) == \"~3.33333333333333333333e-1\"'); 2026 vrfy(str(2e8) == "2e8", \ 2027 '1688: str(2e8) == \"2e8"'); 2028 vrfy(str(200e6) == "2e8", \ 2029 '1689: str(200e6) == \"2e8"'); 2030 vrfy(str(0b100111) == "3.9e1", \ 2031 '1690: str(0b100111) == \"3.9e1"'); 2032 vrfy(str(07543) == "3.939e3", \ 2033 '1691: str(07543) == \"3.939e3"'); 2034 vrfy(str(7543) == "7.543e3", \ 2035 '1692: str(7543) == \"7.543e3"'); 2036 2037 tmp = base(1000); 2038 print '1693: tmp = base(1000)'; 2039 vrfy(str(0x80000000) == "2.147483648e9", \ 2040 '1694: str(0x8000000) == \"2.147483648e9"'); 2041 vrfy(str(0xffffffff) == "4.294967295e9", \ 2042 '1695: str(0xffffffff) == \"4.294967295e9\"'); 2043 vrfy(str(3e9) == "3e9", \ 2044 '1696: str(3e9) == \"3e9\"'); 2045 vrfy(str(1/3) == "~333.33333333333333333333e-3", \ 2046 '1697: str(1/3) == \"~333.33333333333333333333e-3\"'); 2047 vrfy(str(2e8) == "200e6", \ 2048 '1698: str(2e8) == \"200e6"'); 2049 vrfy(str(200e6) == "200e6", \ 2050 '1699: str(200e6) == \"200e6"'); 2051 vrfy(str(0b100111) == "39", \ 2052 '1700: str(0b100111) == \"39"'); 2053 vrfy(str(07543) == "3.939e3", \ 2054 '1701: str(07543) == \"3.939e3"'); 2055 vrfy(str(7543) == "7.543e3", \ 2056 '1702: str(7543) == \"7.543e3"'); 2057 2058 tmp = base(-10); 2059 print '1703: tmp = base(-10)'; 2060 vrfy(str(0x80000000) == "2147483648", \ 2061 '1704: str(0x8000000) == \"2147483648\"'); 2062 vrfy(str(0xffffffff) == "4294967295", \ 2063 '1705: str(0xffffffff) == \"4294967295\"'); 2064 vrfy(str(3e9) == "3000000000", \ 2065 '1706: str(3e9) == \"3000000000\"'); 2066 vrfy(str(1/3) == "~0", \ 2067 '1707: str(1/3) == \"~0\"'); 2068 vrfy(str(2e8) == "200000000", \ 2069 '1708: str(2e8) == \"200000000"'); 2070 vrfy(str(200e6) == "200000000", \ 2071 '1709: str(200e6) == \"200000000"'); 2072 vrfy(str(0b100111) == "39", \ 2073 '1710: str(0b100111) == \"39"'); 2074 vrfy(str(07543) == "3939", \ 2075 '1711: str(07543) == \"3939"'); 2076 vrfy(str(7543) == "7543", \ 2077 '1712: str(7543) == \"7543"'); 2078 2079 tmp = base(10); 2080 print '1713: tmp = base(10)'; 2081 vrfy(str(0x80000000) == "2147483648", \ 2082 '1714: str(0x8000000) == \"2147483648\"'); 2083 vrfy(str(0xffffffff) == "4294967295", \ 2084 '1715: str(0xffffffff) == \"4294967295\"'); 2085 vrfy(str(3e9) == "3000000000", \ 2086 '1716: str(3e9) == \"3000000000\"'); 2087 vrfy(str(1/3) == "~0.33333333333333333333", \ 2088 '1717: str(1/3) == \"~0.33333333333333333333"'); 2089 vrfy(str(2e8) == "200000000", \ 2090 '1718: str(2e8) == \"200000000"'); 2091 vrfy(str(200e6) == "200000000", \ 2092 '1719: str(200e6) == \"200000000"'); 2093 vrfy(str(0b100111) == "39", \ 2094 '1720: str(0b100111) == \"39"'); 2095 vrfy(str(07543) == "3939", \ 2096 '1721: str(07543) == \"3939"'); 2097 vrfy(str(7543) == "7543", \ 2098 '1722: str(7543) == \"7543"'); 2099 2100 /* test base2() functionality */ 2101 vrfy(base2() == 0, '1723: base2() == 0'); 2102 vrfy(base2(0) == 0, '1724: base2(0) == 0'); 2103 vrfy(base2() == 0, '1725: base2() == 0'); 2104 2105 vrfy(base2(16) == 0, '1726: base2(16) == 0'); 2106 vrfy(base2() == 16, '1727: base2() == 16'); 2107 vrfy(str(3e9) == "3000000000 /* 0xb2d05e00 */", 2108 '1728: str(3e9) == "3000000000 /* 0xb2d05e00 */"'); 2109 2110 vrfy(base2(1/3) == 16, '1728: base2(16) == 16'); 2111 vrfy(base2() == 1/3, '1729: base2() == 1/3'); 2112 vrfy(str(23209) == "23209 /* 23209 */", 2113 '1730: str(23209) == "23209 /* 23209 */"'); 2114 vrfy(str(3/2) == "1.5 /* 3/2 */", 2115 '1731: str(3/2) == "1.5 /* 3/2 */"'); 2116 2117 vrfy(base2(8) == 1/3, '1732: base2(8) == 1/3'); 2118 vrfy(base2() == 8, '1733: base2() == 8'); 2119 vrfy(str(23209) == "23209 /* 055251 */", 2120 '1734: str(23209) == "23209 /* 055251 */"'); 2121 vrfy(str(3/2) == "1.5 /* 3/2 */", 2122 '1735: str(3/2) == "1.5 /* 3/2 */"'); 2123 2124 vrfy(base2(2) == 8, '1736: base2(2) == 8'); 2125 vrfy(base2() == 2, '1737: base2() == 2'); 2126 vrfy(str(23209) == "23209 /* 0b101101010101001 */", 2127 '1738: str(23209) == "23209 /* 0b101101010101001 */"'); 2128 vrfy(str(3/2) == "1.5 /* 0b11/0b10 */", 2129 '1739: str(3/2) == "1.5 /* 0b11/0b10 */"'); 2130 2131 vrfy(base2(1e20) == 2, '1740: base2(1e20) == 2'); 2132 vrfy(base2() == 1e20, '1741: base2() == 1e20'); 2133 vrfy(str(23209) == "23209 /* 2.3209e4 */", 2134 '1742: str(23209) == "23209 /* 2.3209e4 */"'); 2135 vrfy(str(3/2) == "1.5 /* 1.5 */", 2136 '1743: str(3/2) == "1.5 /* 1.5 */"'); 2137 2138 vrfy(base2(-10) == 1e20, '1744: base2(-10) == 1e20'); 2139 vrfy(base2() == -10, '1745: base2() == -10'); 2140 vrfy(str(23209) == "23209 /* 23209 */", 2141 '1746: str(23209) == "23209 /* 23209 */"'); 2142 vrfy(str(3/2) == "1.5 /* ~2 */", 2143 '1747: str(3/2) == "1.5 /* ~2 */"'); 2144 2145 vrfy(base2(1000) == -10, '1748: base2(1000) == -1000'); 2146 vrfy(base2() == 1000, '1749: base2() == 1000'); 2147 vrfy(str(23209) == "23209 /* 23.209e3 */", 2148 '1750: str(23209) == "23209 /* 23.209e3 */"'); 2149 vrfy(str(3/2) == "1.5 /* 1.5 */", 2150 '1751: str(3/2) == "1.5 /* 1.5 */"'); 2151 2152 vrfy(base2(10) == 1000, '1752: base2(10) == 1000'); 2153 vrfy(base2() == 10, '1753: base2() == 10'); 2154 vrfy(str(23209) == "23209 /* 23209 */", 2155 '1754: str(23209) == "23209 /* 23209 */"'); 2156 vrfy(str(3/2) == "1.5 /* 1.5 */", 2157 '1755: str(3/2) == "1.5 /* 1.5 */"'); 2158 2159 vrfy(base2(0) == 10, '1756: base2(0) == 10'); 2160 vrfy(base2() == 0, '1757: base2() == 0'); 2161 vrfy(str(23209) == "23209", 2162 '1758: str(23209) == "23209"'); 2163 vrfy(str(3/2) == "1.5", 2164 '1759: str(3/2) == "1.5"'); 2165 2166 vrfy(base() == 10, '1760: base() == 10'); 2167 vrfy(base2() == 0, '1761: base2() == 0'); 2168 2169 print '1762: Ending mode/base test'; 2170} 2171print '026: parsed test_mode()'; 2172 2173 2174/* 2175 * The 1780's and 1790's contain tests for reading resource files. 2176 * 2177 * These tests are done inline near the bottom. 2178 */ 2179 2180 2181/* 2182 * Test objects 2183 */ 2184read -once "surd"; 2185print '027: read -once surd'; 2186/**/ 2187define test_obj() 2188{ 2189 static obj surd a; 2190 static obj surd b; 2191 local PP; 2192 2193 print '1800: Beginning object test'; 2194 2195 surd_type = -1; 2196 vrfy(surd_type == -1, '1801: surd_type == -1'); 2197 a = surd(2,3); 2198 print '1802: a = surd(2,3)'; 2199 vrfy(a == surd(2,3), '1803: a == surd(2,3)'); 2200 vrfy(surd_value(a) == 2+3i, '1804: surd_value(a) == 2+3i'); 2201 vrfy(conj(a) == surd(2,-3), '1805: conj(a) == surd(2,-3)'); 2202 vrfy(norm(a) == 13, '1806: norm(a) == 13'); 2203 vrfy(a+1 == surd(3,3), '1807: a+1 == surd(3,3)'); 2204 b = surd(3,4); 2205 print '1808: b = surd(3,4)'; 2206 vrfy(a+b == surd(5,7), '1809: a+b == surd(5,7)'); 2207 vrfy(a-b == surd(-1,-1), '1810: a-b == surd(-1,-1)'); 2208 vrfy(++a == surd(3,3), '1811: ++a == surd(3,3)'); 2209 vrfy(--a == surd(2,3), '1812: --a == surd(2,3)'); 2210 vrfy(-a == surd(-2,-3), '1813: -a == surd(-2,-3)'); 2211 vrfy(a*2 == surd(4,6), '1814: a*2 == surd(4,6)'); 2212 vrfy(a*b == surd(-6,17), '1815: a*b == surd(-6,17)'); 2213 vrfy(a^2 == surd(-5,12), '1816: a^2 == surd(-5,12)'); 2214 vrfy(scale(a,2) == surd(8,12), '1817: scale(a,2) == surd(8,12)'); 2215 vrfy(a<<3 == surd(16,24), '1818: a<<3 == surd(16,24)'); 2216 vrfy(a/2 == surd(1,1.5), '1819: a/2 == surd(1,1.5)'); 2217 vrfy(a/b == surd(0.72,0.04), '1820: a/b == surd(0.72,0.04)'); 2218 vrfy(1/b == surd(0.12,-0.16), '1821: 1/b == surd(0.12,-0.16)'); 2219 vrfy(inverse(b) == 1/b, '1822: inverse(b) == 1/b'); 2220 vrfy(a != b, '1823: a != b'); 2221 surd_type = 2; 2222 print '1824: surd_type = 2'; 2223 vrfy(surd_type == 2, '1825: surd_type == 2'); 2224 vrfy(sgn(a) == 1, '1826: sgn(a) == 1'); 2225 vrfy(a < b, '1827: a < b'); 2226 vrfy(a <= a, '1828: a < a'); 2227 vrfy(isobj(a) == 1, '1829: isobj(a) == 1'); 2228 2229 obj pt {x,y}, PP = obj pair {A,B} = {obj pt, obj pt}; 2230 print '1830: obj pt {x,y}, PP = obj pair {A,B} = {obj pt, obj pt}'; 2231 2232 print '1831: Ending object test'; 2233} 2234print '028: parsed test_obj()'; 2235 2236 2237/* 2238 * Prime builtin function testing 2239 */ 2240define test_prime() 2241{ 2242 print '1900: Beginning prime builtins test'; 2243 2244 vrfy(isprime(-3) == 1, '1901: isprime(-3) == 1'); 2245 vrfy(isprime(-1) == 0, '1902: isprime(-1) == 0'); 2246 vrfy(isprime(0) == 0, '1903: isprime(0) == 0'); 2247 vrfy(isprime(1) == 0, '1904: isprime(1) == 0'); 2248 vrfy(isprime(2) == 1, '1905: isprime(2) == 1'); 2249 vrfy(isprime(3) == 1, '1906: isprime(3) == 1'); 2250 vrfy(isprime(4) == 0, '1907: isprime(4) == 0'); 2251 vrfy(isprime(5) == 1, '1908: isprime(5) == 1'); 2252 vrfy(isprime(17) == 1, '1909: isprime(17) == 1'); 2253 vrfy(isprime(100) == 0, '1910: isprime(100) == 0'); 2254 vrfy(isprime(21701,-1) == 1, '1911: isprime(21701,-1) == 1'); 2255 vrfy(isprime(65521,-1) == 1, '1912: isprime(65521,-1) == 1'); 2256 vrfy(isprime(65535,-1) == 0, '1913: isprime(65535,-1) == 0'); 2257 vrfy(isprime(65536,-1) == 0, '1914: isprime(65536,-1) == 0'); 2258 vrfy(isprime(1234577) == 1, '1915: isprime(1234577) == 1'); 2259 vrfy(isprime(1234579) == 0, '1916: isprime(1234579) == 0'); 2260 vrfy(isprime(2^31-9) == 0, '1917: isprime(2^31-9) == 0'); 2261 vrfy(isprime(2^31-1) == 1, '1918: isprime(2^31-1) == 1'); 2262 vrfy(isprime(2^31+9) == 0, '1919: isprime(2^31+11) == 0'); 2263 vrfy(isprime(2^31+11) == 1, '1920: isprime(2^31+11) == 1'); 2264 vrfy(isprime(3e9) == 0, '1921: isprime(3e9) == 0'); 2265 vrfy(isprime(3e9+19) == 1, '1922: isprime(3e9+19) == 1'); 2266 vrfy(isprime(2^32-7) == 0, '1923: isprime(2^32-7) == 0'); 2267 vrfy(isprime(2^32-5) == 1, '1924: isprime(2^32-5) == 1'); 2268 vrfy(isprime(2^32,-1) == 0, '1925: isprime(2^32,-1) == 0'); 2269 vrfy(isprime(2^32+1,-1) == -1, '1926: isprime(2^32+1,-1) == -1'); 2270 vrfy(isprime(3^99,2) == 2, '1927: isprime(3^99,2) == 2'); 2271 vrfy(isprime(4^99,2) == 0, '1928: isprime(3^99,2) == 0'); 2272 vrfy(nextprime(-3) == 5, '1929: nextprime(-3) == 5'); 2273 vrfy(nextprime(0) == 2, '1930: nextprime(0) == 2'); 2274 vrfy(nextprime(1) == 2, '1931: nextprime(1) == 2'); 2275 vrfy(nextprime(2) == 3, '1932: nextprime(2) == 3'); 2276 vrfy(nextprime(3) == 5, '1933: nextprime(3) == 5'); 2277 vrfy(nextprime(4) == 5, '1934: nextprime(4) == 5'); 2278 vrfy(nextprime(5) == 7, '1935: nextprime(5) == 7'); 2279 vrfy(nextprime(17) == 19, '1936: nextprime(17) == 19'); 2280 vrfy(nextprime(100) == 101, '1937: nextprime(100) == 101'); 2281 vrfy(nextprime(21701,-1) == 21713, 2282 '1938: nextprime(21701,-1) == 21713'); 2283 vrfy(nextprime(65519) == 65521, 2284 '1939: nextprime(65519) == 65521'); 2285 vrfy(nextprime(65520) == 65521, 2286 '1940: nextprime(65520) == 65521'); 2287 vrfy(nextprime(65521,-1) == 65537, 2288 '1941: nextprime(65521,-1) == 65537'); 2289 vrfy(nextprime(65531) == 65537, 2290 '1942: nextprime(65531) == 65537'); 2291 vrfy(nextprime(65535,-1) == 65537, 2292 '1943: nextprime(65535,-1) == 65537'); 2293 vrfy(nextprime(65536) == 65537, 2294 '1944: nextprime(65536) == 65537'); 2295 vrfy(nextprime(1234576,2)==1234577, 2296 '1945: nextprime(1234576,2)==1234577'); 2297 vrfy(nextprime(2^31-9) == 2^31-1, 2298 '1946: nextprime(2^31-9) == 2^31-1'); 2299 vrfy(nextprime(2^31-1) == 2^31+11, 2300 '1947: nextprime(2^31-1) == 2^31+11'); 2301 vrfy(nextprime(3e9) == 3e9+19,'1948: nextprime(3e9) == 3e9+19'); 2302 vrfy(nextprime(2^32-7) == 2^32-5, 2303 '1949: nextprime(2^32-7) == 2^32-5'); 2304 vrfy(nextprime(2^32,-1) == -1, '1950: nextprime(2^32,-1) == -1'); 2305 vrfy(nextprime(2^32+5,-1) == -1,'1951: nextprime(2^32+5,-1) == -1'); 2306 vrfy(nextprime(3^99,-1) == -1, '1952: nextprime(3^99,-1) == -1'); 2307 vrfy(nextprime(3^99,2) == 2, '1953: nextprime(3^99,2) == 2'); 2308 vrfy(prevprime(-3,-1) == 2, '1954: prevprime(-3,-1) == 2'); 2309 vrfy(prevprime(0,-1) == 0, '1955: prevprime(0,-1) == 0'); 2310 vrfy(prevprime(1,-1) == 0, '1956: prevprime(1,-1) == 0'); 2311 vrfy(prevprime(2,-2) == 0, '1957: prevprime(2,-2) == 0'); 2312 vrfy(prevprime(5) == 3, '1958: prevprime(5) == 3'); 2313 vrfy(prevprime(4) == 3, '1959: prevprime(4) == 3'); 2314 vrfy(prevprime(7) == 5, '1960: prevprime(7) == 5'); 2315 vrfy(prevprime(19) == 17, '1961: prevprime(19) == 17'); 2316 vrfy(prevprime(100) == 97, '1962: prevprime(100) == 97'); 2317 vrfy(prevprime(21713,-1) == 21701, 2318 '1963: prevprime(21713,-1) == 21701'); 2319 vrfy(prevprime(65520) == 65519, 2320 '1964: prevprime(65520) == 65519'); 2321 vrfy(prevprime(65521) == 65519, 2322 '1965: prevprime(65521) == 65519'); 2323 vrfy(prevprime(65522) == 65521, 2324 '1966: prevprime(65520) == 65521'); 2325 vrfy(prevprime(65523) == 65521, 2326 '1967: prevprime(65523) == 65521'); 2327 vrfy(prevprime(65531) == 65521, 2328 '1968: prevprime(65531) == 65521'); 2329 vrfy(prevprime(65535) == 65521, 2330 '1969: prevprime(65535) == 65521'); 2331 vrfy(prevprime(65536) == 65521, 2332 '1970: prevprime(65536) == 65521'); 2333 vrfy(prevprime(65537) == 65521, 2334 '1971: prevprime(65537) == 65521'); 2335 vrfy(prevprime(65539) == 65537, 2336 '1972: prevprime(65539) == 65537'); 2337 vrfy(prevprime(1234578,2)==1234577, 2338 '1973: prevprime(1234578,2)==1234577'); 2339 vrfy(prevprime(2^31-1) == 2^31-19, 2340 '1974: prevprime(2^31-1) == 2^31-19'); 2341 vrfy(prevprime(2^31+11) == 2^31-1, 2342 '1975: prevprime(2^31+11) == 2^31-1'); 2343 vrfy(prevprime(3e9) == 3e9-71,'1976: prevprime(3e9) == 3e9-17'); 2344 vrfy(prevprime(2^32-3) == 2^32-5, 2345 '1977: prevprime(2^32-3) == 2^32-5'); 2346 vrfy(prevprime(2^32-1) == 2^32-5, 2347 '1978: prevprime(2^32-1) == 2^32-5'); 2348 vrfy(prevprime(2^32,-1) == -1, '1979: prevprime(2^32,-1) == -1'); 2349 vrfy(prevprime(3^99,-1) == -1, '1980: prevprime(3^99,-1) == -1'); 2350 vrfy(prevprime(3^99,2) == 2, '1981: prevprime(3^99,2) == 2'); 2351 vrfy(pix(-1) == 0, '1982: pix(-1) == 0'); 2352 vrfy(pix(1) == 0, '1983: pix(1) == 0'); 2353 vrfy(pix(2) == 1, '1984: pix(2) == 1'); 2354 vrfy(pix(3) == 2, '1985: pix(3) == 2'); 2355 vrfy(pix(100) == 25, '1986: pix(100) == 25'); 2356 vrfy(pix(1000) == 168, '1987: pix(1000) == 168'); 2357 vrfy(pix(10000) == 1229, '1988: pix(10000) == 1229'); 2358 vrfy(pix(100000) == 9592, '1989: pix(100000) == 9592'); 2359 vrfy(pix(2^19+59) == 43393, '1990: pix(2^19+59) == 43393'); 2360 vrfy(pix(1000000) == 78498, '1991: pix(1000000) == 78498'); 2361 vrfy(pix(10000000) == 664579, '1992: pix(10000000) == 664579'); 2362 vrfy(pix(2^32-6) == 203280220, '1993: pix(2^32-6) == 203280220'); 2363 vrfy(pix(2^32-5) == 203280221, '1994: pix(2^32-5) == 203280221'); 2364 vrfy(pix(2^32-1) == 203280221, '1995: pix(2^32-1) == 203280221'); 2365 vrfy(pfact(40) == 7420738134810,'1996: pfact(40) == 7420738134810'); 2366 vrfy(pfact(200)/pfact(198)==199,'1997: pfact(200)/pfact(198)==199'); 2367 vrfy(nextprime(3e9)==nextcand(3e9), 2368 '1998: nextprime(3e9)==nextcand(3e9)'); 2369 vrfy(prevprime(3e9)==prevcand(3e9), 2370 '1999: prevprime(3e9)==prevcand(3e9)'); 2371 vrfy(nextcand(2^100,0)-2^100 == 3, 2372 '2000: nextcand(2^100,0)-2^100 == 3'); 2373 vrfy(nextcand(2^100)-2^100 == 277, 2374 '2001: nextcand(2^100)-2^100 == 277'); 2375 vrfy(2^100-prevcand(2^100,0) == 5, 2376 '2002: 2^100-prevcand(2^100,0) == 5'); 2377 vrfy(2^100-prevcand(2^100) == 15, 2378 '2003: 2^100-prevcand(2^100) == 15'); 2379 vrfy(nextcand(2^50,4,5)-2^50 == 55, 2380 '2004: nextcand(2^50,4,5)-2^50 == 55'); 2381 vrfy(2^50-prevcand(2^50,4,5) == 27, 2382 '2005: 2^50-prevcand(2^50,4,5) == 27'); 2383 vrfy(nextprime(2^32-6) == 2^32-5, 2384 '2006: nextprime(2^32-6) == 2^32-5'); 2385 vrfy(nextprime(2^32-5) == 2^32+15, 2386 '2007: nextprime(2^32-5) == 2^32+15'); 2387 vrfy(prevprime(2^32-1) == 2^32-5, 2388 '2008: prevprime(2^32-1) == 2^32-5'); 2389 vrfy(prevcand(2^50,4,5,0,4) == 0, 2390 '2009: prevcand(2^50,4,5,0,4) == 0'); 2391 vrfy(2^50-prevcand(2^50,4,5,1,4) == 27, 2392 '2010: 2^50-prevcand(2^50,4,5,1,4) == 27'); 2393 vrfy(prevcand(2^50,4,5,2,4) == 2, 2394 '2011: prevcand(2^50,4,5,2,4) == 2'); 2395 vrfy(2^50-prevcand(2^50,4,5,3,4) == 113, 2396 '2012: 2^50-prevcand(2^50,4,5,3,4) == 113'); 2397 vrfy(2^50-prevcand(2^50,4,5,7,17) == 813, 2398 '2013: 2^50-prevcand(2^50,4,5,7,17) == 813'); 2399 vrfy(nextcand(2^50,4,5,0,4) == 0, 2400 '2014: nextcand(2^50,4,5,0,4) == 0'); 2401 vrfy(nextcand(2^50,4,5,1,4)-2^50 == 145, 2402 '2015: nextcand(2^50,4,5,1,4)-2^50 == 145'); 2403 vrfy(nextcand(2^50,4,5,2,4) == 0, 2404 '2016: nextcand(2^50,4,5,2,4) == 0'); 2405 vrfy(nextcand(2^50,4,5,3,4)-2^50 == 55, 2406 '2017: nextcand(2^50,4,5,3,4)-2^50 == 55'); 2407 vrfy(nextcand(2^50,4,5,7,17)-2^50 == 853, 2408 '2018: nextcand(2^50,4,5,7,17)-2^50 == 853'); 2409 vrfy(ptest(2^100+277) == 1, '2019: ptest(2^100+277) == 1'); 2410 vrfy(ptest(2^50-27,4,5) == 1, '2020: ptest(2^50-27,4,5) == 1'); 2411 vrfy(ptest(2^50+55,4,5) == 1, '2021: ptest(2^50+55,4,5) == 1'); 2412 vrfy(ptest(2^32+1,10) == 0, '2022: ptest(2^32+1,10) == 0'); 2413 vrfy(lfactor(1001,100) == 7, '2023: lfactor(1001,100) == 7'); 2414 vrfy(lfactor(1001,4) == 7, '2024: lfactor(1001,4) == 7'); 2415 vrfy(lfactor(1001,3) == 1, '2025: lfactor(1001,3) == 1'); 2416 vrfy(lfactor(127,10000) == 1, '2026: lfactor(127,10000) == 1'); 2417 vrfy(lfactor(2^19-1,10000) == 1,'2027: lfactor(2^19-1,10000) == 1'); 2418 vrfy(lfactor(2^31-1,10000) == 1,'2028: lfactor(2^31-1,10000) == 1'); 2419 vrfy(lfactor(2^32-5,10000) == 1,'2029: lfactor(2^32-5,10000) == 1'); 2420 vrfy(lfactor(2^38+7,50000) == 1,'2030: lfactor(2^38+7,50000) == 1'); 2421 vrfy(lfactor(1009^2,pix(1009)) == 1009, 2422 '2031: lfactor(1009^2,pix(1009)) == 1009'); 2423 vrfy(lfactor(1009^2,pix(1009)-1) == 1, 2424 '2032: lfactor(1009^2,pix(1009)-1) == 1'); 2425 vrfy(lfactor(65519*65521,7000) == 65519, 2426 '2033: lfactor(65519*65521,7000) == 65519'); 2427 vrfy(lfactor(65521^2,pix(65521)) == 65521, 2428 '2034: lfactor(65521^2,pix(65521)) == 65521'); 2429 vrfy(lfactor(65521^2,pix(65521)-1) == 1, 2430 '2035: lfactor(65521^2,pix(65521)-1) == 1'); 2431 vrfy(lfactor(524309^6,100000) == 524309, 2432 '2036: lfactor(524309^6,100000) == 524309'); 2433 2434 print '2037: Ending prime builtins test'; 2435} 2436print '029: parsed test_prime()'; 2437 2438 2439/* 2440 * Test the Lucas primality test resource file 2441 */ 2442read -once "lucas_chk"; /* obtain our needed Lucas resource file */ 2443print '030: read lucas_chk'; 2444/**/ 2445define test_lucas() 2446{ 2447 print '2100: Beginning lucas check test'; 2448 2449 vrfy(lucas_chk(100,1) == 1, '2101: lucas_chk(100,1) == 1'); 2450 2451 print '2102: Ending lucas check test'; 2452} 2453print '031: parsed test_lucas()'; 2454 2455 2456/* 2457 * Test new operator functionality 2458 */ 2459define test_newop() 2460{ 2461 static mat A[3] = {1,2,3}; 2462 static mat A2[3] = {1,2,3}; 2463 local B; 2464 local v; 2465 local a; 2466 local b; 2467 2468 print '2200: Beginning new operator functionality test'; 2469 2470 (v = 3) = 4; 2471 print '2201: (v = 3) = 4'; 2472 vrfy(v == 4, '2202: v == 4'); 2473 (v += 3) *= 4; 2474 print '2203: (v += 3) *= 4'; 2475 vrfy(v == 28, '2204: v == 28'); 2476 vrfy(A == A2, '2205: A == A2'); 2477 matfill(B = A, 4); 2478 print '2206: matfill(B = A, 4)'; 2479 vrfy(A == A2, '2207: A == A2'); 2480 vrfy(size(B) == 3, '2208: size(B) == 3'); 2481 vrfy(B[0] == 4, '2209: B[0] == 4'); 2482 vrfy(B[1] == 4, '2210: B[1] == 4'); 2483 vrfy(B[2] == 4, '2211: B[2] == 4'); 2484 a = 3; 2485 print '2212: a = 3'; 2486 ++(b = a); 2487 print '2213: ++(b = a)'; 2488 vrfy(a == 3, '2214: a == 3'); 2489 vrfy(b == 4, '2215: b == 4'); 2490 ++++a; 2491 print '2216: ++++a'; 2492 vrfy(a == 5, '2217: a == 5'); 2493 vrfy((++a)++ == 6, '2218: (++a)++ == 6'); 2494 vrfy(a == 7, '2219: a == 7'); 2495 (++a) *= b; 2496 print '2220: (++a) *= b'; 2497 vrfy(a == 32, '2221: a == 32'); 2498 vrfy(b == 4, '2222: b == 4'); 2499 vrfy(++(a*=b) == 129, '2223: ++(a*=b) == 129'); 2500 vrfy(a == 129, '2224: a == 129'); 2501 vrfy(b == 4, '2225: b == 4'); 2502 vrfy((a = (--a / b++))-- == 32, 2503 '2226: (a = (--a / b++))-- == 32'); 2504 vrfy(a == 31, '2227: a == 31'); 2505 vrfy(b == 5, '2228: b == 5'); 2506 vrfy((++++a / ----b) == 11, 2507 '2229: (++++a / ----b) == 11'); 2508 vrfy(a == 33, '2230: a == 33'); 2509 vrfy(b == 3, '2231: b == 3'); 2510 vrfy((a/=(--a/++b))-- == 4, 2511 '2232: (a/=(--a/++b))-- == 4'); 2512 vrfy(a == 3, '2233: a == 3'); 2513 vrfy(b == 4, '2234: b == 4'); 2514 v = a----; 2515 print '2235: v = a----'; 2516 vrfy(v == 3, '2236: v == 3'); 2517 vrfy(a == 1, '2237: a == 1'); 2518 a = ----v; 2519 print '2238: a = ----v'; 2520 vrfy(a == 1, '2239: a == 1'); 2521 vrfy(v == 1, '2240: v == 1'); 2522 v = a++++; 2523 print '2241: v = a++++'; 2524 vrfy(a == 3, '2242: a == 3'); 2525 vrfy(v == 1, '2243: v == 1'); 2526 a = ++++v; 2527 print '2244: a = ++++v'; 2528 vrfy(a == 3, '2245: a == 3'); 2529 vrfy(v == 3, '2246: v == 3'); 2530 a = ----v----; 2531 print '2247: a = ----v----'; 2532 vrfy(a == 1, '2248: a == 1'); 2533 vrfy(v == -1, '2249: v == -1'); 2534 v = ++++a++++; 2535 print '2250: v = ++++a++++'; 2536 vrfy(a == 5, '2251: a == 5'); 2537 vrfy(v == 3, '2252: v == 3'); 2538 a = ++++v----; 2539 print '2253: a = ++++v----'; 2540 vrfy(a == 5, '2254: a == 5'); 2541 vrfy(v == 3, '2255: v == 3'); 2542 v = --++a--++; 2543 print '2256: v = --++a--++'; 2544 vrfy(a == 5, '2257: a == 5'); 2545 vrfy(v == 5, '2258: v == 5'); 2546 a = -++v; 2547 print '2259: a = -++v'; 2548 vrfy(a == -6, '2260: a == -6'); 2549 vrfy(v == 6, '2261: v == 6'); 2550 2551 print '2262: Ending new operator functionality test'; 2552} 2553print '032: parsed test_newop()'; 2554 2555 2556/* 2557 * Test object increment/decrement 2558 */ 2559read -once "test2300"; 2560print '033: read -once test2300'; 2561/**/ 2562define test_xx_incdec() 2563{ 2564 local A, B; 2565 local n; 2566 2567 print '2300: Beginning object increment/decrement test'; 2568 2569 A = mkmat(1,2,3); 2570 print '2301: A = mkmat(1,2,3)'; 2571 vrfy(ckmat(A,1,2,3) == 1, 2572 '2302: ckmat(A,1,2,3) == 1'); 2573 B = A++; 2574 print '2303: B = A++'; 2575 vrfy(ckmat(B,1,2,3) == 1, 2576 '2304: ckmat(B,1,2,3) == 1'); 2577 vrfy(ckmat(A,2,3,4) == 1, 2578 '2305: ckmat(A,2,3,4) == 1'); 2579 B = A--; 2580 print '2306: B = A--'; 2581 vrfy(ckmat(A,1,2,3) == 1, 2582 '2307: ckmat(A,1,2,3) == 1'); 2583 vrfy(ckmat(B,2,3,4) == 1, 2584 '2308: ckmat(B,2,3,4) == 1'); 2585 B = ++A; 2586 print '2309: B = ++A'; 2587 vrfy(ckmat(A,2,3,4) == 1, 2588 '2310: ckmat(A,2,3,4) == 1'); 2589 vrfy(ckmat(B,2,3,4) == 1, 2590 '2311: ckmat(B,2,3,4) == 1'); 2591 B = --A; 2592 print '2312: B = --A'; 2593 vrfy(ckmat(A,1,2,3) == 1, 2594 '2313: ckmat(A,1,2,3) == 1'); 2595 vrfy(ckmat(B,1,2,3) == 1, 2596 '2314: ckmat(B,1,2,3) == 1'); 2597 2598 n = 1; 2599 print '2315: n = 1'; 2600 vrfy(n + n + n + n++ == 4, 2601 '2316: n + n + n + n++ == 4'); 2602 vrfy(n == 2, '2317: n == 2'); 2603 n = 1; 2604 print '2318: n = 1'; 2605 vrfy(n + n + n++ == 3, '2319: n + n + n++ == 3'); 2606 vrfy(n == 2, '2320: n == 2'); 2607 n = 1; 2608 print '2321: n = 1'; 2609 vrfy(n + n++ == 2, '2322: n + n++ == 3'); 2610 vrfy(n == 2, '2323: n == 2'); 2611 2612 print '2315: Ending object increment/decrement test'; 2613} 2614print '034: parsed test_xx_incdec()'; 2615 2616 2617/* 2618 * testing rounding config modes 2619 */ 2620define test_round() 2621{ 2622 local mode; 2623 2624 print '2400: Beginning config rounding mode test'; 2625 2626 /* appr mode 0 */ 2627 mode = 0; 2628 print '2401: mode = 0'; 2629 vrfy(appr(-5.44,0.1,mode) == -5.5, 2630 '2402: appr(-5.44,0.1,mode) == -5.5'); 2631 vrfy(appr(5.44,0.1,mode) == 5.4, 2632 '2403: appr(5.44,0.1,mode) == 5.4'); 2633 vrfy(appr(5.7,1,mode) == 5, 2634 '2404: appr(5.7,1,mode) == 5'); 2635 vrfy(appr(-5.7,1,mode) == -6, 2636 '2405: appr(-5.7,1,mode) == -6'); 2637 vrfy(appr(-5.44,-0.1,mode) == -5.4, 2638 '2406: appr(-5.44,-0.1,mode) == -5.4'); 2639 vrfy(appr(5.44,-0.1,mode) == 5.5, 2640 '2407: appr(5.44,-0.1,mode) == 5.5'); 2641 vrfy(appr(5.7,-1,mode) == 6, 2642 '2408: appr(5.7,-1,mode) == 6'); 2643 vrfy(appr(-5.7,-1,mode) == -5, 2644 '2409: appr(-5.7,-1,mode) == -5'); 2645 2646 /* appr mode 1 */ 2647 mode = 1; 2648 print '2410: mode = 1'; 2649 vrfy(appr(-5.44,0.1,mode) == -5.4, 2650 '2411: appr(-5.44,0.1,mode) == -5.4'); 2651 vrfy(appr(5.44,0.1,mode) == 5.5, 2652 '2412: appr(5.44,0.1,mode) == 5.5'); 2653 vrfy(appr(5.7,1,mode) == 6, 2654 '2413: appr(5.7,1,mode) == 6'); 2655 vrfy(appr(-5.7,1,mode) == -5, 2656 '2414: appr(-5.7,1,mode) == -5'); 2657 vrfy(appr(-5.44,-0.1,mode) == -5.5, 2658 '2415: appr(-5.44,-0.1,mode) == -5.5'); 2659 vrfy(appr(5.44,-0.1,mode) == 5.4, 2660 '2416: appr(5.44,-0.1,mode) == 5.4'); 2661 vrfy(appr(5.7,-1,mode) == 5, 2662 '2417: appr(5.7,-1,mode) == 5'); 2663 vrfy(appr(-5.7,-1,mode) == -6, 2664 '2418: appr(-5.7,-1,mode) == -6'); 2665 2666 /* appr mode 2 */ 2667 mode = 2; 2668 print '2419: mode = 2'; 2669 vrfy(appr(-5.44,0.1,mode) == -5.4, 2670 '2420: appr(-5.44,0.1,mode) == -5.4'); 2671 vrfy(appr(5.44,0.1,mode) == 5.4, 2672 '2421: appr(5.44,0.1,mode) == 5.4'); 2673 vrfy(appr(5.7,1,mode) == 5, 2674 '2422: appr(5.7,1,mode) == 5'); 2675 vrfy(appr(-5.7,1,mode) == -5, 2676 '2423: appr(-5.7,1,mode) == -5'); 2677 2678 /* appr mode 3 */ 2679 mode = 3; 2680 print '2424: mode = 3'; 2681 vrfy(appr(-5.44,0.1,mode) == -5.5, 2682 '2425: appr(-5.44,0.1,mode) == -5.5'); 2683 vrfy(appr(5.44,0.1,mode) == 5.5, 2684 '2426: appr(5.44,0.1,mode) == 5.5'); 2685 vrfy(appr(5.7,1,mode) == 6, 2686 '2427: appr(5.7,1,mode) == 6'); 2687 vrfy(appr(-5.7,1,mode) == -6, 2688 '2428: appr(-5.7,1,mode) == -6'); 2689 2690 /* appr mode 4 */ 2691 mode = 4; 2692 print '2429: mode = 4'; 2693 vrfy(appr(-5.44,0.1,mode) == -5.5, 2694 '2430: appr(-5.44,0.1,mode) == -5.5'); 2695 vrfy(appr(5.44,0.1,mode) == 5.4, 2696 '2431: appr(5.44,0.1,mode) == 5.4'); 2697 vrfy(appr(5.7,1,mode) == 5, 2698 '2432: appr(5.7,1,mode) == 5'); 2699 vrfy(appr(-5.7,1,mode) == -6, 2700 '2433: appr(-5.7,1,mode) == -6'); 2701 2702 /* appr mode 5 */ 2703 mode = 5; 2704 print '2434: mode = 5'; 2705 vrfy(appr(-5.44,0.1,mode) == -5.4, 2706 '2435: appr(-5.44,0.1,mode) == -5.4'); 2707 vrfy(appr(5.44,0.1,mode) == 5.5, 2708 '2436: appr(5.44,0.1,mode) == 5.5'); 2709 vrfy(appr(5.7,1,mode) == 6, 2710 '2437: appr(5.7,1,mode) == 6'); 2711 vrfy(appr(-5.7,1,mode) == -5, 2712 '2438: appr(-5.7,1,mode) == -5'); 2713 2714 /* appr mode 6 */ 2715 mode = 6; 2716 print '2439: mode = 6'; 2717 vrfy(appr(-5.44,0.1,mode) == -5.4, 2718 '2440: appr(-5.44,0.1,mode) == -5.4'); 2719 vrfy(appr(5.44,0.1,mode) == 5.4, 2720 '2441: appr(5.44,0.1,mode) == 5.4'); 2721 vrfy(appr(5.7,1,mode) == 5, 2722 '2442: appr(5.7,1,mode) == 5'); 2723 vrfy(appr(-5.7,1,mode) == -5, 2724 '2443: appr(-5.7,1,mode) == -5'); 2725 vrfy(appr(-5.44,-0.1,mode) == -5.5, 2726 '2444: appr(-5.44,-0.1,mode) == -5.5'); 2727 vrfy(appr(5.44,-0.1,mode) == 5.5, 2728 '2445: appr(5.44,-0.1,mode) == 5.5'); 2729 vrfy(appr(5.7,-1,mode) == 6, 2730 '2446: appr(5.7,-1,mode) == 6'); 2731 vrfy(appr(-5.7,-1,mode) == -6, 2732 '2447: appr(-5.7,-1,mode) == -6'); 2733 2734 /* appr mode 7 */ 2735 mode = 7; 2736 print '2448: mode = 7'; 2737 vrfy(appr(-5.44,0.1,mode) == -5.5, 2738 '2449: appr(-5.44,0.1,mode) == -5.5'); 2739 vrfy(appr(5.44,0.1,mode) == 5.5, 2740 '2450: appr(5.44,0.1,mode) == 5.5'); 2741 vrfy(appr(5.7,1,mode) == 6, 2742 '2451: appr(5.7,1,mode) == 6'); 2743 vrfy(appr(-5.7,1,mode) == -6, 2744 '2452: appr(-5.7,1,mode) == -6'); 2745 vrfy(appr(-5.44,-0.1,mode) == -5.4, 2746 '2453: appr(-5.44,-0.1,mode) == -5.4'); 2747 vrfy(appr(5.44,-0.1,mode) == 5.4, 2748 '2454: appr(5.44,-0.1,mode) == 5.4'); 2749 vrfy(appr(5.7,-1,mode) == 5, 2750 '2455: appr(5.7,-1,mode) == 5'); 2751 vrfy(appr(-5.7,-1,mode) == -5, 2752 '2456: appr(-5.7,-1,mode) == -5'); 2753 2754 /* appr mode 8 */ 2755 mode = 8; 2756 print '2457: mode = 8'; 2757 vrfy(appr(-5.44,0.1,mode) == -5.4, 2758 '2458: appr(-5.44,0.1,mode) == -5.4'); 2759 vrfy(appr(5.44,0.1,mode) == 5.4, 2760 '2459: appr(5.44,0.1,mode) == 5.4'); 2761 vrfy(appr(5.7,1,mode) == 6, 2762 '2460: appr(5.7,1,mode) == 6'); 2763 vrfy(appr(-5.7,1,mode) == -6, 2764 '2461: appr(-5.7,1,mode) == -6'); 2765 2766 /* appr mode 9 */ 2767 mode = 9; 2768 print '2462: mode = 9'; 2769 vrfy(appr(-5.44,0.1,mode) == -5.5, 2770 '2463: appr(-5.44,0.1,mode) == -5.5'); 2771 vrfy(appr(5.44,0.1,mode) == 5.5, 2772 '2464: appr(5.44,0.1,mode) == 5.5'); 2773 vrfy(appr(5.7,1,mode) == 5, 2774 '2465: appr(5.7,1,mode) == 5'); 2775 vrfy(appr(-5.7,1,mode) == -5, 2776 '2466: appr(-5.7,1,mode) == -5'); 2777 2778 /* appr mode 10 */ 2779 mode = 10; 2780 print '2467: mode = 10'; 2781 vrfy(appr(-5.44,0.1,mode) == -5.5, 2782 '2468: appr(-5.44,0.1,mode) == -5.5'); 2783 vrfy(appr(5.44,0.1,mode) == 5.4, 2784 '2469: appr(5.44,0.1,mode) == 5.4'); 2785 vrfy(appr(5.7,1,mode) == 6, 2786 '2470: appr(5.7,1,mode) == 6'); 2787 vrfy(appr(-5.7,1,mode) == -5, 2788 '2471: appr(-5.7,1,mode) == -5'); 2789 vrfy(appr(-5.44,-0.1,mode) == -5.4, 2790 '2472: appr(-5.44,-0.1,mode) == -5.4'); 2791 vrfy(appr(5.44,-0.1,mode) == 5.5, 2792 '2473: appr(5.44,-0.1,mode) == 5.5'); 2793 vrfy(appr(5.7,-1,mode) == 5, 2794 '2474: appr(5.7,-1,mode) == 5'); 2795 vrfy(appr(-5.7,-1,mode) == -6, 2796 '2475: appr(-5.7,-1,mode) == -6'); 2797 2798 /* appr mode 11 */ 2799 mode = 11; 2800 print '2476: mode = 11'; 2801 vrfy(appr(-5.44,0.1,mode) == -5.4, 2802 '2477: appr(-5.44,0.1,mode) == -5.4'); 2803 vrfy(appr(5.44,0.1,mode) == 5.5, 2804 '2478: appr(5.44,0.1,mode) == 5.5'); 2805 vrfy(appr(5.7,1,mode) == 5, 2806 '2479: appr(5.7,1,mode) == 5'); 2807 vrfy(appr(-5.7,1,mode) == -6, 2808 '2480: appr(-5.7,1,mode) == -6'); 2809 vrfy(appr(-5.44,-0.1,mode) == -5.5, 2810 '2481: appr(-5.44,-0.1,mode) == -5.5'); 2811 vrfy(appr(5.44,-0.1,mode) == 5.4, 2812 '2482: appr(5.44,-0.1,mode) == 5.4'); 2813 vrfy(appr(5.7,-1,mode) == 6, 2814 '2483: appr(5.7,-1,mode) == 6'); 2815 vrfy(appr(-5.7,-1,mode) == -5, 2816 '2484: appr(-5.7,-1,mode) == -5'); 2817 2818 /* appr mode 12 */ 2819 mode = 12; 2820 print '2485: mode = 12'; 2821 vrfy(appr(-5.44,0.1,mode) == -5.4, 2822 '2486: appr(-5.44,0.1,mode) == -5.4'); 2823 vrfy(appr(5.44,0.1,mode) == 5.4, 2824 '2487: appr(5.44,0.1,mode) == 5.4'); 2825 vrfy(appr(5.7,1,mode) == 6, 2826 '2488: appr(5.7,1,mode) == 6'); 2827 vrfy(appr(-5.7,1,mode) == -6, 2828 '2489: appr(-5.7,1,mode) == -6'); 2829 vrfy(appr(-5.44,-0.1,mode) == -5.5, 2830 '2490: appr(-5.44,-0.1,mode) == -5.5'); 2831 vrfy(appr(5.44,-0.1,mode) == 5.5, 2832 '2491: appr(5.44,-0.1,mode) == 5.5'); 2833 vrfy(appr(5.7,-1,mode) == 5, 2834 '2492: appr(5.7,-1,mode) == 5'); 2835 vrfy(appr(-5.7,-1,mode) == -5, 2836 '2493: appr(-5.7,-1,mode) == -5'); 2837 2838 /* appr mode 13 */ 2839 mode = 13; 2840 print '2494: mode = 13'; 2841 vrfy(appr(-5.44,0.1,mode) == -5.5, 2842 '2495: appr(-5.44,0.1,mode) == -5.5'); 2843 vrfy(appr(5.44,0.1,mode) == 5.5, 2844 '2496: appr(5.44,0.1,mode) == 5.5'); 2845 vrfy(appr(5.7,1,mode) == 5, 2846 '2497: appr(5.7,1,mode) == 5'); 2847 vrfy(appr(-5.7,1,mode) == -5, 2848 '2498: appr(-5.7,1,mode) == -5'); 2849 vrfy(appr(-5.44,-0.1,mode) == -5.4, 2850 '2499: appr(-5.44,-0.1,mode) == -5.4'); 2851 vrfy(appr(5.44,-0.1,mode) == 5.4, 2852 '2500: appr(5.44,-0.1,mode) == 5.4'); 2853 vrfy(appr(5.7,-1,mode) == 6, 2854 '2501: appr(5.7,-1,mode) == 6'); 2855 vrfy(appr(-5.7,-1,mode) == -6, 2856 '2502: appr(-5.7,-1,mode) == -6'); 2857 2858 /* appr mode 14 */ 2859 mode = 14; 2860 print '2503: mode = 14'; 2861 vrfy(appr(-5.44,0.1,mode) == -5.5, 2862 '2504: appr(-5.44,0.1,mode) == -5.5'); 2863 vrfy(appr(5.44,0.1,mode) == 5.4, 2864 '2505: appr(5.44,0.1,mode) == 5.4'); 2865 vrfy(appr(5.7,1,mode) == 6, 2866 '2506: appr(5.7,1,mode) == 6'); 2867 vrfy(appr(-5.7,1,mode) == -5, 2868 '2507: appr(-5.7,1,mode) == -5'); 2869 vrfy(appr(-5.44,-0.1,mode) == -5.5, 2870 '2508: appr(-5.44,-0.1,mode) == -5.5'); 2871 vrfy(appr(5.44,-0.1,mode) == 5.4, 2872 '2509: appr(5.44,-0.1,mode) == 5.4'); 2873 vrfy(appr(5.7,-1,mode) == 6, 2874 '2510: appr(5.7,-1,mode) == 6'); 2875 vrfy(appr(-5.7,-1,mode) == -5, 2876 '2511: appr(-5.7,-1,mode) == -5'); 2877 2878 /* appr mode 15 */ 2879 mode = 15; 2880 print '2512: mode = 15'; 2881 vrfy(appr(-5.44,0.1,mode) == -5.4, 2882 '2513: appr(-5.44,0.1,mode) == -5.4'); 2883 vrfy(appr(5.44,0.1,mode) == 5.5, 2884 '2514: appr(5.44,0.1,mode) == 5.5'); 2885 vrfy(appr(5.7,1,mode) == 5, 2886 '2515: appr(5.7,1,mode) == 5'); 2887 vrfy(appr(-5.7,1,mode) == -6, 2888 '2516: appr(-5.7,1,mode) == -6'); 2889 vrfy(appr(-5.44,-0.1,mode) == -5.4, 2890 '2517: appr(-5.44,-0.1,mode) == -5.4'); 2891 vrfy(appr(5.44,-0.1,mode) == 5.5, 2892 '2518: appr(5.44,-0.1,mode) == 5.5'); 2893 vrfy(appr(5.7,-1,mode) == 5, 2894 '2519: appr(5.7,-1,mode) == 5'); 2895 vrfy(appr(-5.7,-1,mode) == -6, 2896 '2520: appr(-5.7,-1,mode) == -6'); 2897 2898 print '2521: Ending config rounding mode test'; 2899} 2900print '035: parsed test_round()'; 2901 2902 2903/* 2904 * Test certain numeric functions extensively 2905 * 2906 * Test multiplication, sqrt(), exp(), ln(), power(), gcd(), complex 2907 * power, complex exp, complex log. 2908 */ 2909read -once "test2600"; 2910print '036: read -once test2600'; 2911define test_2600() 2912{ 2913 local tnum; /* test number */ 2914 local i; 2915 2916 print '2600: Beginning extensive numeric function test'; 2917 2918 i = config("sqrt"); 2919 print '2601: i = config("sqrt")'; 2920 2921 tnum = test2600(1, 2602); 2922 2923 i = config("sqrt", i); 2924 print tnum++: ': i = config("sqrt", i)'; 2925 2926 i = epsilon(1e-100),; 2927 print tnum++: ': i = epsilon(1e-100),;'; 2928 vrfy(ln(exp(6)) == 6, 2929 strcat(str(tnum++), ': ln(exp(6)) == 6')); 2930 vrfy(ln(exp(4)^4) == 16, 2931 strcat(str(tnum++), ': ln(exp(4)^4) == 16')); 2932 vrfy(ln(exp(6.5)^8) == 52, 2933 strcat(str(tnum++), ': ln(exp(6.5)^8) == 52')); 2934 vrfy(ln(exp(5)^16) == 80, 2935 strcat(str(tnum++), ': ln(exp(5)^16) == 80')); 2936 vrfy(ln(exp(4.5)^4) == 18, 2937 strcat(str(tnum++), ': ln(exp(4.5)^4) == 18')); 2938 vrfy(ln(exp(4)^8) == 32, 2939 strcat(str(tnum++), ': ln(exp(4)^8) == 32')); 2940 vrfy(ln(exp(60/11)^11) == 60, 2941 strcat(str(tnum++), ': ln(exp(60/11)^11) == 60')); 2942 vrfy(ln(exp(6)^15) == 90, 2943 strcat(str(tnum++), ': ln(exp(6)^11) == 90')); 2944 vrfy(ln(exp(80/17)^17) == 80, 2945 strcat(str(tnum++), ': ln(exp(80/17)^17) == 80')); 2946 vrfy(ln(exp(6)^15) == 90, 2947 strcat(str(tnum++), ': ln(exp(6)^15) == 90')); 2948 vrfy(ln(exp(5)^18) == 90, 2949 strcat(str(tnum++), ': ln(exp(5)^18) == 90')); 2950 vrfy(log(1e6) == 6, 2951 strcat(str(tnum++), ': log(1e6)) == 6')); 2952 vrfy(log(1) == 0, 2953 strcat(str(tnum++), ': log(1)) == 0')); 2954 vrfy(log(100) == 2, 2955 strcat(str(tnum++), ': log(100)) == 2')); 2956 vrfy(log(1e66) == 66, 2957 strcat(str(tnum++), ': log(1e66)) == 66')); 2958 vrfy(log(1e127) == 127, 2959 strcat(str(tnum++), ': log(1e127)) == 127')); 2960 vrfy(round(log(17^47),10) == 57.8310993048, 2961 strcat(str(tnum++), 2962 ': round(log(17^47),10) == 57.8310993048')); 2963 vrfy(round(log(127),10) == 2.103803721, 2964 strcat(str(tnum++), 2965 ': round(log(127),10) == 2.103803721')); 2966 vrfy(round(log(0.25,0.00001),5) == -0.60206, 2967 strcat(str(tnum++), 2968 ': round(log(0.25,0.00001),5) == -0.60206')); 2969 vrfy(round(log(0.25,1e-10),10) == -0.6020599913, 2970 strcat(str(tnum++), 2971 ': round(log(0.25,1e-10),10) == -0.6020599913')); 2972 vrfy(round( log(1.2+1.2i,1e-5),5) == 0.2297+0.34109i, 2973 strcat(str(tnum++), 2974 ': round(log(1.2+1.2i,1e-5),5) == 0.2297+0.34109i')); 2975 vrfy(round( log(1.2+1.2i,1e-10),10) == 0.2296962439+0.3410940885i, 2976 strcat(str(tnum++), 2977 ': round(log(1.2+1.2i,1e-10),10) == ', 2978 '0.2296962439+0.3410940885i')); 2979 epsilon(i),; 2980 print tnum++: ': epsilon(i),;'; 2981 2982 print tnum: ': Ending extensive numeric function test'; 2983} 2984print '037: parsed test_2600()'; 2985 2986 2987/* 2988 * Test complex sqrt 2989 */ 2990read -once "test2700"; 2991print '038: read -once test2700'; 2992define test_2700() 2993{ 2994 local tnum; /* test number */ 2995 2996 print '2700: Beginning complex sqrt test'; 2997 2998 tnum = test2700(1, 2701); 2999 3000 print tnum: ': Ending complex sqrt test'; 3001} 3002print '039: parsed test_2700()'; 3003 3004 3005/* 3006 * Test matrix operations 3007 */ 3008mat mat_C[2] = {1,2}; 3009print '040: mat mat_C[2] = {1,2}'; 3010mat_C[0] = mat_C; 3011print '041: C[0] = mat_C'; 3012global mat_D; 3013print '042: global mat_D'; 3014/**/ 3015define test_matrix() 3016{ 3017 static mat b[4,4]; 3018 static mat binv[4,4] = { 3019 0, 1, 0, 0, 2, -3/2, 2, -1/2, -3, 3020 0.5, -1.0, 0.5, 1.0, 0.0, 0.0, 0.0 3021 }; 3022 static mat c[] = { 1, 2+3i, -5+4i, 5i+6, -7i }; 3023 static mat d[-1:1, -2:2, -3:3, -4:4]; 3024 static mat A[2] = {1,2}; 3025 static mat id0[2,2] = {1,0,0,1}; 3026 static mat id1[0:2,-1:1] = {1,0,0,0,1,0,0,0,1}; 3027 static mat noid0[2,2] = {1,2,0,1}; 3028 static mat noid1[2,3] = {1,0,0,1,0,0}; 3029 static mat noid2[4] = {1,0,0,1}; 3030 static mat xp[3] = {2,3,4}; 3031 static mat yp[3] = {3,4,5}; 3032 static mat zp[3] = {-1,2,-1}; 3033 static mat X[2,2] = {1,2,3,4}; 3034 static mat Y[2,2] = {5,6,7,8}; 3035 static mat Z[2,2] = {190,232,286,352}; 3036 static mat x[] = {11,13,17,23,29}; 3037 static mat y0[] = {1,3,7,3,9}; 3038 static mat y1[] = {-9,-7,-3,-7,-1}; 3039 static mat y2[] = {-9,-7,-3,3,9}; 3040 static mat y3[] = {1,3,7,-7,-1}; 3041 static mat y4[] = {1,3,-3,3,-1}; 3042 local B; 3043 local mat e[5,5]; 3044 local mat M[2]; 3045 local mat zero3[3]; 3046 3047 print '2800: Beginning test_matrix'; 3048 3049 b[0,0] = 0; 3050 vrfy(b[0,0] == 0, '2801: b[0,0] == 0'); 3051 b[0,1] = 0; 3052 vrfy(b[0,1] == 0, '2802: b[0,1] == 0'); 3053 b[0,2] = 0; 3054 vrfy(b[0,2] == 0, '2803: b[0,2] == 0'); 3055 b[0,3] = 1; 3056 vrfy(b[0,3] == 1, '2804: b[0,3] == 1'); 3057 b[1,0] = 1; 3058 vrfy(b[1,0] == 1, '2805: b[1,0] == 1'); 3059 b[1,1] = 0; 3060 vrfy(b[1,1] == 0, '2806: b[1,1] == 0'); 3061 b[1,2] = 0; 3062 vrfy(b[1,2] == 0, '2807: b[1,2] == 0'); 3063 b[1,3] = 0; 3064 vrfy(b[1,3] == 0, '2808: b[1,3] == 0'); 3065 b[2,0] = 1; 3066 vrfy(b[2,0] == 1, '2809: b[2,0] == 1'); 3067 b[2,1] = 1; 3068 vrfy(b[2,1] == 1, '2810: b[2,1] == 1'); 3069 b[2,2] = 1; 3070 vrfy(b[2,2] == 1, '2811: b[2,2] == 1'); 3071 b[2,3] = 1; 3072 vrfy(b[2,3] == 1, '2812: b[2,3] == 1'); 3073 b[3,0] = 1; 3074 vrfy(b[3,0] == 1, '2813: b[3,0] == 1'); 3075 b[3,1] = 2; 3076 vrfy(b[3,1] == 2, '2814: b[3,1] == 2'); 3077 b[3,2] = 4; 3078 vrfy(b[3,2] == 4, '2815: b[3,2] == 4'); 3079 b[3,3] = 8; 3080 vrfy(b[3,3] == 8, '2816: b[3,3] == 8'); 3081 vrfy(det(b) == -2, '2817: det(b) == -2'); 3082 vrfy(binv[0,0] == 0, '2818: binv[0,0] == 0'); 3083 vrfy(binv[0,1] == 1, '2819: binv[0,1] == 1'); 3084 vrfy(binv[0,2] == 0, '2820: binv[0,2] == 0'); 3085 vrfy(binv[0,3] == 0, '2821: binv[0,3] == 0'); 3086 vrfy(binv[1,0] == 2, '2822: binv[1,0] == 2'); 3087 vrfy(binv[1,1] == -3/2, '2823: binv[1,1] == -3/2'); 3088 vrfy(binv[1,2] == 2, '2824: binv[1,2] == 2'); 3089 vrfy(binv[1,3] == -1/2, '2825: binv[1,3] == -1/2'); 3090 vrfy(binv[2,0] == -3, '2826: binv[2,0] == -3'); 3091 vrfy(binv[2,1] == 1/2, '2827: binv[2,1] == 1/2'); 3092 vrfy(binv[2,2] == -1, '2828: binv[2,2] == -1'); 3093 vrfy(binv[2,3] == 1/2, '2829: binv[2,3] == 1/2'); 3094 vrfy(binv[3,0] == 1, '2830: binv[3,0] == 1'); 3095 vrfy(binv[3,1] == 0, '2831: binv[3,1] == 0'); 3096 vrfy(binv[3,2] == 0, '2832: binv[3,2] == 0'); 3097 vrfy(binv[3,3] == 0, '2833: binv[3,3] == 0'); 3098 vrfy(inverse(b) == binv, '2834: inverse(b) == binv'); 3099 vrfy(avg(b) == b, '2835: avg(b) == b'); 3100 vrfy(avg(binv) == binv, '2836: avg(binv) == binv'); 3101 vrfy((b+binv)/2 == avg(b,binv), '2837: (b+binv)/2 == avg(b,binv)'); 3102 vrfy(ismat(b) == 1, '2838: ismat(b) == 1'); 3103 vrfy(matsum(b) == 21, '2839: matsum(b) == 21'); 3104 vrfy(matsum(binv) == 1, '2840: matsum(binv) == 1'); 3105 vrfy(c[0] == 1, '2841: c[0] == 1'); 3106 vrfy(c[1] == 2+3i, '2842: c[1] == 2+3i'); 3107 vrfy(c[2] == -5+4i, '2843: c[2] == -5+4i'); 3108 vrfy(c[3] == 6+5i, '2844: c[3] == 6+5i'); 3109 vrfy(c[4] == -7i, '2845: c[4] == -7i'); 3110 vrfy(matsum(c) == 4+5i, '2846: matsum(c) == 4+5i'); 3111 vrfy(matdim(b) == 2, '2847: matdim(b) == 2'); 3112 vrfy(matdim(c) == 1, '2848: matdim(c) == 1'); 3113 vrfy(matdim(d) == 4, '2849: matdim(c) == 4'); 3114 vrfy(matmax(c,1) == 4, '2850: matmax(c,1) == 4'); 3115 vrfy(matmin(c,1) == 0, '2851: matmin(c,1) == 0'); 3116 vrfy(matmin(d,1) == -1, '2852: matmin(d,1) == -1'); 3117 vrfy(matmin(d,3) == -3, '2853: matmin(d,3) == -3'); 3118 vrfy(matmax(d,1) == 1, '2854: matmin(d,1) == 1'); 3119 vrfy(matmax(d,3) == 3, '2855: matmin(d,3) == 3'); 3120 vrfy(size(binv) == 16, '2856: size(binv) == 16'); 3121 vrfy(size(c) == 5, '2857: size(c) == 5'); 3122 vrfy(size(d) == 945, '2858: size(d) == 945'); 3123 vrfy(size(e) == 25, '2859: size(e) == 25'); 3124 matfill(d,1); 3125 print '2860: matfill(d,1)'; 3126 vrfy(matsum(d) == 945, '2861: matsum(d) == 945'); 3127 matfill(e,1,0); 3128 print '2862: matfill(e,1,0)'; 3129 vrfy(matsum(d) == 945, '2863: matsum(d) == 945'); 3130 vrfy(matsum(e) == 20, '2864: matsum(e) == 20'); 3131 vrfy(search(binv,1) == 1, '2865: search(binv,1) == 1'); 3132 vrfy(search(binv,2) == 4, '2866: search(binv,2) == 4'); 3133 vrfy(search(binv,2,4) == 4, '2867: search(binv,2,4) == 4'); 3134 vrfy(search(binv,2,5) == 6, '2868: search(binv,2,5) == 6'); 3135 vrfy(rsearch(binv,2) == 6, '2869: rsearch(binv,2) == 6'); 3136 vrfy(rsearch(binv,2,6) == 6, '2870: rsearch(binv,2,6) == 6'); 3137 vrfy(rsearch(binv,2,5) == 4, '2871: rsearch(binv,2,5) == 4'); 3138 vrfy(A[0] == 1, '2872: A[0] == 1'); 3139 vrfy(A[1] == 2, '2873: A[1] == 2'); 3140 A[0] = A; 3141 print '2874: A[0] = A'; 3142 B = A[0]; 3143 print '2875: B = A[0]'; 3144 vrfy(B[0] == 1, '2876: B[0] == 1'); 3145 vrfy(B[1] == 2, '2877: B[1] == 2'); 3146 mat_D = mat_C[0]; 3147 print '2878: mat_D = mat_C[0]'; 3148 vrfy(mat_D[0] == 1, '2879: mat_D[0] == 1'); 3149 vrfy(mat_D[1] == 2, '2880: mat_D[1] == 2'); 3150 vrfy(quomod(15.6,5.2,M[0],M[1]) == 0, 3151 '2881: quomod(15.6,5.2,M[0],M[1]) == 0'); 3152 vrfy(M[0] == 3, '2882: M[0] == 3'); 3153 vrfy(M[1] == 0, '2883: M[1] == 0'); 3154 vrfy(isident(id0) == 1, '2884: isident(id0) == 1'); 3155 vrfy(isident(id1) == 1, '2885: isident(id1) == 1'); 3156 vrfy(isident(noid0) == 0, '2886: isident(noid0) == 0'); 3157 vrfy(isident(noid1) == 0, '2887: isident(noid1) == 0'); 3158 vrfy(isident(noid2) == 0, '2888: isident(noid2) == 0'); 3159 vrfy(xp[0] == 2, '2889: xp[0] == 2'); 3160 vrfy(xp[1] == 3, '2890: xp[1] == 3'); 3161 vrfy(xp[2] == 4, '2891: xp[2] == 4'); 3162 vrfy(yp[0] == 3, '2892: yp[0] == 3'); 3163 vrfy(yp[1] == 4, '2893: yp[1] == 4'); 3164 vrfy(yp[2] == 5, '2894: yp[2] == 5'); 3165 vrfy(zp[0] == -1, '2895: zp[0] == -1'); 3166 vrfy(zp[1] == 2, '2896: zp[1] == 2'); 3167 vrfy(zp[2] == -1, '2897: zp[2] == -1'); 3168 vrfy(cp(xp,yp) == zp, '2898: cp(xp,yp) == zp'); 3169 vrfy(cp(yp,xp) == -zp, '2899: cp(yp,xp) == -zp'); 3170 matfill(zero3,0); 3171 print '2900: matfill(zero3,0)'; 3172 vrfy(cp(xp,xp) == zero3, '2901: cp(xp,xp) == zero3'); 3173 vrfy(dp(xp,yp) == 38, '2902: dp(xp,yp) == 38'); 3174 vrfy(dp(yp,xp) == 38, '2903: dp(yp,xp) == 38'); 3175 vrfy(dp(zp,dp(xp,yp)*zp) == 228,'2904: dp(zp,dp(xp,yp)*zp) == 228'); 3176 vrfy(ssq(X, Y, X + Y) == Z, '2905: ssq(X, Y, X + Y) == Z'); 3177 vrfy(mod(x,10,0) == y0, '2906: mod(x,10,0) == y0'); 3178 vrfy(mod(x,10,1) == y1, '2907: mod(x,10,1) == y1'); 3179 vrfy(mod(x,10,2) == y0, '2908: mod(x,10,2) == y0'); 3180 vrfy(mod(x,10,3) == y1, '2909: mod(x,10,3) == y1'); 3181 vrfy(mod(x,10,4) == y0, '2910: mod(x,10,4) == y0'); 3182 vrfy(mod(x,10,5) == y1, '2911: mod(x,10,5) == y1'); 3183 vrfy(mod(x,10,6) == y0, '2912: mod(x,10,6) == y0'); 3184 vrfy(mod(x,10,7) == y1, '2913: mod(x,10,7) == y1'); 3185 vrfy(mod(x,10,8) == y2, '2914: mod(x,10,8) == y2'); 3186 vrfy(mod(x,10,9) == y3, '2915: mod(x,10,9) == y3'); 3187 vrfy(mod(x,10,10) == y2, '2916: mod(x,10,10) == y2'); 3188 vrfy(mod(x,10,11) == y3, '2917: mod(x,10,11) == y3'); 3189 vrfy(mod(x,10,12) == y2, '2918: mod(x,10,12) == y2'); 3190 vrfy(mod(x,10,13) == y3, '2919: mod(x,10,13) == y3'); 3191 vrfy(mod(x,10,14) == y2, '2920: mod(x,10,14) == y2'); 3192 vrfy(mod(x,10,15) == y3, '2921: mod(x,10,15) == y3'); 3193 vrfy(mod(x,10,16) == y4, '2922: mod(x,10,16) == y4'); 3194 vrfy(mod(x,10,16) == y4, '2923: mod(x,10,16) == y4'); 3195 vrfy(mod(x,10,18) == y4, '2924: mod(x,10,18) == y4'); 3196 vrfy(mod(x,10,19) == y4, '2925: mod(x,10,18) == y4'); 3197 vrfy(mod(x,10,20) == y4, '2926: mod(x,10,20) == y4'); 3198 vrfy(mod(x,10,21) == y4, '2927: mod(x,10,21) == y4'); 3199 vrfy(mod(x,10,22) == y4, '2928: mod(x,10,22) == y4'); 3200 vrfy(mod(x,10,23) == y4, '2929: mod(x,10,23) == y4'); 3201 vrfy(mod(x,10,24) == y4, '2930: mod(x,10,24) == y4'); 3202 vrfy(mod(x,10,25) == y4, '2931: mod(x,10,25) == y4'); 3203 vrfy(mod(x,10,26) == y4, '2932: mod(x,10,26) == y4'); 3204 vrfy(mod(x,10,27) == y4, '2933: mod(x,10,27) == y4'); 3205 vrfy(mod(x,10,28) == y4, '2934: mod(x,10,28) == y4'); 3206 vrfy(mod(x,10,29) == y4, '2935: mod(x,10,29) == y4'); 3207 vrfy(mod(x,10,30) == y4, '2936: mod(x,10,30) == y4'); 3208 vrfy(mod(x,10,31) == y4, '2937: mod(x,10,31) == y4'); 3209 3210 print '2938: Ending mat_functions'; 3211} 3212print '043: parsed test_matrix()'; 3213 3214 3215/* 3216 * Test string constants and comparisons 3217 */ 3218define test_strings() 3219{ 3220 local x, y, z; 3221 3222 print '3000: Beginning test_strings'; 3223 3224 x = 'string'; 3225 print "3001: x = 'string'"; 3226 y = "string"; 3227 print '3002: y = "string"'; 3228 z = x; 3229 print '3003: z = x'; 3230 vrfy(z == "string", '3004: z == "string"'); 3231 vrfy(z != "foo", '3005: z != "foo"'); 3232 vrfy(z != 3, '3006: z != 3'); 3233 vrfy('' == "", '3007: \'\' == ""'); 3234 vrfy("a" == "a", '3008: "a" == "a"'); 3235 vrfy("c" != "d", '3009: "c" != "d"'); 3236 vrfy("" != "a", '3010: "" != "a"'); 3237 vrfy("rs" < "rt", '3011: "rs" < "rt"'); 3238 vrfy("rs" < "ss", '3012: "rs < "ss"'); 3239 vrfy("rs" <= "rs", '3013: "rs" <= "rs"'); 3240 vrfy("rs" <= "tu", '3014: "rs" <= "tu"'); 3241 vrfy("rs" > "cd", '3015: "rs" > "cd"'); 3242 vrfy("rs" >= "rs", '3016: "rs" >= "rs"'); 3243 vrfy("rs" >= "cd", '3017: "rs" >= "cd"'); 3244 vrfy("abc" > "ab", '3018: "abc" > "ab"'); 3245 3246 print '3019: Ending test_strings'; 3247} 3248print '044: parsed test_strings()'; 3249 3250 3251/* 3252 * test_matobj - test determinants of a matrix containing objects 3253 */ 3254read -once "test3100"; 3255print '045: read -once test3100'; 3256/**/ 3257define test_matobj() 3258{ 3259 local mat A[3,3] = {2, 3, 5, 7, 11, 13, 17, 19, 23}; 3260 local mat B[2,2]; 3261 3262 print '3100: Beginning test_matobj'; 3263 3264 vrfy(det(A) == -78, '3101: det(A) == -78'); 3265 vrfy(det(A^2) == 6084, '3102: det(A^2) == 6084'); 3266 vrfy(det(A^3) == -474552, '3103: det(A^3) == -474552'); 3267 vrfy(det(A^-1) == -1/78, '3104: det(A^-1) == -1/78'); 3268 md = 0; 3269 print '3105: md = 0'; 3270 B[0,0] = res(2); 3271 print '3106: B[0,0] = res(2)'; 3272 B[0,1] = res(3); 3273 print '3107: B[0,1] = res(3)'; 3274 B[1,0] = res(5); 3275 print '3108: B[1,0] = res(5)'; 3276 B[1,1] = res(7); 3277 print '3109: B[1,1] = res(7)'; 3278 print '3110: md = 0'; 3279 md = 0; 3280 vrfy(det(B) == res(-1), '3111: det(B) == res(-1)'); 3281 md = 1; 3282 print '3112: md = 1'; 3283 vrfy(det(B) == 0, '3113: det(B) == 0'); 3284 md = 2; 3285 print '3114: md = 2'; 3286 vrfy(det(B) == res(1), '3115: det(B) == res(1)'); 3287 md = 3; 3288 print '3116: md = 3'; 3289 vrfy(det(B) == res(2), '3117: det(B) == res(2)'); 3290 md = 4; 3291 print '3118: md = 4'; 3292 vrfy(det(B) == res(3), '3119: det(B) == res(3)'); 3293 md = 5; 3294 print '3120: md = 5'; 3295 vrfy(det(B) == res(4), '3121: det(B) == res(4)'); 3296 md = 6; 3297 print '3122: md = 6'; 3298 vrfy(det(B) == res(5), '3123: det(B) == res(5)'); 3299 md = 7; 3300 print '3124: md = 7'; 3301 vrfy(det(B) == res(6), '3125: det(B) == res(6)'); 3302 md = 8; 3303 print '3126: md = 8'; 3304 vrfy(det(B) == res(7), '3127: det(B) == res(7)'); 3305 md = 9; 3306 print '3128: md = 9'; 3307 vrfy(det(B) == res(8), '3129: det(B) == res(8)'); 3308 md = 10; 3309 print '3130: md = 10'; 3310 vrfy(det(B) == res(9), '3131: det(B) == res(9)'); 3311 md = 11; 3312 print '3132: md = 11'; 3313 vrfy(det(B) == res(10), '3133: det(B) == res(10)'); 3314 md = 12; 3315 print '3134: md = 12'; 3316 vrfy(det(B) == res(11), '3135: det(B) == res(11)'); 3317 md = 13; 3318 print '3136: md = 13'; 3319 vrfy(det(B) == res(12), '3137: det(B) == res(12)'); 3320 md = 14; 3321 print '3138: md = 14'; 3322 vrfy(det(B) == res(13), '3139: det(B) == res(13)'); 3323 md = 15; 3324 print '3140: md = 15'; 3325 vrfy(det(B) == res(14), '3141: det(B) == res(14)'); 3326 3327 print '3142: Ending test_matobj'; 3328} 3329print '046: parsed test_matobj()'; 3330 3331 3332/* 3333 * test_poly - test the polynomial function 3334 */ 3335define test_poly() 3336{ 3337 print '3200: Beginning test_matobj'; 3338 3339 vrfy(poly(2,3,5,2) == 19, '3201: poly(2,3,5,2) == 19'); 3340 vrfy(poly(list(5,3,2),2) == 19,\ 3341 '3202: poly(list(5,3,2),2) == 19'); 3342 vrfy(poly(list(5,3,2)) == 5, '3203: poly(list(5,3,2)) == 5'); 3343 vrfy(poly(2) == 2, '3204: poly(2) == 2'); 3344 vrfy(poly(list(5,3,2),2,3) == 19,\ 3345 '3205: poly(list(5,3,2),2,3) == 19'); 3346 vrfy(poly(list()) == 0, '3206: poly(list()) == 0'); 3347 vrfy(poly(list(),2,3) == 0, '3207: poly(list(),2,3) == 0'); 3348 vrfy(poly(list(list(5,3,2)),7,2) == 19,\ 3349 '3208: poly(list(list(5,3,2)),7,2) == 19'); 3350 vrfy(poly(list(list(1,2,3),list(4,5),6),7) == 323,\ 3351 '3209: poly(list(list(1,2,3),list(4,5),6),7) == 323'); 3352 vrfy(poly(list(list(1,2,3),list(4,5),6),7,8) == 811,\ 3353 '3210: poly(list(list(1,2,3),list(4,5),6),7,8) == 811'); 3354 vrfy(poly(list(list(1,2,3),list(4,5),6),7,8,9) == 811,\ 3355 '3211: poly(list(list(1,2,3),list(4,5),6),7,8,9)==811'); 3356 vrfy(poly(list(5,3,2), list()) == 5,\ 3357 '3212: poly(list(5,3,2), list() == 5'); 3358 vrfy(poly(list(5,3,2), list(2)) == 19,\ 3359 '3213: poly(list(5,3,2), list(2)) == 19'); 3360 vrfy(poly(list(5,3,2), list(2,3)) == 19,\ 3361 '3214: poly(list(5,3,2), list(2,3)) == 19'); 3362 vrfy(poly(list(list(list(0,0,0,0,0,1))),2,3,4) == 4^5,\ 3363 '3215: poly(list(list(list(0,0,0,0,0,1))),2,3,4)==4^5'); 3364 vrfy(poly(list(list(list(0,0,0,0,0,1))),2,list(3,4)) == 4^5,\ 3365 '3216: poly(list(list(list(0,0,0,0,0,1))),2,list(3,4))==4^5'); 3366 3367 print '3217: Ending test_poly'; 3368} 3369print '047: parsed test_poly()'; 3370 3371 3372/* 3373 * test_det - more determinant testing 3374 */ 3375read -once "test3300"; 3376print '048: read -once test3300'; 3377/**/ 3378define test_det() 3379{ 3380 local tnum; /* test number */ 3381 local i; 3382 3383 print '3300: Beginning test_det'; 3384 3385 tnum = test3300(1, 3301); 3386 3387 print tnum: ': Ending test_det'; 3388} 3389print '049: parsed test_det()'; 3390 3391 3392/* 3393 * test_trig - trig function testing 3394 */ 3395read -once "test3400"; 3396print '050: read -once test3400'; 3397/**/ 3398define test_trig() 3399{ 3400 local tnum; /* test number */ 3401 local i; 3402 3403 print '3400: Beginning test_trig'; 3404 3405 /* test 3401-3407 */ 3406 tnum = test3400(1, 3401); 3407 vrfy(tnum == 3407, '3407: tnum == 3407'); 3408 3409 print '3438: Ending test_trig'; 3410} 3411print '051: parsed test_trig()'; 3412 3413 3414/* 3415 * test_frem - tests of the functions frem, fcnt, gcdrem 3416 */ 3417read -once "test3500"; 3418print '052: read -once test3500'; 3419/**/ 3420define test_frem() 3421{ 3422 local tnum; /* test number */ 3423 3424 print '3500: Beginning test_frem'; 3425 3426 tnum = test3500(1, 3501, 200, 61); 3427 3428 print tnum: ': Ending test_frem'; 3429} 3430print '053: parsed test_frem()'; 3431 3432 3433/* 3434 * test_error - test the error() builtin 3435 * 3436 * This function is designed to trigger 148 errors, so we bump the 3437 * errmax by 148 during this call. 3438 */ 3439define test_error() 3440{ 3441 local strx, e99, list1, e9999; 3442 local a, b, c, n, x; /* used by newerror() */ 3443 3444 print '3600: Beginning test_error'; 3445 3446 /* bump ecnt up by 156 */ 3447 ecnt += 156; 3448 print '3601: ecnt += 156'; 3449 3450 strx = "x"; 3451 print '3602: strx = "x"'; 3452 e99 = error(99); 3453 print '3603: e99 = error(99)'; 3454 vrfy(1/0 == error(10001), '3604: 1/0 == error(10001)'); 3455 vrfy(0/0 == error(10002), '3605: 0/0 == error(10002)'); 3456 vrfy(2 + "x" == error(10003), '3606: 2 + "x" == error(10003)'); 3457 vrfy("x" - 2 == error(10004), '3607: "x" - 2 == error(10004)'); 3458 vrfy("x" * "y" == error(10005), '3608: "x" * "y" == error(10005)'); 3459 vrfy("x" / "y" == error(10006), '3609: "x" / "y" == error(10006)'); 3460 vrfy(-list(1) == error(10007), '3610: -list(1) == error(10007)'); 3461 vrfy("x"^2 == error(10008), '3611: "x"^2 == error(10008)'); 3462 vrfy(inverse("x")==error(10009),'3612: inverse("x") == error(10009)'); 3463 vrfy(++strx == error(10010), '3613: ++strx == error(10010)'); 3464 vrfy(strx == error(10010), '3614: strx == error(10010)'); 3465 strx = "x"; 3466 print '3615: strx = "x"'; 3467 vrfy(strx++ == "x", '3616: strx++ == "x"'); 3468 vrfy(strx == error(10010), '3617: strx == error(10010)'); 3469 strx = "x"; 3470 print '3618: strx = "x"'; 3471 vrfy(--strx == error(10011), '3619: strx == error(10011)'); 3472 vrfy(int("x") == error(10012), '3620: int("x") == error(10012)'); 3473 vrfy(frac("x") == error(10013), '3621: frac("x") == error(10013)'); 3474 vrfy(conj("x") == error(10014), '3622: conj("x") == error(10014)'); 3475 vrfy(appr("x",.1) == error(10015), 3476 '3623: appr("x",.1) == error(10015)'); 3477 vrfy(appr(1.27,.1i) == error(10016), 3478 '3624: appr(1.27,.1i) == error(10016)'); 3479 vrfy(appr(1.27,.1,.1) == error(10017), 3480 '3625: appr(1.27,.1,.1) == error(10017)'); 3481 vrfy(round("x") == error(10018), 3482 '3626: round("x") == error(10018)'); 3483 vrfy(round(1.25,.1) == error(10019), 3484 '3627: round(1.25,.1) == error(10019)'); 3485 vrfy(round(1.25,"x") == error(10019), 3486 '3628: round(1.25,"x") == error(10019)'); 3487 vrfy(round(1.25,1,.1) == error(10020), 3488 '3629: round(1.25,1,.1) == error(10020)'); 3489 vrfy(bround("x") == error(10021), 3490 '3630: bround("x") == error(10021)'); 3491 vrfy(bround(1.25,.1) == error(10022), 3492 '3631: bround(1.25,.1) == error(10022)'); 3493 vrfy(bround(1.25,"x") == error(10022), 3494 '3632: bround(1.25,"x") == error(10022)'); 3495 vrfy(bround(1.25,1,.1) == error(10023), 3496 '3633: bround(1.25,1,.1) == error(10023)'); 3497 vrfy(sqrt("x") == error(10024), 3498 '3634: sqrt("x") == error(10024)'); 3499 vrfy(sqrt(2,"x") == error(10025), 3500 '3635: sqrt(2,"x") == error(10025)'); 3501 vrfy(sqrt(2,0) == error(10025), 3502 '3636: sqrt(2,0) == error(10025)'); 3503 vrfy(sqrt(2,.1,.1) == error(10026), 3504 '3637: sqrt(2,.1,.1) == error(10026)'); 3505 vrfy(root("x",3) == error(10027), 3506 '3638: root("x",3) == error(10027)'); 3507 vrfy(root(3,"x") == error(10028), 3508 '3639: root(3,"x") == error(10028)'); 3509 vrfy(root(3,-2) == error(10028), 3510 '3640: root(3,-2) == error(10028)'); 3511 vrfy(root(3,0) == error(10028), 3512 '3641: root(3,0) == error(10028)'); 3513 vrfy(root(3,.1) == error(10028), 3514 '3642: root(3,.1) == error(10028)'); 3515 vrfy(root(3,2,"x") == error(10029), 3516 '3643: root(3,2,"x") == error(10029)'); 3517 vrfy(root(3,2,0) == error(10029), 3518 '3644: root(3,2,0) == error(10029)'); 3519 vrfy(norm("x") == error(10030), '3645: norm("x") == error(10030)'); 3520 vrfy(list() << 2 == error(10031),'3646: list() << 2 == error(10031)'); 3521 vrfy(1.5 << 2 == error(10031), '3647: 1.5 << 2 == error(10031)'); 3522 vrfy(3 << "x" == error(10032), '3648: 3 << "x" == error(10032)'); 3523 vrfy(3 << 1.5 == error(10032), '3649: 3 << 1.5 == error(10032)'); 3524 vrfy(3 << 2^31 == error(10032), '3650: 3 << 2^31 == error(10032)'); 3525 vrfy(scale("x",2) == error(10033), 3526 '3651: scale("x",2) == error(10033)'); 3527 vrfy(scale(3,"x") == error(10034), 3528 '3652: scale(3,"x") == error(10034)'); 3529 vrfy(scale(3,1.5) == error(10034), 3530 '3653: scale(3,1.5) == error(10034)'); 3531 vrfy(scale(3,2^31) == error(10034), 3532 '3654: scale(3,2^31) == error(10034)'); 3533 vrfy("x" ^ 3 == error(10035), '3655: "x" ^ 3 == error(10035)'); 3534 vrfy(2 ^ "x" == error(10036), '3656: 2 ^ "x" == error(10036)'); 3535 vrfy(2 ^ "2" == error(10036), '3657: 2 ^ "2" == error(10036)'); 3536 vrfy(power("x",2.1) == error(10037), 3537 '3658: power("x",2.1) == error(10037)'); 3538 vrfy(power(2,"x") == error(10038), 3539 '3659: power(2,"x") == error(10038)'); 3540 vrfy(power(2,2.1,"x") == error(10039), 3541 '3660: power(2,2.1,"x") == error(10039)'); 3542 vrfy(quo("x",3) == error(10040), 3543 '3661: quo("x",3) == error(10040)'); 3544 vrfy(quo(8,"x") == error(10041), 3545 '3662: quo(8,"x") == error(10041)'); 3546 vrfy(quo(8,3,"x") == error(10042), 3547 '3663: quo(8,3,"x") == error(10042)'); 3548 vrfy(quo(8,3,2.1) == error(10042), 3549 '3664: quo(8,3,2.1) == error(10042)'); 3550 vrfy(mod("x",3) == error(10043), 3551 '3665: mod("x",3) == error(10043)'); 3552 vrfy(mod(8,"x") == error(10044), 3553 '3666: mod(8,"x") == error(10044)'); 3554 vrfy(mod(8,3,"x") == error(10045), 3555 '3667: mod(8,3,"x") == error(10045)'); 3556 vrfy(mod(8,3,2.1) == error(10045), 3557 '3668: mod(8,3,2.1) == error(10045)'); 3558 vrfy(sgn("x") == error(10046), 3559 '3669: sgn("x") == error(10046)'); 3560 vrfy(abs("x") == error(10047), 3561 '3670: abs("x") == error(10047)'); 3562 vrfy(abs(2+3i,"x") == error(10048), 3563 '3671: abs(2+3i,"x") == error(10048)'); 3564 vrfy(abs(2+3i,0) == error(10048), 3565 '3672: abs(2+3i,0) == error(10048)'); 3566 list1 = list(2,3,"x",4,5); 3567 print '3673: list1 = list(2,3,"x",4,5)'; 3568 vrfy(avg(list1) == error(10003), 3569 '3674: avg(list1) == error(10003)'); 3570 3571 vrfy(iserror(e99)==99, '3675: iserror(e99) == 99'); 3572 vrfy(e99 + 2 == e99, '3676: e99 + 2 == e99'); 3573 vrfy(e99 - 2 == e99, '3677: e99 - 2 == e99'); 3574 vrfy(e99 * 2 == e99, '3678: e99 * 2 == e99'); 3575 vrfy(e99 / 2 == e99, '3679: e99 / 2 == e99'); 3576 vrfy(e99 // 2 == e99, '3680: e99 // 2 == e99'); 3577 vrfy(e99 % 2 == e99, '3681: e99 % 2 == e99'); 3578 vrfy(e99 ^ 2 == e99, '3682: e99 ^ 2 == e99'); 3579 vrfy(2 + e99 == e99, '3683: 2 + e99 == e99'); 3580 vrfy(2 - e99 == e99, '3684: 2 - e99 == e99'); 3581 vrfy(2 * e99 == e99, '3685: 2 * e99 == e99'); 3582 vrfy(2 / e99 == e99, '3686: 2 / e99 == e99'); 3583 vrfy(2 // e99 == e99, '3687: 2 // e99 == e99'); 3584 vrfy(2 % e99 == e99, '3688: 2 % e99 == e99'); 3585 vrfy(2 ^ e99 == e99, '3689: 2 ^ e99 == e99'); 3586 vrfy(- e99 == e99, '3690: -e99 == e99'); 3587 vrfy(inverse(e99) == e99, '3691: inverse(e99) == e99'); 3588 vrfy(++e99 == e99, '3692: ++e99 == e99'); 3589 vrfy(--e99 == e99, '3693: --e99 == e99'); 3590 vrfy(int(e99) == e99, '3694: int(e99) == e99'); 3591 vrfy(frac(e99) == e99, '3695: frac(e99) == e99'); 3592 vrfy(conj(e99) == e99, '3696: conj(e99) == e99'); 3593 vrfy(norm(e99) == e99, '3697: norm(e99) == e99'); 3594 vrfy(sgn(e99) == e99, '3698: sgn(e99) == e99'); 3595 vrfy(appr(e99,1,0) == e99, '3699: appr(e99,1,0) == e99'); 3596 vrfy(round(e99) == e99, '3700: round(e99) == e99'); 3597 vrfy(bround(e99) == e99, '3701: bround(e99) == e99'); 3598 vrfy(sqrt(e99) == e99, '3702: sqrt(e99) == e99'); 3599 print '3703: a = newerror("alpha")'; 3600 a = newerror("alpha"); 3601 print '3704: b = newerror("beta")'; 3602 b = newerror("beta"); 3603 print '3705: c = newerror("alpha")'; 3604 c = newerror("alpha"); 3605 vrfy(a == c, '3706: a == c'); 3606 vrfy(strerror(a) == "alpha", '3707: strerror(a) == "alpha"'); 3607 print '3708: n = iserror(a)'; 3608 n = iserror(a); 3609 vrfy(a == error(n), '3709: a == error(n)'); 3610 vrfy(newerror() == newerror("???"), 3611 '3710: newerror() == newerror("???")'); 3612 vrfy(newerror("") == newerror(), 3613 '3711: newerror("") == newerror()'); 3614 e9999 = error(9999); 3615 print '3712: e9999 = error(9999)'; 3616 vrfy(errno() == 9999, '3713: errno() == 9999'); 3617 vrfy(error() == e9999, '3714: error() == e9999'); 3618 /* test 3715 removed due to non-portable strerror() output */ 3619 x = newerror("Alpha"); 3620 print '3716: x = newerror("Alpha")'; 3621 n = iserror(x); 3622 print '3717: n = iserror(x)'; 3623 vrfy(errno() == n, '3718: errno() == n'); 3624 vrfy(error() == x, '3719: error() == x'); 3625 vrfy(strerror() == "Alpha", '3720: strerror() == "Alpha"'); 3626 vrfy(errno(9999) == n, '3721: errno() == n'); 3627 vrfy(errno() == 9999, '3722: errno() == 9999'); 3628 vrfy(error() == e9999, '3723: error() == e9999'); 3629 /* test 3724 removed due to non-portable strerror() output */ 3630 a = 1/0; 3631 print '3725: a = 1/0'; 3632 vrfy(strerror() == "Division by zero", 3633 '3726: strerror() == "Division by zero"'); 3634 n = 8191; 3635 print '3727: n = 8191'; 3636 /* test 3728 removed due to non-portable strerror() output */ 3637 vrfy(tan(2e9i) == error(10435), '3729: tan(2e9i) == error(10435)'); 3638 vrfy(cot(2e9i) == error(10437), '3730: cot(2e9i) == error(10437)'); 3639 vrfy(sec(2e9i) == error(10439), '3731: sec(2e9i) == error(10439)'); 3640 vrfy(csc(2e9i) == error(10440), '3732: csc(2e9i) == error(10440)'); 3641 3642 /* errmax and errcount should be bumped up the 148 errors above */ 3643 vrfy(errcount() == ecnt, '3733: errcount() == ecnt'); 3644 3645 print '3734: Ending test_error'; 3646} 3647print '054: parsed test_error()'; 3648 3649 3650/* 3651 * test_param - test new param() functionality. 3652 */ 3653define g_param() = (param(2) = param(1)); 3654print '055: define g_param() = (param(2) = param(1))'; 3655define h_param() = (param(1)++, param(2)--); 3656print '056: define h_param() = (param(1)++, param(2)--)'; 3657/**/ 3658global u_glob = 5; 3659print '057: global u_glob = 5'; 3660global v_glob = 10; 3661print '058: global v_glob = 10'; 3662vrfy(g_param(u_glob, `v_glob) == 5, '059: g_param(u_glob, `v_glob) == 5'); 3663vrfy(u_glob == 5, '060: u_glob == 5'); 3664vrfy(v_glob == 5, '061: v_glob == 5'); 3665vrfy(h_param(`u_glob, `v_glob) == 5, '062: h_param(`u_glob, `v_glob) == 5'); 3666vrfy(u_glob == 6, '063: u_glob == 6'); 3667vrfy(v_glob == 4, '064: v_glob == 4'); 3668/**/ 3669define test_param() 3670{ 3671 local u, v; 3672 3673 print '3800: Beginning test_param'; 3674 3675 u = 5; 3676 print '3801: u = 5'; 3677 v = 10; 3678 print '3802: v = 10'; 3679 vrfy(g_param(u, `v) == 5, '3803: g_param(u, `v) == 5'); 3680 vrfy(u == 5, '3804: u == 5'); 3681 vrfy(v == 5, '3805: v == 5'); 3682 vrfy(h_param(`u, `v) == 5, '3806: h_param(`u, `v) == 5'); 3683 vrfy(u == 6, '3807: u == 6'); 3684 vrfy(v == 4, '3808: v == 4'); 3685 3686 print '3809: Ending test_param'; 3687} 3688print '065: parsed test_param()'; 3689 3690 3691/* 3692 * test_noarg - test missing argument functionality 3693 */ 3694define test_noarg() 3695{ 3696 local A,B,C,D; 3697 3698 print '3900: Beginning test_noarg'; 3699 3700 A = list(1,,3); 3701 print '3901: A = list(1,,3)'; 3702 vrfy(A[[0]] == 1, '3902: A[[0]] == 1'); 3703 vrfy(isnull(A[[1]]), '3903: isnull(A[[1]])'); 3704 vrfy(A[[2]] == 3, '3904: A[[2]] == 3'); 3705 vrfy(size(A) == 3, '3905: size(A) == 3'); 3706 3707 B = list(,,); 3708 print '3906: B = list(,,)'; 3709 vrfy(isnull(B[[0]]), '3907: isnull(B[[0]])'); 3710 vrfy(isnull(B[[1]]), '3908: isnull(B[[1]])'); 3711 vrfy(isnull(B[[2]]), '3909: isnull(B[[2]])'); 3712 vrfy(size(B) == 3, '3910: size(B) == 3'); 3713 3714 mat C[] = {,,}; 3715 print '3911: mat C[] = {,,}'; 3716 vrfy(C[0] == 0, '3912: C[0] == 0'); 3717 vrfy(C[1] == 0, '3913: C[1] == 0'); 3718 vrfy(C[2] == 0, '3914: C[2] == 0'); 3719 vrfy(size(C) == 3, '3915: size(C) == 3'); 3720 3721 mat D[] = { }; 3722 print '3916: mat D[] = { }'; 3723 vrfy(D[0] == 0, '3917: D[0] == 0'); 3724 vrfy(size(D) == 1, '3918: size(D) == 1'); 3725 print '3919: Ending test_noarg'; 3726} 3727print '066: parsed test_noarg'; 3728 3729 3730/* 3731 * test_ptest - more tests of the functions ptest, nextcand, prevcand 3732 */ 3733read -once "test4000"; 3734print '067: read -once test4000'; 3735/**/ 3736define test_ptest() 3737{ 3738 local tnum; /* test number */ 3739 3740 print '4000: Beginning test_ptest'; 3741 3742 tnum = test4000(1, 4001); 3743 3744 print tnum: ': Ending test_ptest'; 3745} 3746print '068: parsed test_ptest()'; 3747 3748 3749/* 3750 * test_redc - REDC operation tests 3751 */ 3752read -once "test4100"; 3753print '069: read -once test4100'; 3754/**/ 3755define test_redc() 3756{ 3757 local tnum; /* test number */ 3758 3759 print '4100: Beginning test_redc'; 3760 3761 tnum = test4100(1, 4101); 3762 3763 print tnum: ': Ending test_redc'; 3764} 3765print '070: parsed test_redc()'; 3766 3767 3768/* 3769 * test_fileops - test various file operations 3770 */ 3771define test_fileops() 3772{ 3773 local a, b, c, f, m, n, p, r, s, x, y, z; 3774 local L = "Landon"; 3775 local C = "Curt"; 3776 local N = "Noll"; 3777 local LCN = "Landon\nCurt\nNoll\n"; 3778 local long = "0123456789abcdef0123456789abcdef"; 3779 3780 print '4200: Beginning test_fileops'; 3781 3782 /* 3783 * fputs tests 3784 */ 3785 x = rm("-f", "junk4200"); 3786 print '4201: x = rm("-f", "junk4200")'; 3787 vrfy(!iserror(f = fopen("junk4200", "w+")), 3788 '4202: !iserror(f = fopen("junk4200", "w+"))'); 3789 vrfy(!iserror(fputs(f, LCN)), '4203: !iserror(fputs(f, LCN))'); 3790 vrfy(isnull(rewind(f)), '4204: isnull(rewind(f))'); 3791 vrfy(fgetfield(f) == L, '4205: fgetfield(f) == L'); 3792 vrfy(fgetfield(f) == C, '4206: fgetfield(f) == C'); 3793 vrfy(fgetfield(f) == N, '4207: fgetfield(f) == N'); 3794 vrfy(isnull(fgetfield(f)), '4208: isnull(fgetfield(f))'); 3795 vrfy(isnull(rewind(f)), '4209: isnull(rewind(f))'); 3796 vrfy(fgetline(f) == L, '4210: fgetline(f) == L'); 3797 vrfy(fgetline(f) == C, '4211: fgetline(f) == C'); 3798 vrfy(fgetline(f) == N, '4212: fgetline(f) == N'); 3799 vrfy(isnull(fgetline(f)), '4213: isnull(fgetline(f))'); 3800 vrfy(isnull(rewind(f)), '4214: isnull(rewind(f))'); 3801 vrfy(fgets(f) == strcat(L,"\n"), '4215: fgets(f) == strcat(L,"\\n")'); 3802 vrfy(fgets(f) == strcat(C,"\n"), '4216: fgets(f) == strcat(C,"\\n")'); 3803 vrfy(fgets(f) == strcat(N,"\n"), '4217: fgets(f) == strcat(N,"\\n")'); 3804 vrfy(isnull(fgets(f)), '4218: isnull(fgets(f))'); 3805 vrfy(isnull(rewind(f)), '4219: isnull(rewind(f))'); 3806 vrfy(fgetstr(f) == LCN, '4220: fgetstr(f) == LCN'); 3807 vrfy(isnull(fclose(f)), '4221: isnull(fclose(f))'); 3808 vrfy(isnull(fclose(f)), '4222: isnull(fclose(f))'); 3809 3810 /* 3811 * fgetstr tests 3812 */ 3813 vrfy(!iserror(f = fopen("junk4200", "w+")), 3814 '4223: !iserror(f)'); 3815 3816 vrfy(isnull(fputstr(f, L, C, N)), 3817 '4224: isnulll(fputstr(f, L, C, N))'); 3818 vrfy(isnull(rewind(f)), '4225: isnull(rewind(f))'); 3819 vrfy(fgetstr(f) == L, '4226: fgetstr(f) == L'); 3820 vrfy(fgetstr(f) == C, '4227: fgetstr(f) == C'); 3821 vrfy(fgetstr(f) == N, '4228: fgetstr(f) == N'); 3822 vrfy(isnull(fgetstr(f)), '4229: isnull(fgetstr(f))'); 3823 n = ftell(f); 3824 print '4230: n = ftell(f)'; 3825 vrfy(isnull(fputs(f,L,"\n",C,"\n",N,"\n")), 3826 '4231: isnull(fputs(f,L,"\\n",C,"\\n",N,"\\n"))'); 3827 fseek(f, n); 3828 print '4232: fseek(f, n)'; 3829 vrfy(fgetstr(f) == LCN, '4233: fgetstr(f) == LCN'); 3830 vrfy(isnull(fclose(f)), '4234: isnull(fclose(f))'); 3831 3832 /* 3833 * fscanf tests 3834 */ 3835 a = exp(27, 1e-1000); 3836 print '4235: a = exp(27, 1e-1000)'; 3837 b = sqrt(7 + 5i, 1e-2000); 3838 print '4236: b = sqrt(7 + 5i, 1e-2000)'; 3839 c = config("display", 1000); 3840 print '4237: c = config("display", 1000)'; 3841 vrfy(!iserror(f=fopen("junk4200","w+")), 3842 '4238: !iserror(f=fopen("junk4200","w+"))'); 3843 vrfy(!iserror(fprintf(f, "%f\n\tand\n\t%r",a,b)), 3844 '4239: !iserror(fprintf(f, "%f\\n\\tand\\n\\t%r",a,b))'); 3845 vrfy(isnull(rewind(f)), '4240: isnull(rewind(f))'); 3846 vrfy(fscanf(f,"%f and %r",x,y)==2, 3847 '4241: fscanf(f,"%f and %r",x,y)==2'); 3848 vrfy(x == a && y == b, '4242: x == a && y == b'); 3849 vrfy(!iserror(freopen(f, "w+")), '4243: !iserror(freopen(f, "w+"))'); 3850 L = "Landon\n"; 3851 print '4244: L = "Landon\\n"'; 3852 C = "\tCurt\n"; 3853 print '4245: C = "\tCurt\\n"'; 3854 N = "\t\tNoll\n"; 3855 print '4246: N = "\\t\\tNoll\\n"'; 3856 vrfy(isnull(fputs(f, L, "|", C, "[", N, "]" )), 3857 '4247: isnull(fputs(f, L, "|", C, "[", N, "]" ))'); 3858 vrfy(isnull(rewind(f)), '4248: isnull(rewind(f))'); 3859 vrfy(fscanf(f, "%[^|]%*c%[^[]%*c%[^]]", x,y,z) == 3, 3860 '4249: fscanf(f, "%[^|]%*c%[^[]%*c%[^]]", x,y,z) == 3'); 3861 vrfy(x == L && y == C && z == N, 3862 '4250: x == L && y == C && z == N'); 3863 vrfy(isnull(rewind(f)), '4251: isnull(rewind(f))'); 3864 vrfy(fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2, 3865 '4252: fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2'); 3866 fseek(f, m); 3867 print '4253: fseek(f, m)'; 3868 vrfy(fscanf(f, "%3c", x) == 1, '4254: fscanf(f, "%3c", x) == 1'); 3869 vrfy(x == "\tCu", '4255: x == "\tCu"'); 3870 fseek(f, n); 3871 print '4256: fseek(f, n)'; 3872 vrfy(fscanf(f, "%s", y) == 1, '4257: fscanf(f, "%s", y) == 1'); 3873 vrfy(y == "Noll", '4258: y == "Noll"'); 3874 vrfy(isnull(fclose(f)), '4259: isnull(fclose(f))'); 3875 3876 /* 3877 * fpathopen tests 3878 */ 3879 vrfy(!iserror(p=fpathopen("junk4200","r",".")), 3880 '4260: !iserror(p=fparhopen("junk4200","r","."))'); 3881 vrfy(!iserror(fclose(p)), '4261: !iserror(fclose(p))'); 3882 vrfy(!iserror(r=fpathopen("regress.cal","r")), 3883 '4262: !iserror(r=fparhopen("regress.cal","r","."))'); 3884 vrfy(!iserror(fclose(r)), '4263: !iserror(fclose(r))'); 3885 3886 /* 3887 * verify non-stack overflow on long filenames 3888 */ 3889 long = long + long + long + long; 3890 print '4264: long = long + long + long + long;'; 3891 long = long + long + long + long; 3892 print '4265: long = long + long + long + long;'; 3893 vrfy(strlen(long) == 512, '4266: strlen(long) == 512'); 3894 /* bump ecnt up by 1 */ 3895 ++ecnt; 3896 print '4267: ++ecnt;'; 3897 vrfy(isfile(p=fopen(long,"r")) == 0, 3898 '4268: isfile(p=fopen(long,"r")) == 0'); 3899 3900 /* 3901 * test fgetfile() and fgetline() 3902 */ 3903 vrfy(!iserror(p=fopen("tmp4200","w")), 3904 '4269: !iserror(p=fopen("tmp4200","w"))'); 3905 vrfy(!iserror(fputs(p,"chongo\n")), 3906 '4270: !iserror(fputs(p,"chongo\n"))'); 3907 vrfy(!iserror(fputs(p,"w\0a\0s\n")), 3908 '4271: !iserror(fputs(p,"w\0a\0s\n"))'); 3909 vrfy(!iserror(fputs(p,"here\n")), 3910 '4272: !iserror(fputs(p,"here\n"))'); 3911 vrfy(!iserror(fclose(p)), '4273: !iserror(fclose(p))'); 3912 vrfy(!iserror(p=fopen("tmp4200","r")), 3913 '4274: !iserror(p=fopen("tmp4200","r"))'); 3914 vrfy(!iserror(s=fgetline(p)), '4275: !iserror(s=fgetline(p))'); 3915 vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0'); 3916 vrfy(!iserror(s=fgetfile(p)), '4277: !iserror(s=fgetfile(p))'); 3917 vrfy(strcmp(s,"w\0a\0s\nhere\n") == 0, 3918 '4278: strcmp(s,"w\0a\0s\nhere\n") == 0'); 3919 vrfy(!iserror(fclose(p)), '4279: !iserror(fclose(p))'); 3920 3921 /* 3922 * cleanup 3923 */ 3924 x = rm("junk4200"); 3925 print '4280: x = rm("junk4200")'; 3926 x = rm("tmp4200"); 3927 print '4281: x = rm("tmp4200")'; 3928 3929 print '4282: Ending test_fileops'; 3930} 3931print '071: parsed test_fileops()'; 3932 3933 3934/* 3935 * test_matdcl - test new matrix declaration syntax 3936 */ 3937mat_X0 = mat[4]; 3938print '072: mat_X = mat[4]'; 3939mat mat_X1, mat_X2[2]; mat mat_X3[3]; 3940print '073: mat mat_X1, mat_X2[2]; mat mat_X3[3]'; 3941mat mat_Z0, mat_Z1 [2] = {1,2}; 3942print '074: mat mat_Z0, mat_Z1 [2] = {1,2}'; 3943define test_matdcl() 3944{ 3945 local mat_Y0; 3946 local mat mat_Y1, mat_Y2[2], mat_Y3[3]; 3947 local mat M0, M1, M2[2,2]; 3948 local i; 3949 3950 print '4300: Beginning test_matdcl'; 3951 3952 vrfy(size(mat_X0) == 4, '4301: size(mat_X0) == 4'); 3953 vrfy(size(mat_X1) == 2, '4302: size(mat_X1) == 2'); 3954 vrfy(size(mat_X2) == 2, '4303: size(mat_X2) == 2'); 3955 vrfy(size(mat_X3) == 3, '4304: size(mat_X3) == 3'); 3956 vrfy(ismat(mat_X0), '4305: ismat(mat_X0)'); 3957 vrfy(ismat(mat_X1), '4306: ismat(mat_X1)'); 3958 vrfy(ismat(mat_X2), '4307: ismat(mat_X2)'); 3959 vrfy(ismat(mat_X3), '4308: ismat(mat_X3)'); 3960 mat_Y0 = mat[4]; 3961 print '4309: mat_Y0 = mat[4]'; 3962 vrfy(size(mat_Y0) == 4, '4310: size(mat_Y0) == 4'); 3963 vrfy(size(mat_Y1) == 2, '4311: size(mat_Y1) == 2'); 3964 vrfy(size(mat_Y2) == 2, '4312: size(mat_Y2) == 2'); 3965 vrfy(size(mat_Y3) == 3, '4313: size(mat_Y3) == 3'); 3966 vrfy(ismat(mat_Y0), '4314: ismat(mat_Y0)'); 3967 vrfy(ismat(mat_Y1), '4315: ismat(mat_Y1)'); 3968 vrfy(ismat(mat_Y2), '4316: ismat(mat_Y2)'); 3969 vrfy(ismat(mat_Y3), '4317: ismat(mat_Y3)'); 3970 vrfy(size(mat_Z0) == 2, '4318: size(mat_Z0) == 2'); 3971 vrfy(size(mat_Z1) == 2, '4319: size(mat_Z1) == 2'); 3972 vrfy(ismat(mat_Z0), '4320: ismat(mat_Z0)'); 3973 vrfy(ismat(mat_Z1), '4321: ismat(mat_Z1)'); 3974 vrfy(mat_Z0 == mat_Z1, '4322: mat_Z0 == mat_Z1'); 3975 vrfy(mat_Z0 == (mat[2] = {1,2}), '4323: mat_Z0 == (mat[2] = {1,2})'); 3976 vrfy(mat_Z0[0] == 1, '4324: mat_Z0[0] == 1'); 3977 vrfy(mat_Z0[1] == 2, '4325: mat_Z0[1] == 2'); 3978 mat_Z1 = {,3}; 3979 print '4326: mat_Z1 = {,3}'; 3980 vrfy(mat_Z0 != mat_Z1, '4327: mat_Z0 != mat_Z1'); 3981 vrfy(mat_Z1[0] == 1, '4328: mat_Z1[0] == 1'); 3982 vrfy(mat_Z1[1] == 3, '4329: mat_Z1[1] == 3'); 3983 mat_X3 = {2,3,5}; 3984 print '4330: mat_X3 = {2,3,5}'; 3985 mat_X3 += {3,4,5}; 3986 print '4331: mat_X3 += {3,4,5}'; 3987 vrfy(mat_X3[0] == 5, '4332: mat_X3[0] == 5'); 3988 vrfy(mat_X3[1] == 7, '4333: mat_X3[1] == 7'); 3989 vrfy(mat_X3[2] == 10, '4334: mat_X3[2] == 10'); 3990 mat_Y3 = mat_X3; 3991 print '4335: mat_Y3 = mat_X3'; 3992 mat_Y3 -= {,1,2}; 3993 print '4336: mat_Y3 -= {0,1,}'; 3994 vrfy(mat_Y3[0] == 0, '4337: mat_Y3[0] == 0'); 3995 vrfy(mat_Y3[1] == 6, '4338: mat_Y3[1] == 6'); 3996 vrfy(mat_Y3[2] == 8, '4339: mat_Y3[2] == 8'); 3997 ecnt += 2; 3998 print '4340: ecnt += 2'; 3999 mat_Y3 += 2; 4000 print '4341: mat_Y3 += 2'; 4001 vrfy(mat_Y3 == error(10003), '4342: mat_Y3 == error(10003)'); 4002 vrfy(errcount() == ecnt, '4343: errcount() == ecnt'); 4003 mat_Z0 += { }; 4004 print '4344: mat_Z0 += { }'; 4005 vrfy(mat_Z0[0] == 2, '4345: mat_Z0[0] == 2'); 4006 vrfy(mat_Z0[1] == 4, '4346: mat_Z0[1] == 4'); 4007 mat_Y0 = {mat_Z0, ,mat_Z1, mat_X3}; 4008 print '4347: mat_Y0 = {mat_Z0, ,mat_Z1, mat_X3}'; 4009 vrfy(size(mat_Y0) == 4, '4348: size(mat_Y0) == 4'); 4010 for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i]); 4011 print '4349: for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i])'; 4012 mat_X0==(mat[4]={2,1,2,3}); 4013 print '4350: mat_X0==(mat[4]={2,1,2,3})'; 4014 vrfy(mat_Y0[0] == mat_Z0, '4351: mat_Y0[0] == mat_Z0'); 4015 vrfy(mat_Y0[1] == 0, '4352: mat_Y0[1] == 0'); 4016 vrfy(mat_Y0[2] == mat_Z1, '4353: mat_Y0[2] == mat_Z1'); 4017 vrfy(mat_Y0[3] == mat_X3, '4354: mat_Y0[3] == mat_X3'); 4018 vrfy(mat_Y0[0][0] == 2, '4355: mat_Y0[0][0] == 2'); 4019 vrfy(mat_Y0[0][1] == 4, '4356: mat_Y0[0][1] == 4'); 4020 vrfy(mat_Y0[2][0] == 1, '4357: mat_Y0[2][0] == 1'); 4021 vrfy(mat_Y0[2][1] == 3, '4358: mat_Y0[2][1] == 3'); 4022 vrfy(mat_Y0[3][0] == 5, '4359: mat_Y0[3][0] == 5'); 4023 vrfy(mat_Y0[3][1] == 7, '4360: mat_Y0[3][1] == 7'); 4024 vrfy(mat_Y0[3][2] == 10, '4361: mat_Y0[3][2] == 10'); 4025 4026 M0 = {(mat[2]={5,17}),(mat[2]={3,4}),(mat[2]={2,3}),(mat[2]={1,2})}; 4027 print '4362: M0 = {(mat[2]={5,17}), ...}'; 4028 M1 = {(mat[2]={5,3}),(mat[2]={2,5}),(mat[2]={1,5}),(mat[2]={3,2})}; 4029 print '4363: M1 = {(mat[2]={5,3}), ...}'; 4030 M2 = M0+M1; 4031 print '4364: M2 = M0+M1'; 4032 vrfy(M2[0,0]==(mat[2]={10,20}), '4365: M2[0,0]==(mat[2]={10,20})'); 4033 vrfy(M2[0,1]==(mat[2]={5,9}), '4366: M2[0,1]==(mat[2]={5,9})'); 4034 vrfy(M2[1,0]==(mat[2]={3,8}), '4367: M2[1,0]==(mat[2]={3,20})'); 4035 vrfy(M2[1,1]==(mat[2]={4,4}), '4368: M2[1,1]==(mat[2]={4,4})'); 4036 4037 print '4369: Ending test_matdcl'; 4038} 4039print '075: parsed test_matdcl()'; 4040 4041 4042/* 4043 * test_objmat - test combined obj and mat operations 4044 */ 4045define test_objmat() 4046{ 4047 static obj surd P, R, S, T, U; 4048 local mat M0[2] = {5,17}; 4049 local mat M1[2] = {3,4}; 4050 local mat M2[2,2] = {1,2,3,5}; 4051 local mat M3[2,2] = {3,5,7,11}; 4052 local mat M4[2,2] = {51,82,116,187}; 4053 local Q; 4054 local V; 4055 local A,B,C,M; 4056 4057 print '4400: Beginning test_objmat'; 4058 4059 surd_type = -1; 4060 print '4401: surd_type == -1'; 4061 P = {M0,M1}; 4062 print '4402: P = {M0,M1}'; 4063 vrfy(P == surd(M0,M1), '4403: P == surd(M0,M1)'); 4064 vrfy(P != surd(M1,M0), '4404: P != surd(M1,M0)'); 4065 vrfy(conj(P)==surd(M0,-M1), '4405: conj(P)==surd(M0,-M1)'); 4066 Q = surd_value(P); 4067 print '4406: Q = surd_value(P)'; 4068 vrfy(ismat(Q), '4407: ismat(Q)'); 4069 vrfy(Q == (mat[2]={5+3i,17+4i}), '4408: Q == (mat[2]={5+3i,17+4i})'); 4070 R = {M2,M3}; 4071 print '4409: R = {M2,M3}'; 4072 vrfy(norm(R) == M4, '4410: norm(R) == M4'); 4073 vrfy(det(surd_value(R^2)) == -23-6i, \ 4074 '4411: det(surd_value(R^2)) == -23-6i'); 4075 vrfy(det(norm(R^5))==268107761663283843865, \ 4076 '4412: det(norm(R^5))==268107761663283843865'); 4077 S = {M2+M3, M2-M3}; 4078 print '4413: S = {M2+M3, M2-M3}'; 4079 T = {M2+3*M3, 5*M2-M3}; 4080 print '4414: T = {M2+3*M3, 5*M2-M3}'; 4081 U = {(M4 -= {50,80,110,180}), M4+M2}; 4082 print '4415: U = {(M4 -= {50,80,110,180}), M4+M2}'; 4083 vrfy(det(surd_value(R*S*T*U)) == 480-15040i, 4084 '4416: det(surd_value(R*S*T*U)) == 480-15040i'); 4085 vrfy(det(surd_value(R*S+T*U)) == 78+514i, 4086 '4417: det(surd_value(R*S+T*U)) == 78+514i'); 4087 V = norm(det(surd_value(R^5+S^5+T^5+U^5))); 4088 print '4418: V = norm(det(surd_value(R^5+S^5+T^5+U^5)))'; 4089 vrfy(V == 41952632964892462488299378, \ 4090 '4419: V == 41952632964892462488299378'); 4091 V = norm(det(surd_value(R^5-S^5+T^5-U^5))); 4092 print '4420: V = norm(det(surd_value(R^5-S^5+T^5-U^5)))'; 4093 vrfy(V == 40891924356202870926321650, \ 4094 '4421: V == 40891924356202870926321650'); 4095 4096 4097 vrfy((mat [3] = {2,3,5})+(mat[3] = {7,11,13}) == (mat[3]={9,14,18}),\ 4098 '4422: (mat [3] = {2,3,5})+(mat[3] = {7,11,13}) == (mat[3]={9,14,18})'); 4099 4100 vrfy((mat [2,2] = {2,3,5,7})^2 == (mat[2,2] = {19, 27, 45, 64}),\ 4101 '4423: (mat [2,2] = {2,3,5,7})^2 == (mat[2,2] = {19, 27, 45, 64})'); 4102 4103 vrfy((mat [] = {1,2,3}) == (mat[3] = {1,2,3}), 4104 '4424: (mat [] = {1,2,3}) == (mat[3] = {1,2,3})'); 4105 4106 mat A[3] = {2,3,5}; 4107 print '4425: mat A[3] = {2,3,5}'; 4108 mat A[3] = {A[0], A[2], A[1]}; 4109 print '4426: mat A[3] = {A[0], A[2], A[1]}'; 4110 vrfy(A == (mat[3] = {2, 5, 3}), '4427: A == (mat[3] = {2, 5, 3})'); 4111 4112 B = mat[3] = {2,5,3}; 4113 print '4428: B = mat[3] = {2,5,3}'; 4114 vrfy(A == B, '4429: A == B'); 4115 4116 mat A[2] = {A[1], A[2]}; 4117 print '4430: mat A[2] = {A[1], A[2]}'; 4118 vrfy(A == (mat[2] = {5, 3}), '4431: A == (mat[2] = {5, 3})'); 4119 4120 A = B; 4121 print '4432: A = B'; 4122 A = {A[0], A[2], A[1]}; 4123 print '4433: A = {A[0], A[2], A[1]}'; 4124 vrfy(A == (mat[3] = {2, 3, 3}), '4434: A == (mat[3] = {2, 3, 3})'); 4125 4126 A = mat[3] = {1,2} = {,3,4}; 4127 print '4435: A = mat[3] = {1,2} = {,3,4}'; 4128 vrfy(A == (mat[3] = {1,3,4}), '4436: A == (mat[3] = {1,3,4})'); 4129 4130 mat A[4] = {1,2,3,4}; 4131 print '4437: mat A[4] = {1,2,3,4}'; 4132 A = {,5,,6}; 4133 print '4438: A = {,5,,6}'; 4134 vrfy(A == (mat[4] = {1,5,3,6}), '4439: A == (mat[4] = {1,5,3,6})'); 4135 4136 A = {7}; 4137 print '4440: A = {7}'; 4138 vrfy(A == (mat[4] = {7,5,3,6}), '4441: A == (mat[4] = {7,5,3,6})'); 4139 4140 mat M[2]; 4141 print '4442: mat M[2]'; 4142 mat A, B, C [3] = {M, M, M}; 4143 print '4443: mat A, B, C [3] = {M, M, M}'; 4144 4145 A = {{2, 3}, {5, 7}, {11, 13}}; 4146 print '4444: A = {{2, 3}, {5, 7}, {11, 13}}'; 4147 B = {{1, 2}, {3, 4}, {5, 6}}; 4148 print '4445: B = {{1, 2}, {3, 4}, {5, 6}}'; 4149 C = {{3, 5}, {8, 11}, {16, 19}}; 4150 print '4446: C = {{3, 5}, {8, 11}, {16, 19}}'; 4151 4152 vrfy(A + B == C, '4447: A + B == C'); 4153 4154 mat A[2][3]; 4155 print '4448: mat A[2][3]'; 4156 A = {{1, 2, 3}, {4, 5, 6}}; 4157 print '4449: A = {{1, 2, 3}, {4, 5, 6}}'; 4158 vrfy(A[0][1] == 2, '4450: A[0][1] == 2'); 4159 4160 vrfy(A[1,0] == 4, '4451: A[1,0] == 4'); 4161 4162 B = mat[2][3] = {{1, 2, 3}, {4, 5, 6}}; 4163 print '4452: B = mat[2][3] = {{1, 2, 3}, {4, 5, 6}}'; 4164 vrfy(A == B, '4453: A == B'); 4165 4166 mat A[2][3] = {{1, 2, 3}, {4, 5, 6}}; 4167 print '4454: mat A[2][3] = {{1, 2, 3}, {4, 5, 6}}'; 4168 vrfy(A == B, '4455: A == B'); 4169 4170 mat A[2][3] = {{1,2,3},4}; 4171 print '4456: mat A[2][3] = {{1,2,3},4}'; 4172 vrfy(A[0] == (mat[3] = {1,2,3}), '4457: A[0] == (mat[3] = {1,2,3})'); 4173 4174 vrfy(A[1] == 4, '4458: A[1] == 4'); 4175 4176 A += {{3,5,7}, 11}; 4177 print '4459: A += {{3,5,7}, 11}'; 4178 4179 vrfy(A[0] == (mat[3]={4,7,10}), '4460: A[0] == (mat[3]={4,7,10})'); 4180 4181 vrfy(A[1] == 15, '4461: A[1] == 15'); 4182 4183 mat A[2,2][2,2]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}; 4184 print '4462: mat A[2,2][2,2]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}'; 4185 B = A^2; 4186 print '4463: B = A^2'; 4187 4188 vrfy(B[0,0] == (mat[2,2] = {118, 132, 166, 188}), \ 4189 '4464: B[0,0] == (mat[2,2] = {118, 132, 166, 188})'); 4190 4191 print '4465: Ending test_objmat'; 4192 print; 4193 print '4500: reserved for future expansion of test_objmat'; 4194} 4195print '076: parsed test_objmat()'; 4196 4197 4198/* 4199 * test_fileop - test file operations 4200 */ 4201read -once "test4600"; 4202print '077: read -once test4600'; 4203/**/ 4204define test_fileop() 4205{ 4206 local tnum; /* test number */ 4207 4208 print '4600: Beginning test_fileop'; 4209 4210 tnum = test4600(1, 4601); 4211 4212 print tnum: ': Ending test_fileop'; 4213} 4214print '078: parsed test_fileop()'; 4215 4216 4217/* 4218 * test write/read 4219 */ 4220x_081 = isqrt(2e5000); 4221print '079: x_081 = isqrt(2e5000)' 4222s_x_081 = str(x_081); 4223print '080: s_x_081 = str(x_081)'; 4224d_081 = rm("-f", "test082.cal"); 4225print '081: d_081 = rm("-f", "test082.cal")'; 4226write test082.cal; 4227print '082: write test082.cal'; 4228read "./test082.cal"; 4229print '083: read "./test082.cal"'; 4230d_081 = rm("test082.cal"); 4231print '084: d081 = rm("test082.cal")'; 4232vrfy(__ == 63, '085: __ == 63'); 4233vrfy(x_081 == isqrt(2e5000), '086: x_081 == isqrt(2e5000)'); 4234 4235 4236/* 4237 * test_charset - test the ASCII character set and \'s 4238 */ 4239define test_charset() 4240{ 4241 print '4700: Beginning test_charset'; 4242 4243 vrfy("\a" == char(7), '4701: "\\a" == char(7)'); 4244 vrfy("\v" == char(11), '4702: "\\v" == char(11)'); 4245 vrfy("\e" == char(27), '4703: "\\e" == char(27)'); 4246 vrfy("\\" == char(92), '4704: "\\\\" == char(92)'); 4247 vrfy("\101" == "A", '4705: "\\101" == "A"'); 4248 vrfy("\123" == char(0123), '4706: "\\123" == char(0123)'); 4249 vrfy("\123\124" == "ST", '4707: "\\123\\124" == "ST"'); 4250 vrfy("\311" == char(201), '4708: "\\311" == char(201)'); 4251 vrfy("\119" == "\t9", '4709: "\\119" == "\t9"'); 4252 vrfy("\765" == "\365", '4710: "\\765" == "\365"'); 4253 vrfy("\x61" == "a", '4711: "\\x61" == "a"'); 4254 vrfy("\x73" == "s", '4712: "\\x73" == "s"'); 4255 vrfy("\xea" == char(234), '4713: "\\xea" == char(234)'); 4256 vrfy("\x61\x62\x63" == "abc", '4714: "\\x61\\x62\\x63" == "abc"'); 4257 vrfy("\x8g" == "\bg", '4715: "\\x8g" == "\bg"'); 4258 vrfy(eval('"\\\\"') == "\\", 4259 '4716: eval(\'"\\\\\\\\"\') == "\\\\"'); 4260 4261 print '4717: Ending test_charset'; 4262} 4263print '087: parsed test_fileop()'; 4264 4265 4266/* 4267 * test_strprintf - test strprintf calls 4268 */ 4269define test_strprintf() 4270{ 4271 local callcfg; /* caller configuration value */ 4272 local c; /* modified configuration */ 4273 4274 print '4800: Beginning test_strprintf'; 4275 4276 /* setup */ 4277 callcfg = config("all"); 4278 print '4801: callcfg = config("all")'; 4279 c = config("mode", "frac"); 4280 print '4802: c = config("mode", "frac")'; 4281 c = config("outround", 24); 4282 print '4803: c = config("outround", 24)'; 4283 c = config("display", 2); 4284 print '4804: c = config("display", 2)'; 4285 c = config("tilde", 0); 4286 print '4805: c = config("tilde", 0)'; 4287 c = config("leadzero", 0); 4288 print '4806: c = config("leadzero", 0)'; 4289 c = config("fullzero", 0); 4290 print '4807: c = config("fullzero", 0)'; 4291 4292 /* tests with tilde == 0 */ 4293 vrfy(strprintf("%d%d", 27, 29) == "2729", 4294 '4808: strprintf("%d%d", 27, 29) == "2729"'); 4295 vrfy(strprintf("%5d%3d", 27, 29) == " 27 29", 4296 '4809: strprintf("%5d%3d", 27, 29) == " 27 29"; '); 4297 vrfy(strprintf("%-5d%-3d", 27, 29) == "27 29 ", 4298 '4810: strprintf("%-5d%-3d", 27, 29) == "27 29 "'); 4299 vrfy(strprintf("%f", 1.375) == "1.38", 4300 '4811: strprintf("%f", 1.375) == "1.38"'); 4301 vrfy(strprintf("%f", 1.385) == "1.38", 4302 '4812: strprintf("%f", 1.385) == "1.38"'); 4303 vrfy(strprintf("%f", .375) == ".38", 4304 '4813: strprintf("%f", .375) == ".38"'); 4305 vrfy(strprintf("%f", .385) == ".38", 4306 '4814: strprintf("%f", .385) == ".38"'); 4307 4308 /* tests with tilde == 1 */ 4309 c = config("tilde", 1); 4310 print '4815: c = config("tilde", 1)'; 4311 vrfy(strprintf("%f", 1.375) == "~1.38", 4312 '4816: strprintf("%f", 1.375) == "~1.38"'); 4313 vrfy(strprintf("%f", 27/29) == "~.93", 4314 '4817: strprintf("%f", 27/29) == "~.93"'); 4315 vrfy(strprintf("%r", 27/29) == "27/29", 4316 '4818: strprintf("%r", 27/29) == "27/29"'); 4317 vrfy(strprintf("%o", 27/29) == "033/035", 4318 '4819: strprintf("%o", 27/29) == "033/035"'); 4319 vrfy(strprintf("%x", 27/29) == "0x1b/0x1d", 4320 '4820: strprintf("%x", 27/29) == "0x1b/0x1d"'); 4321 vrfy(strprintf("%b", 27/29) == "0b11011/0b11101", 4322 '4821: strprintf("%b", 27/29) == "0b11011/0b11101"'); 4323 vrfy(strprintf("%e", 12345) == "~1.23e4", 4324 '4822: strprintf("%e", 12345) == "~1.23e4"'); 4325 vrfy(strprintf("%g", .385) == "~.38", 4326 '4823: strprintf("%g", .385) == "~.38"'); 4327 vrfy(strprintf("%g", 385) == "~3.8e2", 4328 '4824: strprintf("%g", 385) == "~3.8e2"'); 4329 4330 /* mode tests with tilde == 0 */ 4331 c = config("tilde", 0); 4332 print '4825: c = config("tilde", 0)'; 4333 vrfy(strprintf("%e", 12345) == "1.23e4", 4334 '4826: strprintf("%e", 12345) == "1.23e4"'); 4335 vrfy(strprintf("%.3e", 12345) == "1.234e4", 4336 '4827: strprintf("%.3e", 12345) == "1.234e4"'); 4337 vrfy(strprintf("%e", .00012345) == "1.23e-4", 4338 '4828: strprintf("%e", .00012345) == "1.23e-4"'); 4339 vrfy(strprintf("%d %d", 27) == "27 ", 4340 '4829: strprintf("%d %d", 27) == "27 "'); 4341 vrfy(strprintf("%d", 27, 29) == "27", 4342 '4830: strprintf("%d", 27, 29) == "27"'); 4343 vrfy(strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93", 4344 '4831: strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93"'); 4345 vrfy(strprintf("%s", "abc") == "abc", 4346 '4832: strprintf("%s", "abc") == "abc"'); 4347 vrfy(strprintf("%f", "abc") == "abc", 4348 '4833: strprintf("%f", "abc") == "abc"'); 4349 vrfy(strprintf("%e", "abc") == "abc", 4350 '4834: strprintf("%e", "abc") == "abc"'); 4351 vrfy(strprintf("%5s", "abc") == " abc", 4352 '4835: strprintf("%5s", "abc") == " abc"'); 4353 vrfy(strprintf("%-5s", "abc") == "abc ", 4354 '4836: strprintf("%-5s", "abc") == "abc "'); 4355 vrfy(strprintf("%g", .385) == ".38", 4356 '4837: strprintf("%g", .385) == ".38"'); 4357 vrfy(strprintf("%g", 385) == "3.8e2", 4358 '4838: strprintf("%g", 385) == "3.8e2"'); 4359 4360 /* restore config */ 4361 c = config("all", callcfg); 4362 print '4839: c = config("all", callcfg)'; 4363 4364 print '4840: Ending test_strprintf'; 4365} 4366print '088: parsed test_fileop()'; 4367 4368 4369/* 4370 * global and static assignment tests 4371 */ 4372global a = 10, b, c d = 20, e; 4373print '089: global a = 10, b, c d = 20, e, f'; 4374vrfy(a == 10, '090: a == 10'); 4375vrfy(b == 0, '091: b == 0'); 4376vrfy(c == 20, '092: c == 20'); 4377vrfy(d == 20, '093: d == 20'); 4378vrfy(e == 0, '094: e == 0'); 4379vrfy(f == 0, '095: f == 0'); 4380static a b = 30, c, e = 30; 4381print '096: static a b = 30, c, e = 30'; 4382vrfy(a == 30, '097: a == 30'); 4383vrfy(b == 30, '098: b == 30'); 4384vrfy(c == 0, '099: c == 0'); 4385vrfy(e == 30, '100: e == 30'); 4386global a, b; 4387print '101: global a, b'; 4388vrfy(a == 10, '102: a == 10'); 4389vrfy(b == 0, '103: b == 0'); 4390static mat A, B[2,2] = {1,2,3,4}; 4391print '104: static mat A, B[2,2] = {1,2,3,4}'; 4392define f100(x,y) = (mat [2,2] = {x,0,0,y}) * A; 4393print '105: define f100(x,y) = (mat [2,2] = {x,0,0,y}) * A'; 4394define g100(x) = (mat[2,2] = {x,x,x,x}) + B; 4395print '106: define g100(x) = (mat[2,2] = {x,x,x,x}) + B'; 4396define h100(a,b,c,d) = ((B = {a,b,c,d}), null()); 4397print '107: define h100(a,b,c,d) = ((B = {a,b,c,d}), null())'; 4398global A, B; 4399print '108: global A, B'; 4400vrfy(A == 0, '109: A == 0'); 4401vrfy(B == 0, '110: B == 0'); 4402x = test(f100(2,3) == (mat[2,2] = {2, 4, 9, 12})); 4403vrfy(x, '111: test(f100(2,3) == (mat[2,2] = {2, 4, 9, 12}))'); 4404x = test(g100(4) == (mat[2,2] = {5,6,7,8})); 4405vrfy(x, '112: test(g100(4) == (mat[2,2] = {5,6,7,8}))'); 4406x = test(h100(2,3,5,7) == null()); 4407vrfy(x, '113: test(h100(2,3,5,7) == null())'); 4408x = test(g100(4) == (mat[2,2] = {6,7,9,11})); 4409vrfy(x, '114: test(g100(4) == (mat[2,2] = {6,7,9,11}))'); 4410global obj point {x,y} P Q = {1,2}, R={3,4}, S; 4411print '115: global obj point {x,y} P, Q = {1,2}, R={3,4}, S'; 4412vrfy(P.x == 1, '116: P.x == 1'); 4413vrfy(P.y == 2, '117: P.y == 2'); 4414vrfy(Q.x == 1, '118: Q.x == 1'); 4415vrfy(Q.y == 2, '119: Q.y == 2'); 4416vrfy(R.x == 3, '120: R.x == 3'); 4417vrfy(R.y == 4, '121: R.y == 4'); 4418vrfy(S.x == 0, '122: S.x == 0'); 4419vrfy(S.y == 0, '123: S.y == 0'); 4420 4421 4422/* 4423 * test_listsearch - test searching in lists 4424 */ 4425define test_listsearch() 4426{ 4427 local L; 4428 4429 print '4900: Beginning test_listsearch'; 4430 4431 L = list(); 4432 print '4901: L = list()'; 4433 vrfy(isnull(search(L,1)), '4902: isnull(search(L,1))'); 4434 vrfy(isnull(rsearch(L,1)), '4903: isnull(search(L,1))'); 4435 L = list(0,1,2,3,0,1,2,3,0,1); 4436 print '4904: L = list(0,1,2,3,0,1,2,3,0,1)'; 4437 vrfy(search(L,0) == 0, '4905: search(L,0) == 0'); 4438 vrfy(rsearch(L,0) == 8, '4906: rsearch(L,0) == 8'); 4439 vrfy(search(L,0,2) == 4, '4907: search(L,0,2) == 4'); 4440 vrfy(rsearch(L,0,7) == 4, '4908: rsearch(L,0,7) == 4'); 4441 vrfy(isnull(search(L,2,7)), '4909: isnull(search(L,2,7))'); 4442 vrfy(isnull(rsearch(L,3,2)), '4910: isnull(rsearch(L,3,2))'); 4443 vrfy(isnull(search(L,0,1,4)), '4911: isnull(search(L,0,1,4)'); 4444 vrfy(isnull(rsearch(L,0,1,4)), '4912: isnull(rsearch(L,0,1,4)'); 4445 vrfy(search(L,0,-5) == 8, '4913: search(L,0,-5) == 8'); 4446 vrfy(rsearch(L,0,-9,-2) == 4, '4914: rsearch(L,0,-9,-2) == 4'); 4447 vrfy(isnull(search(L,3,20)), '4915: isnull(search(L,3,20)'); 4448 vrfy(isnull(search(L,3,0,-20)), '4916: isnull(search(L,3,0,-20)'); 4449 vrfy(isnull(rsearch(L,3,20,2)), '4917: isnull(rsearch(L,3,20,2)'); 4450 vrfy(rsearch(L,3,-20,20) == 7, '4918: rsearch(L,3,-20,20) == 7'); 4451 4452 print '4919: Ending test_strprintf'; 4453} 4454print '124: parsed test_listsearch()'; 4455 4456 4457/* 4458 * test_filesearch - test searching in files 4459 * 4460 * This function is designed to trigger 22 errors, so we bump the 4461 * errmax by 22 during this call. 4462 */ 4463define test_filesearch() 4464{ 4465 local f, g; /* open files */ 4466 local s; /* local string */ 4467 local a, b, c, d; /* new error values */ 4468 local x; 4469 4470 print '5000: Beginning test_filesearch'; 4471 4472 /* 4473 * setup 4474 */ 4475 print '5001: x = rm("-f", "junk5000")'; 4476 x = rm("-f", "junk5000"); 4477 f = fopen("junk5000", "w"); 4478 print '5002: f = fopen("junk5000", "w")'; 4479 if (iserror(f)) { 4480 prob("Unable to open \"junk5000\" for writing"); 4481 return; 4482 } 4483 print '5003: if (iserror(f)) { ... }'; 4484 s = "alpha beta gamma "; 4485 print '5004: s = "alpha beta gamma "'; 4486 4487 fputs(f, s); 4488 print '5005: fputs(f, s)'; 4489 fflush(f); 4490 print '5006: fflush(f)'; 4491 print '5007: test unused'; 4492 4493 /* bump errmax up by 16 */ 4494 ecnt += 16; 4495 print '5008: ecnt += 16'; 4496 4497 vrfy(search(f, 45) == error(10122), 4498 '5009: search(f, 45) == error(10122)'); 4499 vrfy(search(f, "a", 1/2) == error(10123), 4500 '5010: search(f, "a", 1/2) == error(10123)'); 4501 vrfy(search(f, "a", 0, "b") == error(10124), 4502 '5011: search(f, "a", 0, "b") == error(10124)'); 4503 vrfy(search(f, "a", 0) == error(10126), 4504 '5012: search(f, "a") == error(10126)'); 4505 vrfy(rsearch(f, 45) == error(10128), 4506 '5013: rsearch(f, 45) == error(10128)'); 4507 vrfy(rsearch(f, "a", "b") == error(10129), 4508 '5014: rsearch(f, "a", "b") == error(10129)'); 4509 vrfy(rsearch(f, "a", 0, "b") == error(10130), 4510 '5015: rsearch(f, "a", 0, "b") == error(10130)'); 4511 vrfy(rsearch(f, "a", 0) == error(10132), 4512 '5016: rsearch(f,"a",0) == error(10132)'); 4513 4514 /* errmax and errcount should be bumped up the 16 errors above */ 4515 vrfy(errcount() == ecnt, '5017: errcount() == ecnt'); 4516 4517 if (freopen(f, "r")) { 4518 prob("Unable to reopen \"junk5000\" for reading"); 4519 return; 4520 } 4521 print '5018: if (freopen(f, "r")) { ... }'; 4522 vrfy(fsize(f) == 17, '5019: fsize(f) == 17'); 4523 vrfy(search(f, s, 0) == 0, '5020: search(f, s, 0) == 0'); 4524 vrfy(ftell(f) == 17, '5021: ftell(f) == 17'); 4525 vrfy(rsearch(f, s, 0) == 0, '5022: rsearch(f, s, 0) == 0'); 4526 vrfy(ftell(f) == 16, '5023: ftell(f) == 16'); 4527 vrfy(search(f, "", 2) == 2, '5024: search(f, "", 2) == 2'); 4528 vrfy(ftell(f) == 2, '5025: ftell(f) == 2'); 4529 vrfy(search(f, "", 17) == 17, '5026: search(f, "", 17) == 17'); 4530 vrfy(ftell(f) == 17, '5027: ftell(f) == 17'); 4531 vrfy(isnull(search(f, "", 100)), 4532 '5028: isnull(search(f, "", 100))'); 4533 vrfy(ftell(f) == 17, '5029: ftell(f) == 17'); 4534 vrfy(rsearch(f, "", 5) == 5, '5030: rsearch(f, "", 5) == 5'); 4535 vrfy(ftell(f) == 5, '5031: ftell(f) == 5'); 4536 vrfy(search(f, "beta", 0) == 6, '5032: search(f, "beta", 0) == 6'); 4537 vrfy(ftell(f) == 10, '5033: ftell(f) == 10'); 4538 vrfy(rsearch(f, "beta", 100) == 6, 4539 '5034: rsearch(f, "beta", 100) == 6'); 4540 vrfy(ftell(f) == 9, '5035: ftell(f) == 9'); 4541 vrfy(search(f, "a", 2) == 4, '5036: search(f, "a", 2) == 4'); 4542 vrfy(ftell(f) == 5, '5037: ftell(f) == 5'); 4543 vrfy(search(f, "a", 4) == 4, '5038: search(f, "a", 4) == 4'); 4544 vrfy(search(f, "m") == 13, '5039: search(f, "m") == 13'); 4545 vrfy(search(f, "m") == 14, '5040: search(f, "m") == 14'); 4546 vrfy(isnull(search(f, "m")), '5041: isnull(search(f, "m"))'); 4547 vrfy(rsearch(f, "m", 15) == 14, '5042: rsearch(f, "m", 14) == 14'); 4548 vrfy(isnull(search(f, "beta", 7)), 4549 '5043: isnull(search(f, "beta", 7))'); 4550 vrfy(ftell(f) == 14, '5044: ftell(f) == 14'); 4551 vrfy(search(f,"a",2,15) == 4, '5045: search(f,"a",2,15) == 4'); 4552 vrfy(ftell(f) == 5, '5046: ftell(f) == 5'); 4553 vrfy(isnull(search(f,"a",2,4)), '5047: isnull(search(f,"a",2,4))'); 4554 vrfy(ftell(f) == 4, '5048: ftell(f) == 4'); 4555 vrfy(search(f,"a",,5) == 4, '5049: search(f,"a",,5) == 4'); 4556 vrfy(rsearch(f,"a",2,15) == 12, '5050: rsearch(f,"a",2,15) == 12'); 4557 vrfy(ftell(f) == 12, '5051: ftell(f) == 12'); 4558 vrfy(rsearch(f,"a",2,12) == 9, '5052: rsearch(f,"a",2,12) == 9'); 4559 4560 /* generate 2 more errors */ 4561 ecnt += 2; 4562 print '5053: ecnt += 2'; 4563 a = 2 + ""; 4564 print '5054: a = 2 + ""'; 4565 g = fopen(3, "r"); 4566 print '5055: g = fopen(3, "r")'; 4567 c = 5^2; 4568 print '5056: c = 5^2'; 4569 vrfy(errcount() == ecnt, '5057: errcount() == ecnt'); 4570 4571 /* generate 4 more errors by testing newerror */ 4572 ecnt += 4; 4573 print '5058: ecnt += 4'; 4574 a = newerror("alpha"); 4575 print '5059: a = newerror("alpha")'; 4576 b = newerror("beta"); 4577 print '5060: b = newerror("beta")'; 4578 c = newerror("alpha"); 4579 print '5061: c = newerror("alpha")'; 4580 d = newerror("beta"); 4581 print '5062: d = newerror("beta")'; 4582 vrfy(errcount() == ecnt, '5063: errcount() == ecnt'); 4583 vrfy(a == c, '5064: a == c'); 4584 vrfy(b == d, '5065: b == d'); 4585 4586 /* test error(0) */ 4587 error(0); 4588 print '5066: error(0)'; 4589 vrfy(strerror() == "No error", '5067: strerror() == "No error"'); 4590 4591 /* 4592 * close down 4593 */ 4594 fclose(f); 4595 print '5068: fclose(f)'; 4596 rm("junk5000"); 4597 print '5069: rm("junk5000")'; 4598 4599 print '5070: Ending test_filesearch'; 4600} 4601print '125: parsed test_filesearch()'; 4602 4603 4604/* 4605 * test_newdecl - test the new code generator declaration scope and order 4606 */ 4607read -once "test5100"; 4608print '126: read -once test5100'; 4609/**/ 4610define test_newdecl() 4611{ 4612 4613 print '5100: Beginning test_newdecl'; 4614 4615 /* 4616 * test5100 calls 4617 */ 4618 test5100(1); 4619 print '5101: test5100(1)'; 4620 vrfy(a5100 == 0, '5102: a5100 == 0'); 4621 vrfy(b5100 == 2, '5103: b5100 == 2'); 4622 test5100(1); 4623 print '5104: test5100(1)'; 4624 vrfy(a5100 == 0, '5105: a5100 == 0'); 4625 vrfy(b5100 == 3, '5106: b5100 == 3'); 4626 test5100(1); 4627 print '5107: test5100(1)'; 4628 vrfy(a5100 == 0, '5108: a5100 == 0'); 4629 vrfy(b5100 == 4, '5109: b5100 == 4'); 4630 test5100(2); 4631 print '5110: test5100(2)'; 4632 vrfy(a5100 == 3, '5111: a5100 == 3'); 4633 vrfy(b5100 == 4, '5112: b5100 == 4'); 4634 test5100(2); 4635 print '5113: test5100(2)'; 4636 vrfy(a5100 == 4, '5114: a5100 == 4'); 4637 vrfy(b5100 == 4, '5115: b5100 == 4'); 4638 test5100(2); 4639 print '5116: test5100(2)'; 4640 vrfy(a5100 == 5, '5117: a5100 == 5'); 4641 vrfy(b5100 == 4, '5118: b5100 == 4'); 4642 test5100(3); 4643 print '5119: test5100(3)'; 4644 vrfy(a5100 == 5, '5120: a5100 == 5'); 4645 vrfy(b5100 == 5, '5121: b5100 == 5'); 4646 test5100(9); 4647 print '5122: test5100(9)'; 4648 vrfy(a5100 == 5, '5123: a5100 == 5'); 4649 vrfy(b5100 == 6, '5124: b5100 == 6'); 4650 test5100(0); 4651 print '5125: test5100(0)'; 4652 vrfy(a5100 == 5, '5126: a5100 == 5'); 4653 vrfy(b5100 == 6, '5127: b5100 == 6'); 4654 test5100(-1); 4655 print '5128: test5100(-1)'; 4656 vrfy(a5100 == 5, '5129: a5100 == 5'); 4657 vrfy(b5100 == 6, '5130: b5100 == 6'); 4658 4659 print '5131: Ending test_newdecl'; 4660 4661} 4662print '127: parsed test_newdecl()'; 4663 4664 4665/* 4666 * test_globstat - test the fix of a global/static bug 4667 */ 4668read -once "test5200"; 4669print '128: read -once test5200'; 4670/**/ 4671define test_globstat() 4672{ 4673 print '5200: Beginning test_globstat'; 4674 4675 /* 4676 * test {f,g,h}5200 calls 4677 */ 4678 vrfy(a5200 == 10, '5201: a5200 == 10'); 4679 vrfy(eval("a5200") == 10, '5202: eval("a5200") == 10'); 4680 vrfy(f5200(1) == 21, '5203: f5200(1) == 21'); 4681 vrfy(a5200 == 10, '5204: a5200 == 10'); 4682 vrfy(eval("a5200") == 10, '5205: eval("a5200") == 10'); 4683 vrfy(h5200(2) == 12, '5206: h5200(2) == 12'); 4684 vrfy(a5200 == 10, '5207: a5200 == 10'); 4685 vrfy(eval("a5200") == 10, '5208: eval("a5200") == 10'); 4686 vrfy(g5200(3) == 33, '5209: g5200(3) == 33'); 4687 vrfy(a5200 == 30, '5210: a5200 == 30'); 4688 vrfy(eval("a5200") == 30, '5211: eval("a5200") == 30'); 4689 vrfy(h5200(4) == 34, '5212: h5200(4) == 34'); 4690 vrfy(f5200(5) == 25, '5213: f5200(5) == 25'); 4691 vrfy(h5200(6) == 36, '5214: h5200(6) == 36'); 4692 vrfy(g5200(7) == 37, '5215: g5200(7) == 37'); 4693 vrfy(f5200(8) == 28, '5216: f5200(8) == 28'); 4694 vrfy(g5200(9) == 39, '5217: g5200(9) == 39'); 4695 vrfy(a5200 == 30, '5218: a5200 == 30'); 4696 vrfy(eval("a5200") == 30, '5219: eval("a5200") == 30'); 4697 4698 print '5220: Ending test_globstat'; 4699} 4700print '129: parsed test_globstat()'; 4701 4702 4703/* 4704 * test_newop2 - test new label stuff 4705 */ 4706define test_newop2(x) {if (x < 0) goto l130; ++x; l130: return x;} 4707print '130: define test_newop3(x) {if (x < 0) goto l130; ++x; l130: return x;}' 4708vrfy(test_newop2(100) == 101, '131: test_newop2(100) == 101'); 4709vrfy(test_newop2(-100) == -100, '132: test_newop2(-100) == -100'); 4710 4711 4712/* 4713 * test_newop3 - test new label stuff 4714 */ 4715define test_newop3(x) { 4716 if (x < 4) 4717 if (iseven(x)) 4718 goto l135; 4719 else 4720 return 2; 4721 return 3; 4722 l135: 4723 return 1; 4724} 4725print '133: define test_newop3(x) ...'; 4726vrfy(test_newop3(2) == 1, '134: test_newop3(2) == 1'); 4727vrfy(test_newop3(3) == 2, '135: test_newop3(3) == 2'); 4728vrfy(test_newop3(4) == 3, '136: test_newop3(4) == 3'); 4729 4730 4731/* 4732 * Test random - Blum-Blum-Shub pseudo-random number generator 4733 */ 4734define test_random() 4735{ 4736 local init; /* initial generator state */ 4737 local state0; /* a generator state */ 4738 local state1; /* a generator state */ 4739 local tmp; 4740 local n; 4741 4742 print '5300: Beginning random test'; 4743 4744 /* test save and restore of the initial state */ 4745 tmp = srandom(0); 4746 print '5301: tmp = srandom(0)'; 4747 init = srandom(); 4748 print '5302: init = srandom()'; 4749 state0 = srandom(0); 4750 print '5303: state0 = srandom(0)'; 4751 vrfy(state0 == init, '5304: state0 == init'); 4752 4753 /* test the subtractive 100 shuffle generator */ 4754 tmp = srandom(0); 4755 print '5305: tmp = srandom(0)'; 4756 vrfy(random() == 0x7fb838a8a0a95046, \ 4757 '5306: random() == 0x7fb838a8a0a95046'); 4758 vrfy(random() == 0xb9d9d9fb4440f7bb, \ 4759 '5307: random() == 0xb9d9d9fb4440f7bb'); 4760 tmp = srandom(init); 4761 print '5308: tmp = srandom(init)'; 4762 vrfy(random() == 0x7fb838a8a0a95046, \ 4763 '5309: random() == 0x7fb838a8a0a95046'); 4764 vrfy(random() == 0xb9d9d9fb4440f7bb, \ 4765 '5310: random() == 0xb9d9d9fb4440f7bb'); 4766 4767 /* test range interface */ 4768 tmp = srandom(0); 4769 print '5311: tmp = srandom(0)'; 4770 vrfy(random(12345678901234567890) == 0x7fb838a8a0a95046, \ 4771 '5312: random(12345678901234567890) == 0x7fb838a8a0a95046'); 4772 vrfy(random(216091) == 0x2e767, '5313: random(216091) == 0x2e767'); 4773 vrfy(random(100) == 0x33, '5314: random(100) == 0x33'); 4774 vrfy(random(-46,46) == -0xc, '5315: random(-46,46) == -0xc'); 4775 tmp = srandom(0); 4776 print '5316: tmp = srandom(0)'; 4777 vrfy(random(2^64) == 0x7fb838a8a0a95046, \ 4778 '5317: random(2^64) == 0x7fb838a8a0a95046'); 4779 vrfy(random(0,2^64) == 0xb9d9d9fb4440f7bb, \ 4780 '5318: random(0,2^64) == 0xb9d9d9fb4440f7bb'); 4781 4782 /* test different forms of seeding the initial state */ 4783 tmp = srandom(0); 4784 print '5319: tmp = srandom(0)'; 4785 vrfy(srandom() == init, '5320: srandom() == init'); 4786 tmp = srandom(0x87e6ec938ff55aa5<<64); 4787 print '5321: tmp = srandom(0x87e6ec938ff55aa5<<64)'; 4788 vrfy(srandom() == init, '5322: srandom() == init'); 4789 tmp = srandom(state0); 4790 print '5323: tmp = srandom(state0)'; 4791 vrfy(srandom() == init, '5324: srandom() == init'); 4792 tmp = srandom(init); 4793 print '5325: tmp = srandom(init)'; 4794 vrfy(srandom() == init, '5326: srandom() == init'); 4795 vrfy(tmp == init, '5327: tmp == init'); 4796 4797 /* test the bit length interface */ 4798 tmp = srandom(0); 4799 print '5328: tmp = srandomom(0)'; 4800 vrfy(randombit(64) == 0x7fb838a8a0a95046, \ 4801 '5329: randombit(64) == 0x7fb838a8a0a95046'); 4802 vrfy(randombit(128) == 0xb9d9d9fb4440f7bbc1a7bd3b4e853fc9, \ 4803 '5330: randombit(128) == 0xb9d9d9fb4440f7bbc1a7bd3b4e853fc9'); 4804 vrfy(randombit(64) == 0x2d4e1588719986aa, \ 4805 '5331: randombit(64) == 0x2d4e1588719986aa'); 4806 vrfy(randombit(128) == 0x8d68905434b020ccb849e17a03a5c441, \ 4807 '5332: randombit(128) == 0x8d68905434b020ccb849e17a03a5c441'); 4808 tmp = srandom(0); 4809 print '5333: tmp = srandom(0)'; 4810 vrfy(randombit(32) == 0x7fb838a8, '5334: randombit(32) == 0x7fb838a8'); 4811 vrfy(randombit(32) == 0xa0a95046, '5335: randombit(32) == 0xa0a95046'); 4812 vrfy(randombit(1) == 0x1, '5336: randombit(1) == 0x1'); 4813 vrfy(randombit(5) == 0xe, '5337: randombit(5) == 0xe'); 4814 vrfy(randombit(33) == 0xececfda2, '5338: randombit(33) == 0xececfda2'); 4815 vrfy(randombit(25) == 0x40f7bb, '5339: randombit(25) == 0x40f7bb'); 4816 vrfy(randombit(2) == 0x3, '5340: randombit(2) == 0x3'); 4817 vrfy(randombit(13) == 0xd3, '5341: randombit(13) == 0xd3'); 4818 vrfy(randombit(18) == 0x37a76, '5342: randombit(18) == 0x37a76'); 4819 vrfy(randombit(8) == 0x9d, '5343: randombit(8) == 0x9d'); 4820 vrfy(randombit(9) == 0x14, '5344: randombit(9) == 0x14'); 4821 vrfy(randombit(70) == 0x3fc92d4e1588719986, \ 4822 '5345: randombit(70) == 0x3fc92d4e1588719986'); 4823 vrfy(randombit(123) == 0x5546b4482a1a5810665c24f0bd01d2e, \ 4824 '5346: randombit(123) == 0x5546b4482a1a5810665c24f0bd01d2e'); 4825 vrfy(randombit(8) == 0x22, '5347: randombit(8) == 0x22'); 4826 vrfy(randombit(65) == 0x1d2a104aaf523699, \ 4827 '5348: randombit(65) == 0x1d2a104aaf523699'); 4828 vrfy(randombit(63) == 0x60e63d498ba690ec, \ 4829 '5349: randombit(63) == 0x60e63d498ba690ec'); 4830 vrfy(randombit(1) == 0x1, '5350: randombit(1) == 0x1'); 4831 vrfy(randombit(2) == 0x3, '5351: randombit(2) == 0x3'); 4832 vrfy(randombit(4) == 0x0, '5352: randombit(4) == 0x0'); 4833 vrfy(randombit(3) == 0x0, '5353: randombit(3) == 0x0'); 4834 state1 = srandom(); 4835 print '5354: state1 = srandom()'; 4836 4837 /* test randombit skip interface */ 4838 tmp = srandom(0); 4839 print '5355: tmp = srandom(0)'; 4840 vrfy(randombit(20) == 523139, '5356: randombit(20) == 523139'); 4841 vrfy(randombit(20) == 567456, '5357: randombit(20) == 567456'); 4842 vrfy(randombit(20) == 693508, '5358: randombit(20) == 693508'); 4843 vrfy(randombit(20) == 440793, '5359: randombit(20) == 440793'); 4844 tmp = srandom(0); 4845 print '5360: tmp = srandom(0)'; 4846 vrfy(randombit(-20) == 20, '5361: randombit(-20) == 20'); 4847 vrfy(randombit(20) == 567456, '5362: randombit(20) == 567456'); 4848 vrfy(randombit(-20) == 20, '5363: randombit(-20) == 20'); 4849 vrfy(randombit(20) == 440793, '5364: randombit(20) == 440793'); 4850 4851 /* test randombit without and arg */ 4852 tmp = srandom(0); 4853 print '5365: tmp = srandom(0)'; 4854 vrfy(randombit() == 0, '5366: randombit() == 0'); 4855 vrfy(randombit() == 1, '5367: randombit() == 1'); 4856 vrfy(randombit() == 1, '5368: randombit() == 1'); 4857 4858 /* test range interface some more */ 4859 tmp = srandom(state1); 4860 print '5369: tmp = srandom(state1)'; 4861 vrfy(random(-46,46) == -0x7, '5370: random(-46,46) == -0x7'); 4862 vrfy(random(21701,23209) == 23061, 4863 '5371: random(21701,23209) == 23061'); 4864 vrfy(random(0x22,0x1d2a104aaf523699) == 0x17c97dfa80bbdf1b, 4865 '5372: random(0x22,0x1d2a104aaf523699) == 0x17c97dfa80bbdf1b'); 4866 vrfy(random(0x2d4e16aa,0x7fb83046) == 0x48e98d92, 4867 '5373: random(0x2d4e16aa,0x7fb83046) == 0x48e98d92'); 4868 vrfy(random(-0x2d4986aa,0x7fb83846) == 0x3b3f6c0c, 4869 '5374: random(-0x2d4986aa,0x7fb83846) == 0x3b3f6c0c'); 4870 vrfy(random(-0x2d9986aa,-0x7fb9504) == -0x235f9ce1, 4871 '5375: random(-0x2d9986aa,-0x7fb9504) == -0x235f9ce1'); 4872 4873 4874 /* test pre-compiled random states */ 4875 tmp = srandom(init); 4876 print '5376: tmp = srandom(init)'; 4877 state0 = srandom(0,1); 4878 print '5377: state0 = srandom(0,1)'; 4879 vrfy(randombit(123) == 0x4cf8834399f8832d5c1ec35f20095f0, \ 4880 '5378: randombit(123) == 0x4cf8834399f8832d5c1ec35f20095f0'); 4881 state1 = srandom(123455432112345,1); 4882 print '5379: state1 = srandom(123455432112345,1)'; 4883 vrfy(randombit(123) == 0x437c9618d5a9c07d935b0ff7cef7346, \ 4884 '5380: randombit(123) == 0x437c9618d5a9c07d935b0ff7cef7346'); 4885 tmp = srandom(0,1); 4886 print '5381: tmp = srandom(0,1)'; 4887 vrfy(randombit(-123) == 123, '5382: randombit(-123) == 123'); 4888 vrfy(srandom() == state1, '5383: srandom() == state1'); 4889 tmp = srandom(0,2); 4890 print '5384: tmp = srandom(0,2)'; 4891 vrfy(randombit(123) == 0x7d53b2dbfe1edcb07df84f7fe96d5e9, \ 4892 '5385: randombit(123) == 0x7d53b2dbfe1edcb07df84f7fe96d5e9'); 4893 tmp = srandom(0,3); 4894 print '5386: tmp = srandom(0,3)'; 4895 vrfy(randombit(123) == 0x365cbae1adb9a706816abe3b64c1f2a, \ 4896 '5387: randombit(123) == 0x365cbae1adb9a706816abe3b64c1f2a'); 4897 tmp = srandom(0,4); 4898 print '5388: tmp = srandom(0,4)'; 4899 vrfy(randombit(123) == 0x63d9621736e59a3a5a8311117a1ef01, \ 4900 '5389: randombit(123) == 0x63d9621736e59a3a5a8311117a1ef01'); 4901 tmp = srandom(0,5); 4902 print '5390: tmp = srandom(0,5)'; 4903 vrfy(randombit(123) == 0x38d90517d6d532d1efb6eaf26bf927, \ 4904 '5391: randombit(123) == 0x38d90517d6d532d1efb6eaf26bf927'); 4905 tmp = srandom(0,6); 4906 print '5392: tmp = srandom(0,6)'; 4907 vrfy(randombit(123) == 0x146f2a1ce8cabcc313ab24f73747fbc, \ 4908 '5393: randombit(123) == 0x146f2a1ce8cabcc313ab24f73747fbc'); 4909 tmp = srandom(0,7); 4910 print '5394: tmp = srandom(0,7)'; 4911 vrfy(randombit(123) == 0x7a4a2b4ed817e5267358ea2979155d8, \ 4912 '5395: randombit(123) == 0x7a4a2b4ed817e5267358ea2979155d8'); 4913 tmp = srandom(0,8); 4914 print '5396: tmp = srandom(0,8)'; 4915 vrfy(randombit(123) == 0x5f30f211464854a37989cca3a8ecd0a, \ 4916 '5397: randombit(123) == 0x5f30f211464854a37989cca3a8ecd0a'); 4917 tmp = srandom(0,9); 4918 print '5398: tmp = srandom(0,9)'; 4919 vrfy(randombit(123) == 0x73aa8e572ee77682ae317804ed8d6e5, \ 4920 '5399: randombit(123) == 0x73aa8e572ee77682ae317804ed8d6e5'); 4921 tmp = srandom(0,10); 4922 print '5400: tmp = srandom(0,10)'; 4923 vrfy(randombit(123) == 0x49c7acca8f461ad2edf4cb7651f18d3, \ 4924 '5401: randombit(123) == 0x49c7acca8f461ad2edf4cb7651f18d3'); 4925 tmp = srandom(0,11); 4926 print '5402: tmp = srandom(0,11)'; 4927 vrfy(randombit(123) == 0x6042e2169a73140ffab1881df99a0ee, \ 4928 '5403: randombit(123) == 0x6042e2169a73140ffab1881df99a0ee'); 4929 tmp = srandom(0,12); 4930 print '5404: tmp = srandom(0,12)'; 4931 vrfy(randombit(123) == 0x7b98097947d478611d96f4d7a1cd2af, \ 4932 '5405: randombit(123) == 0x7b98097947d478611d96f4d7a1cd2af'); 4933 tmp = srandom(0,13); 4934 print '5406: tmp = srandom(0,13)'; 4935 vrfy(randombit(123) == 0x12324fd76d7a4a5a979765be2d57cfa, \ 4936 '5407: randombit(123) == 0x12324fd76d7a4a5a979765be2d57cfa'); 4937 tmp = srandom(0,14); 4938 print '5408: tmp = srandom(0,14)'; 4939 vrfy(randombit(123) == 0x377ff9ef04ee24887984995f91489a3, \ 4940 '5409: randombit(123) == 0x377ff9ef04ee24887984995f91489a3'); 4941 tmp = srandom(0,15); 4942 print '5410: tmp = srandom(0,15)'; 4943 vrfy(randombit(123) == 0x7db2b6245c5a24a1a52f74c8f828c6f, \ 4944 '5411: randombit(123) == 0x7db2b6245c5a24a1a52f74c8f828c6f'); 4945 tmp = srandom(0,16); 4946 print '5412: tmp = srandom(0,16)'; 4947 vrfy(randombit(123) == 0x5958e6cc460c28a5e741706fd442f12, \ 4948 '5413: randombit(123) == 0x5958e6cc460c28a5e741706fd442f12'); 4949 tmp = srandom(0,17); 4950 print '5414: tmp = srandom(0,17)'; 4951 vrfy(randombit(123) == 0x68c40ccf3805b2734d0d2881ca268d, \ 4952 '5415: randombit(123) == 0x68c40ccf3805b2734d0d2881ca268d'); 4953 tmp = srandom(0,18); 4954 print '5416: tmp = srandom(0,18)'; 4955 vrfy(randombit(123) == 0x4afc6cd3b9e14dadc5b75c6a81602e5, \ 4956 '5417: randombit(123) == 0x4afc6cd3b9e14dadc5b75c6a81602e5'); 4957 tmp = srandom(0,19); 4958 print '5418: tmp = srandom(0,19)'; 4959 vrfy(randombit(123) == 0x3ea4d30abf7da6596d2425e0a9a6348, \ 4960 '5419: randombit(123) == 0x3ea4d30abf7da6596d2425e0a9a6348'); 4961 tmp = srandom(0,20); 4962 print '5420: tmp = srandom(0,20)'; 4963 vrfy(randombit(123) == 0x77f848c70d4622ed41956eceb3f15f6, \ 4964 '5421: randombit(123) == 0x77f848c70d4622ed41956eceb3f15f6'); 4965 vrfy(randombit(123) == 0x5bfa034925acaf7ad5ba5d8f7f32369, \ 4966 '5422: randombit(123) == 0x5bfa034925acaf7ad5ba5d8f7f32369'); 4967 vrfy(randombit(123) == 0x761100a4cecbdac8c8d539dee0e278e, \ 4968 '5423: randombit(123) == 0x761100a4cecbdac8c8d539dee0e278e'); 4969 4970 4971 tmp = srandom(7^23+19,2); 4972 print '5424: tmp = srandom(7^23+19,2)'; 4973 vrfy(randombit(123) == 0x89b7ec9413e8af84a0c64ffc64d5a8, \ 4974 '5425: randombit(123) == 0x89b7ec9413e8af84a0c64ffc64d5a8'); 4975 tmp = srandom(7^23+19,3); 4976 print '5426: tmp = srandom(7^23+19,3)'; 4977 vrfy(randombit(123) == 0x7a2b8a6ca93a29deb1c3a674a30bf26, \ 4978 '5427: randombit(123) == 0x7a2b8a6ca93a29deb1c3a674a30bf26'); 4979 tmp = srandom(7^23+19,4); 4980 print '5428: tmp = srandom(7^23+19,4)'; 4981 vrfy(randombit(123) == 0x5425c6614dffcc0f376de4e9355c7df, \ 4982 '5429: randombit(123) == 0x5425c6614dffcc0f376de4e9355c7df'); 4983 tmp = srandom(7^23+19,5); 4984 print '5430: tmp = srandom(7^23+19,5)'; 4985 vrfy(randombit(123) == 0x70fca502499fa3717e346df5438886d, \ 4986 '5431: randombit(123) == 0x70fca502499fa3717e346df5438886d'); 4987 tmp = srandom(7^23+19,6); 4988 print '5432: tmp = srandom(7^23+19,6)'; 4989 vrfy(randombit(123) == 0x6ff886ac0918ad503290544af2cbd03, \ 4990 '5433: randombit(123) == 0x6ff886ac0918ad503290544af2cbd03'); 4991 tmp = srandom(7^23+19,7); 4992 print '5434: tmp = srandom(7^23+19,7)'; 4993 vrfy(randombit(123) == 0x5747d8c33d6d6dc53357779dffcc430, \ 4994 '5435: randombit(123) == 0x5747d8c33d6d6dc53357779dffcc430'); 4995 tmp = srandom(7^23+19,8); 4996 print '5436: tmp = srandom(7^23+19,8)'; 4997 vrfy(randombit(123) == 0x12769f65324d5e7986120b0caf071ad, \ 4998 '5437: randombit(123) == 0x12769f65324d5e7986120b0caf071ad'); 4999 tmp = srandom(7^23+19,9); 5000 print '5438: tmp = srandom(7^23+19,9)'; 5001 vrfy(randombit(123) == 0x3f94d3585b986539158f6ccd97d261e, \ 5002 '5439: randombit(123) == 0x3f94d3585b986539158f6ccd97d261e'); 5003 tmp = srandom(7^23+19,10); 5004 print '5440: tmp = srandom(7^23+19,10)'; 5005 vrfy(randombit(123) == 0x12874c359fffc6c0eda2aebfea97c71, \ 5006 '5441: randombit(123) == 0x12874c359fffc6c0eda2aebfea97c71'); 5007 tmp = srandom(7^23+19,11); 5008 print '5442: tmp = srandom(7^23+19,11)'; 5009 vrfy(randombit(123) == 0x7e0480a70c6f32f6594db8fd58ada7, \ 5010 '5443: randombit(123) == 0x7e0480a70c6f32f6594db8fd58ada7'); 5011 tmp = srandom(7^23+19,12); 5012 print '5444: tmp = srandom(7^23+19,12)'; 5013 vrfy(randombit(123) == 0x7f900aa8c7b9dacb6bf4ca0f5f81cb8, \ 5014 '5445: randombit(123) == 0x7f900aa8c7b9dacb6bf4ca0f5f81cb8'); 5015 tmp = srandom(7^23+19,13); 5016 print '5446: tmp = srandom(7^23+19,13)'; 5017 vrfy(randombit(123) == 0x39311c5aa41e42bb5d7807bdb60aecc, \ 5018 '5447: randombit(123) == 0x39311c5aa41e42bb5d7807bdb60aecc'); 5019 tmp = srandom(7^23+19,14); 5020 print '5448: tmp = srandom(7^23+19,14)'; 5021 vrfy(randombit(123) == 0x508bc8c5bd4555262b7ecd32a1ecd8e, \ 5022 '5449: randombit(123) == 0x508bc8c5bd4555262b7ecd32a1ecd8e'); 5023 tmp = srandom(7^23+19,15); 5024 print '5450: tmp = srandom(7^23+19,15)'; 5025 vrfy(randombit(123) == 0x442d2076b8d58d3815841180e8401b6, \ 5026 '5451: randombit(123) == 0x442d2076b8d58d3815841180e8401b6'); 5027 tmp = srandom(7^23+19,16); 5028 print '5452: tmp = srandom(7^23+19,16)'; 5029 vrfy(randombit(123) == 0x38db53974de9d3eea82a6ba35d2dc53, \ 5030 '5453: randombit(123) == 0x38db53974de9d3eea82a6ba35d2dc53'); 5031 tmp = srandom(7^23+19,17); 5032 print '5454: tmp = srandom(7^23+19,17)'; 5033 vrfy(randombit(123) == 0x42c1d9d86c9c67acb518ee008ce8f38, \ 5034 '5455: randombit(123) == 0x42c1d9d86c9c67acb518ee008ce8f38'); 5035 tmp = srandom(7^23+19,18); 5036 print '5456: tmp = srandom(7^23+19,18)'; 5037 vrfy(randombit(123) == 0x10dc81d7ef0a7aeb4aea1d4ac1fac2a, \ 5038 '5457: randombit(123) == 0x10dc81d7ef0a7aeb4aea1d4ac1fac2a'); 5039 tmp = srandom(7^23+19,19); 5040 print '5458: tmp = srandom(7^23+19,19)'; 5041 vrfy(randombit(123) == 0x469f8d91b643e0bcc4b5d5c2fe61cfb, \ 5042 '5459: randombit(123) == 0x469f8d91b643e0bcc4b5d5c2fe61cfb'); 5043 tmp = srandom(7^23+19,20); 5044 print '5460: tmp = srandom(7^23+19,20)'; 5045 vrfy(randombit(123) == 0x7f056e87cfcbe04a072e17502ef38f5, \ 5046 '5461: randombit(123) == 0x7f056e87cfcbe04a072e17502ef38f5'); 5047 vrfy(randombit(123) == 0x5d10d7665e56dee0ec5ea7d918ba073, \ 5048 '5462: randombit(123) == 0x5d10d7665e56dee0ec5ea7d918ba073'); 5049 vrfy(randombit(123) == 0x2058f802dd42b3aee4e734eacc13057, \ 5050 '5463: randombit(123) == 0x2058f802dd42b3aee4e734eacc13057'); 5051 5052 /* test seed() as best as we can */ 5053 vrfy(seed() >= 0, '5464: seed() >= 0'); 5054 vrfy(seed() < 2^64, '5465: seed() < 2^64'); 5055 vrfy(israndom(srandom(seed())), '5466: israndom(srandom(seed()))'); 5056 5057 /* verify random(10,11) double bug fix */ 5058 vrfy(random(10,11) == 10, '5467: random(10,11) == 10'); 5059 vrfy(random(10,11) == 10, '5468: random(10,11) == 10'); 5060 vrfy(random(10,11) == 10, '5469: random(10,11) == 10'); 5061 vrfy(random(0,1) == 0, '5470: random(0,1) == 0'); 5062 vrfy(random(0,1) == 0, '5471: random(0,1) == 0'); 5063 5064 print '5472: Ending test_random'; 5065} 5066print '137: parsed test_random()'; 5067 5068 5069/* 5070 * test_newsyn - test new command completion syntax and scope rules 5071 */ 5072for (s5500 = 0, i = 0; i < 5; i++) s5500 += i; 5073print "138: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;"; 5074vrfy(s5500 == 10, '139: s5500 == 10'); 5075vrfy(i == 5, '140: i == 5'); 5076for (s5500 = 0, i = 0; i < 9; i++) { 5077 s5500 += i; 5078} 5079print "141: for (s5500 = 0, i = 0; i < 9; i++) { s5500 += i; }"; 5080vrfy(s5500 == 36, '142: s5500 == 36'); 5081vrfy(i == 9, '143: i == 9'); 5082{ 5083 local i; 5084 for (s5500 = 0, i = 0; i < 10; i++) 5085 s5500 += i; 5086 vrfy(s5500 == 45, '144: s5500 == 45'); 5087 vrfy(i == 10, '145: i == 10'); 5088} 5089print "146: { local i; for (s5500 = 0, i = 0; i < 10; i++) s5500 += i; ... }"; 5090vrfy(s5500 == 45, '147: s5500 == 45'); 5091vrfy(i == 9, '148: i == 9'); 5092/**/ 5093define test_newsyn() 5094{ 5095 local i; /* loop counter */ 5096 5097 print '5500: Beginning test_newsyn'; 5098 5099 /* 5100 * check basic for loop completion and scoping 5101 */ 5102 for (s5500 = 0, i = 0; i < 5; i++) 5103 s5500 += i; 5104 print "5501: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;"; 5105 vrfy(s5500 == 10, '5502: s5500 == 10'); 5106 vrfy(i == 5, '5503: i == 5'); 5107 /**/ 5108 for (s5500 = 0, i = 0; i < 6; i++) 5109 { 5110 s5500 += i; 5111 } 5112 print "5504: for (s5500 = 0, i = 0; i < 6; i++) { s5500 += i; }"; 5113 vrfy(s5500 == 15, '5505: s5500 == 15'); 5114 vrfy(i == 6, '5506: i == 6'); 5115 /**/ 5116 for (s5500 = 0, i = 0; i < 3; i++) { 5117 s5500 += i; 5118 } 5119 print "5507: for (s5500 = 0, i = 0; i < 3; i++) { s5500 += i; }"; 5120 vrfy(s5500 == 3, '5508: s5500 == 3'); 5121 vrfy(i == 3, '5509: i == 3'); 5122 /**/ 5123 { 5124 for (s5500 = 0, i = 0; i < 11; i++) 5125 s5500 += i; 5126 vrfy(s5500 == 55, '5510: s5500 == 45'); 5127 vrfy(i == 11, '5511: i == 11'); 5128 } 5129 print "5512: { local i; for (s5500 = 0, i = 0; i < 10; i++) ": 5130 "s5500 += i; ... }"; 5131 vrfy(s5500 == 55, '5513: s5500 == 55'); 5132 vrfy(i == 11, '5514: i == 11'); 5133 5134 /* 5135 * test completion of while loops 5136 */ 5137 i = 0; 5138 print '5515: i = 0'; 5139 s5500 = 0; 5140 print '5516: s5500 = 0'; 5141 while (++i < 4) 5142 s5500 += i; 5143 print "5517: while (++i < 4) s5500 += i;"; 5144 vrfy(s5500 == 6, '5518: s5500 == 6'); 5145 vrfy(i == 4, '5519: i == 4'); 5146 /**/ 5147 i = 0; 5148 print '5520: i = 0'; 5149 s5500 = 0; 5150 print '5521: s5500 = 0'; 5151 while (++i < 7) 5152 { 5153 s5500 += i; 5154 } 5155 print "5522: while (++i < 7) { s5500 += i; }"; 5156 vrfy(s5500 == 21, '5523: s5500 == 21'); 5157 vrfy(i == 7, '5524: i == 7'); 5158 /**/ 5159 i = 0; 5160 print '5525: i = 0'; 5161 s5500 = 0; 5162 print '5526: s5500 = 0'; 5163 while (++i < 8) { 5164 s5500 += i; 5165 } 5166 print "5527: while (++i < 8) { s5500 += i; }"; 5167 vrfy(s5500 == 28, '5528: s5500 == 28'); 5168 vrfy(i == 8, '5529: i == 8'); 5169 5170 /* 5171 * test completion of do-while loops 5172 */ 5173 i = 0; 5174 print '5530: i = 0'; 5175 s5500 = 0; 5176 print '5531: s5500 = 0'; 5177 do 5178 s5500 += i; 5179 while (++i < 12); 5180 print "5532: do s5500 += i; while (++i < 12);"; 5181 vrfy(s5500 == 66, '5533: s5500 == 66'); 5182 vrfy(i == 12, '5534: i == 12'); 5183 /**/ 5184 i = 0; 5185 print '5535: i = 0'; 5186 s5500 = 0; 5187 print '5536: s5500 = 0'; 5188 do { 5189 s5500 += i; 5190 } while (++i < 14) 5191 print "5537: do { s5500 += i; } while (++i < 14);"; 5192 vrfy(s5500 == 91, '5538: s5500 == 91'); 5193 vrfy(i == 14, '5539: i == 14'); 5194 /**/ 5195 i = 0; 5196 print '5540: i = 0'; 5197 s5500 = 0; 5198 print '5541: s5500 = 0'; 5199 do 5200 { 5201 s5500 += i; 5202 } 5203 while (++i < 13) 5204 ; 5205 print "5542: do { s5500 += i; } while (++i < 13);"; 5206 vrfy(s5500 == 78, '5543: s5500 == 78'); 5207 vrfy(i == 13, '5544: i == 13'); 5208 5209 /* 5210 * test the completion of switch 5211 */ 5212 switch (i) { 5213 case 12: prob("switch showed i was 12 instead of 13"); break; 5214 case 13: 5215 vrfy(i == 13, '5545: i == 13'); 5216 break; 5217 default: 5218 prob("switch showed i was something other than 13"); 5219 break; 5220 } 5221 switch 5222 ( 5223 i 5224 ) 5225 { 5226 case 5227 1 5228 : 5229 prob( 5230 "switch showed i was 1 instead of 13" 5231 ) 5232 ; 5233 break 5234 ; 5235 case 5236 2 5237 : 5238 prob( 5239 "switch showed i was 2 instead of 13" 5240 ) 5241 ; 5242 break 5243 ; 5244 default 5245 : 5246 vrfy 5247 ( 5248 i 5249 == 5250 13 5251 , 5252 '5546: i == 13' 5253 ) 5254 ; 5255 } 5256 5257 print '5547: Ending test_newsyn'; 5258} 5259print '149: parsed test_newsyn()'; 5260vrfy(s5500 == 45, '150: s5500 == 45'); 5261vrfy(i == 9, '151: i == 9'); 5262 5263 5264/* 5265 * test_commaeq - test changes to = and , 5266 */ 5267obj xx5600 {} xx5600; 5268print '152: obj xx5600 {} xx5600'; 5269define xx5600_print() = printf("xx"); 5270print '153: xx5600_print() = printf("xx")'; 5271/**/ 5272define test_commaeq() 5273{ 5274 local i; 5275 local A, B, C, D; 5276 local a5600 = 0, b5600 = 0; 5277 obj xy5600 {x, y}; 5278 5279 /* 5280 * Calculations with i 5281 */ 5282 print '5600: Beginning test_commaeq'; 5283 i = 5; 5284 print '5601: i = 5'; 5285 vrfy(i == 5, '5602: i == 5'); 5286 i += 2 *= 3 -= 1; 5287 print '5603: i += 2 *= 3 -= 1'; 5288 vrfy(i == 20, '5604: i == 20'); 5289 ++i /= 7; 5290 print '5607: ++i /= 7'; 5291 vrfy(i == 3, '5608: i == 3'); 5292 5293 /* 5294 * xx5600 object type 5295 */ 5296 mat A[3] = {1,2,xx5600}; 5297 print '5609: mat A[3] = {1,2,xx5600}'; 5298 vrfy(A[2] == xx5600, '5610: A[2] == xx5600'); 5299 vrfy(strprintf("%d", xx5600) == "xx", 5300 '5611: strprintf("%d", xx5600) == "xx"'); 5301 5302 /* 5303 * xy5600 object type 5304 */ 5305 obj xy5600 A = {1, 2} = {3, 4}; 5306 print '5612: obj xy5600 A = {1, 2} = {3, 4}'; 5307 vrfy(A.x == 3, '5613: A.x == 3'); 5308 vrfy(A.y == 4, '5614: A.y == 4'); 5309 obj xy5600 B = {A,A}; 5310 print '5613: obj xy5600 B = {A,A}'; 5311 vrfy(B.x.x == 3, '5615: B.x.x == 3'); 5312 vrfy(B.y.y == 4, '5616: B.y.y == 4'); 5313 obj xy5600 C; 5314 print '5617: obj xy5600 C'; 5315 C = {1, 2} = {C, C}; 5316 print '5618: C = {1, 2} = {C, C}'; 5317 vrfy(C.x.x == 1, '5619: C.x.x == 1'); 5318 vrfy(C.y.x.y == 2, '5620: C.y.x.y == 2'); 5319 D = 7; 5320 print '5621: D = 7'; 5321 obj xy5600 D = {1,2} = {D,D}; 5322 print '5622: obj xy5600 D = {1,2} = {D,D}'; 5323 vrfy(D.x == 7, '5623: D.x == 7'); 5324 vrfy(D.y == 7, '5624: D.y == 7'); 5325 5326 /* 5327 * matrix assignment 5328 */ 5329 mat A[3] = {1,2,3}, mat B[2] = {1,2}; 5330 print '5625: mat A[3] = {1,2,3}, mat B[2] = {1,2}'; 5331 vrfy(A[0] == 1, '5626: A[0] == 1'); 5332 vrfy(B[1] == 2, '5627: B[1] == 2'); 5333 5334 /* 5335 * misc = and , expressions 5336 */ 5337 vrfy(((a5600 = 2, b5600) = 3) && a5600 + b5600 == 5, 5338 '5628: ((a5600 = 2, b5600) = 3) && a5600 + b5600 == 5'); 5339 vrfy((2 ? a5600 : b5600 = 4) && a5600 == 4, 5340 '5629: (2 ? a5600 : b5600 = 4) && a5600 == 4'); 5341 vrfy((0 ? a5600 : b5600 = 5) && b5600 == 5, 5342 '5630: (0 ? a5600 : b5600 = 5) && b5600 == 5'); 5343 vrfy((a5600 || b5600 = 6) && a5600 == 6 && b5600 == 5, 5344 '5631: (a5600 || b5600 = 6) && a5600 == 6 && b5600 == 5'); 5345 vrfy((a5600 && b5600 = 7) && a5600 == 6 && b5600 == 7, 5346 '5632: (a5600 && b5600 = 7) && a5600 == 6 && b5600 == 7'); 5347 5348 print '5633: Ending test_commaeq'; 5349} 5350print '155: parsed test_commaeq()'; 5351 5352 5353/* 5354 * test_size - test what we can about sizes 5355 * 5356 * Since sizeof() and memsize() deal with machine specific sizes and 5357 * compiler structure layout issues, we cannot just determine if 5358 * these builtin values return a specific value. 5359 */ 5360define test_size() 5361{ 5362 local z; /* test integer values */ 5363 local q; /* test rational values */ 5364 local c; /* test complex values */ 5365 local m; /* test matrix */ 5366 local l; /* test list */ 5367 local a; /* test association */ 5368 5369 print '5700: Beginning test_size'; 5370 5371 /* 5372 * 0, -1 and 1 values are reported as 0 sizeof 5373 */ 5374 vrfy(sizeof(0) == 0, '5701: sizeof(0) == 0'); 5375 vrfy(sizeof(1) == 0, '5702: sizeof(1) == 0'); 5376 vrfy(sizeof(-1) == 0, '5703: sizeof(-1) == 0'); 5377 z = 0; 5378 print '5704: z = 0'; 5379 vrfy(sizeof(z) == 0, '5705: sizeof(z) == 0'); 5380 z = 1; 5381 print '5706: z = 1'; 5382 vrfy(sizeof(z) == 0, '5707: sizeof(z) == 0'); 5383 z = -1; 5384 print '5708: z = -1'; 5385 vrfy(sizeof(z) == 0, '5709: sizeof(z) == 0'); 5386 5387 /* 5388 * non-integer rationals are larger than integers 5389 */ 5390 q = 13/2; 5391 print '5710: q = 13/2'; 5392 vrfy(sizeof(13)*2 == sizeof(q), '5711: sizeof(13)*2 == sizeof(q)'); 5393 q = 13; 5394 print '5712: q = 13'; 5395 vrfy(sizeof(13) == sizeof(q), '5713: sizeof(13) == sizeof(q)'); 5396 q = (17^139 + 674) / (17^139 + 686); 5397 print '5714: q = (17^139 + 674) / (17^139 + 686)'; 5398 vrfy(sizeof(17^139 + 674)*2 == sizeof(q), 5399 '5715: sizeof(17^139 + 674)*2 == sizeof(q)'); 5400 5401 /* 5402 * reciprocals are the same size of their integer inverses 5403 */ 5404 q = 1/13; 5405 print '5716: q = 1/13'; 5406 vrfy(sizeof(13) == sizeof(q), '5717: sizeof(13) == sizeof(q)'); 5407 q = 1/(17^139 + 674); 5408 print '5718: q = 1/(17^139 + 674)'; 5409 vrfy(sizeof(17^139 + 674) == sizeof(q), 5410 '5717: sizeof(17^139 + 674) == sizeof(q)'); 5411 5412 /* 5413 * negative values are the same size as positive values 5414 */ 5415 vrfy(sizeof(17^139 + 674) == sizeof(-q), 5416 '5718: sizeof(17^139 + 674) == sizeof(-q)'); 5417 vrfy(sizeof(-(17^139 + 674)) == sizeof(-q), 5418 '5719: sizeof(-(17^139 + 674)) == sizeof(-q)'); 5419 q = 1/-13; 5420 print '5720: q = 1/-13'; 5421 vrfy(sizeof(13) == sizeof(q), '5721: sizeof(13) == sizeof(q)'); 5422 5423 /* 5424 * complex values with a real or imaginary part of 0, 1 or -1 5425 * are the same size as rationals 5426 */ 5427 c = 0 + 4i; 5428 print '5722: c = 0 + 4i'; 5429 vrfy(sizeof(3) == sizeof(c), '5723: sizeof(3) == sizeof(c)'); 5430 c = 3 + 0i; 5431 print '5724: c = 3 + 0i'; 5432 vrfy(sizeof(3) == sizeof(c), '5725: sizeof(3) == sizeof(c)'); 5433 c = 1 + 4i; 5434 print '5726: c = 1 + 4i'; 5435 vrfy(sizeof(3) == sizeof(c), '5727: sizeof(3) == sizeof(c)'); 5436 c = 3 + 1i; 5437 print '5728: c = 3 + 1i'; 5438 vrfy(sizeof(3) == sizeof(c), '5729: sizeof(3) == sizeof(c)'); 5439 c = -1 + 4i; 5440 print '5730: c = -1 + 4i'; 5441 vrfy(sizeof(3) == sizeof(c), '5731: sizeof(3) == sizeof(c)'); 5442 c = 3 + -1i; 5443 print '5732: c = 3 + -1i'; 5444 vrfy(sizeof(3) == sizeof(c), '5733: sizeof(3) == sizeof(c)'); 5445 5446 /* 5447 * general complex values are twice the size as rationals 5448 */ 5449 c = 3 + 4i; 5450 print '5734: c = 3 + 4i'; 5451 vrfy(sizeof(3)*2 == sizeof(c), '5735: sizeof(3)*2 == sizeof(c)'); 5452 z = 17^139 + 686; 5453 print '5736: z = 17^139 + 686'; 5454 c = z + z*1i; 5455 print '5737: c = z + z*1i'; 5456 vrfy(sizeof(z)*2 == sizeof(c), '5738: sizeof(z)*2 == sizeof(c)'); 5457 q = 1/(17^139 + 674); 5458 print '5739: q = 1/(17^139 + 674)'; 5459 c = q + q*1i; 5460 print '5740: c = q + q*1i'; 5461 vrfy(sizeof(q)*2 == sizeof(c), '5741: sizeof(q)*2 == sizeof(c)'); 5462 c = (z*q) + (1/(z*q))*1i; 5463 print '5742: c = (z*q) + (1/(z*q))*1i'; 5464 vrfy(sizeof(z*q)*2 == sizeof(c), '5743: sizeof(z*q)*2 == sizeof(c)'); 5465 vrfy(sizeof(z)*4 == sizeof(c), '5744: sizeof(z)*4 == sizeof(c)'); 5466 vrfy(sizeof(q)*4 == sizeof(c), '5745: sizeof(q)*4 == sizeof(c)'); 5467 5468 /* 5469 * size of numeric values is always 1 5470 */ 5471 vrfy(size(0) == 1, '5746: size(0) == 1'); 5472 vrfy(size(1) == 1, '5747: size(1) == 1'); 5473 vrfy(size(13^10) == 1, '5748: size(13^10) == 1'); 5474 vrfy(size(z) == 1, '5749: size(z) == 1'); 5475 vrfy(size(q) == 1, '5750: size(q) == 1'); 5476 vrfy(size(c) == 1, '5751: size(c) == 1'); 5477 5478 /* 5479 * size of a matrix is the sum of the sizes of the elements 5480 * sizeof of a matrix is the sum of the sizeof's of the elements 5481 */ 5482 mat m[] = {z,q,c}; 5483 print '5752: mat m[] = {z,q,c}'; 5484 vrfy(size(m) == size(z)+size(q)+size(c), 5485 '5753: size(m) == size(z)+size(q)+size(c)'); 5486 vrfy(sizeof(m) == sizeof(z)+sizeof(q)+sizeof(c), 5487 '5754: sizeof(m) == sizeof(z)+sizeof(q)+sizeof(c)'); 5488 5489 /* 5490 * size of a list is the number of elements 5491 * sizeof of a list is the sum of the sizeof's of the elements 5492 */ 5493 l = list(z,q,c,m); 5494 print '5755: list(z,q,c,m)'; 5495 vrfy(size(l) == 4, '5756: size(l) == 4'); 5496 vrfy(sizeof(l) == 2*sizeof(m), '5757: sizeof(l) == 2*sizeof(m)'); 5497 5498 /* 5499 * size of an assoc is the number of elements 5500 * sizeof of an assoc is the sum of the sizeof's of the elements 5501 */ 5502 a = assoc(); 5503 print '5758: a = assoc()'; 5504 a["z"] = z+1; 5505 print '5759: a["z"] = z+1'; 5506 a["q"] = q+2; 5507 print '5760: a["q"] = q+2'; 5508 a["c"] = c+3; 5509 print '5761: a["c"] = c+3'; 5510 a[m] = m; 5511 print '5762: a[m] = m'; 5512 a[l] = l; 5513 print '5763: a[l] = l'; 5514 vrfy(size(a) == 5, '5764: size(a) == 5'); 5515 vrfy(sizeof(a) == 25*sizeof(z), '5765: sizeof(a) == 25*sizeof(z)'); 5516 5517 /* 5518 * about all we can say about memsize is that it will always be 5519 * larger than sizeof 5520 */ 5521 vrfy(sizeof(z) < memsize(z), '5766: sizeof(z) < memsize(z)'); 5522 vrfy(sizeof(q) < memsize(q), '5767: sizeof(q) < memsize(q)'); 5523 vrfy(sizeof(c) < memsize(c), '5768: sizeof(c) < memsize(c)'); 5524 vrfy(sizeof(m) < memsize(m), '5769: sizeof(m) < memsize(m)'); 5525 vrfy(sizeof(l) < memsize(l), '5770: sizeof(l) < memsize(l)'); 5526 vrfy(sizeof(a) < memsize(a), '5771: sizeof(a) < memsize(a)'); 5527 5528 print '5772: Ending test_size'; 5529} 5530print '156: parsed test_size()'; 5531 5532 5533/* 5534 * test_assign - test assignment of constants and variables 5535 */ 5536global X5800, Y5800; /* X5800, Y5800 for "variables" */ 5537print '158: global X5800, Y5800'; 5538obj xy5800 {x, y}; 5539print '159: obj xy5800 {x, y}'; 5540/**/ 5541define test_assign(base, work) 5542{ 5543 print base: ': Beginning test_assign'; 5544 5545 /* 5546 * value assignments 5547 */ 5548 A = base+1; 5549 print base+1: ': A = base+1'; 5550 B = base+2; 5551 print base+2: ': B = base+2'; 5552 X5800 = base+3; 5553 print base+3: ': X5800 = base+3'; 5554 Y5800 = base+4; 5555 print base+4: ': Y5800 = base+4'; 5556 obj xy5800 A={1,2}, obj xy5800 B={3,4}; 5557 print base+5: ': obj xy5800 A={1,2}, obj xy5800 B={3,4}'; 5558 5559 /* 5560 * test assignment 5561 */ 5562 X5800 = A; 5563 print base+6: ': X5800 = A'; 5564 if (work) { 5565 vrfy(X5800 == A, strprintf('%d: X5800 == A', base+7)); 5566 X5800 = Y5800 = B; 5567 print base+8: ': X5800 = Y5800 = B'; 5568 } else { 5569 vrfy(X5800 == B, strprintf('%d: X5800 == B', base+7)); 5570 X5800 = Y5800 = A; 5571 print base+8: ': X5800 = Y5800 = A'; 5572 } 5573 vrfy(X5800 == B, strprintf('%d: X5800 == B', base+9)); 5574 vrfy(Y5800 == B, strprintf('%d: Y5800 == B', base+10)); 5575 5576 print base+11: ': Ending test_assign'; 5577} 5578print '160: test_assign()'; 5579 5580 5581/* 5582 * test_is - test is functions 5583 */ 5584vrfy(isobjtype("xy5900") == 0, '161: isobjtype("xy5900") == 0'); 5585obj xy5900 {x, y}; 5586print '162: obj xy5900 {x, y}'; 5587vrfy(isobjtype("xy5900") == 1, '163: isobjtype("xy5900") == 1'); 5588/**/ 5589vrfy(isdefined("fun5900") == 0, '164: isdefined("fun5900") == 0'); 5590define fun5900() { return 1; }; 5591print '165: define fun5900() { return 1; }'; 5592vrfy(isdefined("fun5900") == 2, '166: isdefined("fun5900") == 2'); 5593undefine fun5900; 5594vrfy(isdefined("fun5900") == 0, '167: isdefined("fun5900") == 0'); 5595/**/ 5596define test_is() 5597{ 5598 local loc; /* unassigned local variable */ 5599 local a; /* assoc */ 5600 local ofd; /* open file descriptor */ 5601 local cfd; /* closed file descriptor */ 5602 local blk; /* unnamed block */ 5603 local nblk; /* named block */ 5604 local cfg; /* config state */ 5605 local serr; /* system value */ 5606 local nerr; /* new error value */ 5607 local odd; /* odd integer */ 5608 local even; /* even integer that is 10 times odd */ 5609 local hash; /* sha1 hash value */ 5610 local id; /* identity matrix */ 5611 local list; /* list value */ 5612 local matrix; /* non-identity matrix */ 5613 local nul; /* null value */ 5614 local object; /* object */ 5615 local rand; /* rand seed */ 5616 local random; /* random seed */ 5617 local real; /* real non-integer value */ 5618 local prime; /* odd prime */ 5619 local square; /* square of an odd prime */ 5620 local string; /* string */ 5621 local com; /* complex value */ 5622 local rndint; /* a random integer */ 5623 local rndexp; /* a random exponent */ 5624 local rndval; /* rndint ^ rndexp */ 5625 local i; /* integer value */ 5626 local ok; /* 1 ==> issq() tests were OK, 0 ==> failure */ 5627 5628 print '5900: Beginning test_is'; 5629 5630 /* 5631 * setup values 5632 */ 5633 a = assoc(); 5634 print '5901: a = assoc()'; 5635 if (config("windows")) { 5636 ofd = fopen("NUL:", "rb"); 5637 print '5902: ofd = fopen("NUL:", "rb")'; 5638 cfd = fopen("NUL:", "rb"); 5639 print '5903: cfd = fopen("NUL:", "rb")'; 5640 } else { 5641 ofd = fopen("/dev/null","rb"); 5642 print '5902: ofd = fopen("/dev/null","rb")'; 5643 cfd = fopen("/dev/null","rb"); 5644 print '5903: cfd = fopen("/dev/null","rb")'; 5645 } 5646 fclose(cfd); 5647 print '5904: fclose(cfd)'; 5648 blk = blk(); 5649 print '5905: blk = blk()'; 5650 nblk = blk("blk5900"); 5651 print '5906: nblk = blk("blk5900")'; 5652 cfg = config("all"); 5653 print '5907: cfg = config("all")'; 5654 ecnt += 2; 5655 print '5908: ecnt += 2'; 5656 serr = error(1); 5657 print '5909: serr = error(1)'; 5658 nerr = newerror("curds"); 5659 print '5910: nerr = newerror("curds")'; 5660 odd = 23209; 5661 print '5911: odd = 23209'; 5662 even = odd*10; 5663 print '5912: even = odd*10'; 5664 hash = sha1(); 5665 print '5913: hash = sha1()'; 5666 mat id[3,3] = {1,0,0,0,1,0,0,0,1}; 5667 print '5914: id[3,3] = {1,0,0,0,1,0,0,0,1}'; 5668 list = list(2,3,4); 5669 print '5915: list = list(2,3,4)'; 5670 mat matrix[2]; 5671 print '5916: mat matrix[2]'; 5672 nul = null(); 5673 print '5917: nul = null()'; 5674 obj xy5900 object; 5675 print '5918: obj xy5900 object'; 5676 rand = srand(0); 5677 print '5919: rand = srand(0)'; 5678 random = srandom(0); 5679 print '5920: random = srandom(0)'; 5680 real = 345.23045897; 5681 print '5921: real = 345.23045897'; 5682 prime = 3217; 5683 print '5922: prime = 3217'; 5684 square = prime^2; 5685 print '5923: square = prime^2'; 5686 string = "a string"; 5687 print '5924: string = "a string"'; 5688 com = 3+4i; 5689 print '5925: com = 3+4i'; 5690 5691 print '5926: test unused'; 5692 print '5927: test unused'; 5693 print '5928: test unused'; 5694 print '5929: test unused'; 5695 5696 /* 5697 * test isassoc 5698 */ 5699 vrfy(isassoc(loc) == 0, '5930: isassoc(loc) == 0'); 5700 vrfy(isassoc(a) == 1, '5931: isassoc(a) == 1'); 5701 vrfy(isassoc(ofd) == 0, '5932: isassoc(ofd) == 0'); 5702 vrfy(isassoc(cfd) == 0, '5933: isassoc(cfd) == 0'); 5703 vrfy(isassoc(blk) == 0, '5934: isassoc(blk) == 0'); 5704 vrfy(isassoc(nblk) == 0, '5935: isassoc(nblk) == 0'); 5705 vrfy(isassoc(cfg) == 0, '5936: isassoc(cfg) == 0'); 5706 vrfy(isassoc(serr) == 0, '5937: isassoc(serr) == 0'); 5707 vrfy(isassoc(nerr) == 0, '5938: isassoc(nerr) == 0'); 5708 vrfy(isassoc(odd) == 0, '5939: isassoc(odd) == 0'); 5709 vrfy(isassoc(even) == 0, '5940: isassoc(even) == 0'); 5710 vrfy(isassoc(hash) == 0, '5941: isassoc(hash) == 0'); 5711 vrfy(isassoc(id) == 0, '5942: isassoc(id) == 0'); 5712 vrfy(isassoc(list) == 0, '5943: isassoc(list) == 0'); 5713 vrfy(isassoc(matrix) == 0, '5944: isassoc(matrix) == 0'); 5714 vrfy(isassoc(nul) == 0, '5945: isassoc(nul) == 0'); 5715 vrfy(isassoc(object) == 0, '5946: isassoc(object) == 0'); 5716 vrfy(isassoc(rand) == 0, '5947: isassoc(rand) == 0'); 5717 vrfy(isassoc(random) == 0, '5948: isassoc(random) == 0'); 5718 vrfy(isassoc(real) == 0, '5949: isassoc(real) == 0'); 5719 vrfy(isassoc(prime) == 0, '5950: isassoc(prime) == 0'); 5720 vrfy(isassoc(square) == 0, '5951: isassoc(square) == 0'); 5721 vrfy(isassoc(string) == 0, '5952: isassoc(string) == 0'); 5722 vrfy(isassoc(com) == 0, '5953: isassoc(com) == 0'); 5723 print '5954: test unused'; 5724 print '5955: test unused'; 5725 print '5955: test unused'; 5726 print '5956: test unused'; 5727 print '5957: test unused'; 5728 print '5958: test unused'; 5729 print '5959: test unused'; 5730 5731 /* 5732 * test isatty 5733 */ 5734 vrfy(isatty(loc) == 0, '5960: isatty(loc) == 0'); 5735 vrfy(isatty(a) == 0, '5961: isatty(a) == 0'); 5736 vrfy(isatty(ofd) == 0, '5962: isatty(ofd) == 0'); 5737 vrfy(isatty(cfd) == 0, '5963: isatty(cfd) == 0'); 5738 vrfy(isatty(blk) == 0, '5964: isatty(blk) == 0'); 5739 vrfy(isatty(nblk) == 0, '5965: isatty(nblk) == 0'); 5740 vrfy(isatty(cfg) == 0, '5966: isatty(cfg) == 0'); 5741 vrfy(isatty(serr) == 0, '5967: isatty(serr) == 0'); 5742 vrfy(isatty(nerr) == 0, '5968: isatty(nerr) == 0'); 5743 vrfy(isatty(odd) == 0, '5969: isatty(odd) == 0'); 5744 vrfy(isatty(even) == 0, '5970: isatty(even) == 0'); 5745 vrfy(isatty(hash) == 0, '5971: isatty(hash) == 0'); 5746 vrfy(isatty(id) == 0, '5972: isatty(id) == 0'); 5747 vrfy(isatty(list) == 0, '5973: isatty(list) == 0'); 5748 vrfy(isatty(matrix) == 0, '5974: isatty(matrix) == 0'); 5749 vrfy(isatty(nul) == 0, '5975: isatty(nul) == 0'); 5750 vrfy(isatty(object) == 0, '5976: isatty(object) == 0'); 5751 vrfy(isatty(rand) == 0, '5977: isatty(rand) == 0'); 5752 vrfy(isatty(random) == 0, '5978: isatty(random) == 0'); 5753 vrfy(isatty(real) == 0, '5979: isatty(real) == 0'); 5754 vrfy(isatty(prime) == 0, '5980: isatty(prime) == 0'); 5755 vrfy(isatty(square) == 0, '5981: isatty(square) == 0'); 5756 vrfy(isatty(string) == 0, '5982: isatty(string) == 0'); 5757 vrfy(isatty(com) == 0, '5983: isatty(com) == 0'); 5758 print '5984: test disabled due to stdin dependency'; 5759 /* if we pipe to awk (for make chk), stdout and stderr are not ttys */ 5760 print '5985: test unused'; 5761 print '5986: test unused'; 5762 vrfy(isatty(files(3)) == 0, '5987: isatty(files(3)) == 0'); 5763 print '5988: test unused'; 5764 print '5989: test unused'; 5765 5766 /* 5767 * test isblk 5768 */ 5769 vrfy(isblk(loc) == 0, '5990: isblk(loc) == 0'); 5770 vrfy(isblk(a) == 0, '5991: isblk(a) == 0'); 5771 vrfy(isblk(ofd) == 0, '5992: isblk(ofd) == 0'); 5772 vrfy(isblk(cfd) == 0, '5993: isblk(cfd) == 0'); 5773 vrfy(isblk(blk) == 1, '5994: isblk(blk) == 1'); 5774 vrfy(isblk(nblk) == 2, '5995: isblk(nblk) == 2'); 5775 vrfy(isblk(cfg) == 0, '5996: isblk(cfg) == 0'); 5776 vrfy(isblk(serr) == 0, '5997: isblk(serr) == 0'); 5777 vrfy(isblk(nerr) == 0, '5998: isblk(nerr) == 0'); 5778 vrfy(isblk(odd) == 0, '5999: isblk(odd) == 0'); 5779 vrfy(isblk(even) == 0, '6000: isblk(even) == 0'); 5780 vrfy(isblk(hash) == 0, '6001: isblk(hash) == 0'); 5781 vrfy(isblk(id) == 0, '6002: isblk(id) == 0'); 5782 vrfy(isblk(list) == 0, '6003: isblk(list) == 0'); 5783 vrfy(isblk(matrix) == 0, '6004: isblk(matrix) == 0'); 5784 vrfy(isblk(nul) == 0, '6005: isblk(nul) == 0'); 5785 vrfy(isblk(object) == 0, '6006: isblk(object) == 0'); 5786 vrfy(isblk(rand) == 0, '6007: isblk(rand) == 0'); 5787 vrfy(isblk(random) == 0, '6008: isblk(random) == 0'); 5788 vrfy(isblk(real) == 0, '6009: isblk(real) == 0'); 5789 vrfy(isblk(prime) == 0, '6010: isblk(prime) == 0'); 5790 vrfy(isblk(square) == 0, '6011: isblk(square) == 0'); 5791 vrfy(isblk(string) == 0, '6012: isblk(string) == 0'); 5792 vrfy(isblk(com) == 0, '6013: isblk(com) == 0'); 5793 print '6014: test unused'; 5794 print '6015: test unused'; 5795 print '6015: test unused'; 5796 print '6016: test unused'; 5797 print '6017: test unused'; 5798 print '6018: test unused'; 5799 print '6019: test unused'; 5800 5801 /* 5802 * test isconfig 5803 */ 5804 vrfy(isconfig(loc) == 0, '6020: isconfig(loc) == 0'); 5805 vrfy(isconfig(a) == 0, '6021: isconfig(a) == 0'); 5806 vrfy(isconfig(ofd) == 0, '6022: isconfig(ofd) == 0'); 5807 vrfy(isconfig(cfd) == 0, '6023: isconfig(cfd) == 0'); 5808 vrfy(isconfig(blk) == 0, '6024: isconfig(blk) == 0'); 5809 vrfy(isconfig(nblk) == 0, '6025: isconfig(nblk) == 0'); 5810 vrfy(isconfig(cfg) == 1, '6026: isconfig(cfg) == 1'); 5811 vrfy(isconfig(serr) == 0, '6027: isconfig(serr) == 0'); 5812 vrfy(isconfig(nerr) == 0, '6028: isconfig(nerr) == 0'); 5813 vrfy(isconfig(odd) == 0, '6029: isconfig(odd) == 0'); 5814 vrfy(isconfig(even) == 0, '6030: isconfig(even) == 0'); 5815 vrfy(isconfig(hash) == 0, '6031: isconfig(hash) == 0'); 5816 vrfy(isconfig(id) == 0, '6032: isconfig(id) == 0'); 5817 vrfy(isconfig(list) == 0, '6033: isconfig(list) == 0'); 5818 vrfy(isconfig(matrix) == 0, '6034: isconfig(matrix) == 0'); 5819 vrfy(isconfig(nul) == 0, '6035: isconfig(nul) == 0'); 5820 vrfy(isconfig(object) == 0, '6036: isconfig(object) == 0'); 5821 vrfy(isconfig(rand) == 0, '6037: isconfig(rand) == 0'); 5822 vrfy(isconfig(random) == 0, '6038: isconfig(random) == 0'); 5823 vrfy(isconfig(real) == 0, '6039: isconfig(real) == 0'); 5824 vrfy(isconfig(prime) == 0, '6040: isconfig(prime) == 0'); 5825 vrfy(isconfig(square) == 0, '6041: isconfig(square) == 0'); 5826 vrfy(isconfig(string) == 0, '6042: isconfig(string) == 0'); 5827 vrfy(isconfig(com) == 0, '6043: isconfig(com) == 0'); 5828 print '6044: test unused'; 5829 print '6045: test unused'; 5830 print '6045: test unused'; 5831 print '6046: test unused'; 5832 print '6047: test unused'; 5833 print '6048: test unused'; 5834 print '6049: test unused'; 5835 5836 /* 5837 * test isdefined 5838 */ 5839 vrfy(isdefined("loc") == 0, '6050: isdefined("loc") == 0'); 5840 vrfy(isdefined("a") == 0, '6051: isdefined("a") == 0'); 5841 vrfy(isdefined("ofd") == 0, '6052: isdefined("ofd") == 0'); 5842 vrfy(isdefined("cfd") == 0, '6053: isdefined("cfd") == 0'); 5843 vrfy(isdefined("blk") == 1, '6054: isdefined("blk") == 1'); 5844 vrfy(isdefined("nblk") == 0, '6055: isdefined("nblk") == 0'); 5845 vrfy(isdefined("cfg") == 0, '6056: isdefined("cfg") == 0'); 5846 vrfy(isdefined("serr") == 0, '6057: isdefined("serr") == 0'); 5847 vrfy(isdefined("nerr") == 0, '6058: isdefined("nerr") == 0'); 5848 vrfy(isdefined("odd") == 0, '6059: isdefined("odd") == 0'); 5849 vrfy(isdefined("even") == 0, '6060: isdefined("even") == 0'); 5850 vrfy(isdefined("hash") == 1, '6061: isdefined("hash") == 1'); 5851 vrfy(isdefined("id") == 0, '6062: isdefined("id") == 0'); 5852 vrfy(isdefined("list") == 1, '6063: isdefined("list") == 1'); 5853 vrfy(isdefined("matrix") == 0, '6064: isdefined("matrix") == 0'); 5854 vrfy(isdefined("nul") == 0, '6065: isdefined("nul") == 0'); 5855 vrfy(isdefined("object") == 0, '6066: isdefined("object") == 0'); 5856 vrfy(isdefined("rand") == 1, '6067: isdefined("rand") == 1'); 5857 vrfy(isdefined("random") == 1, '6068: isdefined("random") == 1'); 5858 vrfy(isdefined("real") == 0, '6069: isdefined("real") == 0'); 5859 vrfy(isdefined("prime") == 0, '6070: isdefined("prime") == 0'); 5860 vrfy(isdefined("square") == 0, '6071: isdefined("square") == 0'); 5861 vrfy(isdefined("string") == 0, '6072: isdefined("string") == 0'); 5862 vrfy(isdefined("abs") == 1, '6073: isdefined("abs") == 1'); 5863 vrfy(isdefined("notafunc") == 0, '6074: isdefined("notafunc") == 0'); 5864 vrfy(isdefined("com") == 0, '6075: isdefined("com") == 0'); 5865 print '6076: test unused'; 5866 print '6077: test unused'; 5867 print '6078: test unused'; 5868 print '6079: test unused'; 5869 5870 /* 5871 * test iserror 5872 */ 5873 vrfy(iserror(loc) == 0, '6080: iserror(loc) == 0'); 5874 vrfy(iserror(a) == 0, '6081: iserror(a) == 0'); 5875 vrfy(iserror(ofd) == 0, '6082: iserror(ofd) == 0'); 5876 vrfy(iserror(cfd) == 0, '6083: iserror(cfd) == 0'); 5877 vrfy(iserror(blk) == 0, '6084: iserror(blk) == 0'); 5878 vrfy(iserror(nblk) == 0, '6085: iserror(nblk) == 0'); 5879 vrfy(iserror(cfg) == 0, '6086: iserror(cfg) == 0'); 5880 vrfy(iserror(serr) == 1, '6087: iserror(serr) == 1'); 5881 vrfy(iserror(nerr) > 0, '6088: iserror(nerr) > 0'); 5882 vrfy(iserror(odd) == 0, '6089: iserror(odd) == 0'); 5883 vrfy(iserror(even) == 0, '6090: iserror(even) == 0'); 5884 vrfy(iserror(hash) == 0, '6091: iserror(hash) == 0'); 5885 vrfy(iserror(id) == 0, '6092: iserror(id) == 0'); 5886 vrfy(iserror(list) == 0, '6093: iserror(list) == 0'); 5887 vrfy(iserror(matrix) == 0, '6094: iserror(matrix) == 0'); 5888 vrfy(iserror(nul) == 0, '6095: iserror(nul) == 0'); 5889 vrfy(iserror(object) == 0, '6096: iserror(object) == 0'); 5890 vrfy(iserror(rand) == 0, '6097: iserror(rand) == 0'); 5891 vrfy(iserror(random) == 0, '6098: iserror(random) == 0'); 5892 vrfy(iserror(real) == 0, '6099: iserror(real) == 0'); 5893 vrfy(iserror(prime) == 0, '6100: iserror(prime) == 0'); 5894 vrfy(iserror(square) == 0, '6101: iserror(square) == 0'); 5895 vrfy(iserror(string) == 0, '6102: iserror(string) == 0'); 5896 vrfy(iserror(com) == 0, '6103: iserror(com) == 0'); 5897 print '6104: test unused'; 5898 print '6105: test unused'; 5899 print '6105: test unused'; 5900 print '6106: test unused'; 5901 print '6107: test unused'; 5902 print '6108: test unused'; 5903 print '6109: test unused'; 5904 5905 /* 5906 * test iseven 5907 */ 5908 vrfy(iseven(loc) == 1, '6110: iseven(loc) == 1'); 5909 vrfy(iseven(a) == 0, '6111: iseven(a) == 0'); 5910 vrfy(iseven(ofd) == 0, '6112: iseven(ofd) == 0'); 5911 vrfy(iseven(cfd) == 0, '6113: iseven(cfd) == 0'); 5912 vrfy(iseven(blk) == 0, '6114: iseven(blk) == 0'); 5913 vrfy(iseven(nblk) == 0, '6115: iseven(nblk) == 0'); 5914 vrfy(iseven(cfg) == 0, '6116: iseven(cfg) == 0'); 5915 vrfy(iseven(serr) == 0, '6117: iseven(serr) == 0'); 5916 vrfy(iseven(nerr) == 0, '6118: iseven(nerr) == 0'); 5917 vrfy(iseven(odd) == 0, '6119: iseven(odd) == 0'); 5918 vrfy(iseven(even) == 1, '6120: iseven(even) == 1'); 5919 vrfy(iseven(hash) == 0, '6121: iseven(hash) == 0'); 5920 vrfy(iseven(id) == 0, '6122: iseven(id) == 0'); 5921 vrfy(iseven(list) == 0, '6123: iseven(list) == 0'); 5922 vrfy(iseven(matrix) == 0, '6124: iseven(matrix) == 0'); 5923 vrfy(iseven(nul) == 0, '6125: iseven(nul) == 0'); 5924 vrfy(iseven(object) == 0, '6126: iseven(object) == 0'); 5925 vrfy(iseven(rand) == 0, '6127: iseven(rand) == 0'); 5926 vrfy(iseven(random) == 0, '6128: iseven(random) == 0'); 5927 vrfy(iseven(real) == 0, '6129: iseven(real) == 0'); 5928 vrfy(iseven(prime) == 0, '6130: iseven(prime) == 0'); 5929 vrfy(iseven(square) == 0, '6131: iseven(square) == 0'); 5930 vrfy(iseven(string) == 0, '6132: iseven(string) == 0'); 5931 vrfy(iseven(com) == 0, '6133: iseven(com) == 0'); 5932 print '6134: test unused'; 5933 print '6135: test unused'; 5934 print '6135: test unused'; 5935 print '6136: test unused'; 5936 print '6137: test unused'; 5937 print '6138: test unused'; 5938 print '6139: test unused'; 5939 5940 /* 5941 * test isfile 5942 */ 5943 vrfy(isfile(loc) == 0, '6140: isfile(loc) == 0'); 5944 vrfy(isfile(a) == 0, '6141: isfile(a) == 0'); 5945 vrfy(isfile(ofd) == 1, '6142: isfile(ofd) == 1'); 5946 vrfy(isfile(cfd) == 1, '6143: isfile(cfd) == 1'); 5947 vrfy(isfile(blk) == 0, '6144: isfile(blk) == 0'); 5948 vrfy(isfile(nblk) == 0, '6145: isfile(nblk) == 0'); 5949 vrfy(isfile(cfg) == 0, '6146: isfile(cfg) == 0'); 5950 vrfy(isfile(serr) == 0, '6147: isfile(serr) == 0'); 5951 vrfy(isfile(nerr) == 0, '6148: isfile(nerr) == 0'); 5952 vrfy(isfile(odd) == 0, '6149: isfile(odd) == 0'); 5953 vrfy(isfile(even) == 0, '6150: isfile(even) == 0'); 5954 vrfy(isfile(hash) == 0, '6151: isfile(hash) == 0'); 5955 vrfy(isfile(id) == 0, '6152: isfile(id) == 0'); 5956 vrfy(isfile(list) == 0, '6153: isfile(list) == 0'); 5957 vrfy(isfile(matrix) == 0, '6154: isfile(matrix) == 0'); 5958 vrfy(isfile(nul) == 0, '6155: isfile(nul) == 0'); 5959 vrfy(isfile(object) == 0, '6156: isfile(object) == 0'); 5960 vrfy(isfile(rand) == 0, '6157: isfile(rand) == 0'); 5961 vrfy(isfile(random) == 0, '6158: isfile(random) == 0'); 5962 vrfy(isfile(real) == 0, '6159: isfile(real) == 0'); 5963 vrfy(isfile(prime) == 0, '6160: isfile(prime) == 0'); 5964 vrfy(isfile(square) == 0, '6161: isfile(square) == 0'); 5965 vrfy(isfile(string) == 0, '6162: isfile(string) == 0'); 5966 vrfy(isfile(com) == 0, '6163: isfile(com) == 0'); 5967 vrfy(isfile(files(0)) == 1, '6164: isfile(files(0)) == 1'); 5968 vrfy(isfile(files(1)) == 1, '6165: isfile(files(1)) == 1'); 5969 vrfy(isfile(files(2)) == 1, '6166: isfile(files(2)) == 1'); 5970 vrfy(isfile(files(3)) == 1, '6167: isfile(files(3)) == 1'); 5971 print '6168: test unused'; 5972 print '6169: test unused'; 5973 5974 /* 5975 * test ishash 5976 */ 5977 vrfy(ishash(loc) == 0, '6170: ishash(loc) == 0'); 5978 vrfy(ishash(a) == 0, '6171: ishash(a) == 0'); 5979 vrfy(ishash(ofd) == 0, '6172: ishash(ofd) == 0'); 5980 vrfy(ishash(cfd) == 0, '6173: ishash(cfd) == 0'); 5981 vrfy(ishash(blk) == 0, '6174: ishash(blk) == 0'); 5982 vrfy(ishash(nblk) == 0, '6175: ishash(nblk) == 0'); 5983 vrfy(ishash(cfg) == 0, '6176: ishash(cfg) == 0'); 5984 vrfy(ishash(serr) == 0, '6177: ishash(serr) == 0'); 5985 vrfy(ishash(nerr) == 0, '6178: ishash(nerr) == 0'); 5986 vrfy(ishash(odd) == 0, '6179: ishash(odd) == 0'); 5987 vrfy(ishash(even) == 0, '6180: ishash(even) == 0'); 5988 vrfy(ishash(hash) == 2, '6181: ishash(hash) == 2'); 5989 vrfy(ishash(id) == 0, '6182: ishash(id) == 0'); 5990 vrfy(ishash(list) == 0, '6183: ishash(list) == 0'); 5991 vrfy(ishash(matrix) == 0, '6184: ishash(matrix) == 0'); 5992 vrfy(ishash(nul) == 0, '6185: ishash(nul) == 0'); 5993 vrfy(ishash(object) == 0, '6186: ishash(object) == 0'); 5994 vrfy(ishash(rand) == 0, '6187: ishash(rand) == 0'); 5995 vrfy(ishash(random) == 0, '6188: ishash(random) == 0'); 5996 vrfy(ishash(real) == 0, '6189: ishash(real) == 0'); 5997 vrfy(ishash(prime) == 0, '6190: ishash(prime) == 0'); 5998 vrfy(ishash(square) == 0, '6191: ishash(square) == 0'); 5999 vrfy(ishash(string) == 0, '6192: ishash(string) == 0'); 6000 vrfy(ishash(com) == 0, '6193: ishash(com) == 0'); 6001 print '6194: test unused'; 6002 print '6195: test unused'; 6003 print '6196: test unused'; 6004 print '6197: test unused'; 6005 print '6198: test unused'; 6006 print '6199: test unused'; 6007 6008 /* 6009 * test isident 6010 */ 6011 vrfy(isident(loc) == 0, '6200: isident(loc) == 0'); 6012 vrfy(isident(a) == 0, '6201: isident(a) == 0'); 6013 vrfy(isident(ofd) == 0, '6202: isident(ofd) == 0'); 6014 vrfy(isident(cfd) == 0, '6203: isident(cfd) == 0'); 6015 vrfy(isident(blk) == 0, '6204: isident(blk) == 0'); 6016 vrfy(isident(nblk) == 0, '6205: isident(nblk) == 0'); 6017 vrfy(isident(cfg) == 0, '6206: isident(cfg) == 0'); 6018 vrfy(isident(serr) == 0, '6207: isident(serr) == 0'); 6019 vrfy(isident(nerr) == 0, '6208: isident(nerr) == 0'); 6020 vrfy(isident(odd) == 0, '6209: isident(odd) == 0'); 6021 vrfy(isident(even) == 0, '6210: isident(even) == 0'); 6022 vrfy(isident(hash) == 0, '6211: isident(hash) == 0'); 6023 vrfy(isident(id) == 1, '6212: isident(id) == 1'); 6024 vrfy(isident(list) == 0, '6213: isident(list) == 0'); 6025 vrfy(isident(matrix) == 0, '6214: isident(matrix) == 0'); 6026 vrfy(isident(nul) == 0, '6215: isident(nul) == 0'); 6027 vrfy(isident(object) == 0, '6216: isident(object) == 0'); 6028 vrfy(isident(rand) == 0, '6217: isident(rand) == 0'); 6029 vrfy(isident(random) == 0, '6218: isident(random) == 0'); 6030 vrfy(isident(real) == 0, '6219: isident(real) == 0'); 6031 vrfy(isident(prime) == 0, '6220: isident(prime) == 0'); 6032 vrfy(isident(square) == 0, '6221: isident(square) == 0'); 6033 vrfy(isident(string) == 0, '6222: isident(string) == 0'); 6034 vrfy(isident(com) == 0, '6223: isident(com) == 0'); 6035 print '6224: test unused'; 6036 print '6225: test unused'; 6037 print '6226: test unused'; 6038 print '6227: test unused'; 6039 print '6228: test unused'; 6040 print '6229: test unused'; 6041 6042 /* 6043 * test isint 6044 */ 6045 vrfy(isint(loc) == 1, '6230: isint(loc) == 1'); 6046 vrfy(isint(a) == 0, '6231: isint(a) == 0'); 6047 vrfy(isint(ofd) == 0, '6232: isint(ofd) == 0'); 6048 vrfy(isint(cfd) == 0, '6233: isint(cfd) == 0'); 6049 vrfy(isint(blk) == 0, '6234: isint(blk) == 0'); 6050 vrfy(isint(nblk) == 0, '6235: isint(nblk) == 0'); 6051 vrfy(isint(cfg) == 0, '6236: isint(cfg) == 0'); 6052 vrfy(isint(serr) == 0, '6237: isint(serr) == 0'); 6053 vrfy(isint(nerr) == 0, '6238: isint(nerr) == 0'); 6054 vrfy(isint(odd) == 1, '6239: isint(odd) == 1'); 6055 vrfy(isint(even) == 1, '6240: isint(even) == 1'); 6056 vrfy(isint(hash) == 0, '6241: isint(hash) == 0'); 6057 vrfy(isint(id) == 0, '6242: isint(id) == 0'); 6058 vrfy(isint(list) == 0, '6243: isint(list) == 0'); 6059 vrfy(isint(matrix) == 0, '6244: isint(matrix) == 0'); 6060 vrfy(isint(nul) == 0, '6245: isint(nul) == 0'); 6061 vrfy(isint(object) == 0, '6246: isint(object) == 0'); 6062 vrfy(isint(rand) == 0, '6247: isint(rand) == 0'); 6063 vrfy(isint(random) == 0, '6248: isint(random) == 0'); 6064 vrfy(isint(real) == 0, '6249: isint(real) == 0'); 6065 vrfy(isint(prime) == 1, '6250: isint(prime) == 1'); 6066 vrfy(isint(square) == 1, '6251: isint(square) == 1'); 6067 vrfy(isint(string) == 0, '6252: isint(string) == 0'); 6068 vrfy(isint(com) == 0, '6253: isint(com) == 0'); 6069 print '6254: test unused'; 6070 print '6255: test unused'; 6071 print '6255: test unused'; 6072 print '6256: test unused'; 6073 print '6257: test unused'; 6074 print '6258: test unused'; 6075 print '6259: test unused'; 6076 6077 /* 6078 * test islist 6079 */ 6080 vrfy(islist(loc) == 0, '6260: islist(loc) == 0'); 6081 vrfy(islist(a) == 0, '6261: islist(a) == 0'); 6082 vrfy(islist(ofd) == 0, '6262: islist(ofd) == 0'); 6083 vrfy(islist(cfd) == 0, '6263: islist(cfd) == 0'); 6084 vrfy(islist(blk) == 0, '6264: islist(blk) == 0'); 6085 vrfy(islist(nblk) == 0, '6265: islist(nblk) == 0'); 6086 vrfy(islist(cfg) == 0, '6266: islist(cfg) == 0'); 6087 vrfy(islist(serr) == 0, '6267: islist(serr) == 0'); 6088 vrfy(islist(nerr) == 0, '6268: islist(nerr) == 0'); 6089 vrfy(islist(odd) == 0, '6269: islist(odd) == 0'); 6090 vrfy(islist(even) == 0, '6270: islist(even) == 0'); 6091 vrfy(islist(hash) == 0, '6271: islist(hash) == 0'); 6092 vrfy(islist(id) == 0, '6272: islist(id) == 0'); 6093 vrfy(islist(list) == 1, '6273: islist(list) == 1'); 6094 vrfy(islist(matrix) == 0, '6274: islist(matrix) == 0'); 6095 vrfy(islist(nul) == 0, '6275: islist(nul) == 0'); 6096 vrfy(islist(object) == 0, '6276: islist(object) == 0'); 6097 vrfy(islist(rand) == 0, '6277: islist(rand) == 0'); 6098 vrfy(islist(random) == 0, '6278: islist(random) == 0'); 6099 vrfy(islist(real) == 0, '6279: islist(real) == 0'); 6100 vrfy(islist(prime) == 0, '6280: islist(prime) == 0'); 6101 vrfy(islist(square) == 0, '6281: islist(square) == 0'); 6102 vrfy(islist(string) == 0, '6282: islist(string) == 0'); 6103 vrfy(islist(com) == 0, '6283: islist(com) == 0'); 6104 print '6284: test unused'; 6105 print '6255: test unused'; 6106 print '6285: test unused'; 6107 print '6286: test unused'; 6108 print '6287: test unused'; 6109 print '6288: test unused'; 6110 print '6289: test unused'; 6111 6112 /* 6113 * test ismat 6114 */ 6115 vrfy(ismat(loc) == 0, '6290: ismat(loc) == 0'); 6116 vrfy(ismat(a) == 0, '6291: ismat(a) == 0'); 6117 vrfy(ismat(ofd) == 0, '6292: ismat(ofd) == 0'); 6118 vrfy(ismat(cfd) == 0, '6293: ismat(cfd) == 0'); 6119 vrfy(ismat(blk) == 0, '6294: ismat(blk) == 0'); 6120 vrfy(ismat(nblk) == 0, '6295: ismat(nblk) == 0'); 6121 vrfy(ismat(cfg) == 0, '6296: ismat(cfg) == 0'); 6122 vrfy(ismat(serr) == 0, '6297: ismat(serr) == 0'); 6123 vrfy(ismat(nerr) == 0, '6298: ismat(nerr) == 0'); 6124 vrfy(ismat(odd) == 0, '6299: ismat(odd) == 0'); 6125 vrfy(ismat(even) == 0, '6300: ismat(even) == 0'); 6126 vrfy(ismat(hash) == 0, '6301: ismat(hash) == 0'); 6127 vrfy(ismat(id) == 1, '6302: ismat(id) == 1'); 6128 vrfy(ismat(list) == 0, '6303: ismat(list) == 0'); 6129 vrfy(ismat(matrix) == 1, '6304: ismat(matrix) == 1'); 6130 vrfy(ismat(nul) == 0, '6305: ismat(nul) == 0'); 6131 vrfy(ismat(object) == 0, '6306: ismat(object) == 0'); 6132 vrfy(ismat(rand) == 0, '6307: ismat(rand) == 0'); 6133 vrfy(ismat(random) == 0, '6308: ismat(random) == 0'); 6134 vrfy(ismat(real) == 0, '6309: ismat(real) == 0'); 6135 vrfy(ismat(prime) == 0, '6310: ismat(prime) == 0'); 6136 vrfy(ismat(square) == 0, '6311: ismat(square) == 0'); 6137 vrfy(ismat(string) == 0, '6312: ismat(string) == 0'); 6138 vrfy(ismat(com) == 0, '6313: ismat(com) == 0'); 6139 print '6314: test unused'; 6140 print '6215: test unused'; 6141 print '6315: test unused'; 6142 print '6316: test unused'; 6143 print '6317: test unused'; 6144 print '6318: test unused'; 6145 print '6319: test unused'; 6146 6147 /* 6148 * test ismult 6149 */ 6150 vrfy(ismult(odd,even) == 0, '6320: ismult(odd,even) == 0'); 6151 vrfy(ismult(even,odd) == 1, '6321: ismult(even,odd) == 1'); 6152 vrfy(ismult(odd,odd) == 1, '6322: ismult(odd,odd) == 1'); 6153 vrfy(ismult(even,prime) == 0, '6323: ismult(even,prime) == 0'); 6154 vrfy(ismult(square,prime) == 1, '6324: ismult(square,prime) == 1'); 6155 vrfy(ismult(real,prime) == 0, '6325: ismult(real,prime) == 0'); 6156 vrfy(ismult(real,real*34) == 0, '6326: ismult(real,real*34) == 0'); 6157 vrfy(ismult(real*34,real) == 1, '6327: ismult(real*34,real) == 1'); 6158 print '6328: test unused'; 6159 print '6329: test unused'; 6160 6161 /* 6162 * test isnull 6163 */ 6164 vrfy(isnull(loc) == 0, '6330: isnull(loc) == 0'); 6165 vrfy(isnull(a) == 0, '6331: isnull(a) == 0'); 6166 vrfy(isnull(ofd) == 0, '6332: isnull(ofd) == 0'); 6167 vrfy(isnull(cfd) == 0, '6333: isnull(cfd) == 0'); 6168 vrfy(isnull(blk) == 0, '6334: isnull(blk) == 0'); 6169 vrfy(isnull(nblk) == 0, '6335: isnull(nblk) == 0'); 6170 vrfy(isnull(cfg) == 0, '6336: isnull(cfg) == 0'); 6171 vrfy(isnull(serr) == 0, '6337: isnull(serr) == 0'); 6172 vrfy(isnull(nerr) == 0, '6338: isnull(nerr) == 0'); 6173 vrfy(isnull(odd) == 0, '6339: isnull(odd) == 0'); 6174 vrfy(isnull(even) == 0, '6340: isnull(even) == 0'); 6175 vrfy(isnull(hash) == 0, '6341: isnull(hash) == 0'); 6176 vrfy(isnull(id) == 0, '6342: isnull(id) == 0'); 6177 vrfy(isnull(list) == 0, '6343: isnull(list) == 0'); 6178 vrfy(isnull(matrix) == 0, '6344: isnull(matrix) == 0'); 6179 vrfy(isnull(nul) == 1, '6345: isnull(nul) == 1'); 6180 vrfy(isnull(object) == 0, '6346: isnull(object) == 0'); 6181 vrfy(isnull(rand) == 0, '6347: isnull(rand) == 0'); 6182 vrfy(isnull(random) == 0, '6348: isnull(random) == 0'); 6183 vrfy(isnull(real) == 0, '6349: isnull(real) == 0'); 6184 vrfy(isnull(prime) == 0, '6350: isnull(prime) == 0'); 6185 vrfy(isnull(square) == 0, '6351: isnull(square) == 0'); 6186 vrfy(isnull(string) == 0, '6352: isnull(string) == 0'); 6187 vrfy(isnull(com) == 0, '6353: isnull(com) == 0'); 6188 print '6354: test unused'; 6189 print '6355: test unused'; 6190 print '6355: test unused'; 6191 print '6356: test unused'; 6192 print '6357: test unused'; 6193 print '6358: test unused'; 6194 print '6359: test unused'; 6195 6196 /* 6197 * test isnum 6198 */ 6199 vrfy(isnum(loc) == 1, '6360: isnum(loc) == 1'); 6200 vrfy(isnum(a) == 0, '6361: isnum(a) == 0'); 6201 vrfy(isnum(ofd) == 0, '6362: isnum(ofd) == 0'); 6202 vrfy(isnum(cfd) == 0, '6363: isnum(cfd) == 0'); 6203 vrfy(isnum(blk) == 0, '6364: isnum(blk) == 0'); 6204 vrfy(isnum(nblk) == 0, '6365: isnum(nblk) == 0'); 6205 vrfy(isnum(cfg) == 0, '6366: isnum(cfg) == 0'); 6206 vrfy(isnum(serr) == 0, '6367: isnum(serr) == 0'); 6207 vrfy(isnum(nerr) == 0, '6368: isnum(nerr) == 0'); 6208 vrfy(isnum(odd) == 1, '6369: isnum(odd) == 1'); 6209 vrfy(isnum(even) == 1, '6370: isnum(even) == 1'); 6210 vrfy(isnum(hash) == 0, '6371: isnum(hash) == 0'); 6211 vrfy(isnum(id) == 0, '6372: isnum(id) == 0'); 6212 vrfy(isnum(list) == 0, '6373: isnum(list) == 0'); 6213 vrfy(isnum(matrix) == 0, '6374: isnum(matrix) == 0'); 6214 vrfy(isnum(nul) == 0, '6375: isnum(nul) == 0'); 6215 vrfy(isnum(object) == 0, '6376: isnum(object) == 0'); 6216 vrfy(isnum(rand) == 0, '6377: isnum(rand) == 0'); 6217 vrfy(isnum(random) == 0, '6378: isnum(random) == 0'); 6218 vrfy(isnum(real) == 1, '6379: isnum(real) == 1'); 6219 vrfy(isnum(prime) == 1, '6380: isnum(prime) == 1'); 6220 vrfy(isnum(square) == 1, '6381: isnum(square) == 1'); 6221 vrfy(isnum(string) == 0, '6382: isnum(string) == 0'); 6222 vrfy(isnum(com) == 1, '6379: isnum(com) == 1'); 6223 print '6384: test unused'; 6224 print '6385: test unused'; 6225 print '6385: test unused'; 6226 print '6386: test unused'; 6227 print '6387: test unused'; 6228 print '6388: test unused'; 6229 print '6389: test unused'; 6230 6231 /* 6232 * test isobj 6233 */ 6234 vrfy(isobj(loc) == 0, '6390: isobj(loc) == 0'); 6235 vrfy(isobj(a) == 0, '6391: isobj(a) == 0'); 6236 vrfy(isobj(ofd) == 0, '6392: isobj(ofd) == 0'); 6237 vrfy(isobj(cfd) == 0, '6393: isobj(cfd) == 0'); 6238 vrfy(isobj(blk) == 0, '6394: isobj(blk) == 0'); 6239 vrfy(isobj(nblk) == 0, '6395: isobj(nblk) == 0'); 6240 vrfy(isobj(cfg) == 0, '6396: isobj(cfg) == 0'); 6241 vrfy(isobj(serr) == 0, '6397: isobj(serr) == 0'); 6242 vrfy(isobj(nerr) == 0, '6398: isobj(nerr) == 0'); 6243 vrfy(isobj(odd) == 0, '6399: isobj(odd) == 0'); 6244 vrfy(isobj(even) == 0, '6400: isobj(even) == 0'); 6245 vrfy(isobj(hash) == 0, '6401: isobj(hash) == 0'); 6246 vrfy(isobj(id) == 0, '6402: isobj(id) == 0'); 6247 vrfy(isobj(list) == 0, '6403: isobj(list) == 0'); 6248 vrfy(isobj(matrix) == 0, '6404: isobj(matrix) == 0'); 6249 vrfy(isobj(nul) == 0, '6405: isobj(nul) == 0'); 6250 vrfy(isobj(object) == 1, '6406: isobj(object) == 1'); 6251 vrfy(isobj(rand) == 0, '6407: isobj(rand) == 0'); 6252 vrfy(isobj(random) == 0, '6408: isobj(random) == 0'); 6253 vrfy(isobj(real) == 0, '6409: isobj(real) == 0'); 6254 vrfy(isobj(prime) == 0, '6410: isobj(prime) == 0'); 6255 vrfy(isobj(square) == 0, '6411: isobj(square) == 0'); 6256 vrfy(isobj(string) == 0, '6412: isobj(string) == 0'); 6257 vrfy(isobj(com) == 0, '6413: isobj(com) == 0'); 6258 print '6414: test unused'; 6259 print '6415: test unused'; 6260 print '6415: test unused'; 6261 print '6416: test unused'; 6262 print '6417: test unused'; 6263 print '6418: test unused'; 6264 print '6419: test unused'; 6265 6266 /* 6267 * test isobjtype 6268 */ 6269 vrfy(isobjtype("loc") == 0, '6420: isobjtype("loc") == 0'); 6270 vrfy(isobjtype("a") == 0, '6421: isobjtype("a") == 0'); 6271 vrfy(isobjtype("ofd") == 0, '6422: isobjtype("ofd") == 0'); 6272 vrfy(isobjtype("xy5800") == 1, '6423: isobjtype("xy5800") == 1'); 6273 vrfy(isobjtype("xy5900") == 1, '6424: isobjtype("xy5900") == 1'); 6274 print '6425: test unused'; 6275 print '6426: test unused'; 6276 print '6427: test unused'; 6277 print '6428: test unused'; 6278 print '6429: test unused'; 6279 6280 /* 6281 * test isodd 6282 */ 6283 vrfy(isodd(loc) == 0, '6430: isodd(loc) == 0'); 6284 vrfy(isodd(a) == 0, '6431: isodd(a) == 0'); 6285 vrfy(isodd(ofd) == 0, '6432: isodd(ofd) == 0'); 6286 vrfy(isodd(cfd) == 0, '6433: isodd(cfd) == 0'); 6287 vrfy(isodd(blk) == 0, '6434: isodd(blk) == 0'); 6288 vrfy(isodd(nblk) == 0, '6435: isodd(nblk) == 0'); 6289 vrfy(isodd(cfg) == 0, '6436: isodd(cfg) == 0'); 6290 vrfy(isodd(serr) == 0, '6437: isodd(serr) == 0'); 6291 vrfy(isodd(nerr) == 0, '6438: isodd(nerr) == 0'); 6292 vrfy(isodd(odd) == 1, '6439: isodd(odd) == 1'); 6293 vrfy(isodd(even) == 0, '6440: isodd(even) == 0'); 6294 vrfy(isodd(hash) == 0, '6441: isodd(hash) == 0'); 6295 vrfy(isodd(id) == 0, '6442: isodd(id) == 0'); 6296 vrfy(isodd(list) == 0, '6443: isodd(list) == 0'); 6297 vrfy(isodd(matrix) == 0, '6444: isodd(matrix) == 0'); 6298 vrfy(isodd(nul) == 0, '6445: isodd(nul) == 0'); 6299 vrfy(isodd(object) == 0, '6446: isodd(object) == 0'); 6300 vrfy(isodd(rand) == 0, '6447: isodd(rand) == 0'); 6301 vrfy(isodd(random) == 0, '6448: isodd(random) == 0'); 6302 vrfy(isodd(real) == 0, '6449: isodd(real) == 0'); 6303 vrfy(isodd(prime) == 1, '6450: isodd(prime) == 1'); 6304 vrfy(isodd(square) == 1, '6451: isodd(square) == 1'); 6305 vrfy(isodd(string) == 0, '6452: isodd(string) == 0'); 6306 vrfy(isodd(com) == 0, '6453: isodd(com) == 0'); 6307 print '6454: test unused'; 6308 print '6455: test unused'; 6309 print '6455: test unused'; 6310 print '6456: test unused'; 6311 print '6457: test unused'; 6312 print '6458: test unused'; 6313 print '6459: test unused'; 6314 6315 /* 6316 * test isprime 6317 */ 6318 vrfy(isprime(loc) == 0, '6460: isprime(loc) == 0'); 6319 vrfy(isprime(odd) == 1, '6461: isprime(odd) == 1'); 6320 vrfy(isprime(even) == 0, '6462: isprime(even) == 0'); 6321 vrfy(isprime(prime) == 1, '6463: isprime(prime) == 1'); 6322 vrfy(isprime(square) == 0, '6464: isprime(square) == 0'); 6323 print '6465: test unused'; 6324 print '6466: test unused'; 6325 print '6468: test unused'; 6326 print '6468: test unused'; 6327 print '6469: test unused'; 6328 6329 /* 6330 * test isrand 6331 */ 6332 vrfy(isrand(loc) == 0, '6470: isrand(loc) == 0'); 6333 vrfy(isrand(a) == 0, '6471: isrand(a) == 0'); 6334 vrfy(isrand(ofd) == 0, '6472: isrand(ofd) == 0'); 6335 vrfy(isrand(cfd) == 0, '6473: isrand(cfd) == 0'); 6336 vrfy(isrand(blk) == 0, '6474: isrand(blk) == 0'); 6337 vrfy(isrand(nblk) == 0, '6475: isrand(nblk) == 0'); 6338 vrfy(isrand(cfg) == 0, '6476: isrand(cfg) == 0'); 6339 vrfy(isrand(serr) == 0, '6477: isrand(serr) == 0'); 6340 vrfy(isrand(nerr) == 0, '6478: isrand(nerr) == 0'); 6341 vrfy(isrand(odd) == 0, '6479: isrand(odd) == 0'); 6342 vrfy(isrand(even) == 0, '6480: isrand(even) == 0'); 6343 vrfy(isrand(hash) == 0, '6481: isrand(hash) == 0'); 6344 vrfy(isrand(id) == 0, '6482: isrand(id) == 0'); 6345 vrfy(isrand(list) == 0, '6483: isrand(list) == 0'); 6346 vrfy(isrand(matrix) == 0, '6484: isrand(matrix) == 0'); 6347 vrfy(isrand(nul) == 0, '6485: isrand(nul) == 0'); 6348 vrfy(isrand(object) == 0, '6486: isrand(object) == 0'); 6349 vrfy(isrand(rand) == 1, '6487: isrand(rand) == 1'); 6350 vrfy(isrand(random) == 0, '6488: isrand(random) == 0'); 6351 vrfy(isrand(real) == 0, '6489: isrand(real) == 0'); 6352 vrfy(isrand(prime) == 0, '6490: isrand(prime) == 0'); 6353 vrfy(isrand(square) == 0, '6491: isrand(square) == 0'); 6354 vrfy(isrand(string) == 0, '6492: isrand(string) == 0'); 6355 vrfy(isrand(com) == 0, '6493: isrand(com) == 0'); 6356 print '6494: test unused'; 6357 print '6495: test unused'; 6358 print '6495: test unused'; 6359 print '6496: test unused'; 6360 print '6497: test unused'; 6361 print '6498: test unused'; 6362 print '6499: test unused'; 6363 6364 /* 6365 * test israndom 6366 */ 6367 vrfy(israndom(loc) == 0, '6500: israndom(loc) == 0'); 6368 vrfy(israndom(a) == 0, '6501: israndom(a) == 0'); 6369 vrfy(israndom(ofd) == 0, '6502: israndom(ofd) == 0'); 6370 vrfy(israndom(cfd) == 0, '6503: israndom(cfd) == 0'); 6371 vrfy(israndom(blk) == 0, '6504: israndom(blk) == 0'); 6372 vrfy(israndom(nblk) == 0, '6505: israndom(nblk) == 0'); 6373 vrfy(israndom(cfg) == 0, '6506: israndom(cfg) == 0'); 6374 vrfy(israndom(serr) == 0, '6507: israndom(serr) == 0'); 6375 vrfy(israndom(nerr) == 0, '6508: israndom(nerr) == 0'); 6376 vrfy(israndom(odd) == 0, '6509: israndom(odd) == 0'); 6377 vrfy(israndom(even) == 0, '6510: israndom(even) == 0'); 6378 vrfy(israndom(hash) == 0, '6511: israndom(hash) == 0'); 6379 vrfy(israndom(id) == 0, '6512: israndom(id) == 0'); 6380 vrfy(israndom(list) == 0, '6513: israndom(list) == 0'); 6381 vrfy(israndom(matrix) == 0, '6514: israndom(matrix) == 0'); 6382 vrfy(israndom(nul) == 0, '6515: israndom(nul) == 0'); 6383 vrfy(israndom(object) == 0, '6516: israndom(object) == 0'); 6384 vrfy(israndom(rand) == 0, '6517: israndom(rand) == 0'); 6385 vrfy(israndom(random) == 1, '6518: israndom(random) == 1'); 6386 vrfy(israndom(real) == 0, '6519: israndom(real) == 0'); 6387 vrfy(israndom(prime) == 0, '6520: israndom(prime) == 0'); 6388 vrfy(israndom(square) == 0, '6521: israndom(square) == 0'); 6389 vrfy(israndom(string) == 0, '6522: israndom(string) == 0'); 6390 vrfy(israndom(com) == 0, '6523: israndom(com) == 0'); 6391 print '6524: test unused'; 6392 print '6525: test unused'; 6393 print '6526: test unused'; 6394 print '6527: test unused'; 6395 print '6528: test unused'; 6396 print '6529: test unused'; 6397 6398 /* 6399 * test isreal 6400 */ 6401 vrfy(isreal(loc) == 1, '6530: isreal(loc) == 1'); 6402 vrfy(isreal(a) == 0, '6531: isreal(a) == 0'); 6403 vrfy(isreal(ofd) == 0, '6532: isreal(ofd) == 0'); 6404 vrfy(isreal(cfd) == 0, '6533: isreal(cfd) == 0'); 6405 vrfy(isreal(blk) == 0, '6534: isreal(blk) == 0'); 6406 vrfy(isreal(nblk) == 0, '6535: isreal(nblk) == 0'); 6407 vrfy(isreal(cfg) == 0, '6536: isreal(cfg) == 0'); 6408 vrfy(isreal(serr) == 0, '6537: isreal(serr) == 0'); 6409 vrfy(isreal(nerr) == 0, '6538: isreal(nerr) == 0'); 6410 vrfy(isreal(odd) == 1, '6539: isreal(odd) == 1'); 6411 vrfy(isreal(even) == 1, '6540: isreal(even) == 1'); 6412 vrfy(isreal(hash) == 0, '6541: isreal(hash) == 0'); 6413 vrfy(isreal(id) == 0, '6542: isreal(id) == 0'); 6414 vrfy(isreal(list) == 0, '6543: isreal(list) == 0'); 6415 vrfy(isreal(matrix) == 0, '6544: isreal(matrix) == 0'); 6416 vrfy(isreal(nul) == 0, '6545: isreal(nul) == 0'); 6417 vrfy(isreal(object) == 0, '6546: isreal(object) == 0'); 6418 vrfy(isreal(rand) == 0, '6547: isreal(rand) == 0'); 6419 vrfy(isreal(random) == 0, '6548: isreal(random) == 0'); 6420 vrfy(isreal(real) == 1, '6549: isreal(real) == 1'); 6421 vrfy(isreal(prime) == 1, '6550: isreal(prime) == 1'); 6422 vrfy(isreal(square) == 1, '6551: isreal(square) == 1'); 6423 vrfy(isreal(string) == 0, '6552: isreal(string) == 0'); 6424 vrfy(isreal(com) == 0, '6553: isreal(com) == 0'); 6425 print '6554: test unused'; 6426 print '6555: test unused'; 6427 print '6555: test unused'; 6428 print '6556: test unused'; 6429 print '6557: test unused'; 6430 print '6558: test unused'; 6431 print '6559: test unused'; 6432 6433 /* 6434 * test isrel 6435 */ 6436 vrfy(isrel(odd,even) == 0, '6560: isrel(odd,even) == 0'); 6437 vrfy(isrel(even,odd) == 0, '6561: isrel(even,odd) == 0'); 6438 vrfy(isrel(odd,odd) == 0, '6562: isrel(odd,odd) == 0'); 6439 vrfy(isrel(even,prime) == 1, '6563: isrel(even,prime) == 1'); 6440 vrfy(isrel(square,prime) == 0, '6564: isrel(square,prime) == 0'); 6441 vrfy(isrel(prime,square) == 0, '6565: isrel(prime,square) == 0'); 6442 vrfy(isrel(even,square) == 1, '6566: isrel(even,square) == 1'); 6443 vrfy(isrel(prime,even) == 1, '6567: isrel(prime,even) == 1'); 6444 print '6568: test unused'; 6445 print '6569: test unused'; 6446 6447 /* 6448 * test bit (this was isset and thus was included here, however 6449 * we leave it here for now rather than renumber 6450 * the tests below) 6451 */ 6452 vrfy(bit(odd,0) == 1, '6570: bit(odd,0) == 1'); 6453 vrfy(bit(odd,1) == 0, '6571: bit(odd,1) == 0'); 6454 vrfy(bit(odd,2) == 0, '6572: bit(odd,2) == 0'); 6455 vrfy(bit(odd,3) == 1, '6573: bit(odd,3) == 1'); 6456 vrfy(bit(real,4) == 1, '6574: bit(real,4) == 1'); 6457 vrfy(bit(real,5) == 0, '6575: bit(real,5) == 0'); 6458 vrfy(bit(real,6) == 1, '6576: bit(real,6) == 1'); 6459 vrfy(bit(real,7) == 0, '6577: bit(real,7) == 0'); 6460 print '6578: test unused'; 6461 print '6579: test unused'; 6462 6463 /* 6464 * test issimple 6465 */ 6466 vrfy(issimple(loc) == 1, '6580: issimple(loc) == 1'); 6467 vrfy(issimple(a) == 0, '6581: issimple(a) == 0'); 6468 vrfy(issimple(ofd) == 0, '6582: issimple(ofd) == 0'); 6469 vrfy(issimple(cfd) == 0, '6583: issimple(cfd) == 0'); 6470 vrfy(issimple(blk) == 0, '6584: issimple(blk) == 0'); 6471 vrfy(issimple(nblk) == 0, '6585: issimple(nblk) == 0'); 6472 vrfy(issimple(cfg) == 0, '6586: issimple(cfg) == 0'); 6473 vrfy(issimple(serr) == 0, '6587: issimple(serr) == 0'); 6474 vrfy(issimple(nerr) == 0, '6588: issimple(nerr) == 0'); 6475 vrfy(issimple(odd) == 1, '6589: issimple(odd) == 1'); 6476 vrfy(issimple(even) == 1, '6590: issimple(even) == 1'); 6477 vrfy(issimple(hash) == 0, '6591: issimple(hash) == 0'); 6478 vrfy(issimple(id) == 0, '6592: issimple(id) == 0'); 6479 vrfy(issimple(list) == 0, '6593: issimple(list) == 0'); 6480 vrfy(issimple(matrix) == 0, '6594: issimple(matrix) == 0'); 6481 vrfy(issimple(nul) == 1, '6595: issimple(nul) == 1'); 6482 vrfy(issimple(object) == 0, '6596: issimple(object) == 0'); 6483 vrfy(issimple(rand) == 0, '6597: issimple(rand) == 0'); 6484 vrfy(issimple(random) == 0, '6598: issimple(random) == 0'); 6485 vrfy(issimple(real) == 1, '6599: issimple(real) == 1'); 6486 vrfy(issimple(prime) == 1, '6600: issimple(prime) == 1'); 6487 vrfy(issimple(square) == 1, '6601: issimple(square) == 1'); 6488 vrfy(issimple(string) == 1, '6602: issimple(string) == 1'); 6489 vrfy(issimple(com) == 1, '6603: issimple(com) == 1'); 6490 print '6604: test unused'; 6491 print '6605: test unused'; 6492 print '6606: test unused'; 6493 print '6607: test unused'; 6494 print '6608: test unused'; 6495 print '6609: test unused'; 6496 6497 /* 6498 * test issq 6499 */ 6500 vrfy(issq(loc) == 1, '6610: issq(loc) == 1'); 6501 vrfy(issq(odd) == 0, '6611: issq(odd) == 0'); 6502 vrfy(issq(even) == 0, '6612: issq(even) == 0'); 6503 vrfy(issq(prime) == 0, '6613: issq(prime) == 0'); 6504 vrfy(issq(square) == 1, '6614: issq(square) == 1'); 6505 print '6615: test unused'; 6506 print '6616: test unused'; 6507 print '6618: test unused'; 6508 print '6618: test unused'; 6509 print '6619: test unused'; 6510 6511 /* 6512 * test isstr 6513 */ 6514 vrfy(isstr(loc) == 0, '6620: isstr(loc) == 0'); 6515 vrfy(isstr(a) == 0, '6621: isstr(a) == 0'); 6516 vrfy(isstr(ofd) == 0, '6622: isstr(ofd) == 0'); 6517 vrfy(isstr(cfd) == 0, '6623: isstr(cfd) == 0'); 6518 vrfy(isstr(blk) == 0, '6624: isstr(blk) == 0'); 6519 vrfy(isstr(nblk) == 0, '6625: isstr(nblk) == 0'); 6520 vrfy(isstr(cfg) == 0, '6626: isstr(cfg) == 0'); 6521 vrfy(isstr(serr) == 0, '6627: isstr(serr) == 0'); 6522 vrfy(isstr(nerr) == 0, '6628: isstr(nerr) == 0'); 6523 vrfy(isstr(odd) == 0, '6629: isstr(odd) == 0'); 6524 vrfy(isstr(even) == 0, '6630: isstr(even) == 0'); 6525 vrfy(isstr(hash) == 0, '6631: isstr(hash) == 0'); 6526 vrfy(isstr(id) == 0, '6632: isstr(id) == 0'); 6527 vrfy(isstr(list) == 0, '6633: isstr(list) == 0'); 6528 vrfy(isstr(matrix) == 0, '6634: isstr(matrix) == 0'); 6529 vrfy(isstr(nul) == 0, '6635: isstr(nul) == 0'); 6530 vrfy(isstr(object) == 0, '6636: isstr(object) == 0'); 6531 vrfy(isstr(rand) == 0, '6637: isstr(rand) == 0'); 6532 vrfy(isstr(random) == 0, '6638: isstr(random) == 0'); 6533 vrfy(isstr(real) == 0, '6639: isstr(real) == 0'); 6534 vrfy(isstr(prime) == 0, '6640: isstr(prime) == 0'); 6535 vrfy(isstr(square) == 0, '6641: isstr(square) == 0'); 6536 vrfy(isstr(string) == 1, '6642: isstr(string) == 1'); 6537 vrfy(isstr(com) == 0, '6643: isstr(com) == 0'); 6538 print '6644: test unused'; 6539 print '6645: test unused'; 6540 print '6645: test unused'; 6541 print '6646: test unused'; 6542 print '6647: test unused'; 6543 print '6648: test unused'; 6544 print '6649: test unused'; 6545 6546 /* 6547 * test istype 6548 */ 6549 vrfy(istype(odd,even) == 1, '6650: istype(odd,even) == 1'); 6550 vrfy(istype(even,odd) == 1, '6651: istype(even,odd) == 1'); 6551 vrfy(istype(odd,odd) == 1, '6652: istype(odd,odd) == 1'); 6552 vrfy(istype(even,prime) == 1, '6653: istype(even,prime) == 1'); 6553 vrfy(istype(square,prime) == 1, '6654: istype(square,prime) == 1'); 6554 vrfy(istype(prime,square) == 1, '6655: istype(prime,square) == 1'); 6555 vrfy(istype(even,square) == 1, '6656: istype(even,square) == 1'); 6556 vrfy(istype(prime,even) == 1, '6657: istype(prime,even) == 1'); 6557 vrfy(istype(prime,com) == 0, '6658: istype(prime,com) == 0'); 6558 vrfy(istype(matrix,com) == 0, '6659: istype(matrix,com) == 0'); 6559 6560 vrfy(istype(matrix,list) == 0, '6660: istype(matrix,list) == 0'); 6561 vrfy(istype(matrix,odd) == 0, '6661: istype(matrix,odd) == 0'); 6562 vrfy(istype(a,odd) == 0, '6662: istype(a,odd) == 0'); 6563 6564 /* 6565 * perform more extensive issq() testing 6566 */ 6567 ok = 1; 6568 for (i=0; i < 256; ++i) { 6569 /* rndval will be a square - even powers>0 of x>1 */ 6570 rndexp = random(1, 16) * 2; 6571 rndint = random(2, 4294967296); 6572 if (issq(rndint)) { 6573 ++rndint; 6574 } 6575 rndval = rndint ^ rndexp; 6576 if (issq(rndval) == 0) { 6577 prob(strprintf("issq(%d^%d) returned 0", 6578 rndint, rndexp)); 6579 ok = 0; 6580 } 6581 } 6582 if (ok) { 6583 print '6663: issq() on 256 squares'; 6584 } else { 6585 print '****: failure(s): 6663: faiissq() on 256 squares'; 6586 } 6587 for (i=0; i < 256; ++i) { 6588 /* rndval will not be a square - 1 + even powers>0 of x>1 */ 6589 rndexp = random(1, 16) * 2; 6590 rndint = random(2, 4294967296); 6591 rndval = rndint ^ rndexp; 6592 if (issq(rndval+1) != 0) { 6593 prob(strprintf("issq(%d^%d)+1 returned non-zero", 6594 rndint, rndexp)); 6595 ok = 0; 6596 } 6597 } 6598 if (ok) { 6599 print '6664: issq() on 256 squares+1'; 6600 } else { 6601 print '****: failure(s): 6664: issq() on 256 squares+1'; 6602 } 6603 print '6664: issq() on 256 squares+1'; 6604 for (i=0; i < 256; ++i) { 6605 /* rndval will not be a square - odd powers>0 of x>1 */ 6606 rndexp = (random(1, 16) * 2) + 1; 6607 rndint = random(2, 4294967296); 6608 if (issq(rndint)) { 6609 ++rndint; 6610 } 6611 rndval = rndint ^ rndexp; 6612 if (issq(rndval) != 0) { 6613 prob(strprintf("issq(%d^%d) returned non-zero", 6614 rndint, rndexp)); 6615 ok = 0; 6616 } 6617 } 6618 if (ok) { 6619 print '6665: issq() on 256 non-squares'; 6620 } else { 6621 print '****: failure(s): 6665: issq() on 256 non-squares'; 6622 } 6623 6624 /* 6625 * cleanup 6626 */ 6627 blkfree("blk5900"); 6628 print '6666: blkfree("blk5900")'; 6629 fclose(ofd); 6630 print '6667: fclose(ofd)'; 6631 6632 print '6668: Ending test_is'; 6633} 6634print '168: test_is()'; 6635 6636 6637/* 6638 * test_blk - test block of octets 6639 */ 6640define test_blk() 6641{ 6642 local A, B, C, A1, A2, B1; 6643 6644 print '6700: Beginning test_blk'; 6645 6646 A = blk(20); 6647 print '6701: A = blk(20);'; 6648 vrfy(size(A) == 20, '6702: size(A) == 20'); 6649 vrfy(sizeof(A) == 256, '6703: sizeof(A) == 256'); 6650 B = A; 6651 print '6704: B = A;'; 6652 vrfy(size(B) == 20, '6705: size(B) == 20'); 6653 vrfy(A == B, '6706: A == B'); 6654 6655 A[5] = 21; 6656 print '6707: A[5] = 21;'; 6657 vrfy(A[5] == 21, '6708: A[5] == 21'); 6658 6659 A[6] = 'abc'; 6660 print '6709: A[6] = "abc";'; 6661 vrfy(A[6] == ord('a'), '6710: A[6] == ord("a")'); 6662 6663 A[7] = 260; 6664 print '6711: A[7] = 260;'; 6665 vrfy(A[7] == 4, '6712: A[7] == 4'); 6666 6667 A[8] = 3+4i; 6668 print '6713: A[8] = 3+4i;'; 6669 vrfy(A[8] == 3, '6714: A[8] == 3'); 6670 6671 vrfy(A != B, '6715: A != B'); 6672 6673 /* Equality of blocks of same data-length is unaffected by maxsizes */ 6674 6675 C = blk(A, ,128); 6676 print '6716: C = blk(A, ,128);'; 6677 vrfy(size(C) == size(A), '6717: size(C) == size(A)'); 6678 vrfy(sizeof(C) == 128, '6718: sizeof(C) == 128'); 6679 vrfy(C == A, '6719: C == A'); 6680 6681 /* Blocks of different lengths test as unequal */ 6682 6683 C = blk(A,30); 6684 print '6720: C = blk(A,30);'; 6685 vrfy(size(C) == 30, '6721: size(C) == 30'); 6686 vrfy(C != A, '6722: C != A;'); 6687 6688 /* Reducing length to that of original data restores equality */ 6689 6690 C = blk(C,20); 6691 print '6723: C = blk(C,20);'; 6692 vrfy(C == A, '6724: C == A'); 6693 6694 /* Reading block beyond data length extends length */ 6695 6696 A[29] = 7; 6697 print '6725: A[29] = 7;'; 6698 vrfy(A[29] == 7, '6726: A[29] == 7'); 6699 vrfy(size(A) == 30, '6727: size(A) == 30'); 6700 6701 /* Reducing length clears memory beyond new length */ 6702 6703 A = blk(A, 20); 6704 print '6728: A = blk(A, 20);'; 6705 vrfy(A[29] == 0, '6729: A[29] == 0'); 6706 6707 /* Reducing length to zero and initializing a few early values */ 6708 6709 A = blk(A,0) = {1,,3,,5}; 6710 print '6730: A = blk(A,0) = {1,,3,5};'; 6711 6712 vrfy(A[4] == 5, '6731: A[4] == 5'); 6713 vrfy(size(A) == 5, '6732: size(A) == 5'); 6714 6715 /* Assignment of copy with initialization */ 6716 6717 B = A; 6718 print '6733: B = A;'; 6719 C=blk(A)={,,,,,,,,,,0xbb}; 6720 print '6734: C=blk(A)={,,,,,,,,,,0xbb};'; 6721 6722 /* A has not been changed */ 6723 6724 vrfy(A == B, '6735: A == B'); 6725 vrfy(C[10] == 0xbb, '6736: C[10] == 0xbb'); 6726 6727 /* Testing named blocks */ 6728 6729 A1 = blk("blk6700"); 6730 print '6737: A1 = blk("blk6700");'; 6731 A2 = blk("blk6700"); 6732 print '6738: A2 = blk("blk6700");'; 6733 vrfy(A1 == A2, '6739: A1 == A2'); 6734 vrfy(size(A1) == 0, '6740: size(A1) == 0'); 6735 vrfy(sizeof(A1) == 256, '6741: sizeof(A1) == 256'); 6736 print '6742: test disabled: test(A1) == 0'; 6737 print '6743: test disabled: str(A1) == "blk6700"'; 6738 vrfy(blocks() == 1, '6744: blocks() == 1'); 6739 vrfy(blocks(1) == A1, '6745: blocks(1) == A1'); 6740 6741 /* A second named block */ 6742 6743 B1 = blk("+++6700", 15, 10) = {1,2,3,4,5}; 6744 print 6745 '6746: B1 = blk("+++6700", 15 , 10) = {1,2,3,4,5};'; 6746 vrfy(size(B1) == 15, '6747: size(B1) == 15'); 6747 vrfy(sizeof(B1) == 20, '6748: sizeof(B1) == 20'); 6748 vrfy(test(B1) == 1, '6749: test(B1) == 1'); 6749 print '6750: test disabled: str(B1) == "+++6700"'; 6750 vrfy(blocks() == 2, '6751: blocks() == 2'); 6751 vrfy(blocks(2) == B1, '6752: blocks(2) == B1'); 6752 vrfy(B1 != A1, '6753: B1 != A1'); 6753 6754 /* Referencing octets beyond datalen increases datalen */ 6755 6756 A1[15] = 29; 6757 print '6754: A1[15] = 29;'; 6758 vrfy(A1[15] == 29, '6755: A1[15] == 29'); 6759 vrfy(A2[15] == 29, '6756: A2[15] == 29'); 6760 vrfy(size(A1) == 16, '6757: size(A1) == 16'); 6761 vrfy(test(A1) == 1, '6758: test(A1) == 1'); 6762 A1[99] = 11; 6763 print '6759: A1[99] = 11;'; 6764 vrfy(size(A1) == 100, '6760: size(A1) == 100'); 6765 vrfy(A1[99] == 11, '6761: A1[99] == 11'); 6766 6767 /* increasing chunksize */ 6768 6769 null(blk(A1, , 1000)); 6770 print '6762: null(blk(A1, , 1000));'; 6771 vrfy(size(A1) == 100, '6763: size(A1) == 100'); 6772 vrfy(sizeof(A1) == 1000, '6764: sizeof(A1) == 1000'); 6773 vrfy(A1[99] == 11, '6765: A1[99] == 11'); 6774 6775 /* reducing data-length */ 6776 6777 A1 = blk(A1, 10); 6778 print '6766: A1 = blk(A1, 10);'; 6779 vrfy(size(A1) == 10, '6767: size(A1) == 10'); 6780 6781 /* all octets now zero */ 6782 6783 vrfy(test(A1) == 0, '6768: test(A1) == 0'); 6784 vrfy(A1[99] == 0, '6769: A1[99] == 0'); 6785 6786 /* freeing memory */ 6787 6788 blkfree(A1); 6789 print '6770: blkfree(A1);'; 6790 6791 /* freeing named block memory reduces number of unfreed blocks */ 6792 6793 vrfy(blocks() == 1, '6771: blocks() == 1'); 6794 6795 /* 'removed' block still exists but has zero size and maxsize */ 6796 6797 vrfy(blocks(1) == A1, '6772: blocks(1) == A1'); 6798 vrfy(size(A1) == 0, '6773: size(A1) == 0'); 6799 vrfy(sizeof(A1) == 0, '6774: sizeof(A1) == 0'); 6800 vrfy(test(A1) == 0, '6775: test(A1) == 0'); 6801 print '6776: test disabled: str(A1) == "blk6700"'; 6802 6803 /* Equality of named blocks not affected by freeing of memory */ 6804 6805 vrfy(A1 == A2, '6777: A1 == A2'); 6806 6807 /* Executing blk('blk6700') reallocates memory for A1 */ 6808 6809 null(blk('blk6700')); 6810 print '6778: null(blk("blk6700"));'; 6811 vrfy(size(A1) == 0, '6779: size(A1) == 0'); 6812 vrfy(sizeof(A1) == 1000, '6780: sizeof(A1) == 1000'); 6813 6814 /* A2 still refers to same block as A1 */ 6815 6816 A1[100] = 0xff; 6817 print '6781: A1[100] = 0xff;'; 6818 vrfy(A2[100] == 0xff, '6782: A2[100] == 0xff'); 6819 6820 /* A possibly confusing initialization and assignment */ 6821 6822 mat A1[2] = {A1, B1}; 6823 print '6783: mat A1[2] = {A1, B1};'; 6824 vrfy(A1[0] == A2, '6784: A1[0] == A2'); 6825 vrfy(A1[1] == B1, '6785: A1[1] == B1'); 6826 vrfy(A1[0][100] == 0xff, '6786: A1[0][100] == 0xff'); 6827 6828 print '6800: reserved for future expansion of test_blk'; 6829 6830 print '6899: Ending test_blk'; 6831} 6832print '169: parsed test_blk()'; 6833 6834 6835/* 6836 * test_blkcpy - test the new copy builtin function 6837 */ 6838define test_blkcpy() 6839{ 6840 local A, B, C, A1, A2, B1, fs, S, M1, M2, L1, L2, x; 6841 6842 print '6800: Beginning test_blkcpy'; 6843 6844 A = blk() = {1,2,3,4,5}; 6845 print '6801: A = blk() = {1,2,3,4,5};'; 6846 B = blk(); 6847 print '6802: B = blk();'; 6848 blkcpy(B, A); 6849 print '6803: blkcpy(B, A);'; 6850 vrfy(A == B, '6804: A == B'); 6851 blkcpy(B, A, ,10); 6852 print '6805: blkcpy(B, A, ,10)'; 6853 vrfy(size(B) == 15, '6806: size(B) == 15'); 6854 blkcpy(B, A, , 15, 3); 6855 print '6807: blkcpy(A, 3, B, 15);'; 6856 vrfy(size(B) == 17, '6808: size(B) == 17'); 6857 vrfy(B[16] == 5, '6809: B[16] == 5'); 6858 6859 /* create named block A1 and blkcpy A into B[0]... and B[100]... */ 6860 6861 x = rm("-f", "blk6800"); 6862 print '6810: x = rm("-f", "blk6800")'; 6863 A1 = blk("blk6800"); 6864 print '6811: A1 = blk("blk6800");'; 6865 vrfy(size(A1) == 0, '6812: size(A1) == 0'); 6866 blkcpy(A1, A); 6867 print '6813: blkcpy(A1, A);'; 6868 vrfy(size(A1) == 5, '6814: size(A1) == 5'); 6869 blkcpy(A1, A, ,100); 6870 print '6815: blkcpy(A1, A, ,100);'; 6871 vrfy(size(A1) == 105, '6816: size(A1) == 105'); 6872 6873 /* create named block B1 and blkcpy first 5 octets of A1 to B[100]... */ 6874 6875 B1 = blk("beta"); 6876 print '6817: B1 = blk("beta")'; 6877 vrfy(size(B1) == 0, '6818: size(B1) == 0'); 6878 blkcpy(B1, A1, 5, 100, 0); 6879 print '6819: blkcpy(B1, A1, 5, 100, 0)'; 6880 vrfy(size(B1) == 105, '6820: size(B1) == 105'); 6881 6882 /* blkcpy the last 5 octets of B1 to a new block C */ 6883 6884 blkcpy(C = blk(), B1,5,,100); 6885 print '6821: blkcpy(C = blk(), B1,5,,100);'; 6886 vrfy(C == A, '6822: C == A'); 6887 6888 /* blkcpy to and from a file */ 6889 6890 fs = fopen("junk6800", "w+"); 6891 print '6823: fs = fopen("junk6800", "w+");'; 6892 blkcpy(fs, A); 6893 print '6824: blkcpy(fs, A);'; 6894 vrfy(size(fs) == 5, '6825: size(f) == 5'); 6895 blkcpy(B = blk(), fs); 6896 print '6826: blkcpy(B = blk(), fs);'; 6897 vrfy(B == A, '6827: B == A'); 6898 blkcpy(fs, A, ,100); 6899 print '6828: blkcpy(fs, A, ,100);'; 6900 vrfy(size(fs) == 105, '6829: size(f) == 105'); 6901 blkcpy(C = blk(), fs,2,,100); 6902 print '6830: blkcpy(C = blk(), fs,2,,100)'; 6903 vrfy(C == (blk() = {1,2}), '6831: C == (blk() = {1,2}'); 6904 6905 /* blkcpy string to a block */ 6906 6907 A = blk(); 6908 print '6832: A = blk();'; 6909 6910 /* Note that "blk6800" is not here considered to name a block */ 6911 6912 blkcpy(A, "blk6800 "); 6913 print '6833: blkcpy(A, "blk6800");'; 6914 vrfy(size(A) == 9, '6834: size(A) == 9'); 6915 blkcpy(A, "beta", , 7); 6916 print '6835: blkcpy(A, "beta", , 7);'; 6917 vrfy(size(A) == 12, '6836: size(A) == 12'); 6918 6919 /* read strings from A */ 6920 6921 S = strprintf("%s", A[0]); 6922 print '6837: S = strprintf("%s", A[0]);'; 6923 vrfy(S == "blk6800beta", '6838: S == "blk6800beta"'); 6924 S = strprintf("%s", A[8]); 6925 print '6839: S = strprintf("%s", A[8]);'; 6926 vrfy(S == "eta", '6840: S == "eta"'); 6927 6928 mat M1[2,2] = {1,2,3,4}; 6929 print '6841: mat M1[2,2] = {1,2,3,4};'; 6930 mat M2[4]; 6931 print '6842: mat M2[4];'; 6932 blkcpy(M2, M1); 6933 print '6843: blkcpy(M2, M1)'; 6934 vrfy(M2 == (mat[4]={1,2,3,4}), '6844: M2 == (mat[4]={1,2,3,4}'); 6935 blkcpy(M2, M2, 2, 2, 0); 6936 print '6845: blkcpy(M2, M2, 2, 2, 0);'; 6937 vrfy(M2 == (mat[4]={1,2,1,2}), '6846: M2 == (mat[4]={1,2,1,2}'); 6938 6939 /* blkcpy between blocks and matrices */ 6940 6941 B = blk(); 6942 print '6847: B = blk()'; 6943 blkcpy(B, M1); 6944 print '6848: blkcpy(B, M1)'; 6945 vrfy(B == (blk() = {1,2,3,4}), '6849: B == (blk() = {1,2,3,4}'); 6946 blkcpy(M2, B, 2, ,2); 6947 print '6850: blkcpy(B,2,2,M2);'; 6948 vrfy(M2 == (mat[4]={3,4,1,2}), '6851: M2 == (mat[4]={3,4,1,2})'); 6949 6950 /* blkcpy between matrices and lists */ 6951 6952 L1 = makelist(4); 6953 print '6852: L1 = makelist(4);'; 6954 blkcpy(L1, M2); 6955 print '6853: blkcpy(L1, M2);'; 6956 6957 blkcpy(M2, L1, 2, ,2); 6958 print '6854: blkcpy(M2, L1, 2, ,2);'; 6959 vrfy(M2 == (mat[4]={1,2,1,2}), '6855: M2 == (mat[4]={1,2,1,2}'); 6960 6961 /* blkcpy lists to lists */ 6962 6963 L2 = makelist(4); 6964 print '6856: L2 = makelist(4);'; 6965 blkcpy(L2, L1); 6966 print '6857: blkcpy(L2, L1);'; 6967 vrfy(L1 == L2, '6858: L1 == L2'); 6968 blkcpy(L2, L1, 2, 2, 0); 6969 print '6859: blkcpy(L2, L1, 2, 2, 0)'; 6970 vrfy(L2 == list(3,4,3,4), '6860: L2 == list(3,4,3,4)'); 6971 6972 /* blkcpy between structures and substructures */ 6973 6974 M2[0] = L2; 6975 print '6861: M2[0] = L2;'; 6976 blkcpy(M2, M2[0]); 6977 print '6862: blkcpy(M2, M2[0]);'; 6978 vrfy(M2 == (mat[4]={3,4,3,4}), '6863: M2 == (mat[4]={3,4,3,4})'); 6979 M2[2] = list(1,2,3,4); 6980 print '6864: M2[2] = list(1,2,3,4);'; 6981 blkcpy(M2[2], M2); 6982 print '6865: blkcpy(M2[2], M2);'; 6983 vrfy(M2[2][[2]][[2]] == 3, '6866: M2[2][[2]][[2]] == 3'); 6984 6985 /* cleanup */ 6986 fclose(fs); 6987 print '6867: fclose(fs)'; 6988 x = rm("junk6800"); 6989 print '6868: x = rm("junk6800")'; 6990 6991 print '6868: Ending test_blkcpy'; 6992} 6993print '170: parsed test_blkcpy()'; 6994 6995 6996/* 6997 * test_name - test the name builtin 6998 */ 6999define test_name() 7000{ 7001 local f, A, x; 7002 7003 print '6900: Beginning test_name'; 7004 7005 x = rm("-f", "junk6900"); 7006 print '6901: x = rm("-f", "junk6900")'; 7007 f = fopen("junk6900", "w"); 7008 print '6902: f = fopen("junk6900", "w")'; 7009 vrfy(name(f) == "junk6900", '6903: name(f) == "junk6900"'); 7010 7011 /* file stream loses name when file is closed */ 7012 7013 fclose(f); 7014 print '6904: fclose(f)'; 7015 vrfy(name(f) == null(), '6905: name(f) == null()'); 7016 A = blk("blk6900"); 7017 print '6906: A = blk("blk6900")'; 7018 vrfy(name(A) == "blk6900", '6907: name(A) == "blk6900"'); 7019 7020 /* name of block is not lost when its data memory is freed */ 7021 7022 blkfree("blk6900"); 7023 print '6908: blkfree("blk6900");'; 7024 vrfy(name(A) == "blk6900", '6909: name(A) == "blk6900"'); 7025 7026 /* values other than named blocks and files have no name */ 7027 7028 vrfy(name(27) == null(), '6910: name(27) == null()'); 7029 7030 /* cleanup */ 7031 7032 x = rm("junk6900"); 7033 print '6911: x = rm("junk6900")'; 7034 7035 print '6912: Ending test_name'; 7036} 7037print '171: parsed test_name()'; 7038 7039 7040/* 7041 * test_blkprintf - test blk printf 7042 */ 7043define test_blkprintf() 7044{ 7045 local A, B; 7046 7047 print '7000: Beginning test_blkprintf'; 7048 A = blk("alpha"); 7049 print '7001: A = blk("alpha")'; 7050 B = blk(); 7051 print '7002: B = blk();'; 7052 copy("abc yz", A); 7053 print '7003: copy("abc yz", A);'; 7054 copy("defg", B); 7055 print '7004: copy("defg", B);'; 7056 vrfy(strprintf("%s", A) == "abc yz", 7057 '7005: strprintf("%s", A) == "abc yz"'); 7058 vrfy(strprintf("%s", A[2]) == "c yz", 7059 '7006: strprintf("%s", A[2]) == "c yz"'); 7060 vrfy(strprintf("%s", A[7]) == "", 7061 '7007: strprintf("%s", A[7]) == ""'); 7062 vrfy(strprintf("%c", A) == "a", 7063 '7008: strprintf("%c", A == "a"'); 7064 vrfy(strprintf("%c", A[4]) == "y", 7065 '7009: strprintf("%c", A[4]) == "y"'); 7066 vrfy(strprintf("%s", B) == "defg", 7067 '7010: strprintf("%s", B) == "defg"'); 7068 vrfy(strprintf("%s", B[1]) == "efg", 7069 '7011: strprintf("%s", B[1]) == "efg"'); 7070 vrfy(strprintf("%s", B[7]) == "", 7071 '7012: strprintf("%s", B[7]) == ""'); 7072 vrfy(strprintf("%c", B) == "d", 7073 '7013: strprintf("%c", B == "d"'); 7074 vrfy(strprintf("%c", B[2]) == "f", 7075 '7014: strprintf("%c", B[2]) == "f"'); 7076 7077 print '7015: Ending test_blkprintf'; 7078} 7079print '172: parsed test_blkprintf()'; 7080 7081 7082/* 7083 * test_sha1 - test the sha1 hash 7084 */ 7085define test_sha1() 7086{ 7087 local a, b, c, d, e, f, x, y, z, L, M, B; 7088 7089 print '7200: Beginning test_sha1'; 7090 y = sha1(); 7091 print '7201: y = sha1();'; 7092 z = sha1(); 7093 print '7202: z = sha1();'; 7094 vrfy(y == z, '7203: y == z'); 7095 z = sha1(1); 7096 print '7204: z = sha1(1);'; 7097 vrfy(sha1(y,1) == z, '7205: sha1(y,1) == z'); 7098 vrfy(sha1(z,2) == sha1(1,2), '7206: sha1(z,2) == sha1(1,2)'); 7099 vrfy(sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709, 7100 '7207: sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709'); 7101 vrfy(sha1("x", "y", "z") == sha1("xyz"), 7102 '7208: sha1("x", "y", "z") == sha1("xyz")'); 7103 7104 vrfy(sha1(sha1("this is",7^19-8,"a composite",3i+4.5,"hash")) == 7105 0x68aa4fe0a9b6d1662f8d2dbdeee8879239185d09, 7106 '7209: sha1(sha1("this is",7^19-8,"a composite",3i+4.5,"hash")) ' + 7107 '== ...'); 7108 7109 7110 z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100)); 7111 print '7210: z = sha1(list(1,2,3), "curds and whey",', 7112 '2^21701-1, pi(1e-100));'; 7113 vrfy(sha1(z) == 0x158cc87deeb9dd478ca14e3ab359205b0fb15b83, 7114 '7211: sha1(z) == 0x158cc87deeb9dd478ca14e3ab359205b0fb15b83'); 7115 7116 y = sha1(); 7117 print '7212: y = sha1();'; 7118 y = sha1(y, list(1,2,3), "curds and whey"); 7119 print '7213: y = sha1(y, list(1,2,3), "curds and whey");'; 7120 y = sha1(y, 2^21701-1); 7121 print '7214: y = sha1(y, 2^21701-1);'; 7122 y = sha1(y, pi(1e-100)); 7123 print '7215: y = sha1(y, pi(1e-100));'; 7124 vrfy(y == z, '7216: y == z'); 7125 7126 vrfy(sha1(sha1("a"))==0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8, 7127 '7217: sha1(sha1("a"))==0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8'); 7128 7129 vrfy(sha1(sha1("ab"))==0xda23614e02469a0d7c7bd1bdab5c9c474b1904dc, 7130 '7218: sha1(sha1("ab"))==0xda23614e02469a0d7c7bd1bdab5c9c474b1904dc'); 7131 vrfy(sha1(sha1("abc"))==0xa9993e364706816aba3e25717850c26c9cd0d89d, 7132 '7219: sha1(sha1("abc"))==0xa9993e364706816aba3e25717850c26c9cd0d89d' 7133 ); 7134 vrfy(sha1(sha1("abcd"))==0x81fe8bfe87576c3ecb22426f8e57847382917acf, 7135 '7220: sha1(sha1("abcd"))==0x81fe8bfe87576c3ecb22426f8e57847382917acf'); 7136 vrfy(sha1(sha1("abcde"))==0x03de6c570bfe24bfc328ccd7ca46b76eadaf4334, 7137 '7221: sha1(sha1("abcde"))==0x03de6c570bfe24bfc328ccd7ca46b76eadaf4334'); 7138 vrfy(sha1(sha1("abcdef"))== 0x1f8ac10f23c5b5bc1167bda84b833e5c057a77d2, 7139 '7222: sha1(sha1("abcdef"))==0x1f8ac10f23c5b5bc1167bda84b833e5c057a77d2'); 7140 vrfy(sha1(sha1("abcdefg"))==0x2fb5e13419fc89246865e7a324f476ec624e8740, 7141 '7223: sha1(sha1("abcdefg"))==0x2fb5e13419fc89246865e7a324f476ec624e8740'); 7142 vrfy(sha1(sha1("abcdefgh"))==0x425af12a0743502b322e93a015bcf868e324d56a, 7143 '7224: sha1(sha1("abcdefgh"))==0x425af12a0743502b322e93a015bcf868e324d56a'); 7144 7145 vrfy(sha1(sha1(1))==0x53dd4e1734ad47d45e41c23e4ce42d7f1f98c1e8, 7146 '7225: sha1(sha1(1))==0x53dd4e1734ad47d45e41c23e4ce42d7f1f98c1e8'); 7147 vrfy(sha1(sha1(22/7))==0xf8e2510f85f7b9bf088b321188e9f70620f44246, 7148 '7226: sha1(sha1(22/7))==0xf8e2510f85f7b9bf088b321188e9f70620f44246'); 7149 vrfy(sha1(sha1(isqrt(2e1000)))== 7150 0x6852a1365c51050c3d039e3c5d9cf29c12283ef4, 7151 '7227: sha1(sha1(isqrt(2e1000)))==0x6852a1365c51050c3d039e3c5d9cf29c12283ef4' 7152 ); 7153 L = list(1,2,3); 7154 print '7228: L = list(1,2,3)'; 7155 mat M[3] = {4,5,6}; 7156 print '7229: mat M[3] = {4,5,6}'; 7157 B = blk() = {7,8,9}; 7158 print '7230: B = blk() = {7,8,9}'; 7159 vrfy(sha1(sha1(L), M, B) == sha1(L, M, B), 7160 '7231: sha1(sha1(L), M, B) == sha1(L, M, B)'); 7161 vrfy(sha1(sha1(L,M), B) == sha1(L, M, B), 7162 '7232: sha1(sha1(L, M), B) == sha1(L, M, B)'); 7163 7164 print '7233: Ending test_sha1'; 7165} 7166print '174: parsed test_sha1()'; 7167 7168 7169/* 7170 * The 7400's contain tests for saveval and dot. These tests are 7171 * done inline near the bottom. 7172 */ 7173 7174 7175/* 7176 * test_ptr - test pointers 7177 */ 7178define g7500a(a,b) = a = b; 7179print '176: define g7500a(a,b) = a = b'; 7180define g7500b(a,b) = a + b; 7181print '177: define g7500b(a,b) = a + b'; 7182define g7500c(a,b) = *(a + b); 7183print '178: define g7500c(a,b) = *(a + b)'; 7184define g7500d(a) = &a; 7185print '179: define g7500d(a) = &a'; 7186define g7500e(a,b) = *a = b; 7187print '180: define g7500e(a,b) = *a = b' 7188define test_ptr() 7189{ 7190 local a, b, c, A, B, B1, B2, M, L, p, q, p0, q0; 7191 7192 print '7500: Beginning test_ptr'; 7193 7194 vrfy(isoctet(27) == 0, '7501: isoctet(27) == 0'); 7195 vrfy(isptr(27) == 0, '7502: isptr(27) == 0'); 7196 7197 /* testing octet pointers */ 7198 7199 B = blk() = {1,2,3,4,5,6}; 7200 print '7503: B = blk() = {1,2,3,4,5,6};'; 7201 vrfy(isoctet(B[0]) == 1, '7504: isoctet(B[0]) == 1'); 7202 vrfy(isnum(B[0]) == 0, '7505: isnum(B[0]) == 0'); 7203 vrfy(isptr(B[0]) == 0, '7506: isptr(B[0]) == 0'); 7204 vrfy(isoctet(*B[0]) == 0, '7507: isoctet(*B[0]) == 0'); 7205 vrfy(isnum(*B[0]) == 1, '7508: isnum(*B[0]) == 1'); 7206 vrfy(isoctet(&B[0]) == 0, '7509: isoctet(&B[0]) == 0'); 7207 vrfy(isptr(&B[0]) == 1, '7510: isptr(&B[0]) == 1'); 7208 vrfy(*B[3] == B[3], '7511: *B[3]== B[3]'); 7209 vrfy(*&B[3] == B[3], '7512: *&B[3] == B[3]'); 7210 vrfy(&B[0] + 3 == &B[3], '7513: &B[0] + 3 == &B[3]'); 7211 vrfy(&B[3] - &B[0] == 3, '7514: &B[3] - &B[0] == 3'); 7212 vrfy(&B[3] - 3 == &B[0], '7515: &B[3 - 3 == &B[1]'); 7213 vrfy(&B[3] > &B[0], '7516: &B[3] > &B[0]'); 7214 swap(B[0], B[5]); 7215 print '7517: swap(B[0], B[5]);'; 7216 vrfy(B[0] == 6 && B[5] == 1, '7518: B[0] == 6 && B[5] == 1'); 7217 7218 /* testing octet-pointer-valued variables */ 7219 7220 p = &B[0], q = &B[5]; 7221 print '7519: p = &B[0], q = &B[5]'; 7222 vrfy(isoctet(p) == 0, '7520: isoctet(p) == 0'); 7223 vrfy(isptr(p) == 1, '7521: isptr(p) == 1'); 7224 vrfy(isoctet(*p) == 1, '7522: isoctet(*p) == 1'); 7225 vrfy(isptr(*p) == 0, '7523: isptr(*p) == 0'); 7226 vrfy(p == &B[0], '7524: p == &B[0]'); 7227 vrfy(q != p, '7525: q != p'); 7228 vrfy(q > p, '7526: q > p'); 7229 vrfy(*p == B[0], '7527: *p == B[0]'); 7230 vrfy(&B[1] == p + 1, '7528: &B[1] == p + 1'); 7231 vrfy(q == p + 5, '7529: q == p + 5'); 7232 *p = 1, *q = 6; 7233 print '7530: *p = 1, *q = 6'; 7234 vrfy(B[0] == 1 && B[5] == 6, '7531: B[0] == 1 && B[5] == 6'); 7235 a = *p, b = *q; 7236 print '7532: a = *p, b = *q'; 7237 vrfy(a == 1 && b == 6, '7533: a == 1 && b == 6'); 7238 *(p + 3) = 7; 7239 print '7534: *(p + 3) = 7;'; 7240 vrfy(B[3] == 7, '7535: B[3] == 7'); 7241 *(q - 2) = 8; 7242 print '7536: *(q - 2) = 8;'; 7243 vrfy(B[3] == 8, '7537: B[3] == 8'); 7244 p0 = p++; 7245 print '7538: p0 = p++;'; 7246 vrfy(p0 == &B[0] && p == &B[1], '7539: p0 == &B[0] && p == &B[1]'); 7247 q0 = --q; 7248 print '7540: q0 = --q'; 7249 vrfy(q0 == &B[4] && q == q0, '7541: q0 == &B[4] && q == q0'); 7250 a = *p++, b = *q--; 7251 print '7542: a = *p++, b = *q--;'; 7252 vrfy(a == 2 && b == 5, '7543: a == 2 && b == 5'); 7253 vrfy(p - &B[0] == 2 && q == &B[0] + 3, 7254 '7544: p - &B[0] == 2 && q == &B[0] + 3'); 7255 a = *--q, b = *----q; 7256 print '7545: a = *--q, b = *----q;'; 7257 vrfy(q == &B[0], '7546: q == &B[0]'); 7258 vrfy(a == 3 && b == 1, '7547: a == 3 && b == 1'); 7259 a = (*p)++; 7260 print '7548: a = (*p)++;'; 7261 vrfy(a == 3 && B[2] == 4, '7549: a == 3 && B[2] == 4'); 7262 a = ++(*++p)++; 7263 print '7550: a = ++(*++p)++;'; 7264 vrfy(a == 9 && B[3] == 10, '7551: a == 9 && B[3] == 10'); 7265 7266 /* testing octets, & and * in arguments of user-defined functions */ 7267 7268 A = blk() = {1,2,3}; 7269 print '7552: A = blk() = {1,2,3};'; 7270 vrfy(g7500a(A[0],5) == 5, '7553: g7500a(A[0],5) == 5'); 7271 vrfy(A[0] == 5, '7554: A[0] == 5'); 7272 vrfy(g7500a(`A[0],5) == 5, '7555: g7500a(`A[0],5) == 5'); 7273 vrfy(A[0] == 5, '7556: A[0] == 5'); 7274 vrfy(g7500b(&A[0],3) == &A[3], '7557: g7500b(&A[0],3) == &A[3]'); 7275 vrfy(g7500c(&A[0],2) == 3, '7558: g7500c(&A[0], 2) == 3'); 7276 vrfy(g7500d(`A[0]) == &A[0], '7559: g7500d(`A[0]) == &A[0]'); 7277 p = &A[0]; 7278 print '7560: p = &A[0];'; 7279 vrfy(g7500a(*p, 6) == 6, '7561: g7500a(*p, 6) == 6'); 7280 vrfy(*p == 6, '7562: *p == 6'); 7281 vrfy(g7500a(`*p,6) == 6, '7563: g7500a(`*p,6) == 6'); 7282 vrfy(*p == 6, '7564: *p == 6'); 7283 vrfy(g7500b(p,3) == p + 3, '7565: g7500b(p,3) == p + 3'); 7284 vrfy(g7500c(p,2) == 3, '7566: g7500c(p,2) == 3'); 7285 vrfy(g7500d(`*p) == p, '7567: g7500d(`*p) == p'); 7286 vrfy(g7500e(p,4) == 4, '7568: g7500e(p,4) == 4'); 7287 vrfy(A[0] == 4, '7569: A[0] == 4'); 7288 vrfy(g7500e(p+2,5) == 5, '7570: g7500e(p+2,5) == 5'); 7289 vrfy(A[2] == 5, '7571: A[2] == 5'); 7290 7291 /* testing pointers to values */ 7292 7293 A = 27, p = &A; 7294 print '7572: A = 27, p = &A;'; 7295 vrfy(isptr(A) == 0, '7573: isptr(A) == 0'); 7296 vrfy(isptr(&A) == 2, '7574: isptr(&A) == 2'); 7297 vrfy(isptr(p) == 2, '7575: isptr(p) == 2'); 7298 vrfy(*p == 27, '7576: *p == 27'); 7299 vrfy(p == &A, '7577: p == &A'); 7300 *p = 45; 7301 print '7578: *p = 45;'; 7302 vrfy(A == 45, '7579: A == 45'); 7303 q = p; 7304 print '7580: q = p;'; 7305 vrfy(q == &A, '7581: q == &A'); 7306 q = &p; 7307 print '7582: q = &p'; 7308 vrfy(*q == p, '7583: *q == p'); 7309 vrfy(**q == A, '7584: **q == A'); 7310 vrfy(***q == A, '7585: ***q == A'); 7311 M = mat[4] = {1,2,3,4}; 7312 print '7586: M = mat[4] = {1,2,3,4};'; 7313 p = &M[0], *p = 5; 7314 print '7587: p = &M[0], *p = 5;'; 7315 vrfy(M[0] == 5, '7588: M[0] == 5'); 7316 *++p = 6; 7317 print '7589: *++p = 6;'; 7318 vrfy(M[1] == 6, '7590: M[1] == 6'); 7319 q = p++; 7320 print '7591: q = p++;'; 7321 vrfy(q == &M[1], '7592: q == &M[1]'); 7322 vrfy(p == &M[2], '7593: p == &M[2]'); 7323 quomod(17,5,*q,*p); 7324 print '7594: quomod(17,5,*p,*q);'; 7325 vrfy(M[1] == 3 && M[2] == 2, '7595: M[1] == 3 && M[2] == 2'); 7326 swap(*p, *q); 7327 print '7596: swap(*p, *q);'; 7328 vrfy(M[1] == 2 && M[2] == 3, '7597: M[1] == 2 && M[2] == 3'); 7329 A = *M = {7,8}; 7330 print '7598: A = *M = {7,8};'; 7331 vrfy(M == (mat[4] = {5,2,3,4}), '7599: M == (mat[4] = {5,2,3,4})'); 7332 vrfy(A == (mat[4] = {7,8,3,4}), '7600: A == (mat[4] = {7,8,3,4})'); 7333 7334 /* Values which point to themselves */ 7335 7336 A = &A; 7337 print '7601: A = &A;'; 7338 vrfy(&A == A && *A == A, '7602: &A == A && *A == A'); 7339 A = &B, B = &A; 7340 print '7603: A = &B, B = &A;'; 7341 vrfy(**A == A && ***A == B, '7604: **A == A && ***A == B'); 7342 7343 /* Testing functions that return pointers */ 7344 7345 M[3] = 7; 7346 print '7605: M[3] = 7;'; 7347 vrfy(*g7500b(&M[1], 2) == 7, '7606: *g7500b(&M[1], 2) == 7'); 7348 7349 *g7500b(&M[1], 2) = 8; 7350 print '7607: *g7500b(&M[1], 2) = 8;'; 7351 vrfy(M[3] == 8, '7608: M[3] == 8'); 7352 M[3] = list(9,10); 7353 print '7609: M[3] = list(9,10);'; 7354 vrfy((*g7500b(&M[1], 2))[[1]] == 10, 7355 '7610: (*g7500b(&M[1], 2))[[1]] == 10'); 7356 7357 /* Testing number and string pointers */ 7358 7359 a = 24, b = 4 * 6, c = 4!; 7360 print '7611: a = 24, b = 4 * 6, c= 4!;'; 7361 vrfy(isptr(&*a) == 4, '7612: isptr(&*a) == 4'); 7362 vrfy(&*a == &24, '7613: &*a == &24'); 7363 vrfy(&*a == &*b, '7614: &*a == &*b'); 7364 vrfy(&*a != &*c, '7615: &*a != &*c'); 7365 7366 a = b = "abc", c = strcat("a", "bc"); 7367 print '7616: a = b = "abc", c = strcat("a", "bc");'; 7368 vrfy(isptr(&*a) == 3, '7617: isptr(&*a) == 3'); 7369 vrfy(&*a == &"abc", '7618: &*a == &"abc"'); 7370 vrfy(&*a == &*b, '7619: &*a == &*b'); 7371 vrfy(&*a != &*c, '7620: &*a != &*c'); 7372 a = c; 7373 print '7621: a = c;'; 7374 vrfy(&*a == &*c, '7622: &*a == &*c'); 7375 7376 /* Verifying null-ness of freed numbers */ 7377 7378 c = 4!, p = &*c, free(c); 7379 print '7623: c = 4!, p = &*c, free(c)'; 7380 vrfy(isnull(*p), '7624: isnull(*p)'); 7381 7382 print '7625: Ending test_ptr'; 7383} 7384print '181: parsed test_ptr()'; 7385 7386 7387/* 7388 * test_newstring - test new string operations 7389 */ 7390define test_newstring() 7391{ 7392 local A, B, C, D, S, p, q; 7393 7394 print '7700: Beginning test_newstring'; 7395 7396 A = "abcdef", B = "xyz"; 7397 print '7701: A = "abcdef", B = "xyz";'; 7398 vrfy(A + B == "abcdefxyz", '7702: A + B == "abcdefxyz"'); 7399 vrfy(-A == "fedcba", '7703: -A == "fedcba"'); 7400 vrfy(A - B == "abcdefzyx", '7704: A - B == "abcdefzyx"'); 7401 vrfy(2 * B == "xyzxyz", '7705: 2 * B == "xyzxyz"'); 7402 vrfy(-2 * B == "zyxzyx", '7706: -2 * B == "zyxzyx"'); 7403 vrfy(B * 3 == "xyzxyzxyz", '7707: B * 3 == "xyzxyzxyz"'); 7404 vrfy(2.5 * B == "xyzxyzx", '7708: 2.5 * B == "xyzxyzx"'); 7405 vrfy(0 * B == "", '7709: 0 * B == ""'); 7406 vrfy(3 * "12" == "121212", '7710: 2 * "12" == "121212"'); 7407 vrfy(A/2 == "abc", '7711: A/2 == "abc"'); 7408 vrfy(A | B == "y\173\173def", '7712: A | B == "y\\173\\173def"'); 7409 vrfy(A & B == "``b", '7713: A & B == "``b"'); 7410 vrfy(A \ B == "\1\2\1def", '7714: A \\ B == "\\1\\2\\1def"'); 7411 vrfy(A ~ B == "\31\e\31def", '7715: A ~ B == "\\31\\e\\31def"'); 7412 vrfy(~B == "\207\206\205", '7716: ~B == "\\207\\206\\205"'); 7413 C = "abcdef"; 7414 print '7717: C = "abcdef";'; 7415 vrfy(&*A == &*C, '7718: &*A == &*C'); 7416 D = "abc\0ef"; 7417 print '7719: D = "abc\0ef;"'; 7418 vrfy(size(D) == 6, '7720: size(D) == 6'); 7419 vrfy(strlen(D) == 3, '7721: strlen(D) == 3'); 7420 vrfy(strcat(D,B) == "abcxyz", '7722: strcat(D,B) == "abcxyz"'); 7421 7422 vrfy(bit(A,0) == 1, '7723: bit(A,0) == 1'); 7423 vrfy(!bit(A,12), '7724: !bit(A,12)'); 7424 vrfy(bit(A,13), '7725: bit(A,13)'); 7425 vrfy(lowbit(A) == 0, '7726: lowbit(A) == 0'); 7426 vrfy(highbit(A) == 46, '7727: highbit(A) == 46'); 7427 vrfy(#A == 21, '7728: #A == 21'); 7428 7429 vrfy(A[2] == "c", '7729: A[2] == "c"'); 7430 vrfy(char(A[2]) == "c", '7730: char(A[2]) == "c"'); 7431 vrfy(A[2] == 99, '7731: A[2] == 99'); 7432 vrfy(ord(A[2]) == 99, '7731: ord(A[2]) == 99'); 7433 vrfy(A[2] == A[0] + 2, '7732: A[2] == A[0] + 2'); 7434 vrfy(3 * A[2] == 297, '7733: 3 * A[2] == 297'); 7435 vrfy(3 * char(A[2]) == "ccc", '7734: 3 * char(A[2]) == "ccc"'); 7436 7437 vrfy(head(A,3) == "abc", '7735: head(A,3) == "abc"'); 7438 vrfy(head(A,-3) == "cba", '7736: head(A,-3) == "cba"'); 7439 vrfy(tail(A,3) == "def", '7737: tail(A,3) == "def"'); 7440 vrfy(tail(A,-3) == "fed", '7738: tail(A,-3) == "fed"'); 7441 vrfy(segment(A,2) == "c", '7739: segment(A,2) == "c"'); 7442 vrfy(segment(A,2,4) == "cde", '7740: segment(A,2,4) == "cde"'); 7443 vrfy(segment(A,4,2) == "edc", '7741: segment(A,4,2) == "edc"'); 7444 7445 vrfy(search(A, "c") == 2, '7742: search(A, "c") == 2'); 7446 vrfy(search(A, "x") == null(), '7743: search(A, "x") == null()'); 7447 vrfy(search("abbcbc", "bc") == 2, 7448 '7744: search("abbcbc", "bc") == 2'); 7449 vrfy(search("abbcbc", "bc", 2) == 2, 7450 '7745: search("abbcbc", "bc", 2) == 2'); 7451 vrfy(search("abbcbc", "bc", 3) == 4, 7452 '7746: search("abbcbc", "bc", 3) == 4'); 7453 vrfy(search("abbcbc", "bc", -3) == 4, 7454 '7747: search("abbcbc", "bc", -3) == 4'); 7455 vrfy(search("abbcbc", "bc", -4) == 2, 7456 '7748: search("abbcbc", "bc", -4) == 2'); 7457 vrfy(search("abbcbc", "bc", , 3) == null(), 7458 '7749: search("abbcbc", "bc", , 3) == null()'); 7459 vrfy(search("abbcbc", "bc", , 4) == 2, 7460 '7750: search("abbcbc", "bc", , 4) == 2'); 7461 7462 vrfy(rsearch("abbcbc", "bc") == 4, 7463 '7751: rsearch("abbcbc", "bc") == 4'); 7464 7465 p = &A[0]; 7466 print '7752: p = &A[0];'; 7467 vrfy(-*p == -97, '7753: -*p == -97'); 7468 vrfy(~*p == char(158), '7754: ~*p == char(158)'); 7469 vrfy(/-#~*p == -1/5, '7755: /-#~*p == -1/5'); 7470 7471 A[0] = "A"; 7472 print '7756: A[0] = "A";'; 7473 vrfy(A == "Abcdef", '7757: A == "Abcdef"'); 7474 A[1] = 173; 7475 print '7758: A[1] = 173;'; 7476 vrfy(A == "A\255cdef", '7759: A == "A\\255cdef"'); 7477 setbit(A, 18); 7478 print '7760: setbit(A,10);'; 7479 vrfy(A == "A\255gdef", '7761: A == "A\\255gdef"'); 7480 setbit(A, 16, 0); 7481 print '7762: setbit(A, 16, 0);'; 7482 vrfy(A == "A\255fdef", '7763: A == "A\255fdef"'); 7483 7484 q = "curds" " and " "whey"; 7485 print '7764: q = "curds" " and " "whey"'; 7486 vrfy(q == "curds and whey", '7765: q == "curds and whey"'); 7487 q = "chongo" ' was ' "here"; 7488 print '7766: q = "chongo" \' was \' "here"'; 7489 vrfy(q == "chongo was here", '7767: q == "chongo was here"'); 7490 7491 print '7768: Ending test_newstring'; 7492} 7493print '182: parsed test_newstring()'; 7494 7495 7496 7497/* 7498 * test_newcomb - test combinatoric and permutation functions 7499 */ 7500define test_newcomb() 7501{ 7502 print '7800: Beginning test_newcomb'; 7503 vrfy(comb(2, 5) == 0, '7801: comb(2, 5) == 0'); 7504 vrfy(comb(2, -2) == 0, '7802: comb(2, -2) == 0'); 7505 vrfy(comb(1/2, 4) == -5/128, '7803: comb(1/2, 4) == -5/128'); 7506 vrfy(comb(1/2, 5) == 7/256, '7804: comb(1/2, 5) == 7/256'); 7507 7508 vrfy(perm(2, -1) == 1/3, '7805: perm(2, -1) == 1/3'); 7509 vrfy(perm(2, -2) == 1/12, '7806: perm(2, -2) == 1/12'); 7510 vrfy(perm(2, -3) == 1/60, '7807: perm(2, -3) == 1/60'); 7511 vrfy(perm(1/2, 4) == -15/16, '7808: perm(1/2, 4) == -15/16'); 7512 vrfy(perm(1/2, 5) == 105/32, '7809: perm(1/2, 5) == 105/32'); 7513 vrfy(perm(1/2,-1) == 2/3, '7810: perm(1/2, -1) == 2/3'); 7514 vrfy(perm(1/2,-2) == 4/15, '7811: perm(1/2, -2) == 4/15'); 7515 7516 print '7812: Ending test_newcomb'; 7517} 7518print '183: parsed test_newcomb()'; 7519 7520 7521/* 7522 * The following functions f, g should be equal when b-a is an 7523 * integer, and n is any integer other than -1. 7524 */ 7525define f7900(a,b,n) 7526{ 7527 local s, x; 7528 7529 if (a > b) 7530 return -f7900(b, a, n); 7531 for (s = 0, x = a; x < b; x++) 7532 s += perm(x, n); 7533 return s; 7534} 7535print '184: define f7900(a,b,n) {... }'; 7536/**/ 7537define g7900(a,b,n) = (perm(b, n + 1) - perm(a, n + 1))/(n + 1); 7538print '185: define g7900(a,b,n) = ...'; 7539 7540 7541/* 7542 * test_bigcomb - test big combinations and permutations 7543 */ 7544define test_bigcomb() 7545{ 7546 local a, b, n, i, v1, v2; 7547 7548 print '7900: Starting test_bigcomb'; 7549 a = 1234/4321; 7550 print '7901: a = 1234/4321'; 7551 b = 3456/6543; 7552 print '7902: b = 3456/6543'; 7553 n = 47; 7554 print '7903: n = 47'; 7555 v1 = perm(a + b, n); 7556 print '7904: v1 = perm(a + b, n)'; 7557 v2 = 0; 7558 print '7905: v2 = 0'; 7559 for (i = 0; i <= n; i++) 7560 v2 += comb(n, i) * perm(a, i) * perm(b, n - i); 7561 print '7906: for (i=0;i<=n;i++) v2 += comb(n,i)*perm(a,i)*perm(b,n-i)'; 7562 vrfy(v1 == v2, '7910: v1 == v2'); 7563 7564 vrfy(f7900(-10,10,5) == g7900(-10,10,5), 7565 '7911: f7900(-10,10,5) == g7900(10,10,5)'); 7566 vrfy(f7900(5,15,-4) == g7900(5,15,-4), 7567 '7912: f7900(5,15,-4) == g7900(5,15,-4)'); 7568 vrfy(f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2), 7569 '7913: f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2)'); 7570 7571 print '7914: Ending test_bigcomb'; 7572} 7573print '186: parsed test_bigcomb()'; 7574 7575 7576/* 7577 * natnumset - test natural numbers not exceeding a fixed bound 7578 */ 7579read -once natnumset; 7580print '187: read -once natnumset;'; 7581/**/ 7582define test_natnumset() 7583{ 7584 local A, B, C, D, P, P1, L1, L2; 7585 7586 print '8000: Starting test_natnumset'; 7587 7588 A = set(17, 2, 0, 24, 2); 7589 print '8101: A = set(17, 2, 0, 24, 2);'; 7590 B = set(41, 17, 11, 2, 19, 17); 7591 print '8102: B = set(41, 17, 11, 2, 19, 17);'; 7592 vrfy(A | B == set(0,2,11,17,19,24,41), 7593 '8103: A | B == set(0,2,11,17,19,24,41)'); 7594 vrfy(A & B == set(2,17), '8104: A & B == set(2,17)'); 7595 vrfy(A \ B == set(0,24), '8105: A \\ B == set(0, 24)'); 7596 vrfy(B \ A == set(11,19,41), '8106: B \\ A == set(11,19,41)'); 7597 vrfy(A ~ B == set(0,11,19,24,41), 7598 '8107: A ~ B == set(0,11,19,24,41)'); 7599 vrfy(#A == 4, '8108: #A == 4'); 7600 vrfy(#~A == 97, '8109: #~A == 97'); 7601 vrfy(A + 5 == set(5,7,22,29), '8110: A + 5 == set(5,7,22,29)'); 7602 vrfy(A - 5 == set(12,19), '8111: A - 5 == set(12,19)'); 7603 vrfy(30 - A == set(6,13,28,30), '8112: 30 - A == set(6,13,28,30)'); 7604 vrfy(2 * A == set(0,4,34,48), '8113: 2 * A == set(0,4,34,48)'); 7605 vrfy(10 * A == set(0,20), '8114: 10 * A == set(0,20)'); 7606 vrfy(A + A == set(0,2,4,17,19,24,26,34,41,48), 7607 '8115: A + A == set(0,2,4,17,19,24,26,34,41,48)'); 7608 vrfy(A - A == set(0,2,7,15,17,22,24), 7609 '8116: A - A == set(0,2,7,15,17,22,24)'); 7610 vrfy(set(2,3,5,7)^2 == set(4,9,25,49), 7611 '8117: set(2,3,5,7)^2 == set(4,9,25,49)'); 7612 vrfy(interval(8,12) == set(8,9,10,11,12), 7613 '8118: interval(8,12) == set(8,9,10,11,12)'); 7614 vrfy(min(A) == 0, '8119: min(A) == 0'); 7615 vrfy(max(A) == 24, '8120: max(A) == 24'); 7616 P = primes(); 7617 print '8121: P = primes();'; 7618 vrfy(#P == 25, '8122: #P == 25'); 7619 vrfy(+P == 1060, '8123: +P == 1060'); 7620 vrfy(isin(P,31), '8124: isin(P,31)'); 7621 vrfy(!isin(P,51), '8125: !isin(P,51)'); 7622 P1 = primes(20,40); 7623 print '8126: P1 = primes(20,40)'; 7624 vrfy(P1 == set(23,29,31,37), '8127: P1 == set(23,29,31,37)'); 7625 vrfy(P1 < P, '8128: P1 < P'); 7626 vrfy(P1 & (set(3) % 4) == set(23,31), 7627 '8129: P1 & (set(3) % 4) == set(23,31)'); 7628 7629 L1 = list(3,2,1); 7630 print '8130: L1 = list(3,2,1);'; 7631 C = set(2,3,5,7); 7632 print '8131: C = set(2,3,5,7);'; 7633 vrfy(polyvals(L1, C) == set(11,18,38,66), 7634 '8132: polyvals(L1, C) == set(11,18,38,66)'); 7635 L2 = list(0,list(0,1),1); 7636 print '8133: L2 = list(0,list(0,1),1);'; 7637 D = set(4,6); 7638 print '8134: D = set(4,6);'; 7639 7640 vrfy(polyvals2(L2,C,D) == set(12,16,21,27,45,55,77,91), 7641 '8135: polyvals(L2,C,D) == set(12,16,21,27,45,55,77,91)'); 7642 7643 print '8136: Ending test_natnumset'; 7644} 7645print '188: parsed test_natnumset()'; 7646 7647 7648/* 7649 * test_somenew - test some new features 7650 */ 7651define func8200(x,y) {if (x>0) return calclevel()+func8200(x-1,y)-y; return 0;} 7652print '189: define func8200(x,y)'; 7653define test_somenew() 7654{ 7655 local a, s, y; 7656 7657 print '8200: Starting test_somenew'; 7658 7659 vrfy(char(-1) == char(255), '8201: char(-1) == char(255)'); 7660 vrfy(char(258) == char(2), '8202: char(258) == char(2)'); 7661 7662 vrfy(size(char(0)) == 1, '8203: size(char(0)) == 1'); 7663 vrfy(strlen(char(0)) == 0, '8204: strlen(char(0)) == 0'); 7664 vrfy(char(0) != "", '8205: char(0) != ""'); 7665 vrfy(str(char(0)) == "", '8206: str(char(0)) == ""'); 7666 7667 vrfy(str("abc") == "abc", '8207: str("abc") == "abc"'); 7668 7669 vrfy(2^-3^2 == 1/512, '8208: 2^-3^2 == 1/512'); 7670 vrfy(/2 == .5, '8209: /2 == .5'); 7671 vrfy(/-2 == -.5, '8210: /-2 == -.5'); 7672 vrfy(1+/2 == 1.5, '8211: 1+/2 == 1.5'); 7673 7674 ecnt += 6; 7675 print '8212: ecnt += 6'; 7676 vrfy(0^-2 == 1/0, '8213: 0^-2 == 1/0'); 7677 vrfy(inverse(0) == 1/0, '8214: inverse(0) == 1/0'); 7678 vrfy(1/(1/0) == 0, '8215: 1/(1/0) == 0'); 7679 vrfy(inverse(1/0) == 0, '8216: inverse(1/0) == 0'); 7680 7681 a = isqrt(2e1000); s = "xyz"; 7682 print '8217: a = isqrt(2e1000); s = "xyz";'; 7683 vrfy(hash(a,s) == 2708885378, '8218: hash(a,s) == 2708885378'); 7684 vrfy(hash("curds n whey") == 2376141927, 7685 '8219: hash("curds n whey") == 2376141927'); 7686 7687 y = calclevel(); 7688 print '8220: y = calclevel()'; 7689 vrfy(func8200(0,y) == 0, '8221: func8200(0,y) == 0'); 7690 vrfy(func8200(1,y) == 1, '8222: func8200(1,y) == 1'); 7691 vrfy(func8200(10,y) == 55, '8223: func8200(10,y) == 55'); 7692 vrfy(func8200(100,y) == 5050, '8224: func8200(100,y) == 5050'); 7693 7694 vrfy(inputlevel() == 1, '8225: inputlevel() == 1'); 7695 7696 print '8226: Ending test_somenew'; 7697} 7698print '190: parsed test_somenew()'; 7699 7700 7701/* 7702 * test_exponentiation - test new exponentiation functionality 7703 */ 7704define test_exponentiation() 7705{ 7706 local a; 7707 7708 print '8800: Starting test_somenew'; 7709 7710 /* unexpected help file cases */ 7711 vrfy(2^3 == 8, '8801: 2^3 == 8'); 7712 vrfy(2.5 ^ 3.5 == power(2.5, 3.5), 7713 '8802: 2.5 ^ 3.5 == power(2.5, 3.5)'); 7714 vrfy(2.5 ^ 2.718i == power(2.5, 2.718i), 7715 '8803: 2.5 ^ 2.718i == power(2.5, 2.718i)'); 7716 vrfy(3i^4 == 81, '8804: 3i^4 == 81'); 7717 vrfy(0.5i ^ 0.25 == power(0.5i, 0.25), 7718 '8804: 0.5i ^ 0.25 == power(0.5i, 0.25)'); 7719 vrfy(3.13145i^0.30103i == power(3.13145i, 0.30103i), 7720 '8806: 3.13145i^0.30103i == power(3.13145i, 0.30103i)'); 7721 7722 /* deal with some corner error cases */ 7723 ecnt += 12; 7724 print '8807: ecnt += 2'; 7725 vrfy((1/0) ^ -1 == 0, '8808: (1/0) ^ -1 == 0'); 7726 vrfy((1/0) ^ -2 == 0, '8809: (1/0) ^ -2 == 0'); 7727 vrfy((1/0) ^ 0 == error(10001), '8810: (1/0) ^ 0 == error(10001)'); 7728 vrfy((1/0) ^ 3 == error(10001), '8811: (1/0) ^ 3 == error(10001)'); 7729 vrfy(0 ^ -2 == error(10001), '8812: 0 ^ -2 == error(10001)'); 7730 vrfy((1/0) ^ 1i == error(10001),'8813: (1/0) ^ 1i == error(10001)'); 7731 vrfy((1/0) ^ 0i == error(10001),'8814: (1/0) ^ 0i == error(10001)'); 7732 7733 /* real ^ real */ 7734 vrfy(5^6 == 15625, '8815: 5^6 == 15625'); 7735 vrfy(10^31 == 1e31, '8816: 10^31 == 1e31'); 7736 vrfy(10 ^ (127/31) == power(10, 127/31), 7737 '8817: 10 ^ (127/31) == power(10, 127/31)'); 7738 vrfy((10^31) ^ 10 == 1e310, '8818: (10^31) ^ 10 == 1e310'); 7739 7740 /* complex ^ real */ 7741 vrfy(10i ^ 10 == -1e10, '8819: 10i ^ 10 == -1e10'); 7742 vrfy((-10i) ^ 10 == -1e10, '8820: (-10i) ^ 10 == -1e10'); 7743 vrfy((1+1i) ^ 4 == -4, '8821: (1+1i) ^ 4 == -4'); 7744 vrfy((1+1i) ^ 65536 == 2^32768, '8822: (1+1i) ^ 65536 == 2^32768'); 7745 vrfy((1+1i) ^ (2^20) == 2^(2^19), 7746 '8823: (1+1i) ^ (2^20) == 2^(2^19)'); 7747 vrfy((31+17i) ^ pi() == power(31+17i, pi()), 7748 '8824: (31+17i) ^ pi() == power(31+17i, pi()'); 7749 vrfy((5+7i) ^ exp(5) == power(5+7i, exp(5)), 7750 '8825: (5+7i) ^ exp(5) == power(5+7i, exp(5))'); 7751 7752 /* real ^ complex */ 7753 vrfy(10 ^ 1i == power(10, 1i), '8826: 10 ^ 1i == power(10, 1i)'); 7754 vrfy(10 ^ (2+3i) == power(10, 2+3i), 7755 '8827: 10 ^ (2+3i) == power(10, 2+3i)'); 7756 vrfy(pi() ^ (2+3i) == power(pi(), 2+3i), 7757 '8828: pi() ^ (2+3i) == power(pi(), 2+3i)'); 7758 vrfy(exp(64) ^ (2+3i) == power(exp(64), 2+3i), 7759 '8828: exp(64) ^ (2+3i) == power(exp(64), 2+3i)'); 7760 vrfy(pi() ^ (257+127i) == power(pi(), 257+127i), 7761 '8829: pi() ^ (257+127i) == power(pi(), 257+127i)'); 7762 vrfy(pi() ^ asin(-2) == power(pi(), asin(-2)), 7763 '8830: pi() ^ asin(-2) == power(pi(), asin(-2)'); 7764 7765 /* complex ^ complex */ 7766 vrfy((3+4i) ^ (2+3i) == power(3+4i, 2+3i), 7767 '8831: (3+4i) ^ (2+3i) == power(3+4i, 2+3i)'); 7768 vrfy(ln(-10) ^ (2+3i) == power(ln(-10), 2+3i), 7769 '8832: ln(-10) ^ (2+3i) == power(ln(-10), 2+3i)'); 7770 vrfy((pi()*1i) ^ asin(-2) == power(pi()*1i, asin(-2)), 7771 '8833: (pi()*1i) ^ asin(-2) == power(pi()*1i, asin(-2))'); 7772 vrfy((exp(1)+pi()*1i) ^ asin(-2) == power(exp(1)+pi()*1i, asin(-2)), 7773 '8834: (exp(1)+pi()*1i) ^ asin(-2) == power(exp(1)+pi()*1i, asin(-2))'); 7774 7775 print '8835: Ending test_somenew'; 7776} 7777print '191: parsed test_exponentiation()'; 7778 7779 7780/* 7781 * test_quit - test the QUIT functionality 7782 */ 7783define test_quit() 7784{ 7785 local x8400 = 23209; /* watch for lost memory */ 7786 static s8400 = 21701; /* watch for lost memory */ 7787 7788 print '8400: Starting test_quit'; 7789 7790 quit; 7791 prob('quit did not end the test_quit() function'); 7792 7793 /* 8400 series continued after return, do not print end here */ 7794} 7795print '191: parsed test_quit()'; 7796 7797 7798/* 7799 * Reserved for top level test use 7800 */ 7801print '200: Reserved for top level test use'; 7802 7803 7804/* 7805 * Report the number of errors found. 7806 */ 7807define count_errors() 7808{ 7809 if (prob == 0) { 7810 print "9997: passed all tests /\\../\\"; 7811 } else { 7812 print "****", prob, "error(s) found \\/++\\/"; 7813 } 7814} 7815print '298: parsed count_errors()'; 7816 7817 7818print '299: Ending main part of regression test suite read'; 7819 7820 7821print; 7822return test_booleans(); 7823print; 7824return test_variables(); 7825print; 7826return test_arithmetic(); 7827print; 7828return test_config(); 7829print; 7830return test_bignums(); 7831print; 7832return test_functions(); 7833print; 7834return _test_underscore(); 7835print; 7836return test_assoc(); 7837print; 7838return test_list(); 7839print; 7840return test_rand(); 7841print; 7842return test_mode(); 7843print; 7844 7845print '1780: Beginning read test'; 7846value = 0; 7847vrfy(value == 0, '1781: value == 0'); 7848read "test1700"; 7849print '1782: read "test1700";'; 7850vrfy(value == 1, '1783: value == 1'); 7851read -once "test1700"; 7852print '1784: read -once "test1700";'; 7853vrfy(value == 1, '1785: value == 1'); 7854read "test1700.cal"; 7855print '1786: read "test1700.cal";'; 7856vrfy(value == 2, '1787: value == 2'); 7857read -once "test1700.cal" 7858print '1788: read -once "test1700.cal";'; 7859vrfy(value == 2, '1789: value == 2'); 7860read "test1700.cal"; 7861print '1790: read "test1700.cal";'; 7862vrfy(value == 3, '1791: value == 3'); 7863{++value;} read "test1700.cal"; 7864print '1792: {++value;} read "test1700.cal";'; 7865vrfy(value == 5, '1793: value == 5'); 7866{++value;} read -once "test1700.cal"; 7867print '1794: {++value;} read -once "test1700.cal";'; 7868vrfy(value == 6, '1795: value == 6'); 7869print '1796: Ending read test'; 7870 7871print; 7872return test_obj(); 7873print; 7874return test_prime(); 7875print; 7876return test_lucas(); 7877print; 7878return test_newop(); 7879print; 7880return test_xx_incdec(); 7881print; 7882return test_round(); 7883print; 7884return test_2600(); 7885print; 7886return test_2700(); 7887print; 7888return test_matrix(); 7889print; 7890return test_strings(); 7891print; 7892return test_matobj(); 7893print; 7894return test_poly(); 7895print; 7896return test_det(); 7897print; 7898return test_trig(); 7899print; 7900return test_frem(); 7901print; 7902return test_error(); 7903print; 7904return test_param(); 7905print; 7906return test_noarg(); 7907print; 7908return test_ptest(); 7909print; 7910return test_redc(); 7911print; 7912return test_fileops(); 7913print; 7914return test_matdcl(); 7915print; 7916return test_objmat(); 7917print; 7918return test_fileop(); 7919print; 7920return test_charset(); 7921print; 7922return test_strprintf(); 7923print; 7924return test_listsearch(); 7925print; 7926return test_filesearch(); 7927print; 7928return test_newdecl(); 7929print; 7930return test_globstat(); 7931print; 7932return test_random(); 7933print; 7934return test_newsyn(); 7935 7936vrfy(s5500 == 78, '5548: s5500 == 78'); 7937 7938print; 7939return test_commaeq(); 7940print; 7941return test_size(); 7942print; 7943 7944/* 7945 * 5800 assignment tests 7946 */ 7947return test_assign(5800, 1); 7948define xy5800_assign(a,b) { }; 7949print '5812: define xy5800_assign(a,b) { }'; 7950return test_assign(5820, 0); 7951undefine xy5800_assign; 7952print '5832: undefine xy5800_assign'; 7953return test_assign(5840, 1); 7954define xy5800_assign(a, b) = a.y = b; 7955print '5852: define xy5800_assign(a, b) = a.y = b'; 7956X5800 = 9; 7957print '5853: X5800 = 9'; 7958vrfy(X5800 == (obj xy5800 = {3,9}), 7959 '5854: X5800 == (obj xy5800 = {3,9})'); 7960asserr = newerror("Incompatible types for ="); 7961print '5855: asserr = newerror("Incompatible types for =")'; 7962define xy5800_assign(a, b) { 7963 if (istype(b, obj xy5800)) { 7964 a.x = b.x; 7965 a.y = b.y; 7966 } else if (isreal(b)) { 7967 a.x = b; 7968 a.y = 0; 7969 } else { 7970 error(asserr); 7971 } 7972} 7973print '5856: xy5800_assign(a, b) { ... };'; 7974ecnt += 2; 7975print '5857: ecnt += 2'; 7976X5800 = 2 + 3i; 7977print '5858: X5800 = 2 + 3i'; 7978vrfy(X5800 == (obj xy5800 = {3,9}), 7979 '5859: X5800 == (obj xy5800 = {3,9})'); 7980vrfy(errno() > 0, '5860: errno() > 0'); 7981vrfy(strerror() == "Incompatible types for =", 7982 '5861: strerror() == "Incompatible types for ="'); 7983X5800 = 2; 7984print '5862: X5800 = 2'; 7985vrfy(X5800 == (obj xy5800 = {2,0}), 7986 '5863: X5800 == (obj xy5800 = {2,0})'); 7987X5800 = obj xy5800 = {1,2}; 7988print '5864: X5800 = obj xy5800 = {1,2}'; 7989vrfy(X5800 == (obj xy5800 = {1,2}), 7990 '5865: X5800 == (obj xy5800 = {1,2})'); 7991define f5800(a5800 = mat[2] = {3,4}) = 5 * a5800; 7992print '5866: define f5800(a5800 = mat[2] = {3,4}) = 5 * a5800;' 7993vrfy(f5800() == (mat[] = {15,20}),'5867: f5800() == (mat[] = {15,20})'); 7994print '5868: End of 5800 sequence'; 7995 7996print; 7997return test_is(); 7998print; 7999return test_blk(); 8000print; 8001return test_blkcpy(); 8002print; 8003return test_name(); 8004print; 8005return test_blkprintf(); 8006print; 8007return test_sha1(); 8008print; 8009 8010print '7400: Beginning test_savedot'; 8011print '7401: saveval(1);'; 8012saveval(1); 8013print '7402: a7400 = 2;'; 8014a7400 = 2; 8015vrfy(. == 2, '7403: . == 2;'); 8016vrfy((. += 3, . == 5), '7404: (. += 3, . == 5)'); 8017vrfy(. == 5, '7405: . == 5;'); 8018print '7406: a7400 = 5; b7400 = 6;'; 8019a7400 = 5; b7400 = 6; 8020vrfy(. == 6, '7407: . == 6'); 8021print '7408: a7400 = 7; b7400 = 8; null()'; 8022a7400 = 7; b7400 = 8; null(); 8023vrfy(. == 6, '7409: . == 6'); 8024print '7410: saveval(0);'; 8025saveval(0); 8026print '7411: a7400 = 9;'; 8027a7400 = 9; 8028vrfy(. == 6, '7412: . == 6'); 8029print '7413: a7400 = 2; saveval(1); b7400 = 3; saveval(0); c7400 = 4;'; 8030a7400 = 2; saveval(1); b7400 = 3; saveval(0); c7400 = 4; 8031vrfy(. == 3, '7414: . == 3'); 8032print '7415: free(.);'; 8033free(.); 8034vrfy(isnull(.), '7416: isnull(.)'); 8035print '7417: a7400 = 4;'; 8036a7400 = 4; 8037vrfy(isnull(.), '7418: isnull(.)'); 8038print '7419: saveval(1);'; 8039saveval(1); 8040 8041print '7420: obj pair7400 {one,two} = {1,2};'; 8042obj pair7400 {one,two} = {1,2}; 8043vrfy(. .one == 1, '7421: . .one == 1'); 8044print '7422: Ending test_savedot'; 8045 8046print; 8047return test_ptr(); 8048print; 8049return test_newstring(); 8050print; 8051return test_newcomb(); 8052print; 8053return test_bigcomb(); 8054print; 8055return test_natnumset(); 8056print; 8057return test_somenew(); 8058 8059 8060/* 8061 * misc define tests 8062 */ 8063print; 8064print '8300: Starting define tests'; 8065define f8300(x) = x^2; define g8300(x) = 1 - x; 8066print '8301: define f8300(x) = x^2; define g8300(x) = 1 - x;'; 8067vrfy(f8300(10) == 100, '8302: f8300(10) == 100'); 8068vrfy(g8300(10) == -9, '8303: g8300(10) == -9'); 8069define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1; 8070print '8304: define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1;'; 8071vrfy(h8300(10) == 1000, '8305: h8300(10) == 1000'); 8072vrfy(i8300(10) == 9, '8306: i8300(10) == 9'); 8073vrfy(j8300(10) == 11, '8307: j8300(10) == 11'); 8074{static k8300 = 5} define l8300(x) = k8300 + x; 8075print '8308: {static k8300 = 5} define l8300(x) = k8300 + x;'; 8076vrfy(l8300(10) == 15, '8309: l8300(10) == 15'); 8077static a8300 = 1, b8300; 8078vrfy(a8300 == 1, '8310: a8300 == 1'); 8079print '8311: Ending define tests'; 8080 8081 8082/* 8083 * quit tests 8084 */ 8085print; 8086return test_quit(); 8087read -once test8400; 8088print '8404: read -once test8400'; 8089vrfy(test8400() == 64434, '8405: test8400() == 64434'); 8090print '8406: Ending test_quit'; 8091 8092 8093/* 8094 * test_divmod - pseudo-random tests on the // and % with various rounding modes 8095 */ 8096print; 8097print '8500: Starting test of divmod' 8098read -once "test8500"; 8099/* 85xx: Ending test of divmod is printed by test8500.cal */ 8100 8101 8102/* 8103 * test_maxargs - test up to 1024 args being passed to a builtin function 8104 */ 8105print; 8106print '8600: Starting test of up to 1024 args' 8107read -once "test8600"; 8108/* 860x: Ending test of up to 1024 args is printed by test8600.cal */ 8109 8110 8111/* 8112 * dupvar_warn and redecl_warn testing 8113 */ 8114print; 8115print '8650: Starting test of dupvar_warn and redecl_warn config parameters'; 8116vrfy(config("redecl_warn",0), '8651: config("redecl_warn",0)'); 8117vrfy(config("dupvar_warn",0), '8652: config("dupvar_warn",0)'); 8118vrfy(u_glob == 6, '8653: u_glob == 6'); 8119global u_glob = 555; 8120print '8654: declare u_glob'; 8121vrfy(u_glob == 555, '8655: u_glob == 555'); 8122define func_8650(u_glob) { local u_glob; return u_glob; } 8123print '8656: u_glob as both local and parameter'; 8124define func_8650a(u_glob) { static u_glob; return u_glob; } 8125print '8657: u_glob as both static and parameter'; 8126vrfy(config("redecl_warn",1)==0, '8658: config("redecl_warn",1)==0'); 8127vrfy(config("dupvar_warn",1)==0, '8659: config("dupvar_warn",1)==0'); 8128/* 865x: Ending test of up to 1024 args is printed by test8600.cal */ 8129 8130 8131/* 8132 * dotest scripts 8133 * 8134 * We use the dotest driver to evaluate test-97xx data files. 8135 */ 8136print; 8137print '8700: Starting dotest runs' 8138print '8701: read -once "dotest"'; 8139read -once "dotest"; 8140print '8702: read -once "set8700"'; 8141read -once "set8700"; 8142vrfy(dotest("set8700.line", 8703) == 0, 8143 '8703: dotest("set8700.line", 8703) == 0'); 8144/* 87xx: Ending dotest runs is printed by set8700.test */ 8145 8146 8147/* 8148 * new exponentiation functionality 8149 */ 8150print; 8151return test_exponentiation(); 8152/* 88xx: test exponentiation */ 8153 8154 8155/* 8156 * calc resource functions by Christoph Zurnieden 8157 */ 8158print; 8159print '8900: Starting test of calc resource functions by Christoph Zurnieden'; 8160print '8901: read -once "test8900"'; 8161read -once "test8900"; 8162print '8902: about to run test8900(1,,8903)'; 8163testnum = test8900(1,,8903); 8164print '8999: ecnt = 211;' 8165ecnt = 211; 8166/* 89xx: test calc resource functions by Christoph Zurnieden */ 8167 8168 8169/* 8170 * Test more of the built-in functions. 8171 * 8172 * See test_functions() (test 700 - 1238) for other built-in function tests. 8173 * See test_functions2() (test 9000 - 9063) for other built-in function tests. 8174 * See test_functions3() (test 9100 - 9214) for other built-in function tests. 8175 */ 8176define test_functions2() 8177{ 8178 print '9001: Beginning test_functions2'; 8179 8180 /* ctype function tests */ 8181 vrfy(isalnum("A") == 1, '9002: isalnum("A") == 1'); 8182 vrfy(isalnum("a") == 1, '9003: isalnum("a") == 1'); 8183 vrfy(isalnum("2") == 1, '9004: isalnum("2") == 1'); 8184 vrfy(isalnum("\t") == 0, '9005: isalnum("\\t") == 0'); 8185 8186 vrfy(isalpha("A") == 1, '9006: isalpha("A") == 1'); 8187 vrfy(isalpha("a") == 1, '9007: isalpha("a") == 1'); 8188 vrfy(isalpha("2") == 0, '9008: isalpha("2") == 0'); 8189 vrfy(isalpha("\t") == 0, '9009: isalpha("\\t") == 0'); 8190 8191 vrfy(iscntrl("A") == 0, '9010: iscntrl("A") == 0'); 8192 vrfy(iscntrl("a") == 0, '9011: iscntrl("a") == 0'); 8193 vrfy(iscntrl("2") == 0, '9012: iscntrl("2") == 0'); 8194 vrfy(iscntrl("\t") == 1, '9013: iscntrl("\\t") == 1'); 8195 8196 vrfy(isdigit("A") == 0, '9014: isdigit("A") == 0'); 8197 vrfy(isdigit("a") == 0, '9015: isdigit("a") == 0'); 8198 vrfy(isdigit("2") == 1, '9016: isdigit("2") == 1'); 8199 vrfy(isdigit("\t") == 0, '9017: isdigit("\\t") == 0'); 8200 8201 vrfy(isgraph("A") == 1, '9018: isgraph("A") == 1'); 8202 vrfy(isgraph("a") == 1, '9019: isgraph("a") == 1'); 8203 vrfy(isgraph("2") == 1, '9020: isgraph("2") == 1'); 8204 vrfy(isgraph("\t") == 0, '9021: isgraph("\\t") == 0'); 8205 8206 vrfy(islower("A") == 0, '9022: islower("A") == 0'); 8207 vrfy(islower("a") == 1, '9023: islower("a") == 1'); 8208 vrfy(islower("1") == 0, '9024: islower("1") == 0'); 8209 8210 vrfy(isprint("A") == 1, '9025: isprint("A") == 1'); 8211 vrfy(isprint("a") == 1, '9026: isprint("a") == 1'); 8212 vrfy(isprint(" ") == 1, '9027: isprint(" ") == 1'); 8213 vrfy(isprint("\t") == 0, '9028: isprint("\\t") == 0'); 8214 8215 vrfy(ispunct("A") == 0, '9029: ispunct("A") == 0'); 8216 vrfy(ispunct("a") == 0, '9030: ispunct("a") == 0'); 8217 vrfy(ispunct(" ") == 0, '9031: ispunct(" ") == 0'); 8218 vrfy(ispunct("?") == 1, '9032: ispunct("?") == 1'); 8219 8220 vrfy(isspace("A") == 0, '9033: isspace("A") == 0'); 8221 vrfy(isspace("Krik") == 0, '9034: isspace("Krik") == 0'); 8222 vrfy(isspace(" ") == 1, '9035: isspace(" ") == 1'); 8223 vrfy(isspace("?") == 0, '9036: isspace("?") == 0'); 8224 8225 vrfy(isupper("A") == 1, '9037: isupper("A") == 1'); 8226 vrfy(isupper("a") == 0, '9038: isupper("a") == 0'); 8227 vrfy(isupper("1") == 0, '9039: isupper("1") == 0'); 8228 8229 vrfy(isxdigit("A") == 1, '9040: isxdigit("A") == 1'); 8230 vrfy(isxdigit("f") == 1, '9041: isxdigit("f") == 1'); 8231 vrfy(isxdigit("2") == 1, '9042: isxdigit("2") == 1'); 8232 vrfy(isxdigit("x") == 0, '9043: isxdigit("x") == 0'); 8233 8234 vrfy(strcasecmp("ab", "aBc") == -1, 8235 '9044: strcasecmp("ab", "aBc") == -1'); 8236 vrfy(strcasecmp("abc", "aBb") == 1, 8237 '9045: strcasecmp("abc", "aBb") == 1'); 8238 vrfy(strcasecmp("abc", "abc") == 0, 8239 '9046: strcasecmp("abc", "abc") == 0'); 8240 vrfy(strcasecmp("abc", "aBc") == 0, 8241 '9047: strcasecmp("abc", "aBc") == 0'); 8242 vrfy(strcasecmp("abc", "aBd") == -1, 8243 '9048: strcasecmp("abc", "aBd") == -1'); 8244 vrfy(strcasecmp("abc\0", "aBc") == 1, 8245 '9049: strcasecmp("a8c\\0", "aBc") == 1'); 8246 vrfy(strcasecmp("a\0b", "A\0c") == -1, 8247 '9050: strcasecmp("a\\0b", "A\\0c") == -1'); 8248 8249 vrfy(strncasecmp("abc", "xyz", 0) == 0, 8250 '9051: strncasecmp("abc", "xyz", 0) == 0'); 8251 vrfy(strncasecmp("abc", "xyz", 1) == -1, 8252 '9052: strncasecmp("abc", "xyz", 1) == -1'); 8253 vrfy(strncasecmp("abc", "", 1) == 1, 8254 '9053: strncasecmp("abc", "", 1) == 1'); 8255 vrfy(strncasecmp("a", "b", 2) == -1, 8256 '9054: strncasecmp("a", "b", 2) == -1'); 8257 vrfy(strncasecmp("ab", "Ac", 2) == -1, 8258 '9055: strncasecmp("ab", "Ac", 2) == -1'); 8259 vrfy(strncasecmp("\0ac", "\0b", 2) == -1, 8260 '9056: strncasecmp("\\0ac", "\\0b", 2) == -1'); 8261 vrfy(strncasecmp("ab", "aBc", 2) == 0, 8262 '9057: strncasecmp("ab", "aBc", 2) == 0'); 8263 vrfy(strncasecmp("abc", "abd", 2) == 0, 8264 '9058: strncasecmp("abc", "abd", 2) == 0'); 8265 8266 local s1 = " gnu lesser general public license"; 8267 print '9059: local s1 = " gnu lesser general public license";'; 8268 8269 vrfy(strcmp(strtolower(" GNU Lesser General Public License"), s1) == 0, 8270 '9060: strcmp(strtolower(" GNU Lesser General Public License"),' + 8271 ' s1) == 0'); 8272 8273 local s2 = " GNU LESSER GENERAL PUBLIC LICENSE"; 8274 print '9061: local s2 = " GNU LESSER GENERAL PUBLIC LICENSE";'; 8275 8276 vrfy(strcmp(strtoupper(" GNU Lesser General Public License"), s2) == 0, 8277 '9062: strcmp(strtoupper(" GNU Lesser General Public License"),' + 8278 ' s2) == 0'); 8279 8280 print '9063: Ending test_functions2'; 8281} 8282print; 8283print '9000: parsed test_functions2()'; 8284print; 8285return test_functions2(); 8286 8287 8288/* 8289 * Test even more of the built-in functions. 8290 * 8291 * See test_functions() (test 700 - 1238) for other built-in function tests. 8292 * See test_functions2() (test 9000 - 9063) for other built-in function tests. 8293 * See test_functions3() (test 9100 - 9214) for other built-in function tests. 8294 */ 8295define test_functions3() 8296{ 8297 local d, m, s, g, h; 8298 8299 print '9101: Beginning test_functions3'; 8300 8301 /* d2r & r2d */ 8302 vrfy(d2r(180) == pi(), 8303 '9102: d2r(180) == pi()'); 8304 vrfy(d2r(180, 1e-100) == pi(1e-100), 8305 '9103: d2r(180, 1e-100) == pi(1e-100)'); 8306 vrfy(r2d(pi()/2) == 90, 8307 '9104: r2d(pi()/2) == 90'); 8308 vrfy(r2d(pi(1e-15)/2) == 14137166941154068500000/157079632679489661923, 8309 '9105: r2d(pi(1e-15)/2) == ' + 8310 '14137166941154068500000/157079632679489661923'); 8311 vrfy(r2d(d2r(40)) == 40, 8312 '9106: r2d(d2r(40)) == 40'); 8313 vrfy(r2d(d2r(40,1e-90),1e-90) == 40, 8314 '9107: r2d(d2r(40,1e-90),1e-90) == 40'); 8315 vrfy(d2r(180i) == 1i*pi(), 8316 '9108: d2r(1808) == 1i*pi()'); 8317 vrfy(d2r(180i+90) == 1i*pi() + pi()/2, 8318 '9109: d2r(180i+90) == 1i*pi() + pi()/2'); 8319 vrfy(r2d(d2r(40+40i)) == 40+40i, 8320 '9110: r2d(d2r(40+40i)) == 40+40i'); 8321 vrfy(r2d(d2r(40+40i,1e-60),1e-60) == 40+40i, 8322 '9111: r2d(d2r(40+40i,1e-60),1e-60) == 40+40i'); 8323 8324 /* g2r & r2g */ 8325 vrfy(g2r(200) == pi(), 8326 '9112: g2r(200) == pi()'); 8327 vrfy(g2r(200, 1e-100) == pi(1e-100), 8328 '9113: g2r(180, 1e-100) == pi(1e-100)'); 8329 vrfy(r2g(pi()/2) == 100, 8330 '9114: r2g(pi()/2) == 100'); 8331 vrfy(r2g(pi(1e-15)/2) == 15707963267948965000000/157079632679489661923, 8332 '9115: r2g(pi(1e-15)/2) == ' + 8333 '15707963267948965000000/157079632679489661923'); 8334 vrfy(r2g(g2r(40)) == 40, 8335 '9116: r2g(g2r(40)) == 40'); 8336 vrfy(r2g(g2r(40,1e-90),1e-90) == 40, 8337 '9117: r2g(g2r(40,1e-90),1e-90) == 40'); 8338 vrfy(g2r(200i) == 1i*pi(), 8339 '9118: g2r(200i) == 1i*pi()'); 8340 vrfy(g2r(200i+150) == pi()*0.75 + 1i*pi(), 8341 '9119: g2r(200i+150) == pi()*0.75 + 1i*pi()'); 8342 vrfy(r2g(g2r(40+40i)) == 40+40i, 8343 '9120: r2g(g2r(40+40i)) == 40+40i'); 8344 vrfy(r2g(g2r(40+40i,1e-60),1e-60) == 40+40i, 8345 '9121: r2g(g2r(40+40i,1e-60),1e-60) == 40+40i'); 8346 8347 /* g2d & d2g */ 8348 vrfy(g2d(200) == 180, 8349 '9122: g2d(200) == 180'); 8350 vrfy(g2d(200, 1e-100) == 180, 8351 '9123: g2d(180, 1e-100) == 180'); 8352 vrfy(d2g(81) == 90, 8353 '9124: d2g(81) == 90'); 8354 vrfy(d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000, 8355 '9125: d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000'); 8356 vrfy(d2g(g2d(40)) == 40, 8357 '9126: d2g(g2d(40)) == 40'); 8358 vrfy(d2g(g2d(40,1e-90),1e-90) == 40, 8359 '9127: d2g(g2d(40,1e-90),1e-90) == 40'); 8360 vrfy(g2d(200i) == 180i, 8361 '9128: g2d(200i) == 180i'); 8362 vrfy(g2d(200i+47) == 42.3 + 180i, 8363 '9129: g2d(200i+47) == 42.3 + 180i'); 8364 vrfy(d2g(g2d(40+40i)) == 40+40i, 8365 '9130: d2g(g2d(40+40i)) == 40+40i'); 8366 vrfy(d2g(g2d(40+40i,1e-90),1e-90) == 40+40i, 8367 '9131: d2g(g2d(40+40i,1e-90),1e-90) == 40+40i'); 8368 8369 /* d2dms */ 8370 vrfy(d2dms(12.3456,d,m,s) == 12.3456, 8371 '9132: d2dms(12.3456,d,m,s) == 12.3456'); 8372 vrfy(d == 12, 8373 '9133: d == 12'); 8374 vrfy(m == 20, 8375 '9133: m == 20'); 8376 vrfy(s == 44.16, 8377 '9134: s == 44.16'); 8378 8379 vrfy(d2dms(1234.5678,d,m,s) == 154.5678, 8380 '9135: d2dms(1234.5678,d,m,s) == 154.5678'); 8381 vrfy(d == 154, 8382 '9136: d == 154'); 8383 vrfy(m == 34, 8384 '9137: m == 34'); 8385 vrfy(s == 4.08, 8386 '9138: s == 4.08'); 8387 8388 vrfy(d2dms(-1234.5678,d,m,s) == 205.4322, 8389 '9139: d2dms(-1234.5678,d,m,s) == 205.4322'); 8390 vrfy(d == 205, 8391 '9140: d == 205'); 8392 vrfy(m == 25, 8393 '9141: m == 25'); 8394 vrfy(s == 55.92, 8395 '9142: s == 55.92'); 8396 8397 vrfy(d2dms(360.321,d,m,s,1) == -359.679, 8398 '9143: d2dms(360.321,d,m,s,1) == -359.679'); 8399 vrfy(d == -359, 8400 '9144: d == -359'); 8401 vrfy(m == -40, 8402 '9145: m == -40'); 8403 vrfy(s == -44.4, 8404 '9146: s == -44.4'); 8405 8406 /* d2dm */ 8407 vrfy(d2dm(12.3456,d,m) == 12.3456, 8408 '9147: d2dm(12.3456,d,m) == 12.3456'); 8409 vrfy(d == 12, 8410 '9148: d == 12'); 8411 vrfy(m == 20.736, 8412 '9149: m == 20.736'); 8413 8414 vrfy(d2dm(1234.5678,d,m) == 154.5678, 8415 '9150: d2dm(1234.5678,d,m) == 154.5678'); 8416 vrfy(d == 154, 8417 '9151: d == 154'); 8418 vrfy(m == 34.068, 8419 '9152: m == 34.068'); 8420 8421 vrfy(d2dm(-1234.5678,d,m) == 205.4322, 8422 '9153: d2dm(-1234.5678,d,m) == 205.4322'); 8423 vrfy(d == 205, 8424 '9154: d == 205'); 8425 vrfy(m == 25.932, 8426 '9155: m == 25.932'); 8427 8428 vrfy(d2dm(360.321,d,m,1) == -359.679, 8429 '9156: d2dm(360.321,d,m,1) == -359.679'); 8430 vrfy(d == -359, 8431 '9167: d == -359'); 8432 vrfy(m == -40.74, 8433 '9158: m == -40.74'); 8434 8435 /* g2gms */ 8436 vrfy(g2gms(12.3456,g,m,s) == 12.3456, 8437 '9159: g2gms(12.3456,g,m,s) == 12.3456'); 8438 vrfy(g == 12, 8439 '9133: g == 12'); 8440 vrfy(m == 20, 8441 '9160: m == 20'); 8442 vrfy(s == 44.16, 8443 '9161: s == 44.16'); 8444 8445 vrfy(g2gms(1234.5678,g,m,s) == 34.5678, 8446 '9162: g2gms(1234.5678,g,m,s) == 34.5678'); 8447 vrfy(g == 34, 8448 '9163: g == 34'); 8449 vrfy(m == 34, 8450 '9164: m == 34'); 8451 vrfy(s == 4.08, 8452 '9165: s == 4.08'); 8453 8454 vrfy(g2gms(-1234.5678,g,m,s) == 365.4322, 8455 '9166: g2gms(-1234.5678,g,m,s) == 365.4322'); 8456 vrfy(g == 365, 8457 '9167: g == 365'); 8458 vrfy(m == 25, 8459 '9168: m == 25'); 8460 vrfy(s == 55.92, 8461 '9169: s == 55.92'); 8462 8463 vrfy(g2gms(400.321,g,m,s,1) == -399.679, 8464 '9170: g2gms(400.321,g,m,s,1) == -399.679'); 8465 vrfy(g == -399, 8466 '9171: g == -399'); 8467 vrfy(m == -40, 8468 '9172: m == -40'); 8469 vrfy(s == -44.4, 8470 '9173: s == -44.4'); 8471 8472 /* g2gm */ 8473 vrfy(g2gm(12.3456,g,m) == 12.3456, 8474 '9174: g2gm(12.3456,g,m) == 12.3456'); 8475 vrfy(g == 12, 8476 '9175: g == 12'); 8477 vrfy(m == 20.736, 8478 '9176: m == 20.736'); 8479 8480 vrfy(g2gm(1234.5678,g,m) == 34.5678, 8481 '9177: g2gm(1234.5678,g,m) == 34.5678'); 8482 vrfy(g == 34, 8483 '9178: g == 34'); 8484 vrfy(m == 34.068, 8485 '9179: m == 34.068'); 8486 8487 vrfy(g2gm(-1234.5678,g,m) == 365.4322, 8488 '9180: g2gm(-1234.5678,g,m) == 365.4322'); 8489 vrfy(g == 365, 8490 '9181: g == 365'); 8491 vrfy(m == 25.932, 8492 '9182: m == 25.932'); 8493 8494 vrfy(g2gm(400.321,g,m,1) == -399.679, 8495 '9183: g2gm(400.321,g,m,1) == -399.679'); 8496 vrfy(g == -399, 8497 '9184: g == -399'); 8498 vrfy(m == -40.74, 8499 '9185: m == -40.74'); 8500 8501 /* h2hms */ 8502 vrfy(h2hms(12.3456,h,m,s) == 12.3456, 8503 '9186: h2hms(12.3456,h,m,s) == 12.3456'); 8504 vrfy(h == 12, 8505 '9187: h == 12'); 8506 vrfy(m == 20, 8507 '9188: m == 20'); 8508 vrfy(s == 44.16, 8509 '9189: s == 44.16'); 8510 8511 vrfy(h2hms(1234.5678,h,m,s) == 10.5678, 8512 '9190: h2hms(1234.5678,h,m,s) == 10.5678'); 8513 vrfy(h == 10, 8514 '9191: h == 10'); 8515 vrfy(m == 34, 8516 '9192: m == 34'); 8517 vrfy(s == 4.08, 8518 '9193: s == 4.08'); 8519 8520 vrfy(h2hms(-1234.5678,h,m,s) == 13.4322, 8521 '9194: h2hms(-1234.5678,h,m,s) == 13.4322'); 8522 vrfy(h == 13, 8523 '9195: h == 13'); 8524 vrfy(m == 25, 8525 '9196: m == 25'); 8526 vrfy(s == 55.92, 8527 '9197: s == 55.92'); 8528 8529 vrfy(h2hms(24.321,h,m,s,1) == -23.679, 8530 '9198: h2hms(24.321,h,m,s,1) == -23.679'); 8531 vrfy(h == -23, 8532 '9199: h == -23'); 8533 vrfy(m == -40, 8534 '9200: m == -40'); 8535 vrfy(s == -44.4, 8536 '9201: s == -44.4'); 8537 8538 /* h2hm */ 8539 vrfy(h2hm(12.3456,h,m) == 12.3456, 8540 '9202: h2hm(12.3456,h,m) == 12.3456'); 8541 vrfy(h == 12, 8542 '9203: h == 12'); 8543 vrfy(m == 20.736, 8544 '9204: m == 20.736'); 8545 8546 vrfy(h2hm(1234.5678,h,m) == 10.5678, 8547 '9205: h2hm(1234.5678,h,m) == 10.5678'); 8548 vrfy(h == 10, 8549 '9206: h == 10'); 8550 vrfy(m == 34.068, 8551 '9207: m == 34.068'); 8552 8553 vrfy(h2hm(-1234.5678,h,m) == 13.4322, 8554 '9208: h2hm(-1234.5678,h,m) == 13.4322'); 8555 vrfy(h == 13, 8556 '9209: h == 13'); 8557 vrfy(m == 25.932, 8558 '9210: m == 25.932'); 8559 8560 vrfy(h2hm(24.321,h,m,1) == -23.679, 8561 '9211: h2hm(24.321,h,m,1) == -23.679'); 8562 vrfy(h == -23, 8563 '9212: h == -23'); 8564 vrfy(m == -40.74, 8565 '9213: m == -40.74'); 8566 8567 /* dm2d */ 8568 vrfy(dm2d(203, 325.5594) == 208.42599, 8569 '9214: dm2d(203, 325.5594) == 208.42599'); 8570 vrfy(dm2d(3601, -25.5594) == 0.57401, 8571 '9215: dm2d(3601, -25.5594) == 0.57401'); 8572 vrfy(dm2d(-923, -25.5594) == 156.57401, 8573 '9216: dm2d(-923, -25.5594) == 156.57401'); 8574 vrfy(dm2d(203, 325.5594, 1) == -151.57401, 8575 '9217: dm2d(203, 325.5594, 1) == -151.57401'); 8576 8577 vrfy(d2dm(dm2d(12, 20.16),d,m) == 12.336, 8578 '9218: d2dm(dm2d(12, 20.16),d,m) == 12.336'); 8579 vrfy(d == 12, 8580 '9219: d == 12'); 8581 vrfy(m == 20.16, 8582 '9220: m == 20.16'); 8583 8584 /* dms2d */ 8585 vrfy(dms2d(12, 20, 44.16) == 12.3456, 8586 '9221: dms2d(12, 20, 44.16) == 12.3456'); 8587 vrfy(dms2d(123.456, -345.68, 4.08) == 117.6958, 8588 '9222: dms2d(123.456, -345.68, 4.08) == 117.6958'); 8589 vrfy(dms2d(-65, -40, -44.4) == 294.321, 8590 '9223: dms2d(-65, -40, -44.4) == 294.321'); 8591 vrfy(dms2d(12, 20, 44.16, 1) == -347.6544, 8592 '9224: dms2d(12, 20, 44.16, 1) == -347.6544'); 8593 8594 vrfy(d2dms(dms2d(13, 20, 44.16),d,m,s) == 13.3456, 8595 '9225: d2dms(dms2d(13, 20, 44.16),d,m,s) == 13.3456'); 8596 vrfy(d == 13, 8597 '9226: d == 13'); 8598 vrfy(m == 20, 8599 '9227: m == 20'); 8600 vrfy(s == 44.16, 8601 '9228: s == 44.16'); 8602 8603 /* gm2g */ 8604 vrfy(gm2g(203, 325.5594) == 208.42599, 8605 '9229: gm2g(203, 325.5594) == 208.42599'); 8606 vrfy(gm2g(3601, -25.5594) == 0.57401, 8607 '9230: gm2g(3601, -25.5594) == 0.57401'); 8608 vrfy(gm2g(-923, -25.5594) == 276.57401, 8609 '9231: gm2g(-923, -25.5594) == 276.57401'); 8610 vrfy(gm2g(203, 325.5594, 1) == -191.57401, 8611 '9232: gm2g(203, 325.5594, 1) == -191.57401'); 8612 8613 vrfy(g2gm(gm2g(12, 20.16),g,m) == 12.336, 8614 '9233: g2gm(gm2g(12, 20.16),g,m) == 12.336'); 8615 vrfy(g == 12, 8616 '9234: g == 12'); 8617 vrfy(m == 20.16, 8618 '9235: m == 20.16'); 8619 8620 /* gms2g */ 8621 vrfy(gms2g(12, 20, 44.16) == 12.3456, 8622 '9236: gms2g(12, 20, 44.16) == 12.3456'); 8623 vrfy(gms2g(123.456, -345.68, 4.08) == 117.6958, 8624 '9237: gms2g(123.456, -345.68, 4.08) == 117.6958'); 8625 vrfy(gms2g(-65, -40, -44.4) == 334.321, 8626 '9238: gms2g(-65, -40, -44.4) == 334.321'); 8627 vrfy(gms2g(12, 20, 44.16, 1) == -387.6544, 8628 '9239: gms2g(12, 20, 44.16, 1) == -387.6544'); 8629 8630 vrfy(g2gms(gms2g(14, 20, 44.16),g,m,s) == 14.3456, 8631 '9240: g2gms(gms2g(14, 20, 44.16),g,m,s) == 14.3456'); 8632 vrfy(g == 14, 8633 '9241: g == 14'); 8634 vrfy(m == 20, 8635 '9242: m == 20'); 8636 vrfy(s == 44.16, 8637 '9243: s == 44.16'); 8638 8639 /* hm2h */ 8640 vrfy(hm2h(203, 325.5594) == 16.42599, 8641 '9244: hm2h(203, 325.5594) == 16.42599'); 8642 vrfy(hm2h(241, -25.5594) == 0.57401, 8643 '9245: hm2h(241, -25.5594) == 0.57401'); 8644 vrfy(hm2h(-923, -25.5594) == 12.57401, 8645 '9246: hm2h(-923, -25.5594) == 12.57401'); 8646 vrfy(hm2h(203, 325.5594, 1) == -7.57401, 8647 '9247: hm2h(203, 325.5594, 1) == -7.57401'); 8648 8649 vrfy(h2hm(hm2h(12, 20.16),h,m) == 12.336, 8650 '9248: h2hm(hm2h(12, 20.16),h,m) == 12.336'); 8651 vrfy(h == 12, 8652 '9249: h == 12'); 8653 vrfy(m == 20.16, 8654 '9250: m == 20.16'); 8655 8656 /* hms2h */ 8657 vrfy(hms2h(12, 20, 44.16) == 12.3456, 8658 '9251: hms2h(12, 20, 44.16) == 12.3456'); 8659 vrfy(hms2h(123.456, -345.68, 4.08) == 21.6958, 8660 '9252: hms2h(123.456, -345.68, 4.08) == 21.6958'); 8661 vrfy(hms2h(-65, -40, -44.4) == 6.321, 8662 '9253: hms2h(-65, -40, -44.4) == 6.321'); 8663 vrfy(hms2h(12, 20, 44.16, 1) == -11.6544, 8664 '9254: hms2h(12, 20, 44.16, 1) == -11.6544'); 8665 8666 vrfy(h2hms(hms2h(15, 20, 44.16),h,m,s) == 15.3456, 8667 '9255: h2hms(hms2h(15, 20, 44.16),h,m,s) == 15.3456'); 8668 vrfy(h == 15, 8669 '9256: h == 15'); 8670 vrfy(m == 20, 8671 '9257: m == 20'); 8672 vrfy(s == 44.16, 8673 '9258: s == 44.16'); 8674 8675 print '9259: Ending test_functions3'; 8676} 8677print; 8678print '9100: parsed test_functions3()'; 8679print; 8680return test_functions3(); 8681 8682 8683/* 8684 * read various calc resource files 8685 * 8686 * We read most of the standard calc resource files. There are a few 8687 * resource files that are not read: 8688 * 8689 * beer.cal - prints a bunch of things when loaded 8690 * hello.cal - designed to go into an infinite loop 8691 * lucas.cal - already read by this file 8692 * lucas_chk.cal - already read by this file 8693 * regress.cal - this file 8694 * surd.cal - already read by this file 8695 * test9999.cal - files of this form are already read by this file 8696 * xx_print.cal - prints a bunch of things when loaded 8697 * 8698 * We want to do this 2nd to last; ahead of any final cleanup and behind 8699 * all of real actions of regress.cal. 8700 */ 8701print; 8702print '9800: Starting read of selected calc resource files'; 8703read -once bernoulli; 8704print '9801: read -once bernoulli'; 8705read -once bigprime; 8706print '9802: read -once bigprime'; 8707read -once chrem; 8708print '9803: read -once chrem'; 8709read -once deg; 8710print '9804: read -once deg'; 8711read -once ellip; 8712print '9805: read -once ellip'; 8713read -once mersenne; 8714print '9806: read -once mersenne'; 8715read -once mfactor; 8716print '9807: read -once mfactor'; 8717read -once mod; 8718print '9808: read -once mod'; 8719read -once natnumset; 8720print '9809: read -once natnumset'; 8721read -once pell; 8722print '9810: read -once pell'; 8723read -once pi; 8724print '9811: read -once pi'; 8725read -once pix; 8726print '9812: read -once pix'; 8727read -once pollard; 8728print '9813: read -once pollard'; 8729read -once poly; 8730print '9814: read -once poly'; 8731read -once prompt; 8732print '9815: read -once prompt'; 8733read -once psqrt; 8734print '9816: read -once psqrt'; 8735read -once quat; 8736print '9817: read -once quat'; 8737read -once randbitrun; 8738print '9818: read -once randbitrun'; 8739read -once randmprime; 8740print '9819: read -once randmprime'; 8741read -once randombitrun; 8742print '9820: read -once randombitrun'; 8743read -once randomrun; 8744print '9821: read -once randomrun'; 8745read -once randrun; 8746print '9822: read -once randrun'; 8747read -once seedrandom; 8748print '9823: read -once seedrandom'; 8749read -once solve; 8750print '9824: read -once solve'; 8751read -once sumsq; 8752print '9825: read -once sumsq'; 8753read -once unitfrac; 8754print '9826: read -once unitfrac'; 8755read -once varargs; 8756print '9827: read -once varargs'; 8757read -once qtime; 8758print '9828: read -once qtime'; 8759read -once chi; 8760print '9829: read -once chi'; 8761read -once intfile; 8762print '9830: read -once intfile'; 8763read -once lucas; 8764print '9831: read -once lucas'; 8765read -once natnumset; 8766print '9833: read -once natnumset'; 8767read -once repeat; 8768print '9834: read -once repeat'; 8769read -once screen; 8770print '9835: read -once screen'; 8771read -once linear; 8772print '9836: read -once linear'; 8773print '9837: skipping read -once beer.cal because it is an infinite loop'; 8774print '9838: skipping read -once hello.cal because it is an infinite loop'; 8775print '9839: skipping read -once xx_print.cal because it is a printing demo'; 8776read -once sumtimes; 8777print '9840: read -once sumtimes'; 8778read -once dms; 8779print '9841: read -once dms'; 8780read -once hms; 8781print '9842: read -once hms'; 8782print '9843: Ending read of selected calc resource files'; 8783 8784 8785/* 8786 * cleanup and report the results 8787 */ 8788print; 8789freeredc(); 8790print '9995: freeredc()'; 8791freestatics(); 8792print '9996: freestatics()'; 8793return count_errors(); 8794freeglobals(); 8795print '9998: freeglobals()'; 8796print '9999: Ending regression tests'; 8797