2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
7 char rcs_id[] = "$Id$" ;
9 /* This program can be used to test C-compilers */
15 /**********************************************************************/
17 * Testing basic function calls
33 printf("End of test program, %d tests completed, %d errors detected\n",
45 printf("Error %d in test%d \n",n,t);
93 return ( one() + two() + three() + four() + five() );
101 return( one() * two() * three() * four() * five() );
109 return( - one() - two() - three() - four() - five() );
122 if ( one() != 1 ) e(1);
123 if ( two() != 2 ) e(2);
124 if ( three() != 3 ) e(3);
125 if ( four() != 4 ) e(4);
126 if ( five() != 5 ) e(5);
127 if ( (one() + two()) != 3 ) e(6);
128 if ( ((((((one() + two())))))) != 3) e(7);
129 if ( (one() * three()) != 3) e(8);
130 if (( (four() + three()) * two()) != 14) e(9);
131 if ( (four() + four()) != (two() * four()) ) e(10);
132 if ( (four() - four()) / three() ) e(11);
133 if (( four() + 3 * 12 - ( one() * two() * 2 ) ) != 36 ) e(12);
134 if ( one() & two() & four() & three() ) e(13);
135 if ( !( three() && two() ) ) e(14);
138 count = one() + two() + three() + four();
139 count = count * one();
140 count = count * two() - one() - two() - three() - four();
142 if (count != 10) e(15);
144 if ( plus() != 15 ) e(17);
145 if ( multipl() != 120 ) e(18);
146 if ( subtr() != -15 ) e(19);
147 if ( -subtr() != plus() ) e(18);
148 if ( -subtr() != plus() ) e(21);
188 return ( ( a < b ? b : a ) );
201 if ( echo(1) != 1 ) e(1);
202 if ( echo(3) != 3 ) e(2);
204 if ( echo(2) + echo(3) != echo(5) ) e(4);
205 if ( echo( 2 + 3 ) != 5 ) e(5);
206 if ( echo ( 1 + 2 + 3 + 4 + 5 ) != 10 + echo(5) ) e(6);
207 if (( echo( 2<<1 ) ) != 4 ) e(7);
208 if ( echo( 2 >> 1 ) != 1 ) e(8);
209 if ( echo( 1 << 4 ) != echo( 2 << 3 ) ) e(9);
210 if ( echo( echo(4) ) != echo(4) ) e(10);
211 if (( echo ( echo ( echo( echo ( echo ( 3 ) ) ) ) ) ) != 3 ) e(11);
212 if ( echo( echo( echo(2+3-4+echo(4)*echo(2))) ) != 9 ) e(12);
213 if ( min(1,2) != 1) e(13);
214 if (min(0,45) != 0) e(14);
215 if (min(45,0) != 0) e(15);
216 if (min(-72,-100) != -100) e(16);
217 if (min(-100,-72) != -100) e(17);
218 if (min(1<<3,2<<3) != (1<<3) ) e(18);
219 if ( min( echo(3), echo(3) ) != echo (echo(3)) ) e(19);
220 if ( max1('a','b') != 'b' ) e(20);
221 if ( max1('b','a') != 'b' ) e(21);
222 if ( max1(-3,54+2) != ( -3 < 54+2 ? 54+2 : -3 ) ) e(22);
223 if (max1('a'+'b'+34,'a'*2) != max2('a'*2,'a'+'b'+34)) e(23);
224 if (max1(345/23,4) != max1( echo(345/23), 4) ) e(24);
225 if ( max1( max1(2,3), max1(2,3) ) != max1(2,3) ) e(25);
227 if ((max1(i,-i)) != i) e(26);
228 for (j=min('a',34); j<max2('a',34); j++)
230 if ( j<min(max1('a',34),min('a',34)) ) e(27);
231 if ( j>max1(min(34,'a'),max2(34,'a')) ) e(28);
234 if ( min(echo(a),a) != a) e(29);
235 if ( max1(echo(b),max1(b,b)) != b) e(30);
257 return ( ((((( (k*(k+1))/2 ))))) );
271 if ( sum(-4) != 0 ) e(1);
272 if ( sum(0) != 0 ) e(2);
273 if ( sum(2) != 3 ) e(3);
274 if ( sum(10) != 55 ) e(4);
275 if ( sum(34) != formula(34) ) e(5);
276 if ( sum(101) != formula(101) ) e(6);
277 if ( sum( sum(11) ) != formula( formula(11) ) ) e(7);
278 if ( sum( sum(11) ) != formula( sum(11) ) ) e(8);
279 if ( sum( sum( sum(4) )) != sum ( formula ( sum( 4) )) ) e(9);
280 for (k = sum(-45); k<sum('a'); k += sum('b') )
282 if ( echo( sum ( formula( five() ))) != formula ( sum(5) ) ) e(11);
292 int b[1][2][3][4][5];
296 b[0][1][2][3][4] = one();
297 if ( b[0][1][2][3][4] != 1) e(1);
298 if ( b[0][one()][two()][three()][four()] != 1) e(2);
299 if ( b[0][one()][five()-3][one()+2][four()] != b[0][1][2][2*2-1][4]) e(3);
302 if (a[one()-1] != one()) e(4);
303 if (echo(a[4]) != 5) e(5);
304 if ( echo( a[ echo(6) ] ) != 7 ) e(6);
305 if ( a[a[a[0]]] != 3 ) e(7);
306 for (i=11; i<22; i++)
307 if ( echo( a[i+echo('b'-'a'-1)] ) != i+1) e(8);
313 b[echo(i)][echo(j)][echo(k)][l][echo(m)] = j*k*l*m;
316 if (b[0][max1( max1(0,0), 1)][2][i][j] != 1*2*echo(i)*j ) e(9);
326 int sw; /* switch selector */
327 int i; /* value to be returned */
335 case 1: return ( echo(i*i) - (i-1)*i );
337 case 2: return ( 2*func(0,i) );
343 return( 3*a[a[a[a[0]]]] );
351 /* testing function arguments */
370 return ( *ptr | *locptr );
394 for (k = -6353; k < -6003; k++)
395 if (f1(k,k+3-echo(3))) e(1);
398 if ( f2(ptr) != f2(&k) ) e(3);
399 if ( f2(ptr) + f2(&k) != 2*k ) e(4);
400 if ( f1(*ptr,*ptr) ) e(5);
401 if ( f1(*ptr,k) ) e(6);
402 if ( f1( f2(&k), *ptr ) ) e(7);
408 if ( k != *ptr ) e(9);
413 if ( l != 'h' ) e(10);
414 if ( k != -5 ) e(11);
415 if ( *ptr != -5 ) e(12);
416 if ( ptr != &k ) e(13);
436 if (func(0,i) != -i) e(i);
437 for (i=10; i<20; i++)
438 if ( -func(2,i) != 2*i) e(i);
439 if (func(func(0,0),0) != 0) e(20);
440 if (func(-func(0,1),32) != 32) e(21);
441 if (max1(32767,10) != max2(32767,10)) e(22);
442 if (func(3,10) != 30) e(22);
443 if (icount(1)!=2) e(23);
444 if (icount(2)!=3) e(24);
445 if (icount(32766) != 32767) e(25);
446 if (icount((int)-32768) != -32767) e(26);
447 if (icount(icount(1)) != 3) e(27);
448 if ( icount( (int)&i ) != (int)&i + 1 ) e(28) ;
449 if (icount(icount(icount(icount(icount(icount(icount(icount(0))))))))!=8) e(29);