tic();
//
//  RLaB test program
//
//-------------------- Test Relational Expressions -------------------
//
//    SCALAR CONSTANTS (REAL)
if( !(1<2) ) { error(); }
if( !(1<=2) ) { error(); }
if( 1>2 ) { error(); }
if( 1>=2 ) { error(); }
if( 1==2 ) { error(); }
if( !(1!=2) ) { error(); }
if( !1 ) { error(); }
if( !!!1) { error(); }
//    SCALAR CONSTANTS (COMPLEX)
if( !(1+2i<2+3i) ) { error(); }
if( !(1+2i<=2+3i) ) { error(); }
if( 1+2i>2+3i ) { error(); }
if( 1+2i>=2+3i ) { error(); }
if( 1+2i==2+3i ) { error(); }
if( !(1+2i!=2+3i) ) { error(); }
if( !1+2i ) { error(); }
if( !!!1+2i) { error(); }
//    SCALAR ENTITIES (REAL)
a=1;b=2;
if( !(a<b) ) { error(); }
if( !(a<=b) ) { error(); }
if( a>b ) { error(); }
if( a>=b ) { error(); }
if( a==b ) { error(); }
if( !(a!=b) ) { error(); }
if( !a ) { error(); }
if( !!!a) { error(); }
//    SCALAR ENTITIES (COMPLEX)
a=1+2i;b=2+3i;
if( !(a<b) ) { error(); }
if( !(a<=b) ) { error(); }
if( a>b ) { error(); }
if( a>=b ) { error(); }
if( a==b ) { error(); }
if( !(a!=b) ) { error(); }
if( !a ) { error(); }
if( !!!a) { error(); }
//------------------------- Test REAL SCALARS ------------------------
//
//    CONSTANTS
//      Addition
if(1+2 != 3) { error(); }
//      Subtraction
if(1-2 != -1) { error(); }
//      Multiply
if(1*2 != 2) { error(); }
//      Divide
if(1/2 != 0.5) { error(); }
//      Power
if(2^2 != 4) { error(); }
//      Unary Minus
if(2-3 != -1) { error(); }
//
//    ENTITIES
//
a = 1; b = 2; c = 3; d = 0.5;
//      Addition
if(a+b != c) { error(); }
//      Subtraction
if(a-b != -a) { error(); }
//      Multiply
if(a*b != b) { error(); }
//      Divide
if(a/b != d) { error(); }
//      Power
if(b^b != b*b) { error(); }
//      Unary Minus
if(b-c != -a) { error(); }
//
//  ENTITIES & CONSTANTS
//
if(a+2 != c) { error(); }
//      Subtraction
if(1-b != -a) { error(); }
//      Multiply
if(a*2 != 2) { error(); }
//      Divide
if(1/b != d) { error(); }
//      Power
if(2^b != b*b) { error(); }
//      Unary Minus
if(b-3 != -a) { error(); }
//
//------------------------Test COMPLEX SCALARS -------------------------
//
//    CONSTANTS
if(sqrt(-1) != 1i) { error(); }
//      Addition
if((1+2i)+(2+3i) != (3+5i)) { error(); }
//      Subtraction
if((1+2i)-(3+4i) != (-2-2i)) { error(); }
//      Multiply
if((1+2i)*(3+4i) != (-5+10i)) { error(); }
//      Divide
if((1+2i)/(3-4i) != (-.2+.4i)) { error(); }
//      Power
//      Precision problems prevent us from testing these. Have to
//      be checked by hand.
//  (1+2i)^2 = -3 + 4i
//  (1+2i)^.5 = 1.272 + 7.862e-1i
//  if((1+2i)^2 != (-3+4i)) { error(); }
//  if((1+2i)^10 != (237+3116i)) { error(); }
//      Unary Minus
if(-(1+2i) != -1-2i) { error(); }
//
//    ENTITIES
//
a = 1+2i; b = 3+4i; c = 4+6i;
if(a+b != c) { error(); }
//      Subtraction
if(a-b != -2-2i) { error(); }
//      Multiply
if(a*b != -5+10i) { error(); }
//      Divide
//if(a/(3-4i) != -.2+.4i) { error(); }
//      Power
//  if(b^b != b*b) { error(); }
//      Unary Minus
if(-a != -1-2i) { error(); }
//
//    ENTITIES & CONSTANTS
//
if(a+(3+4i) != c) { error(); }
//      Subtraction
if((1+2i)-b != -2-2i) { error(); }
//      Multiply
if(a*(3+4i) != -5+10i) { error(); }
//      Divide
//if(a/(3-4i) != -.2+.4i) { error(); }
//      Power
//  if(b^b != b*b) { error(); }
//      Unary Minus
if(-(1+2i) != -1-2i) { error(); }
//
//----------------------- Test REAL MATRICES ---------------------------
//
printf("\tstart matrix tests...\n");
printf("\t\treal-matrices\n");
//  Read in test matrices
//
read("test.input");
//
//  Matrix construction
//
if(all([3] != matrix(3))) { 
  error(); 
}
if(any([1;2;3] != [1,2,3]')) {
  error();
}
if(any (any (m0 != zeros(2,2)))) { error(); }
if(any (any (m1 != 1+zeros(2,2)))) { error(); }
if(any (any (m2 != [1,2;3,4]))) { error(); }
if(any (any (m3 != [1+2i,2+3i;3+4i,5+6i]))) { error(); }
if(any (any ([1,2;3+0i,4+0i] != m2))) { error(); }
if(any (any ([m2] != m2))) { error(); }
//
//  Sub-Matrix promotion
//
if(m2[2;2] != 4) { error(); }
if(any(m2[2;] != [3,4])) { error(); }
if(any(m2[;2] != [2,4]')) { error(); }
i=2;j=1;
if(m2[i;j] != 3) { error(); }
i=1;j=2;
if(m2[i;j] != 2) { error(); }
m = [1,2,3;4,5,6;7,8,9];
if(any(m[1;1,2] != [1,2])) {
  error();
}
if(any(m[1,2;1] != [1;4])) {
  error();
}
if(any (any (m[1,2;1,2] != [1,2;4,5]))) {
  error();
}
//
if(m3[2;2] != (5+6i)) { error(); }
if(any(m3[2;] != [3+4i,5+6i])) { error(); }
if(any(m3[;2] != conj([2+3i,5+6i]'))) { error(); }
//
//  Automatic creation, extension
//
if(any (any ((mm[3;3]=10) != [0,0,0;0,0,0;0,0,10]))) { error(); }
a=[1,2,3;4,5,6];
if(any (any ((a[3;1]=10) != [1,2,3;4,5,6;10,0,0]))) { error(); }
a=[1,2;3,4];
if(any (any ((a[3,4;3,4]=[5,6;7,8]) != [1,2,0,0;3,4,0,0;0,0,5,6;0,0,7,8]))) {
  error();
}
mmm[2;] = a[1;];
//
//  Matrix binary operations
//
a = m2; b = [5,6;7,8];
if(any (any (a+a != [2,4;6,8]))) { error(); }
if(any (any (a-a != zeros(2,2)))) { error(); }
if(any (any (2+a != [3,4;5,6]))) { error(); }
if(any (any (2-a != [1,0;-1,-2]))) { error(); }
if(any (any (a-2 != [-1,0;1,2]))) { error(); }
if(any (any (2*a != [2,4;6,8]))) { error(); }
if(any (any ((a./2 != [0.5,1;1.5,2])))) { error(); }
if(any (any (a*a != [7,10;15,22]))) { error(); }
if(any (any (a*a*a != [37,54;81,118]))) { error(); }
if(any (any (a .* a != [1,4;9,16]))) { error(); }
if(any (any (a./a != [1,1;1,1]))) { error(); }
if(any (any (a' != [1,3;2,4]))) { error(); }

if(any ([1;2;3]+[4;5;6] != [5;7;9])) {
  error();
}
if(any ([1;2;3]-[4;5;6] != [-3;-3;-3])) {
  error();
}
if(any ([2;2;2] ./ [1;1;1] != [2;2;2])) {
  error();
}
if(any ([1;2;3] .* [4;5;6] != [4;10;18])) {
  error();
}
//
//--------------------- Test COMPLEX MATRICES --------------------------
//
//  Automatic creation, extension
//
printf("\t\tcomplex-matrices\n");
if(any (any ((mm[3;3]=10+10i) != [0,0,0;0,0,0;0,0,10+10i]))) { error(); }
a=[1,2,3;4,5,6];
if(any (any ((a[3;1]=10+10i) != [1,2,3;4,5,6;10+10i,0,0]))) { error(); }
//
a = m3;
if(any (any (a+a != [2+4i,4+6i;6+8i,10+12i]))) { error(); }
if(any (any (a-a != zeros(2,2)))) { error(); }
if(any (any (2+a != [3+2i,4+3i;5+4i,7+6i]))) { error(); }
if(any (any (2-a != [1-2i,0-3i;-1-4i,-3-6i]))) { error(); }
if(any (any (a-2 != [-1+2i,0+3i;1+4i,3+6i]))) { error(); }
if(any (any (2*a != [2+4i,4+6i;6+8i,10+12i]))) { error(); }
if(any (any (a./2 != [.5+1i,1+1.5i;1.5+2i,2.5+3i]))) { error(); }
if(any (any (a*a != [-9+21i,-12+34i;-14+48i,-17+77i]))) { error(); }
if(any (any (a*a*a != [-223+57i,-345+113i;-469+183i,-719+337i]))) { error(); }
if(any (any (a .* a != [-3+4i,-5+12i;-7+24i,-11+60i]))) { error(); }
//
// The following test may not work on some machines
//
if(any (any (a./a != [1,1;1,1]))) { 
  printf("\t***complex division inaccuracy***\n"); 
}

if(any (any (a' != conj([1+2i,3+4i;2+3i,5+6i])))) { error(); }
//  
//--------------------- Test NULL MATRICES -------------------------
//
printf("\t\tnull-matrices\n");
// Create a NULL matrix
mnull = matrix();
// Test it with SCALARS
if( any([1,mnull] != 1)) {
  error();
}
if( any([mnull,1] != 1)) {
  error();
}
// Test with MATRIX construction
m = [1,2;3,4;5,6];
if( any([mnull;1] != [1])) {
  error();
}
if( any([1;mnull] != [1])) {
  error();
}
if( any([mnull;1,2,3] != [1,2,3])) {
  error();
}
if( any([1,2,3;mnull] != [1,2,3])) {
  error();
}
if(any (any ([mnull,m] != m))) {
  error();
}
if(any (any ([m,mnull] != m))) {
  error();
}
if(any (any ([mnull;m] != m))) {
  error();
}
if(any (any ([m;mnull] != m))) {
  error();

mnull = matrix();
mnull[1] = [1];
}

//--------------------- Test Matrix Multiply --------------------------

i = sqrt(-1);
a = [1,2,3;4,5,6;7,8,9];
b = [4,5,6;7,8,9;10,11,12];
c = [ 48,  54,  60 ;
     111, 126, 141 ;
     174, 198, 222 ];

if (any (any (c != a*b))) { error ("failed Real-Real Multiply"); }

az = a + b*i;
bz = b + a*i;

cz = [-18+141*i , -27+162*i , -36+183*i ;
        9+240*i ,   0+279*i ,  -9+318*i ;
       36+339*i ,  27+396*i ,  18+453*i ];

czz = [ 48+30*i ,  54+36*i  ,  60+42*i ;
       111+66*i , 126+81*i  , 141+96*i ;
       174+102*i, 198+126*i , 222+150*i ];

czzz = [ 48+111*i ,  54+126*i ,  60+141*i ;
        111+174*i , 126+198*i , 141+222*i ;
        174+237*i , 198+270*i , 222+303*i ];

if (any (any (cz != az*bz)))  { error ("failed Complex-Complex Multiply"); }
if (any (any (czz != a*bz)))  { error ("failed Real-Complex Multiply"); }
if (any (any (czzz != az*b))) { error ("failed Complex-Real Multiply"); }

a = [a,a];
b = [b;b];
c = [  96 , 108 , 120 ;
      222 , 252 , 282 ;
      348 , 396 , 444 ];

if (any (any (c != a*b))) { error ("failed Real-Real Multiply"); }

az = [az,az];
bz = [bz;bz];

cz = [  -36+282*i ,  -54+324*i ,  -72+366*i ;
         18+480*i ,    0+558*i ,  -18+636*i ;
         72+678*i ,   54+792*i ,   36+906*i ];

czz = [  96+60*i  , 108+72*i  , 120+84*i  ;
        222+132*i , 252+162*i , 282+192*i ;
        348+204*i , 396+252*i , 444+300*i ];

czzz = [  96+222*i , 108+252*i , 120+282*i ;
         222+348*i , 252+396*i , 282+444*i ;
         348+474*i , 396+540*i , 444+606*i ];

if (any (any (cz != az*bz)))  { error ("failed Complex-Complex Multiply"); }
if (any (any (czz != a*bz)))  { error ("failed Real-Complex Multiply"); }
if (any (any (czzz != az*b))) { error ("failed Complex-Real Multiply"); }

printf("\t\tpassed matrix multiply test...\n");

//--------------------- Test STRING MATRICES --------------------------
//
printf("\t\tstring-matrices\n");
sm = ["s1","sm2","sm3";"x1","x2","xxx3";"y1","y2","yyy3"];
if(sm[1] != "s1") { error(); }
if( sm[1;3] != "sm3" ) { error(); }
if(any(sm[2,3;3] != ["xxx3";"yyy3"]) ) { error(); }
if(any (any ((sm[1;1]="xx")!=["xx","sm2","sm3";"x1","x2","xxx3";"y1","y2","yyy3"])))
{
  error();
}
if( ((strm[1] = "strm")[1]) != "strm" ) { error(); }

//
//---------------------------- List Tests --------------------------
//
//  List creation
listest = << << 11; 12 >>; << 21; 22>> >>;
if( listest.[1].[2] != 12 ) { error(); }
if(any(<<a=10;b=1:4;c=[1,2,3;4,5,6;7,8,9]>>.b != [1,2,3,4])) { error(); }
m.[0] = m;

//
//-------------------------- Test abs () ------------------------------
//

A = rand(5,5);
T = ( A == abs (A));
if (!all (all (A))) { error ("abs() incorrect"); }

//
//-------------------------- Test max () ------------------------------
//

A = [1,10,100;2,20,200;1,2,3];
if (!all (max (A) == [2,20,200])) { error( "max() incorrect"); }
if (max (max(A)) != 200) { error ("max() incorrect"); }

//
//-------------------------- Test min () ------------------------------
//

if (!all (min (A) == [1,2,3])) { error( "min() incorrect"); }
if (min (min(A)) != 1) { error ("min() incorrect"); }

//
//-------------------------- Test maxi () -----------------------------
//

if (!all (maxi (A) == [2,2,2])) { error( "maxi() incorrect"); }
if (maxi (maxi(A)) != 1) { error ("maxi() incorrect"); }

//
//-------------------------- Test mini () -----------------------------
//

if (!all (mini (A) == [1,3,3])) { error( "mini() incorrect"); }
if (mini (mini(A)) != 1) { error ("mini() incorrect"); }

//
//-------------------------- Test floor () ----------------------------
//

if (floor (1.9999) != 1) { error ("floor() output incorrect"); }
if (!all (all (floor ([1.99,1.99;2.99,2.99]) == [1,1;2,2]))) {
  error ("floor output incorrect");
}

//
//-------------------------- Test ceil () 0----------------------------
//

if (ceil (1.9999) != 2) { error ("ceil() output incorrect"); }
if (!all (all (ceil ([1.99,1.99;2.99,2.99]) == [2,2;3,3]))) {
  error ("ceil output incorrect");
}

//
//-------------------------- Test round () ----------------------------
//

if (round (1.8) != 2) { error ("round() output incorrect"); }
if (round (1.4) != 1) { error ("round() output incorrect"); }
if (!all (all (round ([1.99,1.99;2.4,2.4]) == [2,2;2,2]))) {
  error ("round output incorrect");
}

//
//-------------------------- Test sum () ------------------------------
//

S = [1:4; 4:7; 8:11];
if (sum (S[1;]) != 10) { error ("sum() incorrect"); }
if (sum (S[3;]) != 38) { error ("sum() incorrect"); }
if (!all (all (sum (S) == [13,16,19,22]))) { error ("sum() incorrect"); }

//
//-------------------------- Test int () ------------------------------
//

if (int (1.9999) != 1) { error ("int() output incorrect"); }
if (!all (all (int ([1.99,1.99;2.99,2.99]) == [1,1;2,2]))) {
  error ("int() output incorrect");
}

//
//-------------------------- Test mod () ------------------------------
//

if (mod (1,1) != 0) { error ("mod() output incorrect"); }
if (mod (4,2) != 0) { error ("mod() output incorrect"); }
if (mod (3,2) != 1) { error ("mod() output incorrect"); }
if (mod (5,3) != 2) { error ("mod() output incorrect"); }

//
//------------------------- Fibonacci Test -------------------------
//
//  Calculate Fibonacci numbers
//
i=1; 
while ( i < 2 ) { 
  i=i+1;
  a=0; b=1;
  while ( b < 10000 ) {
    c = b;
    b = a+b;
    a = c;
  }
}
if ( b != 10946 ) {
  error("failed fibonacci test");
else
  printf("\tpassed fibonacci test...\n");
}

//
//------------------------- Factorial Test -------------------------
//
fac = function(a) {
  if(a <= 1) {
    return 1
  else
    return a*fac(a-1)
  }
}
if(fac(10) != 3628800) { error(); else printf("\tpassed factorial test...\n"); }
//
//--------------------------- ACK Test ----------------------------
//
ack = function(a, b) {
  if(a == 0) { return b + 1; }
  if(b == 0) { return $self(a-1, 1); }
  return $self(a-1, $self(a, b-1));
}	

if(ack(2,2) != 7) {
  error("error in ack() test");
else
  printf("\tpassed ACK test...\n");
}
//
//------------------------- Prime Test -----------------------------
//
// An example that finds all primes less than limit
//
primes = function (limit) {
  local(prime, cnt, i, j, k);

  i = 1; cnt = 0;
  for(k in 2:limit) {
    j = 2;
    while(mod(k,j) != 0) {
      j++;
    }
    if(j == k) {            // Found prime
      cnt++;
      prime[i;1] = k;
      i++;
    }
  }
  return prime;
}

if(max(size(primes(100))) != 25) { 
  error("error in prime test");
else
  printf("\tpassed prime test...\n");
}

//
//--------------------- Nasty Function Test ------------------------
//
//	fibmin() will minimize an arbitrary function 
//	in 1D using Fibonacci search

f065 = function(x)
{
	return (x - 0.65) * (x - 0.65);
}

fib = function(x)
{
	local (n, a, b);

	a = 1;
	b = 1;
	if (x >= 2)
	{
		n = x - 1;
		for (n in n:1:-1)
		{
			c = b;
			b = a + b;
			a = c;
			n = n - 1;
		}
	}
	return b;
}

//  Minimize a 1D function using Fibonacci search
//  f = function to minimize
//  xlo = lower bound
//  xhi = upper bound
//  n = number of iterations (the bigger the more accurate)
fibmin = function(f, xlo, xhi, n) {
	local(a, b, x, y, ex, ey, k, lo, hi);

	lo = xlo;
	hi = xhi;
	k = n;
	for (k in k:2:-1)
	{
		a = fib(k - 2) / fib(k);
                b = fib(k - 1) / fib(k);
                x = lo + (hi - lo) * a;
                y = lo + (hi - lo) * b;
                ex = f(x);
                ey = f(y);
                if (ex >= ey)
                {
                        lo = x;
                else
                        hi = y;
                }
//  printf("%d: (%g %g) %g %g %g %g\n",  k, a, b, lo, hi, ex, ey);
        }
	return (lo + hi) / 2;
}

//
// Simple example using above function to mimize f065. Answer is 0.65
//
x = fibmin(f065, 0, 1, 30); // printf("f(%g)=%g\n", x, f065(x));
if (abs(x - 0.65) > 1e-6)
{
	printf("x = %f\n", x);
	error("failed fibmin test");
}

printf("\tpassed fibmin test...\n");

//
//--------------------- Nasty Function Test ------------------------
//
printf("\tStarting Nasty Function Test...\n");
printf("\tThis will take awhile\n");
check = function( a, b, c, d, e, f, g, h ) {
  if ( a+b+c+d == e+f+g+h && ...
       a^2+b^2+c^2+d^2 == e^2+f^2+g^2+h^2 && ...
       a^3+b^3+c^3+d^3 == e^3+f^3+g^3+h^3 ) {
    return 1;
  else
    return 0;
  }
}

for(a in 8:10) {
  for(b in 7:(a-1)) {
    for(c in 6:(b-1)) {
      for(d in 5:(c-1)) {
        for(e in 4:(d-1)) {
          for(f in 3:(e-1)) {
            for(g in 2:(f-1)) {
              for(h in 1:(g-1)) {                  
	          if(check( a, b, c, d,  e, f, g, h ) || ...
                     check( a, e, c, d,  b, f, g, h ) || ...
                     check( a, f, c, d,  e, b, g, h ) || ...
                     check( a, g, c, d,  e, f, b, h ) || ...
                     check( a, h, c, d,  e, f, g, b ) || ...
                     check( a, b, e, d,  c, f, g, h ) || ...
                     check( a, b, f, d,  e, c, g, h ) || ...
                     check( a, b, g, d,  e, f, c, h ) || ...
                     check( a, b, h, d,  e, f, g, c ) || ...
                     check( a, b, c, e,  d, f, g, h ) || ...
                     check( a, b, c, f,  e, d, g, h ) || ...
                     check( a, b, c, g,  e, f, d, h ) || ...
                     check( a, b, c, h,  e, f, g, d ) || ...
                     check( a, e, f, d,  b, c, g, h ) || ...
                     check( a, e, g, d,  b, f, c, h ) || ...
                     check( a, e, h, d,  b, f, g, c ) || ...
                     check( a, f, g, d,  e, b, c, h ) || ...
                     check( a, f, h, d,  e, b, g, c ) || ...
                     check( a, g, h, d,  e, f, b, c ) || ...
                     check( a, b, e, f,  c, d, g, h ) || ...
                     check( a, b, e, g,  c, f, d, h ) || ...
                     check( a, b, e, h,  c, f, g, d ) || ...
                     check( a, b, f, g,  e, c, d, h ) || ...
                     check( a, b, f, h,  e, c, g, d ) || ...
                     check( a, b, g, h,  e, f, c, d ) || ...
                     check( a, e, f, g,  e, f, g, h ) || ...
                     check( a, e, f, h,  e, f, g, h ) || ...
                     check( a, e, g, h,  e, f, g, h ) || ...
                     check( a, f, g, h,  e, f, g, h ) ) { cnt++; }
              }
            }
          }
        }
      }
    }
  }
}

if(1) {  // figure out the value of cnt, and check!
  printf("\tpassed nasty function test...\n");
else
  error();
}

//
//------------------------- Test getline()  ---------------------------
//
//

close( "test.getline" );

x = getline( "test.getline" );
if ( x.[1] !=  123.456 ) { error(); }
if ( x.[2] != -123.456 ) { error(); }
if ( x.[3] !=  123.456 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  .123 ) { error(); }
if ( x.[2] != -.123 ) { error(); }
if ( x.[3] !=  .123 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  123 ) { error(); }
if ( x.[2] != -123 ) { error(); }
if ( x.[3] !=  123 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  1e6 ) { error(); }
if ( x.[2] != -1e6 ) { error(); }
if ( x.[3] !=  1e6 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  1e5 ) { error(); }
if ( x.[2] != -1e5 ) { error(); }
if ( x.[3] !=  1e5 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  123.456e3 ) { error(); }
if ( x.[2] != -123.456e3 ) { error(); }
if ( x.[3] !=  123.456e3 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  123.456e3 ) { error(); }
if ( x.[2] != -123.456e3 ) { error(); }
if ( x.[3] !=  123.456e3 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  123.456e-3 ) { error(); }
if ( x.[2] != -123.456e-3 ) { error(); }
if ( x.[3] !=  123.456e-3 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  .123e3 ) { error(); }
if ( x.[2] != -.123e3 ) { error(); }
if ( x.[3] !=  .123e3 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] !=  123e3 ) { error(); }
if ( x.[2] != -123e3 ) { error(); }
if ( x.[3] !=  123e3 ) { error(); }

x = getline( "test.getline" );
if ( x.[1] != "123abc" ) { error(); }
if ( x.[2] != "abc123" ) { error(); }
if ( x.[3] != "123.abc" ) { error(); }

x = getline( "test.getline" );
if ( x.[1] != "quoted string" ) { error(); }
if ( x.[2] != "q string with escapes \n \t \" " ) { error(); }

x = getline( "test.getline" );
if ( x.[1] != "quoted string" ) { error(); }
if ( x.[2] !=  1.23e3 ) { error(); }
if ( x.[3] !=  100 ) { error(); }
if ( x.[4] != "q string with escapes \n \t \" " ) { error(); }
if ( x.[5] !=  200 ) { error(); }

printf("\tpassed getline() test...\n");

//
//----------------------------------------------------------------------
//
printf("Elapsed time = %i seconds\n", toc() );
"FINISHED TESTS"
