0; print '2401: mode = 0'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2402: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.4, '2403: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 5, '2404: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -6, '2405: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2406: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2407: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 6, '2408: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -5, '2409: appr(-5.7,-1,mode) == -5'); /* appr mode 1 */ mode = 1; print '2410: mode = 1'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2411: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.5, '2412: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 6, '2413: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -5, '2414: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2415: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2416: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 5, '2417: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -6, '2418: appr(-5.7,-1,mode) == -6'); /* appr mode 2 */ mode = 2; print '2419: mode = 2'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2420: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.4, '2421: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 5, '2422: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -5, '2423: appr(-5.7,1,mode) == -5'); /* appr mode 3 */ mode = 3; print '2424: mode = 3'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2425: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.5, '2426: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 6, '2427: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -6, '2428: appr(-5.7,1,mode) == -6'); /* appr mode 4 */ mode = 4; print '2429: mode = 4'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2430: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.4, '2431: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 5, '2432: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -6, '2433: appr(-5.7,1,mode) == -6'); /* appr mode 5 */ mode = 5; print '2434: mode = 5'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2435: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.5, '2436: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 6, '2437: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -5, '2438: appr(-5.7,1,mode) == -5'); /* appr mode 6 */ mode = 6; print '2439: mode = 6'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2440: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.4, '2441: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 5, '2442: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -5, '2443: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2444: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2445: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 6, '2446: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -6, '2447: appr(-5.7,-1,mode) == -6'); /* appr mode 7 */ mode = 7; print '2448: mode = 7'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2449: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.5, '2450: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 6, '2451: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -6, '2452: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2453: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2454: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 5, '2455: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -5, '2456: appr(-5.7,-1,mode) == -5'); /* appr mode 8 */ mode = 8; print '2457: mode = 8'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2458: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.4, '2459: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 6, '2460: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -6, '2461: appr(-5.7,1,mode) == -6'); /* appr mode 9 */ mode = 9; print '2462: mode = 9'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2463: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.5, '2464: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 5, '2465: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -5, '2466: appr(-5.7,1,mode) == -5'); /* appr mode 10 */ mode = 10; print '2467: mode = 10'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2468: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.4, '2469: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 6, '2470: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -5, '2471: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2472: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2473: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 5, '2474: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -6, '2475: appr(-5.7,-1,mode) == -6'); /* appr mode 11 */ mode = 11; print '2476: mode = 11'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2477: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.5, '2478: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 5, '2479: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -6, '2480: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2481: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2482: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 6, '2483: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -5, '2484: appr(-5.7,-1,mode) == -5'); /* appr mode 12 */ mode = 12; print '2485: mode = 12'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2486: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.4, '2487: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 6, '2488: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -6, '2489: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2490: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2491: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 5, '2492: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -5, '2493: appr(-5.7,-1,mode) == -5'); /* appr mode 13 */ mode = 13; print '2494: mode = 13'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2495: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.5, '2496: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 5, '2497: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -5, '2498: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2499: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2500: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 6, '2501: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -6, '2502: appr(-5.7,-1,mode) == -6'); /* appr mode 14 */ mode = 14; print '2503: mode = 14'; vrfy(appr(-5.44,0.1,mode) == -5.5, '2504: appr(-5.44,0.1,mode) == -5.5'); vrfy(appr(5.44,0.1,mode) == 5.4, '2505: appr(5.44,0.1,mode) == 5.4'); vrfy(appr(5.7,1,mode) == 6, '2506: appr(5.7,1,mode) == 6'); vrfy(appr(-5.7,1,mode) == -5, '2507: appr(-5.7,1,mode) == -5'); vrfy(appr(-5.44,-0.1,mode) == -5.5, '2508: appr(-5.44,-0.1,mode) == -5.5'); vrfy(appr(5.44,-0.1,mode) == 5.4, '2509: appr(5.44,-0.1,mode) == 5.4'); vrfy(appr(5.7,-1,mode) == 6, '2510: appr(5.7,-1,mode) == 6'); vrfy(appr(-5.7,-1,mode) == -5, '2511: appr(-5.7,-1,mode) == -5'); /* appr mode 15 */ mode = 15; print '2512: mode = 15'; vrfy(appr(-5.44,0.1,mode) == -5.4, '2513: appr(-5.44,0.1,mode) == -5.4'); vrfy(appr(5.44,0.1,mode) == 5.5, '2514: appr(5.44,0.1,mode) == 5.5'); vrfy(appr(5.7,1,mode) == 5, '2515: appr(5.7,1,mode) == 5'); vrfy(appr(-5.7,1,mode) == -6, '2516: appr(-5.7,1,mode) == -6'); vrfy(appr(-5.44,-0.1,mode) == -5.4, '2517: appr(-5.44,-0.1,mode) == -5.4'); vrfy(appr(5.44,-0.1,mode) == 5.5, '2518: appr(5.44,-0.1,mode) == 5.5'); vrfy(appr(5.7,-1,mode) == 5, '2519: appr(5.7,-1,mode) == 5'); vrfy(appr(-5.7,-1,mode) == -6, '2520: appr(-5.7,-1,mode) == -6'); print '2521: Ending config rounding mode test'; } print '035: parsed test_round()'; /* * Test certain numeric functions extensively * * Test multiplication, sqrt(), exp(), ln(), power(), gcd(), complex * power, complex exp, complex log. */ read -once "test2600"; print '036: read -once test2600'; define test_2600() { local tnum; /* test number */ local i; print '2600: Beginning extensive numeric function test'; i = config("sqrt"); print '2601: i = config("sqrt")'; tnum = test2600(1, 2602); i = config("sqrt", i); print tnum++: ': i = config("sqrt", i)'; i = epsilon(1e-100),; print tnum++: ': i = epsilon(1e-100),;'; vrfy(ln(exp(6)) == 6, strcat(str(tnum++), ': ln(exp(6)) == 6')); vrfy(ln(exp(4)^4) == 16, strcat(str(tnum++), ': ln(exp(4)^4) == 16')); vrfy(ln(exp(6.5)^8) == 52, strcat(str(tnum++), ': ln(exp(6.5)^8) == 52')); vrfy(ln(exp(5)^16) == 80, strcat(str(tnum++), ': ln(exp(5)^16) == 80')); vrfy(ln(exp(4.5)^4) == 18, strcat(str(tnum++), ': ln(exp(4.5)^4) == 18')); vrfy(ln(exp(4)^8) == 32, strcat(str(tnum++), ': ln(exp(4)^8) == 32')); vrfy(ln(exp(60/11)^11) == 60, strcat(str(tnum++), ': ln(exp(60/11)^11) == 60')); vrfy(ln(exp(6)^15) == 90, strcat(str(tnum++), ': ln(exp(6)^11) == 90')); vrfy(ln(exp(80/17)^17) == 80, strcat(str(tnum++), ': ln(exp(80/17)^17) == 80')); vrfy(ln(exp(6)^15) == 90, strcat(str(tnum++), ': ln(exp(6)^15) == 90')); vrfy(ln(exp(5)^18) == 90, strcat(str(tnum++), ': ln(exp(5)^18) == 90')); vrfy(log(1e6) == 6, strcat(str(tnum++), ': log(1e6)) == 6')); vrfy(log(1) == 0, strcat(str(tnum++), ': log(1)) == 0')); vrfy(log(100) == 2, strcat(str(tnum++), ': log(100)) == 2')); vrfy(log(1e66) == 66, strcat(str(tnum++), ': log(1e66)) == 66')); vrfy(log(1e127) == 127, strcat(str(tnum++), ': log(1e127)) == 127')); vrfy(round(log(17^47),10) == 57.8310993048, strcat(str(tnum++), ': round(log(17^47),10) == 57.8310993048')); vrfy(round(log(127),10) == 2.103803721, strcat(str(tnum++), ': round(log(127),10) == 2.103803721')); vrfy(round(log(0.25,0.00001),5) == -0.60206, strcat(str(tnum++), ': round(log(0.25,0.00001),5) == -0.60206')); vrfy(round(log(0.25,1e-10),10) == -0.6020599913, strcat(str(tnum++), ': round(log(0.25,1e-10),10) == -0.6020599913')); vrfy(round( log(1.2+1.2i,1e-5),5) == 0.2297+0.34109i, strcat(str(tnum++), ': round(log(1.2+1.2i,1e-5),5) == 0.2297+0.34109i')); vrfy(round( log(1.2+1.2i,1e-10),10) == 0.2296962439+0.3410940885i, strcat(str(tnum++), ': round(log(1.2+1.2i,1e-10),10) == ', '0.2296962439+0.3410940885i')); epsilon(i),; print tnum++: ': epsilon(i),;'; print tnum: ': Ending extensive numeric function test'; } print '037: parsed test_2600()'; /* * Test complex sqrt */ read -once "test2700"; print '038: read -once test2700'; define test_2700() { local tnum; /* test number */ print '2700: Beginning complex sqrt test'; tnum = test2700(1, 2701); print tnum: ': Ending complex sqrt test'; } print '039: parsed test_2700()'; /* * Test matrix operations */ mat mat_C[2] = {1,2}; print '040: mat mat_C[2] = {1,2}'; mat_C[0] = mat_C; print '041: C[0] = mat_C'; global mat_D; print '042: global mat_D'; /**/ define test_matrix() { static mat b[4,4]; static mat binv[4,4] = { 0, 1, 0, 0, 2, -3/2, 2, -1/2, -3, 0.5, -1.0, 0.5, 1.0, 0.0, 0.0, 0.0 }; static mat c[] = { 1, 2+3i, -5+4i, 5i+6, -7i }; static mat d[-1:1, -2:2, -3:3, -4:4]; static mat A[2] = {1,2}; static mat id0[2,2] = {1,0,0,1}; static mat id1[0:2,-1:1] = {1,0,0,0,1,0,0,0,1}; static mat noid0[2,2] = {1,2,0,1}; static mat noid1[2,3] = {1,0,0,1,0,0}; static mat noid2[4] = {1,0,0,1}; static mat xp[3] = {2,3,4}; static mat yp[3] = {3,4,5}; static mat zp[3] = {-1,2,-1}; static mat X[2,2] = {1,2,3,4}; static mat Y[2,2] = {5,6,7,8}; static mat Z[2,2] = {190,232,286,352}; static mat x[] = {11,13,17,23,29}; static mat y0[] = {1,3,7,3,9}; static mat y1[] = {-9,-7,-3,-7,-1}; static mat y2[] = {-9,-7,-3,3,9}; static mat y3[] = {1,3,7,-7,-1}; static mat y4[] = {1,3,-3,3,-1}; local B; local mat e[5,5]; local mat M[2]; local mat zero3[3]; print '2800: Beginning test_matrix'; b[0,0] = 0; vrfy(b[0,0] == 0, '2801: b[0,0] == 0'); b[0,1] = 0; vrfy(b[0,1] == 0, '2802: b[0,1] == 0'); b[0,2] = 0; vrfy(b[0,2] == 0, '2803: b[0,2] == 0'); b[0,3] = 1; vrfy(b[0,3] == 1, '2804: b[0,3] == 1'); b[1,0] = 1; vrfy(b[1,0] == 1, '2805: b[1,0] == 1'); b[1,1] = 0; vrfy(b[1,1] == 0, '2806: b[1,1] == 0'); b[1,2] = 0; vrfy(b[1,2] == 0, '2807: b[1,2] == 0'); b[1,3] = 0; vrfy(b[1,3] == 0, '2808: b[1,3] == 0'); b[2,0] = 1; vrfy(b[2,0] == 1, '2809: b[2,0] == 1'); b[2,1] = 1; vrfy(b[2,1] == 1, '2810: b[2,1] == 1'); b[2,2] = 1; vrfy(b[2,2] == 1, '2811: b[2,2] == 1'); b[2,3] = 1; vrfy(b[2,3] == 1, '2812: b[2,3] == 1'); b[3,0] = 1; vrfy(b[3,0] == 1, '2813: b[3,0] == 1'); b[3,1] = 2; vrfy(b[3,1] == 2, '2814: b[3,1] == 2'); b[3,2] = 4; vrfy(b[3,2] == 4, '2815: b[3,2] == 4'); b[3,3] = 8; vrfy(b[3,3] == 8, '2816: b[3,3] == 8'); vrfy(det(b) == -2, '2817: det(b) == -2'); vrfy(binv[0,0] == 0, '2818: binv[0,0] == 0'); vrfy(binv[0,1] == 1, '2819: binv[0,1] == 1'); vrfy(binv[0,2] == 0, '2820: binv[0,2] == 0'); vrfy(binv[0,3] == 0, '2821: binv[0,3] == 0'); vrfy(binv[1,0] == 2, '2822: binv[1,0] == 2'); vrfy(binv[1,1] == -3/2, '2823: binv[1,1] == -3/2'); vrfy(binv[1,2] == 2, '2824: binv[1,2] == 2'); vrfy(binv[1,3] == -1/2, '2825: binv[1,3] == -1/2'); vrfy(binv[2,0] == -3, '2826: binv[2,0] == -3'); vrfy(binv[2,1] == 1/2, '2827: binv[2,1] == 1/2'); vrfy(binv[2,2] == -1, '2828: binv[2,2] == -1'); vrfy(binv[2,3] == 1/2, '2829: binv[2,3] == 1/2'); vrfy(binv[3,0] == 1, '2830: binv[3,0] == 1'); vrfy(binv[3,1] == 0, '2831: binv[3,1] == 0'); vrfy(binv[3,2] == 0, '2832: binv[3,2] == 0'); vrfy(binv[3,3] == 0, '2833: binv[3,3] == 0'); vrfy(inverse(b) == binv, '2834: inverse(b) == binv'); vrfy(avg(b) == b, '2835: avg(b) == b'); vrfy(avg(binv) == binv, '2836: avg(binv) == binv'); vrfy((b+binv)/2 == avg(b,binv), '2837: (b+binv)/2 == avg(b,binv)'); vrfy(ismat(b) == 1, '2838: ismat(b) == 1'); vrfy(matsum(b) == 21, '2839: matsum(b) == 21'); vrfy(matsum(binv) == 1, '2840: matsum(binv) == 1'); vrfy(c[0] == 1, '2841: c[0] == 1'); vrfy(c[1] == 2+3i, '2842: c[1] == 2+3i'); vrfy(c[2] == -5+4i, '2843: c[2] == -5+4i'); vrfy(c[3] == 6+5i, '2844: c[3] == 6+5i'); vrfy(c[4] == -7i, '2845: c[4] == -7i'); vrfy(matsum(c) == 4+5i, '2846: matsum(c) == 4+5i'); vrfy(matdim(b) == 2, '2847: matdim(b) == 2'); vrfy(matdim(c) == 1, '2848: matdim(c) == 1'); vrfy(matdim(d) == 4, '2849: matdim(c) == 4'); vrfy(matmax(c,1) == 4, '2850: matmax(c,1) == 4'); vrfy(matmin(c,1) == 0, '2851: matmin(c,1) == 0'); vrfy(matmin(d,1) == -1, '2852: matmin(d,1) == -1'); vrfy(matmin(d,3) == -3, '2853: matmin(d,3) == -3'); vrfy(matmax(d,1) == 1, '2854: matmin(d,1) == 1'); vrfy(matmax(d,3) == 3, '2855: matmin(d,3) == 3'); vrfy(size(binv) == 16, '2856: size(binv) == 16'); vrfy(size(c) == 5, '2857: size(c) == 5'); vrfy(size(d) == 945, '2858: size(d) == 945'); vrfy(size(e) == 25, '2859: size(e) == 25'); matfill(d,1); print '2860: matfill(d,1)'; vrfy(matsum(d) == 945, '2861: matsum(d) == 945'); matfill(e,1,0); print '2862: matfill(e,1,0)'; vrfy(matsum(d) == 945, '2863: matsum(d) == 945'); vrfy(matsum(e) == 20, '2864: matsum(e) == 20'); vrfy(search(binv,1) == 1, '2865: search(binv,1) == 1'); vrfy(search(binv,2) == 4, '2866: search(binv,2) == 4'); vrfy(search(binv,2,4) == 4, '2867: search(binv,2,4) == 4'); vrfy(search(binv,2,5) == 6, '2868: search(binv,2,5) == 6'); vrfy(rsearch(binv,2) == 6, '2869: rsearch(binv,2) == 6'); vrfy(rsearch(binv,2,6) == 6, '2870: rsearch(binv,2,6) == 6'); vrfy(rsearch(binv,2,5) == 4, '2871: rsearch(binv,2,5) == 4'); vrfy(A[0] == 1, '2872: A[0] == 1'); vrfy(A[1] == 2, '2873: A[1] == 2'); A[0] = A; print '2874: A[0] = A'; B = A[0]; print '2875: B = A[0]'; vrfy(B[0] == 1, '2876: B[0] == 1'); vrfy(B[1] == 2, '2877: B[1] == 2'); mat_D = mat_C[0]; print '2878: mat_D = mat_C[0]'; vrfy(mat_D[0] == 1, '2879: mat_D[0] == 1'); vrfy(mat_D[1] == 2, '2880: mat_D[1] == 2'); vrfy(quomod(15.6,5.2,M[0],M[1]) == 0, '2881: quomod(15.6,5.2,M[0],M[1]) == 0'); vrfy(M[0] == 3, '2882: M[0] == 3'); vrfy(M[1] == 0, '2883: M[1] == 0'); vrfy(isident(id0) == 1, '2884: isident(id0) == 1'); vrfy(isident(id1) == 1, '2885: isident(id1) == 1'); vrfy(isident(noid0) == 0, '2886: isident(noid0) == 0'); vrfy(isident(noid1) == 0, '2887: isident(noid1) == 0'); vrfy(isident(noid2) == 0, '2888: isident(noid2) == 0'); vrfy(xp[0] == 2, '2889: xp[0] == 2'); vrfy(xp[1] == 3, '2890: xp[1] == 3'); vrfy(xp[2] == 4, '2891: xp[2] == 4'); vrfy(yp[0] == 3, '2892: yp[0] == 3'); vrfy(yp[1] == 4, '2893: yp[1] == 4'); vrfy(yp[2] == 5, '2894: yp[2] == 5'); vrfy(zp[0] == -1, '2895: zp[0] == -1'); vrfy(zp[1] == 2, '2896: zp[1] == 2'); vrfy(zp[2] == -1, '2897: zp[2] == -1'); vrfy(cp(xp,yp) == zp, '2898: cp(xp,yp) == zp'); vrfy(cp(yp,xp) == -zp, '2899: cp(yp,xp) == -zp'); matfill(zero3,0); print '2900: matfill(zero3,0)'; vrfy(cp(xp,xp) == zero3, '2901: cp(xp,xp) == zero3'); vrfy(dp(xp,yp) == 38, '2902: dp(xp,yp) == 38'); vrfy(dp(yp,xp) == 38, '2903: dp(yp,xp) == 38'); vrfy(dp(zp,dp(xp,yp)*zp) == 228,'2904: dp(zp,dp(xp,yp)*zp) == 228'); vrfy(ssq(X, Y, X + Y) == Z, '2905: ssq(X, Y, X + Y) == Z'); vrfy(mod(x,10,0) == y0, '2906: mod(x,10,0) == y0'); vrfy(mod(x,10,1) == y1, '2907: mod(x,10,1) == y1'); vrfy(mod(x,10,2) == y0, '2908: mod(x,10,2) == y0'); vrfy(mod(x,10,3) == y1, '2909: mod(x,10,3) == y1'); vrfy(mod(x,10,4) == y0, '2910: mod(x,10,4) == y0'); vrfy(mod(x,10,5) == y1, '2911: mod(x,10,5) == y1'); vrfy(mod(x,10,6) == y0, '2912: mod(x,10,6) == y0'); vrfy(mod(x,10,7) == y1, '2913: mod(x,10,7) == y1'); vrfy(mod(x,10,8) == y2, '2914: mod(x,10,8) == y2'); vrfy(mod(x,10,9) == y3, '2915: mod(x,10,9) == y3'); vrfy(mod(x,10,10) == y2, '2916: mod(x,10,10) == y2'); vrfy(mod(x,10,11) == y3, '2917: mod(x,10,11) == y3'); vrfy(mod(x,10,12) == y2, '2918: mod(x,10,12) == y2'); vrfy(mod(x,10,13) == y3, '2919: mod(x,10,13) == y3'); vrfy(mod(x,10,14) == y2, '2920: mod(x,10,14) == y2'); vrfy(mod(x,10,15) == y3, '2921: mod(x,10,15) == y3'); vrfy(mod(x,10,16) == y4, '2922: mod(x,10,16) == y4'); vrfy(mod(x,10,16) == y4, '2923: mod(x,10,16) == y4'); vrfy(mod(x,10,18) == y4, '2924: mod(x,10,18) == y4'); vrfy(mod(x,10,19) == y4, '2925: mod(x,10,18) == y4'); vrfy(mod(x,10,20) == y4, '2926: mod(x,10,20) == y4'); vrfy(mod(x,10,21) == y4, '2927: mod(x,10,21) == y4'); vrfy(mod(x,10,22) == y4, '2928: mod(x,10,22) == y4'); vrfy(mod(x,10,23) == y4, '2929: mod(x,10,23) == y4'); vrfy(mod(x,10,24) == y4, '2930: mod(x,10,24) == y4'); vrfy(mod(x,10,25) == y4, '2931: mod(x,10,25) == y4'); vrfy(mod(x,10,26) == y4, '2932: mod(x,10,26) == y4'); vrfy(mod(x,10,27) == y4, '2933: mod(x,10,27) == y4'); vrfy(mod(x,10,28) == y4, '2934: mod(x,10,28) == y4'); vrfy(mod(x,10,29) == y4, '2935: mod(x,10,29) == y4'); vrfy(mod(x,10,30) == y4, '2936: mod(x,10,30) == y4'); vrfy(mod(x,10,31) == y4, '2937: mod(x,10,31) == y4'); print '2938: Ending mat_functions'; } print '043: parsed test_matrix()'; /* * Test string constants and comparisons */ define test_strings() { local x, y, z; print '3000: Beginning test_strings'; x = 'string'; print "3001: x = 'string'"; y = "string"; print '3002: y = "string"'; z = x; print '3003: z = x'; vrfy(z == "string", '3004: z == "string"'); vrfy(z != "foo", '3005: z != "foo"'); vrfy(z != 3, '3006: z != 3'); vrfy('' == "", '3007: \'\' == ""'); vrfy("a" == "a", '3008: "a" == "a"'); vrfy("c" != "d", '3009: "c" != "d"'); vrfy("" != "a", '3010: "" != "a"'); vrfy("rs" < "rt", '3011: "rs" < "rt"'); vrfy("rs" < "ss", '3012: "rs < "ss"'); vrfy("rs" <= "rs", '3013: "rs" <= "rs"'); vrfy("rs" <= "tu", '3014: "rs" <= "tu"'); vrfy("rs" > "cd", '3015: "rs" > "cd"'); vrfy("rs" >= "rs", '3016: "rs" >= "rs"'); vrfy("rs" >= "cd", '3017: "rs" >= "cd"'); vrfy("abc" > "ab", '3018: "abc" > "ab"'); print '3019: Ending test_strings'; } print '044: parsed test_strings()'; /* * test_matobj - test determinants of a matrix containing objects */ read -once "test3100"; print '045: read -once test3100'; /**/ define test_matobj() { local mat A[3,3] = {2, 3, 5, 7, 11, 13, 17, 19, 23}; local mat B[2,2]; print '3100: Beginning test_matobj'; vrfy(det(A) == -78, '3101: det(A) == -78'); vrfy(det(A^2) == 6084, '3102: det(A^2) == 6084'); vrfy(det(A^3) == -474552, '3103: det(A^3) == -474552'); vrfy(det(A^-1) == -1/78, '3104: det(A^-1) == -1/78'); md = 0; print '3105: md = 0'; B[0,0] = res(2); print '3106: B[0,0] = res(2)'; B[0,1] = res(3); print '3107: B[0,1] = res(3)'; B[1,0] = res(5); print '3108: B[1,0] = res(5)'; B[1,1] = res(7); print '3109: B[1,1] = res(7)'; print '3110: md = 0'; md = 0; vrfy(det(B) == res(-1), '3111: det(B) == res(-1)'); md = 1; print '3112: md = 1'; vrfy(det(B) == 0, '3113: det(B) == 0'); md = 2; print '3114: md = 2'; vrfy(det(B) == res(1), '3115: det(B) == res(1)'); md = 3; print '3116: md = 3'; vrfy(det(B) == res(2), '3117: det(B) == res(2)'); md = 4; print '3118: md = 4'; vrfy(det(B) == res(3), '3119: det(B) == res(3)'); md = 5; print '3120: md = 5'; vrfy(det(B) == res(4), '3121: det(B) == res(4)'); md = 6; print '3122: md = 6'; vrfy(det(B) == res(5), '3123: det(B) == res(5)'); md = 7; print '3124: md = 7'; vrfy(det(B) == res(6), '3125: det(B) == res(6)'); md = 8; print '3126: md = 8'; vrfy(det(B) == res(7), '3127: det(B) == res(7)'); md = 9; print '3128: md = 9'; vrfy(det(B) == res(8), '3129: det(B) == res(8)'); md = 10; print '3130: md = 10'; vrfy(det(B) == res(9), '3131: det(B) == res(9)'); md = 11; print '3132: md = 11'; vrfy(det(B) == res(10), '3133: det(B) == res(10)'); md = 12; print '3134: md = 12'; vrfy(det(B) == res(11), '3135: det(B) == res(11)'); md = 13; print '3136: md = 13'; vrfy(det(B) == res(12), '3137: det(B) == res(12)'); md = 14; print '3138: md = 14'; vrfy(det(B) == res(13), '3139: det(B) == res(13)'); md = 15; print '3140: md = 15'; vrfy(det(B) == res(14), '3141: det(B) == res(14)'); print '3142: Ending test_matobj'; } print '046: parsed test_matobj()'; /* * test_poly - test the polynomial function */ define test_poly() { print '3200: Beginning test_matobj'; vrfy(poly(2,3,5,2) == 19, '3201: poly(2,3,5,2) == 19'); vrfy(poly(list(5,3,2),2) == 19,\ '3202: poly(list(5,3,2),2) == 19'); vrfy(poly(list(5,3,2)) == 5, '3203: poly(list(5,3,2)) == 5'); vrfy(poly(2) == 2, '3204: poly(2) == 2'); vrfy(poly(list(5,3,2),2,3) == 19,\ '3205: poly(list(5,3,2),2,3) == 19'); vrfy(poly(list()) == 0, '3206: poly(list()) == 0'); vrfy(poly(list(),2,3) == 0, '3207: poly(list(),2,3) == 0'); vrfy(poly(list(list(5,3,2)),7,2) == 19,\ '3208: poly(list(list(5,3,2)),7,2) == 19'); vrfy(poly(list(list(1,2,3),list(4,5),6),7) == 323,\ '3209: poly(list(list(1,2,3),list(4,5),6),7) == 323'); vrfy(poly(list(list(1,2,3),list(4,5),6),7,8) == 811,\ '3210: poly(list(list(1,2,3),list(4,5),6),7,8) == 811'); vrfy(poly(list(list(1,2,3),list(4,5),6),7,8,9) == 811,\ '3211: poly(list(list(1,2,3),list(4,5),6),7,8,9)==811'); vrfy(poly(list(5,3,2), list()) == 5,\ '3212: poly(list(5,3,2), list() == 5'); vrfy(poly(list(5,3,2), list(2)) == 19,\ '3213: poly(list(5,3,2), list(2)) == 19'); vrfy(poly(list(5,3,2), list(2,3)) == 19,\ '3214: poly(list(5,3,2), list(2,3)) == 19'); vrfy(poly(list(list(list(0,0,0,0,0,1))),2,3,4) == 4^5,\ '3215: poly(list(list(list(0,0,0,0,0,1))),2,3,4)==4^5'); vrfy(poly(list(list(list(0,0,0,0,0,1))),2,list(3,4)) == 4^5,\ '3216: poly(list(list(list(0,0,0,0,0,1))),2,list(3,4))==4^5'); print '3217: Ending test_poly'; } print '047: parsed test_poly()'; /* * test_det - more determinent testing */ read -once "test3300"; print '048: read -once test3300'; /**/ define test_det() { local tnum; /* test number */ local i; print '3300: Beginning test_det'; tnum = test3300(1, 3301); print tnum: ': Ending test_det'; } print '049: parsed test_det()'; /* * test_trig - trig function testing */ read -once "test3400"; print '050: read -once test3400'; /**/ define test_trig() { local tnum; /* test number */ local i; print '3400: Beginning test_trig'; tnum = test3400(1, 3401); print tnum: ': Ending test_trig'; } print '051: parsed test_trig()'; /* * test_frem - tests of the functions frem, fcnt, gcdrem */ read -once "test3500"; print '052: read -once test3500'; /**/ define test_frem() { local tnum; /* test number */ print '3500: Beginning test_frem'; tnum = test3500(1, 3501, 200, 61); print tnum: ': Ending test_frem'; } print '053: parsed test_frem()'; /* * test_error - test the error() builtin * * This function is designed to trigger 148 errors, so we bump the * errmax by 148 during this call. */ define test_error() { local strx, e99, list1, e9999; local a, b, c, n, x; /* used by newerror() */ print '3600: Beginning test_error'; /* bump ecnt up by 148 */ ecnt += 148; print '3601: ecnt += 148'; strx = "x"; print '3602: strx = "x"'; e99 = error(99); print '3603: e99 = error(99)'; vrfy(1/0 == error(10001), '3604: 1/0 == error(10001)'); vrfy(0/0 == error(10002), '3605: 0/0 == error(10002)'); vrfy(2 + "x" == error(10003), '3606: 2 + "x" == error(10003)'); vrfy("x" - 2 == error(10004), '3607: "x" - 2 == error(10004)'); vrfy("x" * "y" == error(10005), '3608: "x" * "y" == error(10005)'); vrfy("x" / "y" == error(10006), '3609: "x" / "y" == error(10006)'); vrfy(-list(1) == error(10007), '3610: -list(1) == error(10007)'); vrfy("x"^2 == error(10008), '3611: "x"^2 == error(10008)'); vrfy(inverse("x")==error(10009),'3612: inverse("x") == error(10009)'); vrfy(++strx == error(10010), '3613: ++strx == error(10010)'); vrfy(strx == error(10010), '3614: strx == error(10010)'); strx = "x"; print '3615: strx = "x"'; vrfy(strx++ == "x", '3616: strx++ == "x"'); vrfy(strx == error(10010), '3617: strx == error(10010)'); strx = "x"; print '3618: strx = "x"'; vrfy(--strx == error(10011), '3619: strx == error(10011)'); vrfy(int("x") == error(10012), '3620: int("x") == error(10012)'); vrfy(frac("x") == error(10013), '3621: frac("x") == error(10013)'); vrfy(conj("x") == error(10014), '3622: conj("x") == error(10014)'); vrfy(appr("x",.1) == error(10015), '3623: appr("x",.1) == error(10015)'); vrfy(appr(1.27,.1i) == error(10016), '3624: appr(1.27,.1i) == error(10016)'); vrfy(appr(1.27,.1,.1) == error(10017), '3625: appr(1.27,.1,.1) == error(10017)'); vrfy(round("x") == error(10018), '3626: round("x") == error(10018)'); vrfy(round(1.25,.1) == error(10019), '3627: round(1.25,.1) == error(10019)'); vrfy(round(1.25,"x") == error(10019), '3628: round(1.25,"x") == error(10019)'); vrfy(round(1.25,1,.1) == error(10020), '3629: round(1.25,1,.1) == error(10020)'); vrfy(bround("x") == error(10021), '3630: bround("x") == error(10021)'); vrfy(bround(1.25,.1) == error(10022), '3631: bround(1.25,.1) == error(10022)'); vrfy(bround(1.25,"x") == error(10022), '3632: bround(1.25,"x") == error(10022)'); vrfy(bround(1.25,1,.1) == error(10023), '3633: bround(1.25,1,.1) == error(10023)'); vrfy(sqrt("x") == error(10024), '3634: sqrt("x") == error(10024)'); vrfy(sqrt(2,"x") == error(10025), '3635: sqrt(2,"x") == error(10025)'); vrfy(sqrt(2,0) == error(10025), '3636: sqrt(2,0) == error(10025)'); vrfy(sqrt(2,.1,.1) == error(10026), '3637: sqrt(2,.1,.1) == error(10026)'); vrfy(root("x",3) == error(10027), '3638: root("x",3) == error(10027)'); vrfy(root(3,"x") == error(10028), '3639: root(3,"x") == error(10028)'); vrfy(root(3,-2) == error(10028), '3640: root(3,-2) == error(10028)'); vrfy(root(3,0) == error(10028), '3641: root(3,0) == error(10028)'); vrfy(root(3,.1) == error(10028), '3642: root(3,.1) == error(10028)'); vrfy(root(3,2,"x") == error(10029), '3643: root(3,2,"x") == error(10029)'); vrfy(root(3,2,0) == error(10029), '3644: root(3,2,0) == error(10029)'); vrfy(norm("x") == error(10030), '3645: norm("x") == error(10030)'); vrfy(list() << 2 == error(10031),'3646: list() << 2 == error(10031)'); vrfy(1.5 << 2 == error(10031), '3647: 1.5 << 2 == error(10031)'); vrfy(3 << "x" == error(10032), '3648: 3 << "x" == error(10032)'); vrfy(3 << 1.5 == error(10032), '3649: 3 << 1.5 == error(10032)'); vrfy(3 << 2^31 == error(10032), '3650: 3 << 2^31 == error(10032)'); vrfy(scale("x",2) == error(10033), '3651: scale("x",2) == error(10033)'); vrfy(scale(3,"x") == error(10034), '3652: scale(3,"x") == error(10034)'); vrfy(scale(3,1.5) == error(10034), '3653: scale(3,1.5) == error(10034)'); vrfy(scale(3,2^31) == error(10034), '3654: scale(3,2^31) == error(10034)'); vrfy("x" ^ 3 == error(10035), '3655: "x" ^ 3 == error(10035)'); vrfy(2 ^ "x" == error(10036), '3656: 2 ^ "x" == error(10036)'); vrfy(2 ^ "2" == error(10036), '3657: 2 ^ "2" == error(10036)'); vrfy(power("x",2.1) == error(10037), '3658: power("x",2.1) == error(10037)'); vrfy(power(2,"x") == error(10038), '3659: power(2,"x") == error(10038)'); vrfy(power(2,2.1,"x") == error(10039), '3660: power(2,2.1,"x") == error(10039)'); vrfy(quo("x",3) == error(10040), '3661: quo("x",3) == error(10040)'); vrfy(quo(8,"x") == error(10041), '3662: quo(8,"x") == error(10041)'); vrfy(quo(8,3,"x") == error(10042), '3663: quo(8,3,"x") == error(10042)'); vrfy(quo(8,3,2.1) == error(10042), '3664: quo(8,3,2.1) == error(10042)'); vrfy(mod("x",3) == error(10043), '3665: mod("x",3) == error(10043)'); vrfy(mod(8,"x") == error(10044), '3666: mod(8,"x") == error(10044)'); vrfy(mod(8,3,"x") == error(10045), '3667: mod(8,3,"x") == error(10045)'); vrfy(mod(8,3,2.1) == error(10045), '3668: mod(8,3,2.1) == error(10045)'); vrfy(sgn("x") == error(10046), '3669: sgn("x") == error(10046)'); vrfy(abs("x") == error(10047), '3670: abs("x") == error(10047)'); vrfy(abs(2+3i,"x") == error(10048), '3671: abs(2+3i,"x") == error(10048)'); vrfy(abs(2+3i,0) == error(10048), '3672: abs(2+3i,0) == error(10048)'); list1 = list(2,3,"x",4,5); print '3673: list1 = list(2,3,"x",4,5)'; vrfy(avg(list1) == error(10003), '3674: avg(list1) == error(10003)'); vrfy(iserror(e99)==99, '3675: iserror(e99) == 99'); vrfy(e99 + 2 == e99, '3676: e99 + 2 == e99'); vrfy(e99 - 2 == e99, '3677: e99 - 2 == e99'); vrfy(e99 * 2 == e99, '3678: e99 * 2 == e99'); vrfy(e99 / 2 == e99, '3679: e99 / 2 == e99'); vrfy(e99 // 2 == e99, '3680: e99 // 2 == e99'); vrfy(e99 % 2 == e99, '3681: e99 % 2 == e99'); vrfy(e99 ^ 2 == e99, '3682: e99 ^ 2 == e99'); vrfy(2 + e99 == e99, '3683: 2 + e99 == e99'); vrfy(2 - e99 == e99, '3684: 2 - e99 == e99'); vrfy(2 * e99 == e99, '3685: 2 * e99 == e99'); vrfy(2 / e99 == e99, '3686: 2 / e99 == e99'); vrfy(2 // e99 == e99, '3687: 2 // e99 == e99'); vrfy(2 % e99 == e99, '3688: 2 % e99 == e99'); vrfy(2 ^ e99 == e99, '3689: 2 ^ e99 == e99'); vrfy(- e99 == e99, '3690: -e99 == e99'); vrfy(inverse(e99) == e99, '3691: inverse(e99) == e99'); vrfy(++e99 == e99, '3692: ++e99 == e99'); vrfy(--e99 == e99, '3693: --e99 == e99'); vrfy(int(e99) == e99, '3694: int(e99) == e99'); vrfy(frac(e99) == e99, '3695: frac(e99) == e99'); vrfy(conj(e99) == e99, '3696: conj(e99) == e99'); vrfy(norm(e99) == e99, '3697: norm(e99) == e99'); vrfy(sgn(e99) == e99, '3698: sgn(e99) == e99'); vrfy(appr(e99,1,0) == e99, '3699: appr(e99,1,0) == e99'); vrfy(round(e99) == e99, '3700: round(e99) == e99'); vrfy(bround(e99) == e99, '3701: bround(e99) == e99'); vrfy(sqrt(e99) == e99, '3702: sqrt(e99) == e99'); print '3703: a = newerror("alpha")'; a = newerror("alpha"); print '3704: b = newerror("beta")'; b = newerror("beta"); print '3705: c = newerror("alpha")'; c = newerror("alpha"); vrfy(a == c, '3706: a == c'); vrfy(strerror(a) == "alpha", '3707: strerror(a) == "alpha"'); print '3708: n = iserror(a)'; n = iserror(a); vrfy(a == error(n), '3709: a == error(n)'); vrfy(newerror() == newerror("???"), '3710: newerror() == newerror("???")'); vrfy(newerror("") == newerror(), '3711: newerror("") == newerror()'); e9999 = error(9999); print '3712: e9999 = error(9999)'; vrfy(errno() == 9999, '3713: errno() == 9999'); vrfy(error() == e9999, '3714: error() == e9999'); /* test 3715 removed due to non-portable strerror() output */ x = newerror("Alpha"); print '3716: x = newerror("Alpha")'; n = iserror(x); print '3717: n = iserror(x)'; vrfy(errno() == n, '3718: errno() == n'); vrfy(error() == x, '3719: error() == x'); vrfy(strerror() == "Alpha", '3720: strerror() == "Alpha"'); vrfy(errno(9999) == n, '3721: errno() == n'); vrfy(errno() == 9999, '3722: errno() == 9999'); vrfy(error() == e9999, '3723: error() == e9999'); /* test 3724 removed due to non-portable strerror() output */ a = 1/0; print '3725: a = 1/0'; vrfy(strerror() == "Division by zero", '3726: strerror() == "Division by zero"'); n = 8191; print '3727: n = 8191'; /* test 3728 removed due to non-portable strerror() output */ /* errmax and errcount should be bumped up the 148 errors above */ vrfy(errcount() == ecnt, '3729: errcount() == ecnt'); print '3730: Ending test_error'; } print '054: parsed test_error()'; /* * test_param - test new param() functionality. */ define g_param() = (param(2) = param(1)); print '055: define g_param() = (param(2) = param(1))'; define h_param() = (param(1)++, param(2)--); print '056: define h_param() = (param(1)++, param(2)--)'; /**/ global u_glob = 5; print '057: global u_glob = 5'; global v_glob = 10; print '058: global v_glob = 10'; vrfy(g_param(u_glob, `v_glob) == 5, '059: g_param(u_glob, `v_glob) == 5'); vrfy(u_glob == 5, '060: u_glob == 5'); vrfy(v_glob == 5, '061: v_glob == 5'); vrfy(h_param(`u_glob, `v_glob) == 5, '062: h_param(`u_glob, `v_glob) == 5'); vrfy(u_glob == 6, '063: u_glob == 6'); vrfy(v_glob == 4, '064: v_glob == 4'); /**/ define test_param() { local u, v; print '3800: Beginning test_param'; u = 5; print '3801: u = 5'; v = 10; print '3802: v = 10'; vrfy(g_param(u, `v) == 5, '3803: g_param(u, `v) == 5'); vrfy(u == 5, '3804: u == 5'); vrfy(v == 5, '3805: v == 5'); vrfy(h_param(`u, `v) == 5, '3806: h_param(`u, `v) == 5'); vrfy(u == 6, '3807: u == 6'); vrfy(v == 4, '3808: v == 4'); print '3809: Ending test_param'; } print '065: parsed test_param()'; /* * test_noarg - test missing argment functionality */ define test_noarg() { local A,B,C,D; print '3900: Beginning test_noarg'; A = list(1,,3); print '3901: A = list(1,,3)'; vrfy(A[[0]] == 1, '3902: A[[0]] == 1'); vrfy(isnull(A[[1]]), '3903: isnull(A[[1]])'); vrfy(A[[2]] == 3, '3904: A[[2]] == 3'); vrfy(size(A) == 3, '3905: size(A) == 3'); B = list(,,); print '3906: B = list(,,)'; vrfy(isnull(B[[0]]), '3907: isnull(B[[0]])'); vrfy(isnull(B[[1]]), '3908: isnull(B[[1]])'); vrfy(isnull(B[[2]]), '3909: isnull(B[[2]])'); vrfy(size(B) == 3, '3910: size(B) == 3'); mat C[] = {,,}; print '3911: mat C[] = {,,}'; vrfy(C[0] == 0, '3912: C[0] == 0'); vrfy(C[1] == 0, '3913: C[1] == 0'); vrfy(C[2] == 0, '3914: C[2] == 0'); vrfy(size(C) == 3, '3915: size(C) == 3'); mat D[] = { }; print '3916: mat D[] = { }'; vrfy(D[0] == 0, '3917: D[0] == 0'); vrfy(size(D) == 1, '3918: size(D) == 1'); print '3919: Ending test_noarg'; } print '066: parsed test_noarg'; /* * test_ptest - more tests of the functions ptest, nextcand, prevcand */ read -once "test4000"; print '067: read -once test4000'; /**/ define test_ptest() { local tnum; /* test number */ print '4000: Beginning test_ptest'; tnum = test4000(1, 4001); print tnum: ': Ending test_ptest'; } print '068: parsed test_ptest()'; /* * test_redc - REDC operation tests */ read -once "test4100"; print '069: read -once test4100'; /**/ define test_redc() { local tnum; /* test number */ print '4100: Beginning test_redc'; tnum = test4100(1, 4101); print tnum: ': Ending test_redc'; } print '070: parsed test_redc()'; /* * test_fileops - test various file operations */ define test_fileops() { local a, b, c, f, m, n, p, r, s, x, y, z; local L = "Landon"; local C = "Curt"; local N = "Noll"; local LCN = "Landon\nCurt\nNoll\n"; local long = "0123456789abcdef0123456789abcdef"; print '4200: Beginning test_fileops'; /* * fputs tests */ x = rm("-f", "junk4200"); print '4201: x = rm("-f", "junk4200")'; vrfy(!iserror(f = fopen("junk4200", "w+")), '4202: !iserror(f = fopen("junk4200", "w+"))'); vrfy(!iserror(fputs(f, LCN)), '4203: !iserror(fputs(f, LCN))'); vrfy(isnull(rewind(f)), '4204: isnull(rewind(f))'); vrfy(fgetfield(f) == L, '4205: fgetfield(f) == L'); vrfy(fgetfield(f) == C, '4206: fgetfield(f) == C'); vrfy(fgetfield(f) == N, '4207: fgetfield(f) == N'); vrfy(isnull(fgetfield(f)), '4208: isnull(fgetfield(f))'); vrfy(isnull(rewind(f)), '4209: isnull(rewind(f))'); vrfy(fgetline(f) == L, '4210: fgetline(f) == L'); vrfy(fgetline(f) == C, '4211: fgetline(f) == C'); vrfy(fgetline(f) == N, '4212: fgetline(f) == N'); vrfy(isnull(fgetline(f)), '4213: isnull(fgetline(f))'); vrfy(isnull(rewind(f)), '4214: isnull(rewind(f))'); vrfy(fgets(f) == strcat(L,"\n"), '4215: fgets(f) == strcat(L,"\\n")'); vrfy(fgets(f) == strcat(C,"\n"), '4216: fgets(f) == strcat(C,"\\n")'); vrfy(fgets(f) == strcat(N,"\n"), '4217: fgets(f) == strcat(N,"\\n")'); vrfy(isnull(fgets(f)), '4218: isnull(fgets(f))'); vrfy(isnull(rewind(f)), '4219: isnull(rewind(f))'); vrfy(fgetstr(f) == LCN, '4220: fgetstr(f) == LCN'); vrfy(isnull(fclose(f)), '4221: isnull(fclose(f))'); vrfy(isnull(fclose(f)), '4222: isnull(fclose(f))'); /* * fgetstr tests */ vrfy(!iserror(f = fopen("junk4200", "w+")), '4223: !iserror(f)'); vrfy(isnull(fputstr(f, L, C, N)), '4224: isnulll(fputstr(f, L, C, N))'); vrfy(isnull(rewind(f)), '4225: isnull(rewind(f))'); vrfy(fgetstr(f) == L, '4226: fgetstr(f) == L'); vrfy(fgetstr(f) == C, '4227: fgetstr(f) == C'); vrfy(fgetstr(f) == N, '4228: fgetstr(f) == N'); vrfy(isnull(fgetstr(f)), '4229: isnull(fgetstr(f))'); n = ftell(f); print '4230: n = ftell(f)'; vrfy(isnull(fputs(f,L,"\n",C,"\n",N,"\n")), '4231: isnull(fputs(f,L,"\\n",C,"\\n",N,"\\n"))'); fseek(f, n); print '4232: fseek(f, n)'; vrfy(fgetstr(f) == LCN, '4233: fgetstr(f) == LCN'); vrfy(isnull(fclose(f)), '4234: isnull(fclose(f))'); /* * fscanf tests */ a = exp(27, 1e-1000); print '4235: a = exp(27, 1e-1000)'; b = sqrt(7 + 5i, 1e-2000); print '4236: b = sqrt(7 + 5i, 1e-2000)'; c = config("display", 1000); print '4237: c = config("display", 1000)'; vrfy(!iserror(f=fopen("junk4200","w+")), '4238: !iserror(f=fopen("junk4200","w+"))'); vrfy(!iserror(fprintf(f, "%f\n\tand\n\t%r",a,b)), '4239: !iserror(fprintf(f, "%f\\n\\tand\\n\\t%r",a,b))'); vrfy(isnull(rewind(f)), '4240: isnull(rewind(f))'); vrfy(fscanf(f,"%f and %r",x,y)==2, '4241: fscanf(f,"%f and %r",x,y)==2'); vrfy(x == a && y == b, '4242: x == a && y == b'); vrfy(!iserror(freopen(f, "w+")), '4243: !iserror(freopen(f, "w+"))'); L = "Landon\n"; print '4244: L = "Landon\\n"'; C = "\tCurt\n"; print '4245: C = "\tCurt\\n"'; N = "\t\tNoll\n"; print '4246: N = "\\t\\tNoll\\n"'; vrfy(isnull(fputs(f, L, "|", C, "[", N, "]" )), '4247: isnull(fputs(f, L, "|", C, "[", N, "]" ))'); vrfy(isnull(rewind(f)), '4248: isnull(rewind(f))'); vrfy(fscanf(f, "%[^|]%*c%[^[]%*c%[^]]", x,y,z) == 3, '4249: fscanf(f, "%[^|]%*c%[^[]%*c%[^]]", x,y,z) == 3'); vrfy(x == L && y == C && z == N, '4250: x == L && y == C && z == N'); vrfy(isnull(rewind(f)), '4251: isnull(rewind(f))'); vrfy(fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2, '4252: fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2'); fseek(f, m); print '4253: fseek(f, m)'; vrfy(fscanf(f, "%3c", x) == 1, '4254: fscanf(f, "%3c", x) == 1'); vrfy(x == "\tCu", '4255: x == "\tCu"'); fseek(f, n); print '4256: fseek(f, n)'; vrfy(fscanf(f, "%s", y) == 1, '4257: fscanf(f, "%s", y) == 1'); vrfy(y == "Noll", '4258: y == "Noll"'); vrfy(isnull(fclose(f)), '4259: isnull(fclose(f))'); /* * fpathopen tests */ vrfy(!iserror(p=fpathopen("junk4200","r",".")), '4260: !iserror(p=fparhopen("junk4200","r","."))'); vrfy(!iserror(fclose(p)), '4261: !iserror(fclose(p))'); vrfy(!iserror(r=fpathopen("regress.cal","r")), '4262: !iserror(r=fparhopen("regress.cal","r","."))'); vrfy(!iserror(fclose(r)), '4263: !iserror(fclose(r))'); /* * verify non-stack overflow on long filenames */ long = long + long + long + long; print '4264: long = long + long + long + long;'; long = long + long + long + long; print '4265: long = long + long + long + long;'; vrfy(strlen(long) == 512, '4266: strlen(long) == 512'); /* bump ecnt up by 1 */ ++ecnt; print '4267: ++ecnt;'; vrfy(isfile(p=fopen(long,"r")) == 0, '4268: isfile(p=fopen(long,"r")) == 0'); /* * test fgetfile() and fgetline() */ vrfy(!iserror(p=fopen("tmp4200","w")), '4269: !iserror(p=fopen("tmp4200","w"))'); vrfy(!iserror(fputs(p,"chongo\n")), '4270: !iserror(fputs(p,"chongo\n"))'); vrfy(!iserror(fputs(p,"w\0a\0s\n")), '4271: !iserror(fputs(p,"w\0a\0s\n"))'); vrfy(!iserror(fputs(p,"here\n")), '4272: !iserror(fputs(p,"here\n"))'); vrfy(!iserror(fclose(p)), '4273: !iserror(fclose(p))'); vrfy(!iserror(p=fopen("tmp4200","r")), '4274: !iserror(p=fopen("tmp4200","r"))'); vrfy(!iserror(s=fgetline(p)), '4275: !iserror(s=fgetline(p))'); vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0'); vrfy(!iserror(s=fgetfile(p)), '4277: !iserror(s=fgetfile(p))'); vrfy(strcmp(s,"w\0a\0s\nhere\n") == 0, '4278: strcmp(s,"w\0a\0s\nhere\n") == 0'); vrfy(!iserror(fclose(p)), '4279: !iserror(fclose(p))'); /* * cleanup */ x = rm("junk4200"); print '4280: x = rm("junk4200")'; x = rm("tmp4200"); print '4281: x = rm("tmp4200")'; print '4282: Ending test_fileops'; } print '071: parsed test_fileops()'; /* * test_matdcl - test new matrix declaration syntax */ mat_X0 = mat[4]; print '072: mat_X = mat[4]'; mat mat_X1, mat_X2[2]; mat mat_X3[3]; print '073: mat mat_X1, mat_X2[2]; mat mat_X3[3]'; mat mat_Z0, mat_Z1 [2] = {1,2}; print '074: mat mat_Z0, mat_Z1 [2] = {1,2}'; define test_matdcl() { local mat_Y0; local mat mat_Y1, mat_Y2[2], mat_Y3[3]; local mat M0, M1, M2[2,2]; local i; print '4300: Beginning test_matdcl'; vrfy(size(mat_X0) == 4, '4301: size(mat_X0) == 4'); vrfy(size(mat_X1) == 2, '4302: size(mat_X1) == 2'); vrfy(size(mat_X2) == 2, '4303: size(mat_X2) == 2'); vrfy(size(mat_X3) == 3, '4304: size(mat_X3) == 3'); vrfy(ismat(mat_X0), '4305: ismat(mat_X0)'); vrfy(ismat(mat_X1), '4306: ismat(mat_X1)'); vrfy(ismat(mat_X2), '4307: ismat(mat_X2)'); vrfy(ismat(mat_X3), '4308: ismat(mat_X3)'); mat_Y0 = mat[4]; print '4309: mat_Y0 = mat[4]'; vrfy(size(mat_Y0) == 4, '4310: size(mat_Y0) == 4'); vrfy(size(mat_Y1) == 2, '4311: size(mat_Y1) == 2'); vrfy(size(mat_Y2) == 2, '4312: size(mat_Y2) == 2'); vrfy(size(mat_Y3) == 3, '4313: size(mat_Y3) == 3'); vrfy(ismat(mat_Y0), '4314: ismat(mat_Y0)'); vrfy(ismat(mat_Y1), '4315: ismat(mat_Y1)'); vrfy(ismat(mat_Y2), '4316: ismat(mat_Y2)'); vrfy(ismat(mat_Y3), '4317: ismat(mat_Y3)'); vrfy(size(mat_Z0) == 2, '4318: size(mat_Z0) == 2'); vrfy(size(mat_Z1) == 2, '4319: size(mat_Z1) == 2'); vrfy(ismat(mat_Z0), '4320: ismat(mat_Z0)'); vrfy(ismat(mat_Z1), '4321: ismat(mat_Z1)'); vrfy(mat_Z0 == mat_Z1, '4322: mat_Z0 == mat_Z1'); vrfy(mat_Z0 == (mat[2] = {1,2}), '4323: mat_Z0 == (mat[2] = {1,2})'); vrfy(mat_Z0[0] == 1, '4324: mat_Z0[0] == 1'); vrfy(mat_Z0[1] == 2, '4325: mat_Z0[1] == 2'); mat_Z1 = {,3}; print '4326: mat_Z1 = {,3}'; vrfy(mat_Z0 != mat_Z1, '4327: mat_Z0 != mat_Z1'); vrfy(mat_Z1[0] == 1, '4328: mat_Z1[0] == 1'); vrfy(mat_Z1[1] == 3, '4329: mat_Z1[1] == 3'); mat_X3 = {2,3,5}; print '4330: mat_X3 = {2,3,5}'; mat_X3 += {3,4,5}; print '4331: mat_X3 += {3,4,5}'; vrfy(mat_X3[0] == 5, '4332: mat_X3[0] == 5'); vrfy(mat_X3[1] == 7, '4333: mat_X3[1] == 7'); vrfy(mat_X3[2] == 10, '4334: mat_X3[2] == 10'); mat_Y3 = mat_X3; print '4335: mat_Y3 = mat_X3'; mat_Y3 -= {,1,2}; print '4336: mat_Y3 -= {0,1,}'; vrfy(mat_Y3[0] == 0, '4337: mat_Y3[0] == 0'); vrfy(mat_Y3[1] == 6, '4338: mat_Y3[1] == 6'); vrfy(mat_Y3[2] == 8, '4339: mat_Y3[2] == 8'); ecnt += 2; print '4340: ecnt += 2'; mat_Y3 += 2; print '4341: mat_Y3 += 2'; vrfy(mat_Y3 == error(10003), '4342: mat_Y3 == error(10003)'); vrfy(errcount() == ecnt, '4343: errcount() == ecnt'); mat_Z0 += { }; print '4344: mat_Z0 += { }'; vrfy(mat_Z0[0] == 2, '4345: mat_Z0[0] == 2'); vrfy(mat_Z0[1] == 4, '4346: mat_Z0[1] == 4'); mat_Y0 = {mat_Z0, ,mat_Z1, mat_X3}; print '4347: mat_Y0 = {mat_Z0, ,mat_Z1, mat_X3}'; vrfy(size(mat_Y0) == 4, '4348: size(mat_Y0) == 4'); for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i]); print '4349: for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i])'; mat_X0==(mat[4]={2,1,2,3}); print '4350: mat_X0==(mat[4]={2,1,2,3})'; vrfy(mat_Y0[0] == mat_Z0, '4351: mat_Y0[0] == mat_Z0'); vrfy(mat_Y0[1] == 0, '4352: mat_Y0[1] == 0'); vrfy(mat_Y0[2] == mat_Z1, '4353: mat_Y0[2] == mat_Z1'); vrfy(mat_Y0[3] == mat_X3, '4354: mat_Y0[3] == mat_X3'); vrfy(mat_Y0[0][0] == 2, '4355: mat_Y0[0][0] == 2'); vrfy(mat_Y0[0][1] == 4, '4356: mat_Y0[0][1] == 4'); vrfy(mat_Y0[2][0] == 1, '4357: mat_Y0[2][0] == 1'); vrfy(mat_Y0[2][1] == 3, '4358: mat_Y0[2][1] == 3'); vrfy(mat_Y0[3][0] == 5, '4359: mat_Y0[3][0] == 5'); vrfy(mat_Y0[3][1] == 7, '4360: mat_Y0[3][1] == 7'); vrfy(mat_Y0[3][2] == 10, '4361: mat_Y0[3][2] == 10'); M0 = {(mat[2]={5,17}),(mat[2]={3,4}),(mat[2]={2,3}),(mat[2]={1,2})}; print '4362: M0 = {(mat[2]={5,17}), ...}'; M1 = {(mat[2]={5,3}),(mat[2]={2,5}),(mat[2]={1,5}),(mat[2]={3,2})}; print '4363: M1 = {(mat[2]={5,3}), ...}'; M2 = M0+M1; print '4364: M2 = M0+M1'; vrfy(M2[0,0]==(mat[2]={10,20}), '4365: M2[0,0]==(mat[2]={10,20})'); vrfy(M2[0,1]==(mat[2]={5,9}), '4366: M2[0,1]==(mat[2]={5,9})'); vrfy(M2[1,0]==(mat[2]={3,8}), '4367: M2[1,0]==(mat[2]={3,20})'); vrfy(M2[1,1]==(mat[2]={4,4}), '4368: M2[1,1]==(mat[2]={4,4})'); print '4369: Ending test_matdcl'; } print '075: parsed test_matdcl()'; /* * test_objmat - test combined obj and mat operations */ define test_objmat() { static obj surd P, R, S, T, U; local mat M0[2] = {5,17}; local mat M1[2] = {3,4}; local mat M2[2,2] = {1,2,3,5}; local mat M3[2,2] = {3,5,7,11}; local mat M4[2,2] = {51,82,116,187}; local Q; local V; local A,B,C,M; print '4400: Beginning test_objmat'; surd_type = -1; print '4401: surd_type == -1'; P = {M0,M1}; print '4402: P = {M0,M1}'; vrfy(P == surd(M0,M1), '4403: P == surd(M0,M1)'); vrfy(P != surd(M1,M0), '4404: P != surd(M1,M0)'); vrfy(conj(P)==surd(M0,-M1), '4405: conj(P)==surd(M0,-M1)'); Q = surd_value(P); print '4406: Q = surd_value(P)'; vrfy(ismat(Q), '4407: ismat(Q)'); vrfy(Q == (mat[2]={5+3i,17+4i}), '4408: Q == (mat[2]={5+3i,17+4i})'); R = {M2,M3}; print '4409: R = {M2,M3}'; vrfy(norm(R) == M4, '4410: norm(R) == M4'); vrfy(det(surd_value(R^2)) == -23-6i, \ '4411: det(surd_value(R^2)) == -23-6i'); vrfy(det(norm(R^5))==268107761663283843865, \ '4412: det(norm(R^5))==268107761663283843865'); S = {M2+M3, M2-M3}; print '4413: S = {M2+M3, M2-M3}'; T = {M2+3*M3, 5*M2-M3}; print '4414: T = {M2+3*M3, 5*M2-M3}'; U = {(M4 -= {50,80,110,180}), M4+M2}; print '4415: U = {(M4 -= {50,80,110,180}), M4+M2}'; vrfy(det(surd_value(R*S*T*U)) == 480-15040i, '4416: det(surd_value(R*S*T*U)) == 480-15040i'); vrfy(det(surd_value(R*S+T*U)) == 78+514i, '4417: det(surd_value(R*S+T*U)) == 78+514i'); V = norm(det(surd_value(R^5+S^5+T^5+U^5))); print '4418: V = norm(det(surd_value(R^5+S^5+T^5+U^5)))'; vrfy(V == 41952632964892462488299378, \ '4419: V == 41952632964892462488299378'); V = norm(det(surd_value(R^5-S^5+T^5-U^5))); print '4420: V = norm(det(surd_value(R^5-S^5+T^5-U^5)))'; vrfy(V == 40891924356202870926321650, \ '4421: V == 40891924356202870926321650'); vrfy((mat [3] = {2,3,5})+(mat[3] = {7,11,13}) == (mat[3]={9,14,18}),\ '4422: (mat [3] = {2,3,5})+(mat[3] = {7,11,13}) == (mat[3]={9,14,18})'); vrfy((mat [2,2] = {2,3,5,7})^2 == (mat[2,2] = {19, 27, 45, 64}),\ '4423: (mat [2,2] = {2,3,5,7})^2 == (mat[2,2] = {19, 27, 45, 64})'); vrfy((mat [] = {1,2,3}) == (mat[3] = {1,2,3}), '4424: (mat [] = {1,2,3}) == (mat[3] = {1,2,3})'); mat A[3] = {2,3,5}; print '4425: mat A[3] = {2,3,5}'; mat A[3] = {A[0], A[2], A[1]}; print '4426: mat A[3] = {A[0], A[2], A[1]}'; vrfy(A == (mat[3] = {2, 5, 3}), '4427: A == (mat[3] = {2, 5, 3})'); B = mat[3] = {2,5,3}; print '4428: B = mat[3] = {2,5,3}'; vrfy(A == B, '4429: A == B'); mat A[2] = {A[1], A[2]}; print '4430: mat A[2] = {A[1], A[2]}'; vrfy(A == (mat[2] = {5, 3}), '4431: A == (mat[2] = {5, 3})'); A = B; print '4432: A = B'; A = {A[0], A[2], A[1]}; print '4433: A = {A[0], A[2], A[1]}'; vrfy(A == (mat[3] = {2, 3, 3}), '4434: A == (mat[3] = {2, 3, 3})'); A = mat[3] = {1,2} = {,3,4}; print '4435: A = mat[3] = {1,2} = {,3,4}'; vrfy(A == (mat[3] = {1,3,4}), '4436: A == (mat[3] = {1,3,4})'); mat A[4] = {1,2,3,4}; print '4437: mat A[4] = {1,2,3,4}'; A = {,5,,6}; print '4438: A = {,5,,6}'; vrfy(A == (mat[4] = {1,5,3,6}), '4439: A == (mat[4] = {1,5,3,6})'); A = {7}; print '4440: A = {7}'; vrfy(A == (mat[4] = {7,5,3,6}), '4441: A == (mat[4] = {7,5,3,6})'); mat M[2]; print '4442: mat M[2]'; mat A, B, C [3] = {M, M, M}; print '4443: mat A, B, C [3] = {M, M, M}'; A = {{2, 3}, {5, 7}, {11, 13}}; print '4444: A = {{2, 3}, {5, 7}, {11, 13}}'; B = {{1, 2}, {3, 4}, {5, 6}}; print '4445: B = {{1, 2}, {3, 4}, {5, 6}}'; C = {{3, 5}, {8, 11}, {16, 19}}; print '4446: C = {{3, 5}, {8, 11}, {16, 19}}'; vrfy(A + B == C, '4447: A + B == C'); mat A[2][3]; print '4448: mat A[2][3]'; A = {{1, 2, 3}, {4, 5, 6}}; print '4449: A = {{1, 2, 3}, {4, 5, 6}}'; vrfy(A[0][1] == 2, '4450: A[0][1] == 2'); vrfy(A[1,0] == 4, '4451: A[1,0] == 4'); B = mat[2][3] = {{1, 2, 3}, {4, 5, 6}}; print '4452: B = mat[2][3] = {{1, 2, 3}, {4, 5, 6}}'; vrfy(A == B, '4453: A == B'); mat A[2][3] = {{1, 2, 3}, {4, 5, 6}}; print '4454: mat A[2][3] = {{1, 2, 3}, {4, 5, 6}}'; vrfy(A == B, '4455: A == B'); mat A[2][3] = {{1,2,3},4}; print '4456: mat A[2][3] = {{1,2,3},4}'; vrfy(A[0] == (mat[3] = {1,2,3}), '4457: A[0] == (mat[3] = {1,2,3})'); vrfy(A[1] == 4, '4458: A[1] == 4'); A += {{3,5,7}, 11}; print '4459: A += {{3,5,7}, 11}'; vrfy(A[0] == (mat[3]={4,7,10}), '4460: A[0] == (mat[3]={4,7,10})'); vrfy(A[1] == 15, '4461: A[1] == 15'); mat A[2,2][2,2]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}; print '4462: mat A[2,2][2,2]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}'; B = A^2; print '4463: B = A^2'; vrfy(B[0,0] == (mat[2,2] = {118, 132, 166, 188}), \ '4464: B[0,0] == (mat[2,2] = {118, 132, 166, 188})'); print '4465: Ending test_objmat'; print; print '4500: reserved for future expansion of test_objmat'; } print '076: parsed test_objmat()'; /* * test_fileop - test file operations */ read -once "test4600"; print '077: read -once test4600'; /**/ define test_fileop() { local tnum; /* test number */ print '4600: Beginning test_fileop'; tnum = test4600(1, 4601); print tnum: ': Ending test_fileop'; } print '078: parsed test_fileop()'; /* * test write/read */ x_081 = isqrt(2e5000); print '079: x_081 = isqrt(2e5000)' s_x_081 = str(x_081); print '080: s_x_081 = str(x_081)'; d_081 = rm("-f", "test082.cal"); print '081: d_081 = rm("-f", "test082.cal")'; write test082.cal; print '082: write test082.cal'; read "./test082.cal"; print '083: read "./test082.cal"'; d_081 = rm("test082.cal"); print '084: d081 = rm("test082.cal")'; vrfy(__ == 63, '085: __ == 63'); vrfy(x_081 == isqrt(2e5000), '086: x_081 == isqrt(2e5000)'); /* * test_charset - test the ASCII character set and \'s */ define test_charset() { print '4700: Beginning test_charset'; vrfy("\a" == char(7), '4701: "\\a" == char(7)'); vrfy("\v" == char(11), '4702: "\\v" == char(11)'); vrfy("\e" == char(27), '4703: "\\e" == char(27)'); vrfy("\\" == char(92), '4704: "\\\\" == char(92)'); vrfy("\101" == "A", '4705: "\\101" == "A"'); vrfy("\123" == char(0123), '4706: "\\123" == char(0123)'); vrfy("\123\124" == "ST", '4707: "\\123\\124" == "ST"'); vrfy("\311" == char(201), '4708: "\\311" == char(201)'); vrfy("\119" == "\t9", '4709: "\\119" == "\t9"'); vrfy("\765" == "\365", '4710: "\\765" == "\365"'); vrfy("\x61" == "a", '4711: "\\x61" == "a"'); vrfy("\x73" == "s", '4712: "\\x73" == "s"'); vrfy("\xea" == char(234), '4713: "\\xea" == char(234)'); vrfy("\x61\x62\x63" == "abc", '4714: "\\x61\\x62\\x63" == "abc"'); vrfy("\x8g" == "\bg", '4715: "\\x8g" == "\bg"'); vrfy(eval('"\\\\"') == "\\", '4716: eval(\'"\\\\\\\\"\') == "\\\\"'); print '4717: Ending test_charset'; } print '087: parsed test_fileop()'; /* * test_strprintf - test strprintf calls */ define test_strprintf() { local callcfg; /* caller configuration value */ local c; /* modified configuration */ print '4800: Beginning test_strprintf'; /* setup */ callcfg = config("all"); print '4801: callcfg = config("all")'; c = config("mode", "frac"); print '4802: c = config("mode", "frac")'; c = config("outround", 24); print '4803: c = config("outround", 24)'; c = config("display", 2); print '4804: c = config("display", 2)'; c = config("tilde", 0); print '4805: c = config("tilde", 0)'; c = config("leadzero", 0); print '4806: c = config("leadzero", 0)'; c = config("fullzero", 0); print '4807: c = config("fullzero", 0)'; /* tests with tilde == 0 */ vrfy(strprintf("%d%d", 27, 29) == "2729", '4808: strprintf("%d%d", 27, 29) == "2729"'); vrfy(strprintf("%5d%3d", 27, 29) == " 27 29", '4809: strprintf("%5d%3d", 27, 29) == " 27 29"; '); vrfy(strprintf("%-5d%-3d", 27, 29) == "27 29 ", '4810: strprintf("%-5d%-3d", 27, 29) == "27 29 "'); vrfy(strprintf("%f", 1.375) == "1.38", '4811: strprintf("%f", 1.375) == "1.38"'); vrfy(strprintf("%f", 1.385) == "1.38", '4812: strprintf("%f", 1.385) == "1.38"'); vrfy(strprintf("%f", .375) == ".38", '4813: strprintf("%f", .375) == ".38"'); vrfy(strprintf("%f", .385) == ".38", '4814: strprintf("%f", .385) == ".38"'); /* tests with tilde == 1 */ c = config("tilde", 1); print '4815: c = config("tilde", 1)'; vrfy(strprintf("%f", 1.375) == "~1.38", '4816: strprintf("%f", 1.375) == "~1.38"'); vrfy(strprintf("%f", 27/29) == "~.93", '4817: strprintf("%f", 27/29) == "~.93"'); vrfy(strprintf("%r", 27/29) == "27/29", '4818: strprintf("%r", 27/29) == "27/29"'); vrfy(strprintf("%o", 27/29) == "033/035", '4819: strprintf("%o", 27/29) == "033/035"'); vrfy(strprintf("%x", 27/29) == "0x1b/0x1d", '4820: strprintf("%x", 27/29) == "0x1b/0x1d"'); vrfy(strprintf("%b", 27/29) == "0b11011/0b11101", '4821: strprintf("%b", 27/29) == "0b11011/0b11101"'); vrfy(strprintf("%e", 12345) == "~1.23e4", '4822: strprintf("%e", 12345) == "~1.23e4"'); /* mode tests with tilde == 0 */ c = config("tilde", 0); print '4823: c = config("tilde", 0)'; vrfy(strprintf("%e", 12345) == "1.23e4", '4824: strprintf("%e", 12345) == "1.23e4"'); vrfy(strprintf("%.3e", 12345) == "1.234e4", '4825: strprintf("%.3e", 12345) == "1.234e4"'); vrfy(strprintf("%e", .00012345) == "1.23e-4", '4826: strprintf("%e", .00012345) == "1.23e-4"'); vrfy(strprintf("%d %d", 27) == "27 ", '4827: strprintf("%d %d", 27) == "27 "'); vrfy(strprintf("%d", 27, 29) == "27", '4828: strprintf("%d", 27, 29) == "27"'); vrfy(strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93", '4829: strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93"'); vrfy(strprintf("%s", "abc") == "abc", '4830: strprintf("%s", "abc") == "abc"'); vrfy(strprintf("%f", "abc") == "abc", '4831: strprintf("%f", "abc") == "abc"'); vrfy(strprintf("%e", "abc") == "abc", '4832: strprintf("%e", "abc") == "abc"'); vrfy(strprintf("%5s", "abc") == " abc", '4833: strprintf("%5s", "abc") == " abc"'); vrfy(strprintf("%-5s", "abc") == "abc ", '4834: strprintf("%-5s", "abc") == "abc "'); /* restore config */ c = config("all", callcfg); print '4835: c = config("all", callcfg)'; print '4836: Ending test_strprintf'; } print '088: parsed test_fileop()'; /* * global and static assignment tests */ global a = 10, b, c d = 20, e; print '089: global a = 10, b, c d = 20, e, f'; vrfy(a == 10, '090: a == 10'); vrfy(b == 0, '091: b == 0'); vrfy(c == 20, '092: c == 20'); vrfy(d == 20, '093: d == 20'); vrfy(e == 0, '094: e == 0'); vrfy(f == 0, '095: f == 0'); static a b = 30, c, e = 30; print '096: static a b = 30, c, e = 30'; vrfy(a == 30, '097: a == 30'); vrfy(b == 30, '098: b == 30'); vrfy(c == 0, '099: c == 0'); vrfy(e == 30, '100: e == 30'); global a, b; print '101: global a, b'; vrfy(a == 10, '102: a == 10'); vrfy(b == 0, '103: b == 0'); static mat A, B[2,2] = {1,2,3,4}; print '104: static mat A, B[2,2] = {1,2,3,4}'; define f100(x,y) = (mat [2,2] = {x,0,0,y}) * A; print '105: define f100(x,y) = (mat [2,2] = {x,0,0,y}) * A'; define g100(x) = (mat[2,2] = {x,x,x,x}) + B; print '106: define g100(x) = (mat[2,2] = {x,x,x,x}) + B'; define h100(a,b,c,d) = ((B = {a,b,c,d}), null()); print '107: define h100(a,b,c,d) = ((B = {a,b,c,d}), null())'; global A, B; print '108: global A, B'; vrfy(A == 0, '109: A == 0'); vrfy(B == 0, '110: B == 0'); x = test(f100(2,3) == (mat[2,2] = {2, 4, 9, 12})); vrfy(x, '111: test(f100(2,3) == (mat[2,2] = {2, 4, 9, 12}))'); x = test(g100(4) == (mat[2,2] = {5,6,7,8})); vrfy(x, '112: test(g100(4) == (mat[2,2] = {5,6,7,8}))'); x = test(h100(2,3,5,7) == null()); vrfy(x, '113: test(h100(2,3,5,7) == null())'); x = test(g100(4) == (mat[2,2] = {6,7,9,11})); vrfy(x, '114: test(g100(4) == (mat[2,2] = {6,7,9,11}))'); global obj point {x,y} P Q = {1,2}, R={3,4}, S; print '115: global obj point {x,y} P, Q = {1,2}, R={3,4}, S'; vrfy(P.x == 1, '116: P.x == 1'); vrfy(P.y == 2, '117: P.y == 2'); vrfy(Q.x == 1, '118: Q.x == 1'); vrfy(Q.y == 2, '119: Q.y == 2'); vrfy(R.x == 3, '120: R.x == 3'); vrfy(R.y == 4, '121: R.y == 4'); vrfy(S.x == 0, '122: S.x == 0'); vrfy(S.y == 0, '123: S.y == 0'); /* * test_listsearch - test searching in lists */ define test_listsearch() { local L; print '4900: Beginning test_listsearch'; L = list(); print '4901: L = list()'; vrfy(isnull(search(L,1)), '4902: isnull(search(L,1))'); vrfy(isnull(rsearch(L,1)), '4903: isnull(search(L,1))'); L = list(0,1,2,3,0,1,2,3,0,1); print '4904: L = list(0,1,2,3,0,1,2,3,0,1)'; vrfy(search(L,0) == 0, '4905: search(L,0) == 0'); vrfy(rsearch(L,0) == 8, '4906: rsearch(L,0) == 8'); vrfy(search(L,0,2) == 4, '4907: search(L,0,2) == 4'); vrfy(rsearch(L,0,7) == 4, '4908: rsearch(L,0,7) == 4'); vrfy(isnull(search(L,2,7)), '4909: isnull(search(L,2,7))'); vrfy(isnull(rsearch(L,3,2)), '4910: isnull(rsearch(L,3,2))'); vrfy(isnull(search(L,0,1,4)), '4911: isnull(search(L,0,1,4)'); vrfy(isnull(rsearch(L,0,1,4)), '4912: isnull(rsearch(L,0,1,4)'); vrfy(search(L,0,-5) == 8, '4913: search(L,0,-5) == 8'); vrfy(rsearch(L,0,-9,-2) == 4, '4914: rsearch(L,0,-9,-2) == 4'); vrfy(isnull(search(L,3,20)), '4915: isnull(search(L,3,20)'); vrfy(isnull(search(L,3,0,-20)), '4916: isnull(search(L,3,0,-20)'); vrfy(isnull(rsearch(L,3,20,2)), '4917: isnull(rsearch(L,3,20,2)'); vrfy(rsearch(L,3,-20,20) == 7, '4918: rsearch(L,3,-20,20) == 7'); print '4919: Ending test_strprintf'; } print '124: parsed test_listsearch()'; /* * test_filesearch - test searching in files * * This function is designed to trigger 22 errors, so we bump the * errmax by 22 during this call. */ define test_filesearch() { local f, g; /* open files */ local s; /* local string */ local a, b, c, d; /* new error values */ local x; print '5000: Beginning test_filesearch'; /* * setup */ print '5001: x = rm("-f", "junk5000")'; x = rm("-f", "junk5000"); f = fopen("junk5000", "w"); print '5002: f = fopen("junk5000", "w")'; if (iserror(f)) { prob("Unable to open \"junk5000\" for writing"); return; } print '5003: if (iserror(f)) { ... }'; s = "alpha beta gamma "; print '5004: s = "alpha beta gamma "'; fputs(f, s); print '5005: fputs(f, s)'; fflush(f); print '5006: fflush(f)'; print '5007: test unused'; /* bump errmax up by 16 */ ecnt += 16; print '5008: ecnt += 16'; vrfy(search(f, 45) == error(10122), '5009: search(f, 45) == error(10122)'); vrfy(search(f, "a", 1/2) == error(10123), '5010: search(f, "a", 1/2) == error(10123)'); vrfy(search(f, "a", 0, "b") == error(10124), '5011: search(f, "a", 0, "b") == error(10124)'); vrfy(search(f, "a", 0) == error(10126), '5012: search(f, "a") == error(10126)'); vrfy(rsearch(f, 45) == error(10128), '5013: rsearch(f, 45) == error(10128)'); vrfy(rsearch(f, "a", "b") == error(10129), '5014: rsearch(f, "a", "b") == error(10129)'); vrfy(rsearch(f, "a", 0, "b") == error(10130), '5015: rsearch(f, "a", 0, "b") == error(10130)'); vrfy(rsearch(f, "a", 0) == error(10132), '5016: rsearch(f,"a",0) == error(10132)'); /* errmax and errcount should be bumped up the 16 errors above */ vrfy(errcount() == ecnt, '5017: errcount() == ecnt'); if (freopen(f, "r")) { prob("Unable to reopen \"junk5000\" for reading"); return; } print '5018: if (freopen(f, "r")) { ... }'; vrfy(fsize(f) == 17, '5019: fsize(f) == 17'); vrfy(search(f, s, 0) == 0, '5020: search(f, s, 0) == 0'); vrfy(ftell(f) == 17, '5021: ftell(f) == 17'); vrfy(rsearch(f, s, 0) == 0, '5022: rsearch(f, s, 0) == 0'); vrfy(ftell(f) == 16, '5023: ftell(f) == 16'); vrfy(search(f, "", 2) == 2, '5024: search(f, "", 2) == 2'); vrfy(ftell(f) == 2, '5025: ftell(f) == 2'); vrfy(search(f, "", 17) == 17, '5026: search(f, "", 17) == 17'); vrfy(ftell(f) == 17, '5027: ftell(f) == 17'); vrfy(isnull(search(f, "", 100)), '5028: isnull(search(f, "", 100))'); vrfy(ftell(f) == 17, '5029: ftell(f) == 17'); vrfy(rsearch(f, "", 5) == 5, '5030: rsearch(f, "", 5) == 5'); vrfy(ftell(f) == 5, '5031: ftell(f) == 5'); vrfy(search(f, "beta", 0) == 6, '5032: search(f, "beta", 0) == 6'); vrfy(ftell(f) == 10, '5033: ftell(f) == 10'); vrfy(rsearch(f, "beta", 100) == 6, '5034: rsearch(f, "beta", 100) == 6'); vrfy(ftell(f) == 9, '5035: ftell(f) == 9'); vrfy(search(f, "a", 2) == 4, '5036: search(f, "a", 2) == 4'); vrfy(ftell(f) == 5, '5037: ftell(f) == 5'); vrfy(search(f, "a", 4) == 4, '5038: search(f, "a", 4) == 4'); vrfy(search(f, "m") == 13, '5039: search(f, "m") == 13'); vrfy(search(f, "m") == 14, '5040: search(f, "m") == 14'); vrfy(isnull(search(f, "m")), '5041: isnull(search(f, "m"))'); vrfy(rsearch(f, "m", 15) == 14, '5042: rsearch(f, "m", 14) == 14'); vrfy(isnull(search(f, "beta", 7)), '5043: isnull(search(f, "beta", 7))'); vrfy(ftell(f) == 14, '5044: ftell(f) == 14'); vrfy(search(f,"a",2,15) == 4, '5045: search(f,"a",2,15) == 4'); vrfy(ftell(f) == 5, '5046: ftell(f) == 5'); vrfy(isnull(search(f,"a",2,4)), '5047: isnull(search(f,"a",2,4))'); vrfy(ftell(f) == 4, '5048: ftell(f) == 4'); vrfy(search(f,"a",,5) == 4, '5049: search(f,"a",,5) == 4'); vrfy(rsearch(f,"a",2,15) == 12, '5050: rsearch(f,"a",2,15) == 12'); vrfy(ftell(f) == 12, '5051: ftell(f) == 12'); vrfy(rsearch(f,"a",2,12) == 9, '5052: rsearch(f,"a",2,12) == 9'); /* generate 2 more errors */ ecnt += 2; print '5053: ecnt += 2';