--- /dev/null
+This directory contains some testapps found in the ack compiler:
+ http://www.cs.vu.nl/ack/
--- /dev/null
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+/* Author: E.G. Keizer */
+
+char rcs_id[] = "$Id$" ;
+
+main() {
+ t1() ;
+ t2() ;
+ return 0 ;
+}
+
+t1() {
+ char c ; int i ; long l ; unsigned u ;
+#ifndef NOFLOAT
+ float f ;
+#endif
+
+ /* test conversions */
+
+ /* first some conversions on constants */
+
+ printf("(int) '\\377' = %d\n",(int) '\377') ;
+ printf("(long) -1 = %ld\n",(long) -1 ) ;
+#ifndef NOFLOAT
+ printf("(float) 12 = %f\n",(float) 12 ) ;
+ printf("(int) 3.14 = %d\n",(int) 3.14 ) ;
+#endif
+ printf("(int) 32767L = %d\n",(int) 32767L ) ;
+ printf("(int) -32768L = %d\n",(int) -32768L ) ;
+ printf("(char) 128L = %d\n",(char) 128L) ;
+ printf("(char) 0377 = %d\n",(char) 0377 ) ;
+ printf("(char) -1 = %d\n",(char) -1 ) ;
+ printf("(char) 10000 = %d\n",(char) 10000 ) ;
+
+ /* conversions from characters */
+ printf("From character\n") ;
+ c = 127 ;
+ i=c ;
+ l=c ;
+ u=c ;
+#ifndef NOFLOAT
+ f=c ;
+#endif
+ printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ;
+#ifndef NOFLOAT
+ printf("\t\t\t\t\tfloat %f\n",f) ;
+#endif
+ c = -1 ;
+ i=c ;
+ l=c ;
+ u=c ;
+#ifndef NOFLOAT
+ f=c ;
+#endif
+ printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ;
+#ifndef NOFLOAT
+ printf("\t\t\t\t\tfloat %f\n",f) ;
+#endif
+ c = 0377 ;
+ i=c ;
+ l=c ;
+ u=c ;
+#ifndef NOFLOAT
+ f=c ;
+#endif
+ printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ;
+#ifndef NOFLOAT
+ printf("\t\t\t\t\tfloat %f\n",f) ;
+#endif
+
+ /* from integer */
+ printf("From integer\n") ;
+ i= -64 ;
+ c=i ;
+ l=i ;
+ u=i ;
+#ifndef NOFLOAT
+ f=i ;
+#endif
+ printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ;
+#ifndef NOFLOAT
+ printf("\t\t\t\t\tfloat %f\n",f) ;
+#endif
+ /* from long */
+ printf("From long\n") ;
+ l = -3 ;
+ c = l ;
+ i = l ;
+ u = l ;
+#ifndef NOFLOAT
+ f = l ;
+#endif
+ printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ;
+#ifndef NOFLOAT
+ printf("\t\t\t\t\tfloat %f\n",f) ;
+#endif
+
+ printf("Casts from long\n");
+ l = 75000;
+ printf("\tchar %5d, int %d, unsigned short %6o, long %11ld\n",
+ (char) l,(int) l,(unsigned short)l ,l) ;
+
+#ifndef NOFLOAT
+ printf("From float\n") ;
+ f = 121.5 ;
+ c = f ;
+ i = f ;
+ u = f ;
+ l = f ;
+ printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+ f = 1e-4 ;
+ c = f ;
+ i = f ;
+ u = f ;
+ l = f ;
+ printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+ f = 3276.6e1 ;
+ i = f ;
+ u = f ;
+ l = f ;
+ printf("\tint %6d, unsigned %6o, long %11ld, float %f\n",i,u,l,f) ;
+ f = 1223432e3 ;
+ l = f ;
+ printf("\tlong %11ld, float %f\n",l,f) ;
+#endif
+
+ /* some special cases */
+ {
+ int a[4] ;
+
+ l = 3 ; a[3]= -17 ;
+ printf("a[l] (l==%ld) %d\n",l,a[l]) ;
+ printf("a[3l] %d\n",a[3l] ) ;
+
+ }
+ return 0 ;
+}
+
+t2()
+{
+ long l1 = 0x1f010L;
+ long l2;
+
+ l2 = (unsigned short) l1;
+ printf("(unsigned short) 0x1f010L = 0x%lx\n", l2);
+ l2 = (short) l1;
+ printf("(short) 0x1f010L = 0x%lx\n", l2);
+}
--- /dev/null
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+/* Author: E.G. Keizer */
+
+char rcs_id[] = "$Id$" ;
+
+/* Test a few declaration features */
+/* Such as:
+ forward function declarations,
+ redeclarations,
+ pointer to function declarations.
+*/
+
+static int sqr() ; /* forward declarations */
+extern int sqrt();
+
+main() {
+ fdcl() ;
+ hidden() ;
+ return 0 ;
+}
+
+fdcl() {
+ int (*a[2])() ;
+
+ printf("sqr(4) %d\n",sqr(4)) ;
+
+ a[0]=sqr ; a[1]=sqrt ;
+ printf("(*a[0])(16) %d\n",(*a[0])(16) ) ;
+ printf("(*a[1])( (*a[0])(3) ) %d\n", (*a[1])( (*a[0])(3) ) ) ;
+}
+
+static int sqr(par) int par ; {
+ return par*par ;
+}
+
+int sqrt(par) int par ; {
+ int x1,x2 ;
+ int i ;
+
+ if ( par<0 ) return -1 ;
+ x1 = par ;
+ i=0 ;
+ do {
+ x2 = x1 ;
+ x1 = ( x2*x2 + par ) / (2*x2) ;
+ if ( i++>=100 ) return -2 ;
+ } while ( ( x2<x1 ? x1-x2 : x2-x1 ) > 0 ) ;
+ return (x1+x2)/2 ;
+}
+
+int a = -8 ;
+
+hidden() {
+ hide() ;
+ printf("a outside hide %d\n",a) ;
+}
+
+int hide() {
+ int a ;
+
+ a = 4 ;
+ printf("a in hide %d\n",a) ;
+ {
+ int a ;
+
+ a = 16 ;
+ printf("a in in hide %d\n",a) ;
+
+ }
+ printf("a in hide %d\n",a) ;
+}
--- /dev/null
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+/* Author: E.G. Keizer */
+
+char rcs_id[] = "$Id$" ;
+
+/* Test initialisation of a V7 C-compiler */
+/* 1 sept 1980 */
+#include "local.h"
+
+/* Integers and constant expressions */
+
+int in1 = 4 ;
+int in2 = MAXINT ;
+int in3 = MININT ;
+int in4 ;
+int inzero ;
+
+int ice1 = (1-2+3*4/2)%3 ;
+int ice2 = ((((1&3)|4)^014) >> 1) <<1 ;
+int ice3 = ( (1==2) & (3<4) ) | (4>3) | (0<=0) | -2>=17 ;
+int ice4 = (~-1) ;
+int ice5 = (1==1 ? 3+4 : 5+6 ) ;
+int ice6 = (1!=1 ? 7+8 : 9+10 ) ;
+int ina[] = { 1, 3, 5 } ;
+
+pint() {
+ static int sint = -1 ;
+ int lint = in1+in3+sint ;
+
+ printf("Integers:\n\n") ;
+ printf("in1\t%d\nin2\t%d\nin3\t%d\nin4\t%d\ninzero\t%d\n\n",
+ in1,in2,in3,in4,inzero ) ;
+ printf("ice1\t%d\nice2\t%d\nice3\t%d\nice4\t%d\nice5\t%d\nice6\t%d\n\n",
+ ice1,ice2,ice3,ice4,ice5,ice6 ) ;
+ printf("ina\t%d,%d,%d\n\n",ina[0],ina[1],ina[2]) ;
+ printf("sint\t%d\nlint\t%d\n\n",sint,lint) ;
+}
+
+/* Characters */
+
+char ch1 = 'a' ;
+char ch2 ;
+char cha1[] = "Mesg" ;
+char cha2[] = "" ;
+char cha3[] = "1" ;
+char cha4[] = "12" ;
+char cha5[] = "0123456789112345678921234567893123456789412345678951234567896123456789712345678981234567899123456789" ;
+
+char cha6[2][3] = {
+ { 1, 2, 3 },
+ { 4, 5, 6 }
+};
+char *pch1 = cha2 ;
+char *pch2 = "pch2" ;
+char *pch3 = "ppch3" ;
+char *pch4 = 0 ;
+
+pch() {
+ static char stc[] = "123" ;
+ static char stc1[] = "1234" ;
+ static char *mult[] = { "ab" , "bc" , "de" } ;
+
+ printf("Characters:\n\n") ;
+
+ printf("ch1\t%c(%d)\n",ch1,ch1) ;
+ printf("ch2\t%d\n",ch2) ;
+ printf("cha1\t%s\ncha2\t%s\ncha3\t%s\ncha4\t%s\n",
+ cha1,cha2,cha3,cha4 ) ;
+ printf("cha5\t%s\n\n",cha5) ;
+ printf("cha6\t%d, %d, %d\n\t%d, %d, %d\n",
+ cha6[0][0],cha6[0][1],cha6[0][2],cha6[1][0],cha6[1][1],cha6[1][2]);
+ printf("pch1==cha2\t%s\n",(pch1 == cha2 ? "yes" : "no" ) ) ;
+ printf("pch2\t%s\npch3\t%s\n",pch2,pch3+1) ;
+ printf("pch4==0\t%s\n\n",(pch4 != 0 ? "no" : "yes" ) ) ;
+ printf("stc\t%s\nstc1\t%s\n",stc,stc1) ;
+ printf("mult[0],mult[1],mult[2] %s, %s, %s\n",mult[0],mult[1],mult[2]);
+}
+
+#ifndef NOFLOAT
+/* floats */
+
+float fl1 = 0 ;
+float fl2 = 2 ;
+float fl3 = 2e-10 ;
+float fl4 = 4.0 ;
+float fl5 = EPSFLOAT ;
+float fl6 = MAXFLOAT ;
+float fl7 ;
+
+float fla1[4][3] = {
+ { 1, 3, 5 },
+ { 2, 4, 6 },
+ { 3, 5, 7 }
+} ;
+float fla2[4][3] = {
+ -1,-3,-5,-2,-4,-6,-3,-5,-7
+} ;
+float fla3[4][3] = {
+ { 11 } , { 12 } , { 13 } , { 14 }
+} ;
+
+pflt() {
+ register i,j ;
+
+ printf("Floats:\n\n") ;
+
+printf("fl1\t%.20e\nfl2\t%.20e\nfl2\t%.20e\nfl4\t%.20e\nfl5\t%.20e\nfl6\t%.20e\nfl7\t%.20e\n",
+ fl1,fl2,fl2,fl4,fl5,fl6,fl7 ) ;
+
+ printf(" fla1 fla2 fla3\n") ;
+ for ( i=0 ; i<4 ; i++ ) {
+ for ( j=0 ; j<3 ; j++ ) {
+ printf(" %20e %20e %20e\n",
+ fla1[i][j],fla2[i][j],fla3[i][j]) ;
+ }
+ }
+
+ printf("\n") ;
+}
+
+/* doubles */
+
+double dbl1 = 0 ;
+double dbl2 = 2 ;
+double dbl3 = 2e-10 ;
+double dbl4 = 4.0 ;
+double dbl5 = EPSDOUBLE ;
+double dbl6 = MAXDOUBLE ;
+double dbl7 ;
+
+double dbla1[4][3] = {
+ { 1, 3, 5 },
+ { 2, 4, 6 },
+ { 3, 5, 7 }
+} ;
+double dbla2[4][3] = {
+ -1,-3,-5,-2,-4,-6,-3,-5,-7
+} ;
+double dbla3[4][3] = {
+ { 11 } , { 12 } , { 13 } , { 14 }
+} ;
+
+pdbl() {
+ register i,j ;
+
+ printf("Doubles:\n\n") ;
+
+printf("dbl1\t%.20e\ndbl2\t%.20e\ndbl2\t%.20e\ndbl4\t%.20e\ndbl5\t%.20e\ndbl6\t%.20e\ndbl7\t%.20e\n",
+ dbl1,dbl2,dbl2,dbl4,dbl5,dbl6,dbl7 ) ;
+
+ printf(" dbla1 dbla2 dbla3\n") ;
+ for ( i=0 ; i<4 ; i++ ) {
+ for ( j=0 ; j<3 ; j++ ) {
+ printf(" %20e %20e %20e\n",
+ dbla1[i][j],dbla2[i][j],dbla3[i][j]) ;
+ }
+ }
+
+ printf("\n") ;
+}
+#endif
+
+/* long */
+long lo1 = 14L ;
+long lo2 = -17 ;
+long lo3 = MAXLONG ;
+long lo4 = MINLONG ;
+long lo5 ;
+long lo6 = ( 0==1 ? -1L : 1L ) ;
+
+plong() {
+ printf("long\n\n") ;
+
+ printf("lo1\t%ld\nlo2\t%ld\nlo3\t%ld\nlo4\t%ld\nlo5\t%ld\nlo6\t%ld\n\n",
+ lo1,lo2,lo3,lo4,lo5,lo6 ) ;
+}
+
+/* structures and bit fields */
+
+struct s1 {
+ int s_i ;
+ char s_ca[3] ;
+ long s_l ;
+#ifndef NOFLOAT
+ double s_f ;
+#endif
+ struct s1 *s_s1 ;
+} ;
+struct s1 st1 ;
+struct s1 sta[3] = {
+#ifndef NOFLOAT
+ 1 , { 'a' , 'b' , 'c' } , 10 , -10 , &sta[0] ,
+#else
+ 1 , { 'a' , 'b' , 'c' } , 10 , &sta[0] ,
+#endif
+ { 2 } ,
+ 3
+} ;
+struct s2 {
+ int s2_1 :1 ;
+ int s2_2 :2 ;
+ int s2_3 :4 ;
+ int s2_4 :7 ;
+ int s2_5 :2 ;
+ int s2_6 :11 ;
+ int s2_7 :6 ;
+} stb = {
+ 1,2,3,4,3,6,7
+} ;
+
+pstruct() {
+ printf("structures\n\n") ;
+
+ printf("\t st1 sta[0..2]\n") ;
+
+ printf("s_i\t%15d%15d%15d%15d\n",
+ st1.s_i,sta[0].s_i,sta[1].s_i,sta[2].s_i) ;
+ printf("s_ca[0]\t%15d%15d%15d%15d\n",
+ st1.s_ca[0],sta[0].s_ca[0],sta[1].s_ca[0],sta[2].s_ca[0]) ;
+ printf("s_ca[1]\t%15d%15d%15d%15d\n",
+ st1.s_ca[1],sta[0].s_ca[1],sta[1].s_ca[1],sta[2].s_ca[1]) ;
+ printf("s_ca[2]\t%15d%15d%15d%15d\n",
+ st1.s_ca[2],sta[0].s_ca[2],sta[1].s_ca[2],sta[2].s_ca[2]) ;
+ printf("s_l\t%15ld%15ld%15ld%15ld\n",
+ st1.s_l,sta[0].s_l,sta[1].s_l,sta[2].s_l) ;
+#ifndef NOFLOAT
+ printf("s_f\t %13e %13e %13e %13e\n\n",
+ st1.s_f,sta[0].s_f,sta[1].s_f,sta[2].s_f) ;
+#endif
+ printf("(sta[0].s_s1)->s_i = %d\n",(sta[0].s_s1)->s_i) ;
+
+ printf("\nbit fields:\n\n") ;
+ printf("sizeof stb %d\n",sizeof stb) ;
+ printf("stb\t%d %d %d %d %d %d %d\n\n",
+ stb.s2_1,stb.s2_2,stb.s2_3,stb.s2_4,stb.s2_5,stb.s2_6,stb.s2_7);
+}
+
+main() {
+ pint() ;
+ pch() ;
+#ifndef NOFLOAT
+ pflt() ;
+ pdbl() ;
+#endif
+ plong() ;
+ pstruct() ;
+ return(0) ;
+}
--- /dev/null
+/* $Id$ */
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+# define MAXINT 32767
+# define MININT -32768
+# define MAXLONG 2147483647
+# define MINLONG -2147483648
+# define EPSFLOAT 2.938736e-39
+# define MAXFLOAT 1.7014117e38
+# define EPSDOUBLE 2.938736e-39
+/* for 64-bit double 1.701411834604692293e38 */
+# define MAXDOUBLE 1.7014117e38
--- /dev/null
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+/* Author: E.G. Keizer */
+
+char rcs_id[] = "$Id$" ;
+
+main() {
+
+ assnull() ;
+ ushift() ;
+ lshift() ;
+ uadd() ;
+ return 0 ;
+}
+
+int a,b ;
+assnull() {
+ int c,d ;
+ /* test a few cases handled especially by the cem-compiler */
+
+ a= -1 ; b= -1 ; c= -1 ; d = -1 ;
+
+ a=b=0 ;
+ c=d=0 ;
+ printf("a %d, b %d, c %d, d %d\n",a,b,c,d) ;
+ a = b = c = d = -32 ;
+ printf (" (a=0) %d, (c=0) %d\n",(a=0),(c=0) ) ;
+ printf("a %d, b %d, c %d, d %d\n",a,b,c,d) ;
+
+}
+ushift() {
+ unsigned u ;
+
+ printf("Unsigned shifts by constants\n") ;
+ u = 0150715 ;
+ printf(" u = %6o\n",u) ;
+ printf(" u>>0 %6o\n", u>>0 ) ;
+ printf(" u>>1 %6o\n", u>>1 ) ;
+ printf(" u>>2 %6o\n", u>>2 ) ;
+ printf(" u>>3 %6o\n", u>>3 ) ;
+ printf(" u>>4 %6o\n", u>>4 ) ;
+ printf(" u>>5 %6o\n", u>>5 ) ;
+ printf(" u>>6 %6o\n", u>>6 ) ;
+ printf(" u>>7 %6o\n", u>>7 ) ;
+ printf(" u>>8 %6o\n", u>>8 ) ;
+ printf(" u>>9 %6o\n", u>>9 ) ;
+ printf(" u>>10 %6o\n", u>>10 ) ;
+ printf(" u>>11 %6o\n", u>>11 ) ;
+ printf(" u>>12 %6o\n", u>>12 ) ;
+ printf(" u>>13 %6o\n", u>>13 ) ;
+ printf(" u>>14 %6o\n", u>>14 ) ;
+ printf(" u>>15 %6o\n", u>>15 ) ;
+ if (sizeof(unsigned) > 2) printf(" u>>16 %6o\n", u>>16 ) ;
+ printf(" u<<0 %6o\n", u<<0 ) ;
+ printf(" u<<1 %6o\n", u<<1 ) ;
+ printf(" u<<2 %6o\n", u<<2 ) ;
+ printf(" u<<3 %6o\n", u<<3 ) ;
+ printf(" u<<4 %6o\n", u<<4 ) ;
+ printf(" u<<5 %6o\n", u<<5 ) ;
+ printf(" u<<6 %6o\n", u<<6 ) ;
+ printf(" u<<7 %6o\n", u<<7 ) ;
+ printf(" u<<8 %6o\n", u<<8 ) ;
+ printf(" u<<9 %6o\n", u<<9 ) ;
+ printf(" u<<10 %6o\n", u<<10 ) ;
+ printf(" u<<11 %6o\n", u<<11 ) ;
+ printf(" u<<12 %6o\n", u<<12 ) ;
+ printf(" u<<13 %6o\n", u<<13 ) ;
+ printf(" u<<14 %6o\n", u<<14 ) ;
+ printf(" u<<15 %6o\n", u<<15 ) ;
+ if (sizeof(unsigned) > 2) printf(" u<<16 %6o\n", u<<16 ) ;
+}
+
+lshift() {
+ long ll ;
+
+ printf("Long shifts by constants\n") ;
+ ll = 400000L - 0532 ;
+ printf(" ll = %11lo\n",ll) ;
+ printf(" ll>>0 %11lo\n", ll>>0 ) ;
+ printf(" ll>>1 %11lo\n", ll>>1 ) ;
+ printf(" ll>>2 %11lo\n", ll>>2 ) ;
+ printf(" ll>>3 %11lo\n", ll>>3 ) ;
+ printf(" ll>>4 %11lo\n", ll>>4 ) ;
+ printf(" ll>>5 %11lo\n", ll>>5 ) ;
+ printf(" ll>>6 %11lo\n", ll>>6 ) ;
+ printf(" ll>>7 %11lo\n", ll>>7 ) ;
+ printf(" ll>>8 %11lo\n", ll>>8 ) ;
+ printf(" ll>>9 %11lo\n", ll>>9 ) ;
+ printf(" ll>>10 %11lo\n", ll>>10 ) ;
+ printf(" ll>>11 %11lo\n", ll>>11 ) ;
+ printf(" ll>>12 %11lo\n", ll>>12 ) ;
+ printf(" ll>>13 %11lo\n", ll>>13 ) ;
+ printf(" ll>>14 %11lo\n", ll>>14 ) ;
+ printf(" ll>>15 %11lo\n", ll>>15 ) ;
+ printf(" ll>>16 %11lo\n", ll>>16 ) ;
+ printf(" ll>>17 %11lo\n", ll>>17 ) ;
+ printf(" ll>>18 %11lo\n", ll>>18 ) ;
+ printf(" ll>>19 %11lo\n", ll>>19 ) ;
+ printf(" ll>>20 %11lo\n", ll>>20 ) ;
+ printf(" ll>>21 %11lo\n", ll>>21 ) ;
+ printf(" ll>>22 %11lo\n", ll>>22 ) ;
+ printf(" ll>>23 %11lo\n", ll>>23 ) ;
+ printf(" ll>>24 %11lo\n", ll>>24 ) ;
+ printf(" ll>>25 %11lo\n", ll>>25 ) ;
+ printf(" ll>>26 %11lo\n", ll>>26 ) ;
+ printf(" ll>>27 %11lo\n", ll>>27 ) ;
+ printf(" ll>>28 %11lo\n", ll>>28 ) ;
+ printf(" ll>>29 %11lo\n", ll>>29 ) ;
+ printf(" ll>>30 %11lo\n", ll>>30 ) ;
+ printf(" ll>>31 %11lo\n", ll>>31 ) ;
+ ll = 1 ;
+ printf(" ll<<0 %11lo\n", ll<<0 ) ;
+ printf(" ll<<1 %11lo\n", ll<<1 ) ;
+ printf(" ll<<2 %11lo\n", ll<<2 ) ;
+ printf(" ll<<3 %11lo\n", ll<<3 ) ;
+ printf(" ll<<4 %11lo\n", ll<<4 ) ;
+ printf(" ll<<5 %11lo\n", ll<<5 ) ;
+ printf(" ll<<6 %11lo\n", ll<<6 ) ;
+ printf(" ll<<7 %11lo\n", ll<<7 ) ;
+ printf(" ll<<8 %11lo\n", ll<<8 ) ;
+ printf(" ll<<9 %11lo\n", ll<<9 ) ;
+ printf(" ll<<10 %11lo\n", ll<<10 ) ;
+ printf(" ll<<11 %11lo\n", ll<<11 ) ;
+ printf(" ll<<12 %11lo\n", ll<<12 ) ;
+ printf(" ll<<13 %11lo\n", ll<<13 ) ;
+ printf(" ll<<14 %11lo\n", ll<<14 ) ;
+ printf(" ll<<15 %11lo\n", ll<<15 ) ;
+ printf(" ll<<16 %11lo\n", ll<<16 ) ;
+ printf(" ll<<17 %11lo\n", ll<<17 ) ;
+ printf(" ll<<18 %11lo\n", ll<<18 ) ;
+ printf(" ll<<19 %11lo\n", ll<<19 ) ;
+ printf(" ll<<20 %11lo\n", ll<<20 ) ;
+ printf(" ll<<21 %11lo\n", ll<<21 ) ;
+ printf(" ll<<22 %11lo\n", ll<<22 ) ;
+ printf(" ll<<23 %11lo\n", ll<<23 ) ;
+ printf(" ll<<24 %11lo\n", ll<<24 ) ;
+ printf(" ll<<25 %11lo\n", ll<<25 ) ;
+ printf(" ll<<26 %11lo\n", ll<<26 ) ;
+ printf(" ll<<27 %11lo\n", ll<<27 ) ;
+ printf(" ll<<28 %11lo\n", ll<<28 ) ;
+ printf(" ll<<29 %11lo\n", ll<<29 ) ;
+ printf(" ll<<30 %11lo\n", ll<<30 ) ;
+}
+uadd() {
+ unsigned u ;
+ int i ;
+
+ u = 32760 ;
+ for ( i=0 ; i<=16 ; ++i ) {
+ printf("%2d %6o\n",i,u+i) ;
+ }
+}
--- /dev/null
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+/* Author: E.G. Keizer */
+static char rcs_id[]= "$Id$" ;
+
+/* test for structure parameters, assignment and return */
+# define ASIZE 26
+
+struct w1 {
+ int w1_i ;
+} ;
+struct w2 {
+ int w2_i ;
+ long w2_l ;
+} ;
+struct w3 {
+ char w3_a[ASIZE] ;
+ unsigned w3_u ;
+} ;
+
+struct w1 es1 ;
+struct w1 es2[3] ;
+
+main() {
+ asst() ;
+ part() ;
+ callt() ;
+ return 0 ;
+
+}
+
+asst() {
+ /* test structure assignment */
+ struct w1 st1, st2, *st3 ;
+ struct w2 s2t1, s2t2, *s2t3 ;
+ struct w3 s3t1, s3t2, *s3t3 ;
+
+
+ register int i ;
+
+ printf("w1\n") ;
+ st1.w1_i = 506 ;
+ st2 = st1 ;
+ printf("\tst2.w1_i %d\n",st2.w1_i) ;
+ st3 = &st1 ;
+ printf("\t(*st3).w1_i %d\n",(*st3).w1_i) ;
+ es1.w1_i = 711 ;
+ st1 = st2 = es1 ;
+ printf("\tst1.w1_i %d\n",st1.w1_i) ;
+ printf("\tst2.w1_i %d\n",st2.w1_i) ;
+ es2[2] = st1 ;
+ printf("\tes2[2].w1_i %d\n",es2[2].w1_i) ;
+
+ st1.w1_i = -577 ;
+ es1.w1_i = 577 ;
+ for ( i=0 ; i<2 ; i++ ) {
+ st2 = ( i ? st1 : es1 ) ;
+ printf("\tst2.w1_i %d\n",st2.w1_i) ;
+ }
+
+ st1 = ( i , es1 ) ;
+ printf("\tst1.w1_i %d\n",st1.w1_i) ;
+
+ printf("w2\n") ;
+ s2t1.w2_i = 18000 ;
+ s2t1.w2_l = 31415 ;
+ s2t2 = s2t1 ;
+ printf("\ts2t2: .w2_i %d .w2_l %ld\n",s2t2.w2_i,s2t2.w2_l) ;
+ s2t3 = &s2t2 ;
+ printf("\ts2t3->w2_l %ld\n",s2t3->w2_l) ;
+
+ printf("w3\n") ;
+ for ( i = 0 ; i<ASIZE ; i++ ) {
+ s3t1.w3_a[i]= 'a'+i ;
+ }
+ s3t1.w3_u = 0x8000 ;
+ s3t2 = s3t1 ;
+ s3t3 = &s3t1 ;
+ for ( i = 0 ; i<ASIZE ; i++ ) {
+ printf("s3t2.w3_a[%2d] %c\n",i,s3t2.w3_a[i]) ;
+ }
+ printf("s3t2.w3_u %x\n",s3t2.w3_u) ;
+ s3t2.w3_u = 1415 ;
+ for ( i = 0 ; i<ASIZE ; i++ ) {
+ s3t2.w3_a[i]= 'A'+i ;
+ }
+ *s3t3 = s3t2 ;
+ for ( i = 0 ; i<ASIZE ; i++ ) {
+ printf("s3t1.w3_a[%2d] %c\n",i,s3t1.w3_a[i]) ;
+ }
+ printf("s3t1.w3_u %x",s3t1.w3_u) ;
+}
+
+struct w3 epars ;
+
+part() {
+ /* test structure parameters */
+
+ struct w3 pars ;
+
+ register int i ;
+
+ for ( i=0 ; i<ASIZE ; i++ ) {
+ pars.w3_a[i]=i+1 ;
+ }
+ pars.w3_u = 281 ;
+ printf("\nstructure parameters\n") ;
+ psc(-1,pars,1000) ;
+}
+
+psc(before,str,after) int before, after ; struct w3 str ; {
+ register int i ;
+
+ printf("before %d\n",before) ;
+ for ( i=0 ; i<ASIZE ; i++ ) {
+ printf("str.w3_a[%2d]\t%d\n",i,str.w3_a[i]) ;
+ }
+ printf("str.w3_u %x\n",str.w3_u) ;
+ printf("after %d\n",after) ;
+}
+
+callt() {
+ /* test structure valued functions */
+ extern struct w3 setp1(), setp2() ;
+ struct w3 myp ;
+ register int i ;
+
+ printf("\nStucture valued functions\n") ;
+ myp = setp1(ASIZE) ;
+ printf("myp.w3_a:\n") ;
+ for ( i=0 ; i<ASIZE ; i++ ) {
+ printf("\t%2d\t%d\n",i,myp.w3_a[i]) ;
+ }
+
+
+ myp = setp2() ;
+ for ( i=0 ; i<ASIZE ; i++ ) {
+ printf("\t%2d\t%d\n",i,myp.w3_a[i]) ;
+ }
+}
+
+struct w3 setp1(count) {
+ struct w3 myp ;
+
+ if ( count<=0 ) {
+ return(myp) ;
+ }
+ myp = setp1(count-1) ;
+ myp.w3_a[count-1] = 99-count-1 ;
+ return(myp) ;
+}
+
+static struct w3 myp2 ;
+
+struct w3 setp2() {
+ struct w3 *w3p ;
+ register int i ;
+
+ for ( i=0 ; i<ASIZE ; i++ ) {
+ myp2.w3_a[i]= 99+i ;
+ }
+ w3p = &myp2 ;
+ return(*w3p) ;
+}
--- /dev/null
+#
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+char rcs_id[] = "$Id$" ;
+
+
+/*
+#define TEST1 1
+*/
+
+
+/* This program can be used to test C-compilers */
+/* It is supposed the first test program (= "test1") */
+/* is used to test the basic arithmetic */
+
+/* The following are global counters */
+
+int t, /* the value indicates the number of the test procedure */
+ ect, /* error counter */
+ tct; /* count the number of test procedures called */
+
+/************************************************************************/
+/* */
+/* The following is tested: */
+/* FOR STATEMENTS in test1 */
+/* WHILE STATEMENTS in test2 */
+/* WHILE and FOR STATEMENTS in test3 */
+/* DO STATEMENTS in test4 */
+/* SWITCH STATEMENTS in test5\e */
+/* */
+/************************************************************************/
+
+
+
+char *pp1 = "End of test program, ";
+char *pp2 = " test(s) completed, ";
+char *pp3 = " errors detected\n";
+char *pp4 = "Error ";
+char *pp5 = " in test";
+char *pp6 = "\n";
+
+itoa(p,ptr)
+/* converts integer "p" to ascii string "ptr" */
+int p;
+char *ptr;
+{
+ register int k,l;
+ register char *str;
+ int sign;
+
+ str=ptr;
+ k=p;
+ if ((sign=k)<0)
+ k = -k;
+ do
+ {
+ l = k % 10;
+ k /= 10;
+ *str++ = l + '0';
+ }
+ while(k);
+ if (sign<0)
+ *str++ = '-';
+ *str = '\0';
+ reverse(ptr);
+}
+
+
+
+reverse(s)
+char s[];
+{
+ register int c,i,j;
+
+ for (i=0, j=strlen(s)-1; i<j; i++, j--)
+ {
+ c=s[i];
+ s[i]=s[j];
+ s[j]=c;
+ }
+}
+
+strlen(str)
+/* returns the length of string str */
+char *str;
+{
+ register char *s, *p;
+
+ p = s = str;
+ while (*p)
+ p++;
+ return(p-s);
+}
+
+
+
+main()
+{
+ char chtct[10],chect[10];
+ tct = 0;
+ ect = 0; /* No errors, so far so good */
+ test1(); /* testing FOR STATEMENTS */
+ test2(); /* testing WHILE STATEMENTS */
+ test3(); /* testing combined FOR and WHILE statements */
+ test4(); /* testing DO statements */
+ test5(); /* testing SWITCH statements */
+ test6(); /* testing GOTO statements */
+ test7();
+ test8();
+ write(1,pp1,strlen(pp1));
+ itoa(tct,chtct);
+ write(1,chtct,strlen(chtct));
+ write(1,pp2,strlen(pp2));
+ itoa(ect,chect);
+ write(1,chect,strlen(chect));
+ write(1,pp3,strlen(pp3));
+ return(ect);
+}
+
+
+
+e(n) /* prints an error message */
+int n;
+{
+ char cht[10],chn[10];
+ ect++; /* total number of errors increased by 1 */
+ write(1,pp4,strlen(pp4));
+ itoa(n,chn);
+ write(1,chn,strlen(chn));
+ write(1,pp5,strlen(pp5));
+ itoa(t,cht);
+ write(1,cht,strlen(cht));
+ write(1,pp6,strlen(pp6));
+}
+
+
+
+test1() /* Testing the for statement */
+{
+ int i, j; /* variables, used as contolling integers in the */
+ /* for statements */
+
+ t = 1; /* This is test 1 */
+ tct++;
+ for ( ; ; )
+ {
+ break;
+ e(1);
+ return; /* If the break doesn't work, let's hope the */
+ /* return does ! */
+ }
+ for ( ; ; )
+ {
+ for ( ; ; )
+ {
+ for ( ; ; )
+ {
+ for ( ; ; )
+ {
+ for ( ; ; )
+ {
+ for ( ; ; )
+ {
+ break;
+ e(2);
+ return;
+ }
+ break;
+ e(3);
+ return;
+ }
+ break;
+ e(4);
+ return;
+ }
+ break;
+ e(5);
+ return;
+ }
+ break;
+ e(6);
+ return;
+ }
+ break;
+ e(7);
+ return;
+ }
+ i=0;
+ for ( ; ; i++)
+ {
+ break;
+ e(8);
+ return;
+ }
+ for (i=0 ; ; i++)
+ {
+ break;
+ e(9);
+ return;
+ }
+ for (i=0 ; i<3; i++)
+ ;
+ if (i != 3) e(10);
+ for (i=0; i<0; i++)
+ e(11);
+ if (i != 0) e(12);
+ for (i=0; i<1; i++)
+ for (i=i; i<i; i++)
+ for (i=i; i<(i+0); i++)
+ for (i=i+0; i<(i-0); i++)
+ for (i=i-0; i<i; i++)
+ e(13);
+ if (i != 1) e(14);
+ for (i=0; i<3; )
+ i++;
+ if (i != 3) e(15);
+ i = 18;
+ j = 3;
+ for ( ; j<i; --i)
+ ;
+ if (i != j) e(16);
+ if (i != 3) e(17);
+ j = -30;
+ for ( ; ; )
+ if (++j)
+ continue;
+ else break;
+ if (j != 0) e(18);
+ i = 0;
+ for (i++, i++, i++, i++; ; )
+ {
+ if (i != 4) e(19);
+ break;
+ }
+ i = 1;
+ for (i=j=i=j=i=j=i; i && j && i; --i, --j)
+ {
+ if (i != 1) e(20);
+ }
+ j=0;
+ for (i=32700; i<32767; i++)
+ j++;
+ if (j != 67) e(21);
+ j=0;
+#ifdef TEST1
+ printf("*** 1\n");
+ for (i=32000; i<=32767; i++)
+ j++;
+ if (j != 68) e(22);
+ printf("*** 2\n");
+#endif
+ j=0;
+ for (i=32767; i>32700; i--)
+ j++;
+ if (j != 67) e(23);
+ j=0;
+ for (i= -32768; i<-32700; i++)
+ j++;
+ if (j != 68) e(24);
+}
+
+
+
+
+test2() /* Testing the while statement */
+{
+ int i, j;
+
+ t = 2;
+ tct++;
+ while(1)
+ {
+ break;
+ e(1);
+ return;
+ }
+ while(0)
+ {
+ e(2);
+ break;
+ e(3);
+ return;
+ }
+ while (1 || 0)
+ {
+ break;
+ e(4);
+ return;
+ }
+ while (1 && 0)
+ {
+ e(5);
+ break;
+ e(6);
+ return;
+ }
+ j = 10;
+ while (--j)
+ ;
+ if (j != 0) e(7);
+ while (j)
+ {
+ e(8);
+ break;
+ }
+ while ( i=j )
+ {
+ e(9);
+ break;
+ }
+ while ( (i==j) && (i!=j) )
+ {
+ e(10);
+ break;
+ }
+ j = 1;
+ while (j)
+ while(j)
+ while(j)
+ while(j)
+ while(j)
+ while(--j)
+ ;
+ if (j != 0) e(11);
+ if (j) e(12);
+ j = 30;
+ while (--j)
+ {
+ continue;
+ continue;
+ continue;
+ continue;
+ continue;
+ break;
+ e(13);
+ }
+}
+
+
+
+
+test3() /* Combined FOR and WHILE statements */
+{
+ int i,j;
+
+ t = 3;
+ tct++;
+ j = 0;
+ for (i=3; i; i++)
+ {
+ while (i--)
+ ;
+ if (++j > 1) e(1);
+ }
+}
+
+
+
+
+test4() /* Do statement */
+{
+ int i;
+
+ t = 4;
+ tct++;
+ i = 0;
+ do
+ if (i) e(1);
+ while (i);
+ do
+ {
+ do
+ {
+ do
+ {
+ do
+ {
+ i++;
+ }
+ while (!i);
+ i++;
+ }
+ while (!i);
+ i++;
+ }
+ while (!i);
+ i++;
+ }
+ while (!i);
+ if (i != 4) e(2);
+}
+
+
+
+
+test5() /* SWITCH statement */
+{
+ int i,j;
+
+ t = 5;
+ tct++;
+ for (i=0; i<10; i++)
+ {
+ switch (i)
+ {
+ case 0: if (i != 0) e(1);
+ break;
+ case 1: if (i != 1) e(2);
+ break;
+ case 2: if (i != 2) e(3);
+ break;
+ case 3: if (i != 3) e(4);
+ i++;
+ case 4: if (i != 4) e(5);
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ break;
+ default: e(6);
+ }
+ }
+ for (i=j= -18; i<10; i++, j++)
+ {
+ switch (i)
+ {
+ case -3:
+ case 7:
+ case 1: switch (j)
+ {
+ case -3:
+ case 7:
+ case 1:
+ break;
+ default: e(7);
+ }
+ break;
+ e(8);
+ case -4: switch (j)
+ {
+ case -4: if (i != -4) e(9);
+ break;
+ default: e(10);
+ }
+ }
+ }
+ i = 'a';
+ switch (i)
+ {
+ case 'a':
+ switch ( i )
+ {
+ case 'a':
+ switch ( i )
+ {
+ case 'a':
+ break;
+ default: e(11);
+ }
+ break;
+ default: e(12);
+ }
+ break;
+ default: e(13);
+ }
+}
+
+
+
+test6() /* goto statement */
+{
+ int k;
+
+ t = 6;
+ tct++;
+ k = 0;
+ goto lab0;
+xl1:
+ k = 1;
+ goto lab1;
+xl2:
+ k = 2;
+ goto lab2;
+xl3:
+ k = 3;
+ goto lab3;
+xl4:
+ k = 4;
+ goto llab1;
+llab2: goto llab3;
+llab4: goto llab5;
+llab6: goto llab7;
+llab8: if ( k != 4 ) e(5);
+ return ;
+llab1: goto llab2;
+llab3: goto llab4;
+llab5: goto llab6;
+llab7: goto llab8;
+lab0: if ( k!= 0 ) e(1);
+ goto xl1 ;
+lab1: if ( k!= 1 ) e(2);
+ goto xl2 ;
+lab2: if ( k!= 2 ) e(3);
+ goto xl3 ;
+lab3: if ( k!= 3 ) e(4);
+ goto xl4 ;
+}
+
+
+
+test7() /* Combinations of FOR, WHILE, DO and SWITCH statements */
+{
+ int i,j,k;
+
+ t = 7;
+ tct++;
+ for ( i=j=k=0; i<6; i++, j++, k++ )
+ {
+ if ( i != j ) e(1);
+ if ( i != k ) e(2);
+ if ( j != k ) e(3);
+ while ( i > j )
+ {
+ e(4);
+ break;
+ }
+ while ( i > k )
+ {
+ e(5);
+ break;
+ }
+ while ( j != k )
+ {
+ e(6);
+ break;
+ }
+ switch(i)
+ {
+ case 0:
+ switch(j)
+ {
+ case 0:
+ switch(k)
+ {
+ case 0: if ( i+j+k != 0 ) e(7);
+ break;
+ e(8);
+ default: if ( i+j+k != k ) e(9);
+ }
+ break;
+ default: if ( j > 6 ) e(10);
+ if ( k != j ) e(11);
+ }
+ break;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5: break;
+ default: e(12);
+ }
+ }
+ for ( i=j= -3; i<0; i++,j++)
+ if ( j == -3 )
+ do
+ if ( i )
+ switch ( i )
+ {
+ case -3: if ( j != i ) e(13);
+ case -2: if ( j != i ) e(14);
+ case -1: for ( k=i; k < 2*j-j; k++)
+ {
+ e(15);
+ break;
+ }
+ break;
+ case 0: e(16);
+ break;
+ default: e(17);
+ break;
+ }
+ else e(18);
+ while ( 0 );
+ if ( i != j ) e(19);
+}
+
+
+
+
+test8()
+{
+ int *p1, *p2;
+ int i,j,k;
+ int a1[1], a2[2][2], a3[3][3][3];
+
+ t = 8;
+ tct++;
+ a1[0] = 0;
+ for ( i=0; i<2; i++ )
+ for ( j=0; j<2; j++ )
+ a2[i][j] = (i*j) ^ (i+j);
+ if ( a2[0][0] != 0 ) e(1);
+ if ( a2[0][1] != 1 ) e(2);
+ if ( a2[1][0] != a2[0][1] ) e(3);
+ for ( i=0; i<3; i++)
+ for (j=0; j<3; j++)
+ for (k=0; k<3; k++)
+ a3[i][j][k] = i | j | k;
+ if ( a3[0][0][0] != 0 ) e(4);
+ if ( a3[0][1][2] != a3[2][0][1] ) e(5);
+ if ( a3[2][1][1] != (2 | 1 | 1) ) e(6);
+ p2 = &a3[0][1][2];
+ p1 = &a3[0][1][2];
+ for ( ; p1 == p2 ; p1++ )
+ {
+ switch ( *p1 )
+ {
+ case 3: break;
+ default: e(7);
+ }
+ if ( *p1 != *p2 ) e(8);
+ }
+}
--- /dev/null
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+char rcs_id[] = "$Id$" ;
+
+/* C-compiler test 1 */
+/* This program can be used to test C-compilers */
+
+#ifndef NOFLOAT
+# define EPSD 1e-6
+# define EPSF 1e-6
+#endif
+
+/* global counters */
+
+int t, /* the value indicates the number of the test procedure */
+ ect, /* error counter */
+ tct; /* count the number of test procedures called */
+
+/****************************************************************************/
+/*
+ * The following is tested:
+ * INTEGER CONSTANTS in test1
+ * GLOBAL INTEGER VARIABLES in test2
+ * LOCAL INTEGER VARIABLES in test3
+ * GLOBAL LONG VARIABLES in test4
+ * LOCAL LONG VARIABLES in test5
+ * REAL ARITHMETIC in test6
+ * GLOBAL RECORDS in test7
+ * LOCAL RECORDS in test8
+ * GLOBAL ARRAYS in test9
+ * LOCAL ARRAYS in test10
+ * GLOBAL POINTERS in test11
+ */
+/***************************************************************************/
+char alstr[1000] ;
+char *alptr = alstr ;
+
+char *alloc(size) {
+ register char *retval ;
+
+ retval=alptr ;
+ alptr += size ;
+ if ( alptr-alstr>sizeof alstr ) {
+ printf("allocation overflow\n") ;
+ exit(8) ;
+ }
+ return(retval) ;
+}
+
+#ifndef NOFLOAT
+double fabs(a) double a ; { return( a<0 ? -a : a) ; }
+#endif
+
+
+
+/* global variables for the test procedures */
+
+int i,j,k,l,m;
+
+long li,lj,lk,ll,lm;
+
+#ifndef NOFLOAT
+float xf, yf, zf;
+
+double xd, yd, zd;
+#endif
+
+struct tp2 {
+ char c1;
+ int i,j;
+#ifndef NOFLOAT
+ float aaa;
+ double bbb;
+#endif
+} r1, r2;
+
+int p, *p1, *p11, **p2, ***p3, ****p4, *****p5;
+
+struct tp2 *pp1, *pp2, *pp3;
+int a1[20];
+#ifndef NOFLOAT
+float a2[20];
+double a3[20];
+#endif
+
+main()
+{
+ tct = 0;
+ ect = 0;
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+ test9();
+ test10();
+#ifndef NOFLOAT
+ test11();
+#endif
+ printf("End of test program, %d tests completed, %d errors detected\n",
+ tct,ect);
+ return 0 ;
+}
+
+
+
+e(n)
+int n;
+{
+ ect++;
+ printf("Error %d in test%d \n",n,t);
+}
+
+
+
+test1() /* testing integer constants */
+{
+ t = 1;
+ tct++;
+ if (0) e(1);
+ if (!1) e(2);
+ if ( 1+2 != 3 ) e(3);
+ if (-500 - 234 != -734) e(4);
+ if (-32 + 155 != 123) e(5);
+ if ( 2*3 != 6) e(6);
+ if ( 3*4*5*6 != 360) e(7);
+ if ( 654-3*2 != 648) e(8);
+ if (5*5 + 5*5 != 50) e(9);
+ if ( 1+1-1+1-1+1-1+1-1+1 != 2) e(10);
+/**********************************************************************/
+ if ( ((((((((((((((((((((0)))))))))))))))))))) ) e(11);
+ if ( (((-2))) - ((((-3)))) * (3+((2))) != 13 ) e(12);
+ if ( 1+1 != 2 ) e(13);
+ if ( 3333 + 258 != 3591) e(14);
+ if (3*4 != 12) e(15);
+ if (111*111 != 12321) e(16);
+ if (50 / 5 != 10) e(17);
+ if (7498 / 75 != 99) e(18);
+ if (456 - 345 != 111) e(19);
+ if (1+(-2) != -1) e(20);
+ if (-3 * -4 != 12) e(21);
+ if (-2 / 2 != -1) e(22);
+ if (-5 / 1 != -5) e(23);
+ if (-4 - -5 != 1) e(24);
+ if ( 03 + 02 != 05) e(25);
+ if ( 03456 + 88 != 03606 ) e(26);
+ if ( 0100 * 23 != 02700 ) e(27);
+ if ( 045 / 020 != 2 ) e(28);
+ if ( 0472 - 0377 != 073 ) e(29);
+ if ( 'a' != 'a' ) e(30);
+ if ( 'a' + 'c' != 'b' + 'b' ) e(31);
+ if ( 'z' * 'z' != 14884 ) e(32);
+ if ( -'z' / 01 != -'z' ) e(33);
+ if ( 077777 >> 3 != 07777 ) e(34);
+ if ( 077777 >> 15 ) e(35);
+ if ( ( 0124 & 07765 ) != 0124 ) e(37);
+ if ( ( 34 & 31 ) != 2 ) e(38);
+ if (( 5 | 013 | 020 ) != 31 ) e(39);
+ if ( ( -7 ^ 3 ) != -6 ) e(40);
+ if ( (07373 ^ 4632 ) != 016343 ) e(41);
+ if ( (1+2+3)*(2+3+4)*(3+5+5) / 2 != ((3*((5+3+2)*10)+51)*6)/6 ) e(42);
+ if ( (1000*2+5*7+13)/8 != 2*2*2*2*4*4 ) e(43);
+ if ( ( 1*2*3*4*5*6*7 / 5040 ) != 5040 / 7 / 6 / 5 / 4 / 3 / 2 / 1 ) e(44);
+ if ( (-(-(-(-(-(-(1))))))) != 1) e(45);
+ if ( - 1 != -((((((((1)))))))) ) e(46);
+ if ( -1-1-1-1-1-1 != -6+3-3 ) e(47);
+ if ( 2<1 ) e(48);
+ if ( 2==3 ) e(49);
+ if ( 2 != 2 ) e(50);
+ if ( 2>3 ) e(51);
+ if ( 2+0 != 2 ) e(52);
+ if ( 2-0 != 2 ) e(53);
+ if ( 2*0 != 0 ) e(54);
+ if ( 0/1 != 0 ) e(55);
+ if ( 0*0 != 0 ) e(56);
+ if (32767 > 32767) e(57);
+ if ( -32768 > -32767 ) e(58);
+ if ( 0456 < 0400 ) e(59);
+ if ( 0456 != ( 0400 | 050 | 06 ) ) e(60);
+ if ( 2*2 + (2<<2) != 12 ) e(61);
+ if ( 0 || 0 ) e(62);
+ if ( 1 && 0 ) e(63);
+ if ( ( 123 ? 123*4 : 345 ) != 492 ) e(64);
+ if ( ( 0 ? 345 : 280 ) != 280 ) e(65);
+ if ( ( 4>>10 ) + 3 != 3 ) e(66);
+ if ( ! ( 111 || 23 && 0 ) ) e(67);
+ if ( !1 ) e(68);
+ if ( !0 == 0 ) e(69);
+ if ( !!!!!!!!!!0 ) e(70);
+ if ( 2*2*2*2 != 4*4 ) e(71);
+ if ( 0 && 0 && 0 && 0000 && 000000000000 ) e(72);
+ if ( 1 & 1 & 1 && 1 & 1 && 1 & 0 ) e(73);
+ if ( 01 + 01 + 01 != 1 + 1 + 1 ) e(74);
+ if ( 07 + 1 != 010 ) e(75);
+ if ( ('a' & 017777) != 'a' ) e(76);
+ if ( ( 3 >> 0 ) != 3 ) e(77);
+ if ( ( 3 << 0 ) != 3 ) e(78);
+ if ( ((((((((((3)))))))))) << ((((((((((((2)))))))))))) != 12 ) e(79);
+ if ( (((3 << 4)) >> 4) != 3 ) e(80);
+ if ( (2+'a')*'b' != 2*'b' + 'a'*'b' ) e(81);
+ if ( 'a' * 'a' < 0 ) e(82);
+ if ( ('a'-'a'+'a'-'a'+('a'-'a')*'h') >> 3 ) e(82);
+ if ( 'z' - 01 != 'y' + 00 ) e(83);
+ if ( 'a' ^ 'a' ) e(84);
+ if ( 'h' ^ 'h' ^ 'a' ^ 'a' ) e(85);
+ if ( 0567 ^ (0500 | 060 | 7 ) ) e(86);
+ if ( 0 ^ 0 ^ 0 ^ 00 ) e(87);
+ if ( ( !0 ) ^ (!0) ) e(88);
+ if ( ( !!!40 ) ^ (!!!050) ) e(89);
+ if ( ( 6^7 ) * 345 != 345 ) e(90);
+ if ( !!!!!!!!!!!!! 'k' ) e(91);
+ if ( !!!((('k'))) ) e(92);
+ if ( -0 != 0 ) e(93) ;
+}
+
+
+
+
+test2() /* testing global integer variables */
+{
+ t = 2;
+ tct++;
+ i = 1;
+ j = 2;
+ k = 3;
+ l = 4;
+ m = 10;
+ if ( i + j != k ) e(1);
+ if ( i + k != l ) e(2);
+ if ( j - k != -i ) e(3);
+ if ( j*(j+k) != m ) e(4);
+ if ( -m != -(k+k+l) ) e(5);
+ if ( i/i != 1 ) e(6);
+ if ( m*m / m != m ) e(7);
+ if ( 10*m != 100 ) e(8);
+ if ( m * (-10) != -100 ) e(9);
+ if ( j/k != 0 ) e(10);
+ if ( 100/k != 33 ) e(11);
+ if ( i+j*k+l+m / j+50 / k != 32 ) e(12);
+ if ( j*k*m / 6 != 10 ) e(13);
+ if ( (k>4) || (k>=4) || (k==4) ) e(14);
+ if ( (m<j) || (m<=j) || (m==j) ) e(15);
+ if ( i+j-k ) e(16);
+ if ( j<i ) e(17);
+ if ( j != j ) e(18);
+ if ( i>j ) e(19);
+ if ( (i>j ? k : k*j) != 6 ) e(20);
+ if ( (i<j ? k : k*j) != 3 ) e(21);
+ if ( j<<i != l ) e(22);
+ if ( j>> i != i ) e(25);
+ if ( i++ != 1 ) e(26);
+ if ( --i != 1 ) e(27);
+ if ( i-- != 1 ) e(28);
+ if ( (i+j) && (i<0) || (m-10) && (064) ) e(29);
+ if ( (i+j) && !(i>=0) || (m-10) && !(0) ) e(30);
+ i = 2;
+ j = 4;
+ k = 8;
+ l = 16;
+ m = 32;
+ if ( i != 02 ) e(31);
+ if ( j != 04 ) e(32);
+ if ( k != 010 ) e(33);
+ if ( l != 020 ) e(34);
+ if ( i & j ) e(35);
+ if ( i & j & k & l & m ) e(36);
+ if ( ! ( i & j & k & l & m | i ) ) e(37);
+ if ( ( i >> 0 ) != i ) e(38);
+ if ( (( i/i ) << 1 ) != 02 ) e(39);
+ if ( ( i | (j) | (k) | (l) | (m) ) != i+j+k+l+m ) e(40);
+ if (!(i^j) ) e(41);
+ if ( !(i^j^k^l^m) ) e(42);
+ if ( ( --i << 1 ) != 2 ) e(43);
+ if ( ( i << 01 ) != 2 ) e(44);
+ if ( i%j != i ) e(45);
+ if ( k%l != k ) e(46);
+ if (( (m/l) << i >> i ) != 2 ) e(47);
+ if ( (i = j = k = l = m) != m ) e(48);
+ if ( ( i!=j ) || ( j!=k ) || !(l==m) ) e(49);
+ if ( (i<j) || (j>i) || (k<m) ) e(50);
+ if ( (i%j) || (j%i) || (k%l) || (m%l) ) e(51);
+ if ( (i% (j<<0) + ((j<<3)>>3)%(i/i)) ) e(52);
+ if ( ! ( i++ == j++ ) ) e(53);
+ if ( i != j ) e(54);
+ if ( i++ != (j++) ) e(55);
+ i = 1;
+ j = i + 1;
+ if ( -i != -i ) e(56);
+ if ( i != --j ) e(57);
+ if ( (((((i))))) != -(-(-(-(i)))) ) e(59);
+ if ( j != 1 ) e(60);
+}
+
+
+
+
+test3() /* testing local integer variables */
+{
+ int a,b,c,d,f;
+
+ t = 3;
+ tct++;
+ a = 1;
+ b = 2;
+ c = 3;
+ d = 4;
+ f = 10;
+ if ( a + b != c ) e(1);
+ if ( a + c != d ) e(2);
+ if ( b - c != -a ) e(3);
+ if ( b*(b+c) != f ) e(4);
+ if ( -f != -(c+c+d) ) e(5);
+ if ( a/a != 1 ) e(6);
+ if ( f*f / f != f ) e(7);
+ if ( 10*f != 100 ) e(8);
+ if ( f * (-10) != -100 ) e(9);
+ if ( b/c != 0 ) e(10);
+ if ( 100/c != 33 ) e(11);
+ if ( a+b*c+d+f / b+50 / c != 32 ) e(12);
+ if ( b*c*f / 6 != 10 ) e(13);
+ if ( (c>4) || (c>=4) || (c==4) ) e(14);
+ if ( (f<b) || (f<=b) || (f==b) ) e(15);
+ if ( a+b-c ) e(16);
+ if ( b<a ) e(17);
+ if ( b != b ) e(18);
+ if ( a>b ) e(19);
+ if ( (a>b ? c : c*b) != 6 ) e(20);
+ if ( (a<b ? c : c*b) != 3 ) e(21);
+ if ( b<<a != d ) e(22);
+ if ( b>> a != a ) e(25);
+ if ( a++ != 1 ) e(26);
+ if ( --a != 1 ) e(27);
+ if ( a-- != 1 ) e(28);
+ if ( (a+b) && (a<0) || (f-10) && (064) ) e(29);
+ if ( (a+b) && !(a>=0) || (f-10) && !(0) ) e(30);
+ a = 2;
+ b = 4;
+ c = 8;
+ d = 16;
+ f = 32;
+ if ( a != 02 ) e(31);
+ if ( b != 04 ) e(32);
+ if ( c != 010 ) e(33);
+ if ( d != 020 ) e(34);
+ if ( a & b ) e(35);
+ if ( a & b & c & d & f ) e(36);
+ if ( ! ( a & b & c & d & f | a ) ) e(37);
+ if ( ( a >> 0 ) != a ) e(38);
+ if ( (( a/a ) << 1 ) != 02 ) e(39);
+ if ( ( a | (b) | (c) | (d) | (f) ) != a+b+c+d+f ) e(40);
+ if (!(a^b) ) e(41);
+ if ( !(a^b^c^d^f) ) e(42);
+ if ( ( --a << 1 ) != 2 ) e(43);
+ if ( ( a << 01 ) != 2 ) e(44);
+ if ( a%b != a ) e(45);
+ if ( c%d != c ) e(46);
+ if (( (f/d) << a >> a ) != 2 ) e(47);
+ if ( (a = b = c = d = f) != f ) e(48);
+ if ( ( a!=b ) || ( b!=c ) || !(d==f) ) e(49);
+ if ( (a<b) || (b>a) || (c<f) ) e(50);
+ if ( (a%b) || (b%a) || (c%d) || (f%d) ) e(51);
+ if ( (a%(b<<0) + ((b<<3)>>3)%(a/a)) ) e(52);
+ if ( ! ( a++ == b++ ) ) e(53);
+ if ( a != b ) e(54);
+ if ( a++ != (b++) ) e(55);
+ a = 1;
+ b = a + 1;
+ if ( -a != -a ) e(56);
+ if ( a != --b ) e(57);
+ if ( (((((a))))) != -(-(-(-(a)))) ) e(59);
+ if ( b != 1 ) e(60);
+}
+
+
+
+
+test4() /* testing global long variables */
+{
+ t = 4;
+ tct++;
+ li = 1;
+ lj = 2;
+ lk = 3;
+ ll = 4;
+ lm = 10;
+ if ( li + lj != lk ) e(1);
+ if ( li + lk != ll ) e(2);
+ if ( lj - lk != -li ) e(3);
+ if ( lj*(lj+lk) != lm ) e(4);
+ if ( -lm != -(lk+lk+ll) ) e(5);
+ if ( li/li != 1 ) e(6);
+ if ( lm*lm / lm != lm ) e(7);
+ if ( 10*lm != 100 ) e(8);
+ if ( lm * (-10) != -100 ) e(9);
+ if ( lj/lk != 0 ) e(10);
+ if ( 100/lk != 33 ) e(11);
+ if ( li+lj*lk+ll+lm / lj+50 / lk != 32 ) e(12);
+ if ( lj*lk*lm / 6 != 10 ) e(13);
+ if ( (lk>4) || (lk>=4) || (lk==4) ) e(14);
+ if ( (lm<lj) || (lm<=lj) || (lm==lj) ) e(15);
+ if ( li+lj-lk ) e(16);
+ if ( lj<li ) e(17);
+ if ( lj != lj ) e(18);
+ if ( li>lj ) e(19);
+ if ( (li>lj ? lk : lk*lj) != 6 ) e(20);
+ if ( (li<lj ? lk : lk*lj) != 3 ) e(21);
+ if ( lj<<li != ll ) e(22);
+ if ( lj>> li != li ) e(25);
+ if ( li++ != 1 ) e(26);
+ if ( --li != 1 ) e(27);
+ if ( li-- != 1 ) e(28);
+ if ( (li+lj) && (li<0) || (lm-10) && (064) ) e(29);
+ if ( (li+lj) && !(li>=0) || (lm-10) && !(0) ) e(30);
+ li = 2;
+ lj = 4;
+ lk = 8;
+ ll = 16;
+ lm = 32;
+ if ( li != 02 ) e(31);
+ if ( lj != 04 ) e(32);
+ if ( lk != 010 ) e(33);
+ if ( ll != 020 ) e(34);
+ if ( li & lj ) e(35);
+ if ( li & lj & lk & ll & lm ) e(36);
+ if ( ! ( li & lj & lk & ll & lm | li ) ) e(37);
+ if ( ( li >> 0 ) != li ) e(38);
+ if ( (( li/li ) << 1 ) != 02 ) e(39);
+ if ( ( li | (lj) | (lk) | (ll) | (lm) ) != li+lj+lk+ll+lm ) e(40);
+ if (!(li^lj) ) e(41);
+ if ( !(li^lj^lk^ll^lm) ) e(42);
+ if ( ( --li << 1 ) != 2 ) e(43);
+ if ( ( li << 01 ) != 2 ) e(44);
+ if ( li%lj != li ) e(45);
+ if ( lk%ll != lk ) e(46);
+ if (( (lm/ll) << li >> li ) != 2 ) e(47);
+ if ( (li = lj = lk = ll = lm) != lm ) e(48);
+ if ( ( li!=lj ) || ( lj!=lk ) || !(ll==lm) ) e(49);
+ if ( (li<lj) || (lj>li) || (lk<lm) ) e(50);
+ if ( (li%lj) || (lj%li) || (lk%ll) || (lm%ll) ) e(51);
+ if ( (li%(lj<<0) + ((lj<<3)>>3)%(li/li)) ) e(52);
+ if ( ! ( li++ == lj++ ) ) e(53);
+ if ( li != lj ) e(54);
+ if ( li++ != (lj++) ) e(55);
+ li = 1;
+ lj = li + 1;
+ if ( -li != -li ) e(56);
+ if ( li != --lj ) e(57);
+ if ( (((((li))))) != -(-(-(-(li)))) ) e(59);
+ if ( lj != 1 ) e(60);
+ li = 40000;
+ lj = 80000;
+ lk = 800000L;
+ ll = -800000L;
+ lm = 1200000L;
+ if ( lk != -ll ) e(61);
+ if ( 10 * li != 400000L ) e(62);
+ if ( 2 * li != lj ) e(63);
+ if ( -(-(-(-(li)))) != li ) e(64);
+ if ( 10 * lj != lk ) e(65);
+ if ( lm + lm != 2 * lm ) e(66);
+ if ( lm - lm ) e(67);
+ if ( lk / lk != 1 ) e(68);
+ if ( lk / lj != 10 ) e(69);
+ if ( lm / li != 30 ) e(70);
+ if ( li + lj != lm / 10 ) e(71);
+ if ( li - 40000 - 1 != lk - 800001L ) e(72);
+ if ( li + li + li + li +li + li != lj + lj + lj ) e(73);
+ if ( li > lj ) e(74);
+ if ( lj > lk ) e(75);
+ if ( lm < ll ) e(76);
+ if ( (lm<1000000L) || (((lk-lj-lj*10)>0)) ) e(77);
+ if ( lm / 01 != lm ) e(78);
+ if ( lm * 01 != lm ) e(79);
+ if ( lm + 'a' != lm + 'b' -1 ) e(80);
+ if ( (lm % 'a') % 'a' != lm % 'a' ) e(81);
+ if ( lm % lm ) e(82);
+ if ( lj % li ) e(83);
+ if ( (lm<<1) != lm * 2 ) e(84);
+ if ( ! ( ( --lm % li ) + 1 ) ) e(86);
+ if ( ( lj >> 1 ) ^ li ) e(87);
+ li = 1;
+ if ( li != 1 ) e(89);
+ li <<= 20;
+ lj = 2;
+ if ( (lj<<19) != li ) e(90);
+ li = lj = lk= ll = lm = -345678L;
+ if ( (li != lj) || (lj != lk) || (ll != lm) ) e(91);
+ if ( (li != lj) || (lj != lk) || (lk != ll) || (ll != lm) ) e(92);
+ if ( li != -345678L ) e(93);
+ li = 1 | 2;
+ li <<= 20;
+ lj = li & li & li & li & li | li | li | li;
+ if ( li != lj ) e(94);
+ if ( ! ( li & lj ) ) e(95);
+ if ( li ^ lj ) e(96);
+ if ( ! (li | lj) ) e(97);
+ if ( (li >> 20) != 3 ) e(98);
+ li = 20000;
+ li *= 2;
+ if ( li < 0 ) e(99);
+ if ( 1 * li != li ) e(100);
+ lj = 20000;
+ if ( (lj<<1) != li ) e(101);
+ if ( (5*lj)/10 != lj/2 ) e(102);
+ if ( 4*lj != 1*01*2*2*lj ) e(103);
+ li = lj = 30000;
+ if ( li != li * lj / 30000 ) e(104);
+ if ( ++li != ++lj ) e(105);
+ lk = 5;
+ ll = 150000L;
+ if ( lk * (li-1) != ll ) e(106);
+}
+
+
+
+
+test5() /* testing local long variables */
+{
+ long la, lb, lc, ld, lf;
+
+ t = 5;
+ tct++;
+ la = 1;
+ lb = 2;
+ lc = 3;
+ ld = 4;
+ lf = 10;
+ if ( la + lb != lc ) e(1);
+ if ( la + lc != ld ) e(2);
+ if ( lb - lc != -la ) e(3);
+ if ( lb*(lb+lc) != lf ) e(4);
+ if ( -lf != -(lc+lc+ld) ) e(5);
+ if ( la/la != 1 ) e(6);
+ if ( lf*lf / lf != lf ) e(7);
+ if ( 10*lf != 100 ) e(8);
+ if ( lf * (-10) != -100 ) e(9);
+ if ( lb/lc != 0 ) e(10);
+ if ( 100/lc != 33 ) e(11);
+ if ( la+lb*lc+ld+lf / lb+50 / lc != 32 ) e(12);
+ if ( lb*lc*lf / 6 != 10 ) e(13);
+ if ( (lc>4) || (lc>=4) || (lc==4) ) e(14);
+ if ( (lf<lb) || (lf<=lb) || (lf==lb) ) e(15);
+ if ( la+lb-lc ) e(16);
+ if ( lb<la ) e(17);
+ if ( lb != lb ) e(18);
+ if ( la>lb ) e(19);
+ if ( (la>lb ? lc : lc*lb) != 6 ) e(20);
+ if ( (la<lb ? lc : lc*lb) != 3 ) e(21);
+ if ( lb<<la != ld ) e(22);
+ if ( lb>> la != la ) e(25);
+ if ( la++ != 1 ) e(26);
+ if ( --la != 1 ) e(27);
+ if ( la-- != 1 ) e(28);
+ if ( (la+lb) && (la<0) || (lf-10) && (064) ) e(29);
+ if ( (la+lb) && !(la>=0) || (lf-10) && !(0) ) e(30);
+ la = 2;
+ lb = 4;
+ lc = 8;
+ ld = 16;
+ lf = 32;
+ if ( la != 02 ) e(31);
+ if ( lb != 04 ) e(32);
+ if ( lc != 010 ) e(33);
+ if ( ld != 020 ) e(34);
+ if ( la & lb ) e(35);
+ if ( la & lb & lc & ld & lf ) e(36);
+ if ( ! ( la & lb & lc & ld & lf | la ) ) e(37);
+ if ( ( la >> 0 ) != la ) e(38);
+ if ( (( la/la ) << 1 ) != 02 ) e(39);
+ if ( ( la | (lb) | (lc) | (ld) | (lf) ) != la+lb+lc+ld+lf ) e(40);
+ if (!(la^lb) ) e(41);
+ if ( !(la^lb^lc^ld^lf) ) e(42);
+ if ( ( --la << 1 ) != 2 ) e(43);
+ if ( ( la << 01 ) != 2 ) e(44);
+ if ( la%lb != la ) e(45);
+ if ( lc%ld != lc ) e(46);
+ if (( (lf/ld) << la >> la ) != 2 ) e(47);
+ if ( (la = lb = lc = ld = lf) != lf ) e(48);
+ if ( ( la!=lb ) || ( lb!=lc ) || !(ld==lf) ) e(49);
+ if ( (la<lb) || (lb>la) || (lc<lf) ) e(50);
+ if ( (la%lb) || (lb%la) || (lc%ld) || (lf%ld) ) e(51);
+ if ( (la%(lb<<0) + ((lb<<3)>>3)%(la/la)) ) e(52);
+ if ( ! ( la++ == lb++ ) ) e(53);
+ if ( la != lb ) e(54);
+ if ( la++ != (lb++) ) e(55);
+ la = 1;
+ lb = la + 1;
+ if ( -la != -la ) e(56);
+ if ( la != --lb ) e(57);
+ if ( (((((la))))) != -(-(-(-(la)))) ) e(59);
+ if ( lb != 1 ) e(60);
+ la = 40000;
+ lb = 80000;
+ lc = 800000L;
+ ld = -800000L;
+ lf = 1200000L;
+ if ( lc != -ld ) e(61);
+ if ( 10 * la != 400000L ) e(62);
+ if ( 2 * la != lb ) e(63);
+ if ( -(-(-(-(la)))) != la ) e(64);
+ if ( 10 * lb != lc ) e(65);
+ if ( lf + lf != 2 * lf ) e(66);
+ if ( lf - lf ) e(67);
+ if ( lc / lc != 1 ) e(68);
+ if ( lc / lb != 10 ) e(69);
+ if ( lf / la != 30 ) e(70);
+ if ( la + lb != lf / 10 ) e(71);
+ if ( la - 40000 - 1 != lc - 800001L ) e(72);
+ if ( la + la + la + la +la + la != lb + lb + lb ) e(73);
+ if ( la > lb ) e(74);
+ if ( lb > lc ) e(75);
+ if ( lf < ld ) e(76);
+ if ( (lf<1000000L) || (((lc-lb-lb*10)>0)) ) e(77);
+ if ( lf / 01 != lf ) e(78);
+ if ( lf * 01 != lf ) e(79);
+ if ( lf + 'a' != lf + 'b' -1 ) e(80);
+ if ( (lf % 'a') % 'a' != lf % 'a' ) e(81);
+ if ( lf % lf ) e(82);
+ if ( lb % la ) e(83);
+ if ( (lf<<1) != lf * 2 ) e(84);
+ if ( ! ( ( --lf % la ) + 1 ) ) e(86);
+ if ( ( lb >> 1 ) ^ la ) e(87);
+ la = 1;
+ if ( la != 1 ) e(89);
+ la <<= 20;
+ lb = 2;
+ if ( (lb<<19) != la ) e(90);
+ la = lb = lc= ld = lf = -345678L;
+ if ( (la != lb) || (lb != lc) || (ld != lf) ) e(91);
+ if ( (la != lb) || (lb != lc) || (lc != ld) || (ld != lf) ) e(92);
+ if ( la != -345678L ) e(93);
+ la = 1 | 2;
+ la <<= 20;
+ lb = la & la & la & la & la | la | la | la;
+ if ( la != lb ) e(94);
+ if ( ! ( la & lb ) ) e(95);
+ if ( la ^ lb ) e(96);
+ if ( ! (la | lb) ) e(97);
+ if ( (la >> 20) != 3 ) e(98);
+ la = 20000;
+ la *= 2;
+ if ( la < 0 ) e(99);
+ if ( 1 * la != la ) e(100);
+ lb = 20000;
+ if ( (lb<<1) != la ) e(101);
+ if ( (5*lb)/10 != lb/2 ) e(102);
+ if ( 4*lb != 1*01*2*2*lb ) e(103);
+ la = lb = 30000;
+ if ( la != la * lb / 30000 ) e(104);
+ if ( ++la != ++lb ) e(105);
+ lc = 5;
+ ld = 150000L;
+ if ( lc * (la-1) != ld ) e(106);
+}
+
+
+
+test6() /* global records */
+{
+#ifndef NOFLOAT
+ double epsd;
+ float epsf;
+ double fabs();
+#endif
+
+ t = 6;
+ tct++;
+#ifndef NOFLOAT
+ epsd = EPSD;
+ epsf = EPSF;
+#endif
+ r1.c1 = 'x';
+ r1.i = 40;
+ r1.j = 50;
+#ifndef NOFLOAT
+ r1.aaa = 3.0;
+ r1.bbb = 4.0;
+#endif
+ r2.c1 = r1.c1;
+ r2.i = 50;
+ r2.j = 40;
+#ifndef NOFLOAT
+ r2.aaa = 4.0;
+ r2.bbb = 5.0;
+#endif
+ if ( r1.c1 != 'x' || r1.i != 40 ) e(1);
+#ifndef NOFLOAT
+ if ( r1.aaa != 3.0 ) e(1);
+#endif
+ if ( r1.i != 40 || r2.i != 50 ) e(2);
+ if ( r2.j != 40 || r1.j != 50 ) e(3);
+ if ( (r1.c1 + r2.c1)/2 != 'x' ) e(4);
+#ifndef NOFLOAT
+ if ( r1.aaa * r1.aaa + r2.aaa * r2.aaa != r2.bbb * r2.bbb ) e(5);
+ r1.i = r1.j = r2.i = r2.j = 3.0;
+#else
+ r1.i = r1.j = r2.i = r2.j = 3;
+#endif
+ if ( r1.i != 3 ) e(6);
+ if ( r1.i * r2.j - 9 ) e(7);
+ r1.i++;
+ if ( r1.i != 4 ) e(8);
+ if ( --r1.i != 3 ) e(9);
+ if ( (++r2.i) * (--r2.j) != 8 ) e(10);
+ if ( (r2.i = r2.j = r1.j = r1.i = -5 ) != -5 ) e(11);
+ if ( r2.i * r1.j / 25 != 1 ) e(12);
+ r1.c1 = '\0';
+ if ( r1.i * r1.j * r2.i * r1.c1 * r2.j ) e(13);
+ r2.c1 = 'j';
+ if ( r1.c1 + r2.c1 != 'j' ) e(14);
+ if ( r1.c1 * r2.c1 ) e(15);
+ r2.j = r1.i = r2.i = r1.j = 1;
+ if ( (r1.i<<0) != r1.j ) e(16);
+ if ( (r1.i >> -0 ) != ( r1.j >> 0 ) ) e(17);
+ if ( (r1.i<<1) != 2 ) e(18);
+ if ( (r1.i<<2) != 4 ) e(19);
+ if ( (r1.j<<3) != (r2.j<<3) ) e(20);
+ if ( (r1.i | r1.i | r1.i | r1.i | r1.i) != r1.i ) e(21);
+ if ( (r2.j & r1.j & r2.j & r2.i) != (r1.i<<3>>3) ) e(22);
+ r1.j = 1;
+#ifndef NOFLOAT
+ r1.aaa = 2.0;
+ if ( fabs ( r1.j * r1.aaa - 2.0 ) > epsd ) e(23);
+ if ( (r1.j << 4) * r1.aaa != (r1.j << 4) * r1.aaa ) e(24);
+ if ( ((r1.j<<6)&r1.j) * r1.aaa ) e(25);
+ if ((r1.j | (r1.j << 1)) * r1.aaa != ((r1.j << 1) ^ r1.j) * r1.aaa) e(26);
+#endif
+ r1.i = r1.j = r2.i = r2.j = -2;
+ if ( r1.i > 0 || r1.j >= 0 ) e(27);
+ if ( r1.i != r2.j ) e(28);
+ if ( !!! ((((( r1.i == r2.j ))))) ) e(28);
+ if ( -(-(r1.j)) != r2.j ) e(29);
+ if ( r1.i % r1.j ) e(30);
+ if ( (r1.i % r1.j) % r1.i ) e(31);
+ if ( 0 % r2.j ) e(32);
+ if ( 03 * r1.i != -6 ) e(33);
+#ifndef NOFLOAT
+ r1.aaa = r2.aaa = -4;
+ r1.bbb = r2.bbb = 4;
+ if ( r1.aaa > -3.5 ) e(34);
+ if ( fabs ( r1.aaa - r2.aaa ) > epsf ) e(35);
+#endif
+ r1.c1 = '\03';
+#ifndef NOFLOAT
+ if ( fabs ( r2.aaa * r1.aaa - r1.c1 * 5 - 1.0 ) > epsf ) e(36);
+#else
+ if ( 5*r1.c1 != 15 ) e(36) ;
+#endif
+}
+
+
+
+
+test7() /* local records */
+{
+#ifndef NOFLOAT
+ double epsd;
+ float epsf;
+ double fabs();
+#endif
+ struct tp2 s1, s2;
+
+ t = 7;
+ tct++;
+#ifndef NOFLOAT
+ epsd = EPSD;
+ epsf = EPSF;
+#endif
+ s1.c1 = 'x';
+ s1.i = 40;
+ s1.j = 50;
+#ifndef NOFLOAT
+ s1.aaa = 3.0;
+ s1.bbb = 4.0;
+#endif
+ s2.c1 = s1.c1;
+ s2.i = 50;
+ s2.j = 40;
+#ifndef NOFLOAT
+ s2.aaa = 4.0;
+ s2.bbb = 5.0;
+#endif
+ if ( s1.c1 != 'x' || s1.i != 40 ) e(1);
+#ifndef NOFLOAT
+ if ( s1.aaa != 3.0 ) e(1);
+#endif
+ if ( s1.i != 40 || s2.i != 50 ) e(2);
+ if ( s2.j != 40 || s1.j != 50 ) e(3);
+ if ( (s1.c1 + s2.c1)/2 != 'x' ) e(4);
+#ifndef NOFLOAT
+ if ( s1.aaa * s1.aaa + s2.aaa * s2.aaa != s2.bbb * s2.bbb ) e(5);
+ s1.i = s1.j = s2.i = s2.j = 3.0;
+#else
+ s1.i = s1.j = s2.i = s2.j = 3;
+#endif
+ if ( s1.i != 3 ) e(6);
+ if ( s1.i * s2.j - 9 ) e(7);
+ s1.i++;
+ if ( s1.i != 4 ) e(8);
+ if ( --s1.i != 3 ) e(9);
+ if ( (++s2.i) * (--s2.j) != 8 ) e(10);
+ if ( (s2.i = s2.j = s1.j = s1.i = -5 ) != -5 ) e(11);
+ if ( s2.i * s1.j / 25 != 1 ) e(12);
+ s1.c1 = '\0';
+ if ( s1.i * s1.j * s2.i * s1.c1 * s2.j ) e(13);
+ s2.c1 = 'j';
+ if ( s1.c1 + s2.c1 != 'j' ) e(14);
+ if ( s1.c1 * s2.c1 ) e(15);
+ s2.j = s1.i = s2.i = s1.j = 1;
+ if ( (s1.i<<0) != s1.j ) e(16);
+ if ( (s1.i >> -0 ) != ( s1.j >> 0 ) ) e(17);
+ if ( (s1.i<<1) != 2 ) e(18);
+ if ( (s1.i<<2) != 4 ) e(19);
+ if ( (s1.j<<3) != (s2.j<<3) ) e(20);
+ if ( (s1.i | s1.i | s1.i | s1.i | s1.i) != s1.i ) e(21);
+ if ( (s2.j & s1.j & s2.j & s2.i) != (s1.i<<3>>3) ) e(22);
+ s1.j = 1;
+#ifndef NOFLOAT
+ s1.aaa = 2.0;
+ if ( fabs ( s1.j * s1.aaa - 2.0 ) > epsd ) e(23);
+ if ( (s1.j << 4) * s1.aaa != (s1.j << 4) * s1.aaa ) e(24);
+ if ( ((s1.j<<6)&s1.j) * s1.aaa ) e(25);
+ if ((s1.j | (s1.j << 1)) * s1.aaa != ((s1.j << 1) ^ s1.j) * s1.aaa) e(26);
+#endif
+ s1.i = s1.j = s2.i = s2.j = -2;
+ if ( s1.i > 0 || s1.j >= 0 ) e(27);
+ if ( s1.i != s2.j ) e(28);
+ if ( !!! ((((( s1.i == s2.j ))))) ) e(28);
+ if ( -(-(s1.j)) != s2.j ) e(29);
+ if ( s1.i % s1.j ) e(30);
+ if ( (s1.i % s1.j) % s1.i ) e(31);
+ if ( 0 % s2.j ) e(32);
+ if ( 03 * s1.i != -6 ) e(33);
+#ifndef NOFLOAT
+ s1.aaa = s2.aaa = -4;
+ s1.bbb = s2.bbb = 4;
+ if ( s1.aaa > -3.5 ) e(34);
+ if ( fabs ( s1.aaa - s2.aaa ) > epsf ) e(35);
+#endif
+ s1.c1 = '\03';
+#ifndef NOFLOAT
+ if ( fabs ( s2.aaa * s1.aaa - s1.c1 * 5 - 1.0 ) > epsf ) e(36);
+#else
+ if ( 5*s1.c1 != 15 ) e(36) ;
+#endif
+}
+
+
+
+
+test8() /* global arrays */
+{
+#ifndef NOFLOAT
+ float epsf;
+ double epsd;
+ double fabs();
+#endif
+
+ t = 8;
+ tct++;
+#ifndef NOFLOAT
+ epsf = EPSF;
+ epsd = EPSD;
+#endif
+ for ( i=0; i<20 ; i++ )
+ a1[i] = i*i;
+ if ( a1[9] != 81 || a1[17] != 289 || a1[0] != 0 ) e(1);
+ if ( a1[1] + a1[2] + a1[3] != 14 ) e(2);
+ if ( ! a1[15] ) e(3);
+ if ( a1[8] / a1[4] != 4 ) e(4);
+#ifndef NOFLOAT
+ for ( i=0; i<20; i++ )
+ a2[i] = 10.0e-1 + i/54.324e-1;
+ if ( fabs(a2[4]*a2[4]-a2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5);
+ if ( fabs(a2[8]/a2[8]*a2[9]/a2[9]-a2[10]+a2[10]-1.0 ) > epsf ) e(6);
+ if ( fabs(a2[5]-a2[4]-1/54.324e-1 ) > epsf ) e(7);
+ for ( i=0; i<20; i++)
+ a3[i]= 10.0e-1 + i/54.324e-1;
+ if ( fabs(a3[4]*a3[4]-a3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8);
+ if ( fabs( a3[8]*a3[9]/a3[8]/a3[9]-a3[10]+a3[10]-1000e-3) > epsd ) e(9);
+ if ( fabs(a3[8]+a3[6]-2*a3[7]) > epsd ) e(10);
+#endif
+ for ( i=0; i<20; i++ )
+ a1[i] = i+1;
+ if ( a1[a1[a1[a1[a1[a1[0]]]]]] != 6 ) e(11);
+ if ( a1[a1[0]+a1[1]+a1[2]+a1[3]] != 11 ) e(12);
+ if ( (a1[0] << 2) != 4 ) e(13);
+ if ( (a1[0] >> 2) ) e(14);
+ if ( (a1[0] << 3 >> 3) != a1[0] ) e(15);
+ if ( a1[a1[0] << 1] != 3 ) e(16);
+ if ( a1[4<<1] != 9 ) e(17);
+ if ( a1[4 << 1] != 9 ) e(18);
+ if ( (1 << a1[0]) != 2 ) e(19);
+ if ( (1 & a1[0]) != 1 ) e(20);
+ if ( a1[4]++ != 5 ) e(21);
+ if ( a1[4] != 6 ) e(22);
+ if ( --a1[4] != 5 ) e(23);
+ if ( a1[ --a1[10] ] != 10 ) e(24);
+ a1[0] = 0;
+ a1[1] = 1;
+ a1[2] = 2;
+ a1[3] = 3;
+ i = 3;
+ if ( a1[--i] != 2 ) e(25);
+ if ( a1[ a1[--i] ] != 1 ) e(26);
+ if ( a1[a1[a1[a1[a1[a1[a1[a1[3]]]]]]]] != 3 ) e(27);
+ if ( a1[1+2] != 3 ) e(28);
+ if ( a1[1+2] != a1[3/3] + 2 ) e(29);
+ if ( a1[i=2] != 2 ) e(30);
+ if ( -a1[i==3] ) e(31);
+ if ( a1[3*2 + a1[0]*6 - 10/2 -4 + 3/1] != 0 ) e(32);
+ if ( a1['a' + 'c' -2*'b'] ) e(33);
+ if ( a1[ a1[0]==a1[1] ] ) e(34);
+ if ( a1[a1[1<<1]>>1] != 1 ) e(35);
+ a1[i=j=4] = 10;
+ if ( (i!=4) || (j!=4) || (i!=j) ) e(36);
+ if ( a1[4] != 10 ) e(37);
+ if ( a1[--i] != 3 ) e(38);
+ if ( a1[i++] != 3 ) e(39);
+ if ( --a1[--i] != 2 ) e(40);
+ a1[a1[a1[a1[a1[0]=7]=5]=8]=2]=0;
+ if ( a1[0] != 7) e(41);
+ if ((a1[7] != 5) || (a1[5]!=8) || (a1[8]!=2))e(42);
+ if (a1[2]) e(43);
+ for ( i=0 ; i<20; i++)
+ a1[i] = i;
+ a1[0] = 0;
+ a1[1] = 01;
+ a1[2] = 02;
+ a1[3] = 04;
+ a1[4] = 010;
+ if ((a1[0] | a1[1] | a1[2] | a1[3] | a1[4]) != 017 ) e(44);
+ if ( a1[0]<<4 ) e(45);
+ if ( (a1[4]>>3) != 1 ) e(46);
+ a1[4] = 04;
+ a1[010] = 010;
+ if ( a1[8] != 8 ) e(47);
+ if ( a1[0|1|2|4|8] != (a1[0]|a1[1]|a1[2]|a1[4]|a1[8]) ) e(48);
+ if ( a1[a1[0]|a1[1]|a1[2]|a1[4]|a1[8]] != a1[017] ) e(49);
+ if ( a1[a1[1]^a1[2]^a1[4]^a1[8]] != a1[a1[1]|a1[2]|a1[4]|a1[8]] ) e(50);
+ for ( i = 0; i<20; i++ )
+ a1[i] = i+1;
+#ifndef NOFLOAT
+ for ( i = 0; i<20; i++ )
+ a2[i] = a3[i] = a1[i];
+ if ( a2[5] != 6.0 ) e(51);
+ if ( a2[13] != 14.0 ) e(52);
+ if ( a2[a1[a1[a1[a1[a1[0]]]]]] != 6.0 ) e(53);
+#endif
+ if ( a1[12] != 13 ) e(54);
+#ifndef NOFLOAT
+ if ( a1[ a1[12] = a2[a1[11]] ] != 14 ) e(55);
+ if ( fabs( a2[13] - a2[a1[12]] ) > epsf ) e(56);
+ if ( a2[8] != a1[8] ) e(57);
+#endif
+}
+
+
+
+
+test9() /* local arrays */
+{
+#ifndef NOFLOAT
+ float epsf;
+ double epsd;
+ double fabs();
+#endif
+ int b1[20];
+#ifndef NOFLOAT
+ float b2[20];
+ double b3[20];
+#endif
+
+ t = 9;
+ tct++;
+#ifndef NOFLOAT
+ epsf = EPSF;
+ epsd = EPSD;
+#endif
+ for ( i=0; i<20 ; i++ )
+ b1[i] = i*i;
+ if ( b1[9] != 81 || b1[17] != 289 || b1[0] != 0 ) e(1);
+ if ( b1[1] + b1[2] + b1[3] != 14 ) e(2);
+ if ( ! b1[15] ) e(3);
+ if ( b1[8] / b1[4] != 4 ) e(4);
+#ifndef NOFLOAT
+ for ( i=0; i<20; i++ )
+ b2[i] = 10.0e-1 + i/54.324e-1;
+ if ( fabs(b2[4]*b2[4]-b2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5);
+ if ( fabs(b2[8]/b2[8]*b2[9]/b2[9]-b2[10]+b2[10]-1.0 ) > epsf ) e(6);
+ if ( fabs(b2[5]-b2[4]-1/54.324e-1 ) > epsf ) e(7);
+ for ( i=0; i<20; i++)
+ b3[i]= 10.0e-1 + i/54.324e-1;
+ if ( fabs(b3[4]*b3[4]-b3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8);
+ if ( fabs( b3[8]*b3[9]/b3[8]/b3[9]-b3[10]+b3[10]-1000e-3) > epsd ) e(9);
+ if ( fabs(b3[8]+b3[6]-2*b3[7]) > epsd ) e(10);
+#endif
+ for ( i=0; i<20; i++ )
+ b1[i] = i+1;
+ if ( b1[b1[b1[b1[b1[b1[0]]]]]] != 6 ) e(11);
+ if ( b1[b1[0]+b1[1]+b1[2]+b1[3]] != 11 ) e(12);
+ if ( (b1[0] << 2) != 4 ) e(13);
+ if ( (b1[0] >> 2) ) e(14);
+ if ( (b1[0] << 3 >> 3) != b1[0] ) e(15);
+ if ( b1[b1[0] << 1] != 3 ) e(16);
+ if ( b1[4<<1] != 9 ) e(17);
+ if ( b1[4 << 1] != 9 ) e(18);
+ if ( (1 << b1[0]) != 2 ) e(19);
+ if ( (1 & b1[0]) != 1 ) e(20);
+ if ( b1[4]++ != 5 ) e(21);
+ if ( b1[4] != 6 ) e(22);
+ if ( --b1[4] != 5 ) e(23);
+ if ( b1[ --b1[10] ] != 10 ) e(24);
+ b1[0] = 0;
+ b1[1] = 1;
+ b1[2] = 2;
+ b1[3] = 3;
+ i = 3;
+ if ( b1[--i] != 2 ) e(25);
+ if ( b1[ b1[--i] ] != 1 ) e(26);
+ if ( b1[b1[b1[b1[b1[b1[b1[b1[3]]]]]]]] != 3 ) e(27);
+ if ( b1[1+2] != 3 ) e(28);
+ if ( b1[1+2] != b1[3/3] + 2 ) e(29);
+ if ( b1[i=2] != 2 ) e(30);
+ if ( -b1[i==3] ) e(31);
+ if ( b1[3*2 + b1[0]*6 - 10/2 -4 + 3/1] != 0 ) e(32);
+ if ( b1['a' + 'c' -2*'b'] ) e(33);
+ if ( b1[ b1[0]==b1[1] ] ) e(34);
+ if ( b1[b1[1<<1]>>1] != 1 ) e(35);
+ b1[i=j=4] = 10;
+ if ( (i!=4) || (j!=4) || (i!=j) ) e(36);
+ if ( b1[4] != 10 ) e(37);
+ if ( b1[--i] != 3 ) e(38);
+ if ( b1[i++] != 3 ) e(39);
+ if ( --b1[--i] != 2 ) e(40);
+ b1[b1[b1[b1[b1[0]=7]=5]=8]=2]=0;
+ if ( b1[0] != 7) e(41);
+ if ((b1[7] != 5) || (b1[5]!=8) || (b1[8]!=2))e(42);
+ if (b1[2]) e(43);
+ for ( i=0 ; i<20; i++)
+ b1[i] = i;
+ b1[0] = 0;
+ b1[1] = 01;
+ b1[2] = 02;
+ b1[3] = 04;
+ b1[4] = 010;
+ if ((b1[0] | b1[1] | b1[2] | b1[3] | b1[4]) != 017 ) e(44);
+ if ( b1[0]<<4 ) e(45);
+ if ( (b1[4]>>3) != 1 ) e(46);
+ b1[4] = 04;
+ b1[010] = 010;
+ if ( b1[8] != 8 ) e(47);
+ if ( b1[0|1|2|4|8] != (b1[0]|b1[1]|b1[2]|b1[4]|b1[8]) ) e(48);
+ if ( b1[b1[0]|b1[1]|b1[2]|b1[4]|b1[8]] != b1[017] ) e(49);
+ if ( b1[b1[1]^b1[2]^b1[4]^b1[8]] != b1[b1[1]|b1[2]|b1[4]|b1[8]] ) e(50);
+ for ( i = 0; i<20; i++ )
+ b1[i] = i+1;
+#ifndef NOFLOAT
+ for ( i = 0; i<20; i++ )
+ b2[i] = b3[i] = b1[i];
+ if ( b2[5] != 6.0 ) e(51);
+ if ( b2[13] != 14.0 ) e(52);
+ if ( b2[b1[b1[b1[b1[b1[0]]]]]] != 6.0 ) e(53);
+#endif
+ if ( b1[12] != 13 ) e(54);
+#ifndef NOFLOAT
+ if ( b1[ b1[12] = b2[b1[11]] ] != 14 ) e(55);
+ if ( fabs( b2[13] - b2[b1[12]] ) > epsf ) e(56);
+ if ( b2[8] != b1[8] ) e(57);
+#endif
+}
+
+
+
+
+test10() /* global pointers */
+{
+#ifndef NOFLOAT
+ float epsf;
+ double fabs();
+#endif
+ int li;
+ struct tp2 strp2;
+
+#ifndef NOFLOAT
+ epsf = EPSF;
+#endif
+ t = 10;
+ tct++;
+ p1 = &li;
+ li = 076;
+ if ( p1 != &li ) e(1);
+ p11 = &li;
+ if ( p1 != p11 ) e(3);
+ if ( *p1 != *p11 ) e(4);
+ if ( &li != p11 ) e(5);
+ if ( *&p1 != p1 ) e(6);
+ if ( &*p1 != p1 ) e(7);
+ if ( **&p1 != *&*p1 ) e(10);
+ if ( *&*&*&*&*&li != li ) e(11);
+ p1 = &p ;
+ p2 = &p1;
+ *p1 = **p2 = 34;
+ if ( p1 != *p2 ) e(25);
+ li = 4;
+ p1 = &li;
+ p2 = &p1;
+ p3 = &p2;
+ p4 = &p3;
+ p5 = &p4;
+ if ( *p1 != **p2 ) e(26);
+ if ( **p2 != **p2 ) e(27);
+ if ( ***p3 != **p2 ) e(28);
+ if ( *****p5 != 4 ) e(30);
+ li = 3;
+ if ( *p1 - *p1 ) e(44);
+ if ( p1 != &li ) e(46);
+ pp1 = (struct tp2 *) alloc( sizeof *pp1 );
+ pp2 = (struct tp2 *) alloc( sizeof *pp2 );
+ pp3 = (struct tp2 *) alloc( sizeof *pp3 );
+ pp1->i = 1325;
+ if ( pp1->i != 1325 ) e(47);
+ pp1->i = pp2->i = pp3->i = 3;
+ if ( pp1->i * pp1->i != 9 ) e(48);
+ if ( pp1->i * pp2->i * pp3->i != pp2->i * 3 * 3 ) e(49);
+ if ( pp1->i - pp3->i ) e(50);
+ if ( (*pp1).i != pp1->i ) e(51);
+ pp1->i++;
+ if ( ++pp2->i != pp1->i ) e(52);
+ if ( pp2->i != 4 ) e(53);
+#ifndef NOFLOAT
+ pp1->aaa = 3.0;
+ pp2->aaa = -3.0;
+ pp3->bbb = 25.0;
+ if ( pp1->aaa != 3.0 ) e(54);
+ if ( fabs( pp1->aaa + pp2->aaa ) > epsf ) e(55);
+ if ( fabs( pp1->aaa * pp2->aaa + pp3->bbb - 16 ) > epsf ) e(56);
+ if ( fabs( pp1->aaa / pp2->aaa + 1 ) > epsf ) e(57);
+#endif
+ pp1->c1 = 'x';
+ pp1->i = pp1->j = 45;
+#ifndef NOFLOAT
+ pp1->aaa = 100.0;
+ pp1->bbb = 1024.0;
+#endif
+ strp2.c1 = pp1->c1; /* strp2 is a local struct */
+ strp2.i = pp1->i = strp2.j = pp1->j;
+#ifndef NOFLOAT
+ strp2.aaa = pp1->aaa;
+ strp2.bbb = pp1->bbb;
+#endif
+ if ( strp2.c1 != 'x' ) e(58);
+ if ( strp2.i != strp2.j ) e(59);
+#ifndef NOFLOAT
+ if ( strp2.aaa != pp1->aaa ) e(60);
+ if ( strp2.bbb != pp1->bbb ) e(61);
+#endif
+}
+
+#ifndef NOFLOAT
+
+test11() /* real arithmetic */
+{
+ double fabs();
+ double epsd;
+ float epsf;
+ float locxf;
+
+ t = 11 ;
+ tct++;
+ epsf = EPSF;
+ epsd = EPSD;
+ xf = 1.50;
+ yf = 3.00;
+ zf = 0.10;
+ xd = 1.50;
+ yd = 3.00;
+ zd = 0.10;
+ if ( fabs(1.0 + 1.0 - 2.0) > epsd ) e(1);
+ if ( fabs( 1e10-1e10 ) > epsd ) e(2);
+ if ( fabs( 1.0e+5 * 1.0e+5 - 100e+8 ) > epsd ) e(3);
+ if ( fabs( 10.0/3.0 * 3.0/10.0 - 100e-2 ) > epsd ) e(4);
+ if ( 0.0e0 != 0 ) e(5);
+ if ( fabs( 32767.0 - 32767 ) > epsd ) e(6);
+ if ( fabs( 1.0+2+5+3.0e0+7.5e+1+140e-1-100.0 ) > epsd ) e(7);
+ if ( fabs(-1+(-1)+(-1.0)+(-1.0e0)+(-1.0e-0)+(-1e0)+6 ) > epsd ) e(8);
+ if ( fabs(5.0*yf*zf-xf) > epsf ) e(9);
+ if ( fabs(5.0*yd*zd-xd) > epsd ) e(10);
+ if ( fabs(yd*yd - (2.0*xd)*(2.0*xd) ) > epsd ) e(11);
+ if ( fabs(yf*yf - (2.0*xf)*(2.0*xf) ) > epsf ) e(12);
+ if ( fabs( yd*yd+zd*zd+2.0*yd*zd-(yd+zd)*(zd+yd) ) > epsf ) e(13);
+ if ( fabs( yf*yf+zf*zf+2.0*yf*zf-(yf+zf)*(zf+yf) ) > epsf ) e(14);
+ xf = 1.10;
+ yf = 1.20;
+ if ( yd<xd ) e(15);
+ if ( yd<=xd ) e(16);
+ if ( yd==xd ) e(17);
+ if ( xd>=yd ) e(18);
+ if ( yd<xd ) e(19);
+ if ( fabs(yd-xd-1.5) > epsd ) e(20);
+ if ( 1.0 * 3.0 != 3.0 * 1.0 ) e(21);
+ if ( 1.0 != 1e+0 ) e(22);
+ if ( 4.5 < 4.4 ) e(23);
+ if ( -3.4 != -3.4 ) e(24);
+ if ( 10/3.0 - 10/3.0 != 0.0 ) e(25);
+ if ( fabs( (1<<0) * (-5.3) + 5.3 ) > epsd ) e(26);
+ if ( fabs( (1<<3) * 5.0 - 4e+1 ) > epsd ) e(27);
+ if ( fabs( ((1<<5)>>5) - 1e-0 ) > epsd ) e(28);
+ if ( fabs ( 00000 * 3.0 ) > epsd ) e(29);
+ if ( fabs ( 8 * 5.0 - 02 * 02 + 04 / 1.0 -40.0 ) > epsd ) e(30);
+ if ( fabs ( 'a' / 1.0 - 'a' ) > epsd ) e(31);
+ if ( fabs ( (!1) * ( 2.0 / -34e-1 ) ) > epsd ) e(32);
+ if ( fabs ( (01 | 1 | 2) * 4.0 - 12.0 ) > epsd ) e(33);
+ if ( fabs ( 1.0 * 2.0 * 3.0 * 4.0 * 5.0 - 120.0 ) > epsd ) e(34);
+ if ( fabs ( 1.0 * 2.0 * (1 | (4>>1)) - 6 ) > epsd ) e(35);
+ if ( fabs ( ( 0 ^ 0 ^ 0 ^ 0 ) * 0.0 ) > epsd ) e(36);
+ if ( fabs ( 1.0 * 2.0 * (1 ^ (4>>1)) - 6 ) > epsd ) e(37);
+ if ( fabs ( (((((-1.0 * (((((-1.0))))) - 1.0 ))))) ) > epsd) e(38);
+ if ( fabs ( ( 2==3 ) * 3.0 ) > epsd ) e(39);
+ if ( ( 4 + 3 > 5 ? 3.4 : -5e+3 ) != 3.4 ) e(40);
+ if ( ( -4 -'a' > 0 ? 3.4 : -5e+3 ) != -5e+3 ) e(41);
+ locxf = 3.0;
+ xf = 3.0;
+ if ( locxf != locxf ) e(42);
+ if ( locxf != xf ) e(43);
+ if ( locxf * xf != xf * locxf ) e(44);
+ if ( fabs ( ((2*3)>>1) / 3.0 - 1.0 ) > epsd ) e(45);
+ if ( fabs ( 'a' / locxf - 'a' / xf ) > epsd ) e(46);
+ if ( fabs( xf * locxf - 9.0 ) > epsd ) e(47);
+ yd = 3.0;
+ if ( fabs( xf*yd - 9.0) > epsd ) e(48);
+ if ( yd >= 4 ) e(49);
+ if ( locxf == 2 ) e(50);
+}
+
+#endif
--- /dev/null
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+char rcs_id[] = "$Id$" ;
+
+/* This program can be used to test C-compilers */
+
+int i,j,k,l,m,ect,pct,t,*p1;
+int a1[20];
+#ifndef NOFLOAT
+float a2[20],xf,yf,zf;
+double a3[20],xd,yd,zd;
+#endif
+
+char alstr[3000] ;
+char *alptr = alstr ;
+
+struct tp2
+{ char c1;
+ int i,j;
+#ifndef NOFLOAT
+ float aaa;
+ double bbb;
+#endif
+} r1,r2,*p3;
+
+struct node
+{ int val;
+ struct node *next;
+} *head,*tail,*p2;
+
+main()
+{ ect = 0; pct = 0;
+ test1();test2();test3();
+ test4();test5();
+ test6();test7();test8();
+ test9();test10();
+#ifndef NOFLOAT
+ test11();
+#endif
+ printf("program test1\n");
+ printf("%d tests completed. Number of errors = %d\n",pct,ect);
+ return 0 ;
+}
+
+char *alloc(size) {
+ register char *retval ;
+
+ retval=alptr ;
+ alptr += size ;
+ if ( alptr-alstr>sizeof alstr ) {
+ printf("allocation overflow\n") ;
+ exit(8) ;
+ }
+ return(retval) ;
+}
+
+int abs(a) int a ; { return ( a<0 ? -a : a) ; }
+#ifndef NOFLOAT
+double fabs(a) double a ; { return( a<0 ? -a : a) ; }
+#endif
+
+e(n)
+{ ect++; printf("error %d in test %d \n",n,t);
+}
+
+inc(n)
+{ return(++n);}
+
+/***********************************************************************/
+
+test1()
+/*arithmetic on constants */
+{ t = 1; pct++;
+ if (1+1 != 2) e(1);
+ if (3333 + 258 != 3591) e(2);
+ if (3*4 != 12) e(3);
+ if (111*111 != 12321) e(4);
+ if (50 / 5 != 10) e(5);
+ if (7498 / 75 != 99) e(6);
+ if (456 - 345 != 111) e(7);
+ if (1+(-2) != -1) e(8);
+ if (-3 * -4 != 12) e(9);
+ if (-2 / 2 != -1) e(10);
+ if (-5 / 1 != -5 ) e(11);
+ if (-4 - -5 != 1) e(12);
+ if ( 03 + 02 != 05) e(13);
+ if ( 03456 + 88 != 03606 ) e(14);
+ if ( 0100 * 23 != 02700 ) e(15);
+ if ( 045 / 020 != 2) e(16);
+ if (0472 - 0377 != 073 ) e(17);
+ if ('a' + 3 != 100) e(18);
+ if ('a' + 'c' != 'b' + 'b') e(19);
+ if ( 'z' * 'z' != 14884 ) e(20);
+ if ( -'z' / 01 != -'z' ) e(21);
+ if ( 077777 >> 3 != 07777 ) e(22);
+ if ( 077777 >> 15 ) e(23);
+ if ( 234 << 6 != 234 << 6 ) e(24);
+ if ( 0124 & 07765 != 0124 ) e(25);
+ if ( 34 & 31 != 2 ) e(26);
+ if ( ( -4 | 3 ) != -1 ) e(27);
+ if ( ( 5 | 013 | 020 ) != 31 ) e(28);
+ if ( ( -7 ^ 3 ) != -6 ) e(29);
+ if ( ( 07373 ^ 4632 ) != 016343 ) e(30);
+ if ( (1+2+3)*(2+3+4)*(3+5+5) / 2 != ((3*((5+3+2)*10)+51)*6)/6 ) e(31);
+ if ( (1000*2+5*7+13)/ 8 != 2*2*2*2*4*4 ) e(32);
+ if ((1*2*3*4*5*6*7 / 5040 !=
+ 5040 / 7 / 6 / 5 / 4 / 3 / 2 / 1 )) e(33);
+ if ( -(-(-(-(-(-(1)))))) != 1 ) e(34);
+ if (- 1 != -((((((((((1)))))))))) ) e(35);
+ if ( -1-1-1-1-1-1 != -6-3+3 ) e(36);
+ if ( -4 * -5 != 20 ) e(37);
+ if ( 2<1 ) e(38);
+ if ( 2<= 1 ) e(39);
+ if ( 2==3 ) e(40);
+ if ( 2 != 2 ) e(41);
+ if ( 2 >= 3) e(42);
+ if ( 2 > 3 ) e(43);
+ if (2 + 0 != 2 ) e(44);
+ if (2 - 0 != 2 ) e(45);
+ if (2 * 0 != 0 ) e(46);
+ if ( 0 / 1 != 0 ) e(47);
+ if ( -0 != 0 ) e(48);
+ if ( 0 * 0 != 0 ) e(49);
+ if ( 32767 > 32767 ) e(50);
+ if ( 0456 < 0400 ) e(51);
+ if ( 0456 != ( 0400 | 050 | 06 ) ) e(52);
+ if ( 2*2<<2*2/4 != 010 ) e(53);
+ if ( 0 || 0 ) e(54);
+ if ( 1 && 0 ) e(55);
+ if ( ( 123 ? 123 * 4 :345) != 492 ) e(56);
+ if ( ( 0 ? 345 : 280) != 280 ) e(57);
+ if ( ( (2*2/2<<2)|(2/2) ) != 9 ) e(58);
+ if ( !( 111 || 23 && 0 ) ) e(59);
+ if ( !1 ) e(60);
+ if ( !0 == 0 ) e(61);
+ if ( !!!!!!!!0 ) e(62);
+}
+
+/***********************************************************************/
+
+test2()
+/*arithmetic on global integer variables*/
+{ t = 2; pct++;
+ i = 1; j = 2; k = 3; l = 4; m = 10;
+ if ( i+j != k ) e(1);
+ if ( i+k != l ) e(2);
+ if ( j-k != -i ) e(3);
+ if ( j*(j + k) != m ) e(4);
+ if ( -m != -(k+k+l) ) e(5);
+ if ( i / i != 1 ) e(6);
+ if ( m*m / m != m ) e(7);
+ if ( 10 * m != 100 ) e(8);
+ if ( m * (-10) != -100 ) e(9);
+ if ( j / k != 0 ) e(10);
+ if ( 100 / k != 33 ) e(11);
+ if ( i+j*k+l+m / j + 50 / k != 32 ) e(12);
+ if ( j*k*m / 6 != 10 ) e(13);
+ if ( (k>4) || (k>=4) || (k==4) ) e(14);
+ if ( (m<j) || (m<=j) || (m==j) ) e(15);
+ if ( i+j-k ) e(16);
+ if ( j<i ) e(17);
+ if ( j != j ) e(18);
+ if ( i > j ) e(19);
+ if ( (i > j ? k : k*j ) != 6 ) e(20);
+ if ( (i < j ? k : k*j ) != 3 ) e(21);
+ if ( j<<i != l ) e(22);
+ if ( j>> i != i ) e(25);
+ if ( i++ != 1 ) e(26);
+ if ( --i != 1 ) e(27);
+ if ( i-- != 1 ) e(28);
+ if ( ( i+j ) && ( i<0 ) || (m-10) && (064) ) e(29);
+ if ( ( i+j ) && !(i>=0) || (m-10) && !( 0 ) ) e(30);
+}
+
+/***********************************************************************/
+
+test3()
+/*arithmetic on local integer variables*/
+{ int a,b,c,d,f;
+ t = 3; pct++;
+ a = 1; b = 2; c = 3; d = 4; f = 10;
+ if ( a+b != c ) e(1);
+ if ( a+c != d ) e(2);
+ if ( b-c != -a ) e(3);
+ if ( b*(b + c) != f ) e(4);
+ if ( -f != -(c+c+d) ) e(5);
+ if ( a / a != 1 ) e(6);
+ if ( f*f / f != f ) e(7);
+ if ( 10 * f != 100 ) e(8);
+ if ( f * (-10) != -100 ) e(9);
+ if ( b / c != 0 ) e(10);
+ if ( 100 / c != 33 ) e(11);
+ if ( a+b*c+d+f / b + 50 / c != 32 ) e(12);
+ if ( b*c*f / 6 != 10 ) e(13);
+ if ( (c>4) || (c>=4) || (c==4) ) e(14);
+ if ( (f<b) || (f<=b) || (f==b) ) e(15);
+ if ( c != a+b ) e(16);
+ if ( b<a ) e(17);
+ if ( b != b ) e(18);
+ if ( a > b ) e(19);
+ if ( (a > b ? c : c*b ) != 6 ) e(20);
+ if ( (a < b ? c : c*b ) != 3 ) e(21);
+ if ( b<<a != d ) e(22);
+ if ( b>> a != a ) e(25);
+ if ( a++ != 1 ) e(26);
+ if ( --a != 1 ) e(27);
+ if ( a-- != 1 ) e(28);
+ if ( ( a+b ) && ( a<0 ) || (f-10) && (064) ) e(29);
+ if ( ( a+b ) && !(a>=0) || (f-10) && !( 0 ) ) e(30);
+}
+
+/***********************************************************************/
+
+test4()
+/* global arrays */
+{
+#ifndef NOFLOAT
+ float epsf;
+ double epsd;
+#endif
+ t=4; pct++;
+#ifndef NOFLOAT
+ epsf = 1e-7; epsd = 1e-14;
+#endif
+ for ( i=0; i<20 ; i++ ) a1[i] = i*i;
+ if ( a1[9] != 81 || a1[17] != 289 || a1[0] != 0 ) e(1);
+ if ( a1[1] + a1[2] + a1[3] != 14 ) e(2);
+ if ( ! a1[15] ) e(3);
+ if ( a1[8] / a1[4] != 4 ) e(4);
+#ifndef NOFLOAT
+ for ( i=0; i<20; i++ ) a2[i] = 10.0e-1 + i/54.324e-1;
+ if ( fabs(a2[4]*a2[4]-a2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5);
+ if ( fabs(a2[8]/a2[8]*a2[9]/a2[9]-a2[10]+a2[10]-1.0 ) > epsf ) e(6);
+ if ( fabs(a2[5]-a2[4]-1/54.324e-1 ) > epsf ) e(7);
+ for ( i=0; i<20; i++ ) a3[i]= 10.0e-1 + i/54.324e-1;
+ if ( fabs(a3[4]*a3[4]-a3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8);
+ if ( fabs( a3[8]*a3[9]/a3[8]/a3[9]-a3[10]+a3[10]-1000e-3) > epsd ) e(9);
+ if ( fabs(a3[8]+a3[6]-2*a3[7]) > epsd ) e(10);
+#endif
+}
+
+/****************************************************************/
+
+test5()
+/* local arrays */
+{ int b1[20];
+#ifndef NOFLOAT
+ float epsf, b2[20]; double b3[20],epsd;
+ epsf = 1e-7; epsd = 1e-14;
+#endif
+ t = 5; pct++;
+ for ( i=0; i<20 ; i++ ) b1[i] = i*i;
+ if ( b1[9]-b1[8] != 17 ) e(1);
+ if ( b1[3] + b1[4] != b1[5] ) e(2);
+ if ( b1[1] != 1||b1[3] != 9 || b1[5] != 25 || b1[7] != 49 ) e(3);
+ if ( b1[12] / b1[6] != 4 ) e(4);
+#ifndef NOFLOAT
+ for ( i=0; i<20; i += 1) b2[i] = 10.0e-1+i/54.324e-1;
+ if (fabs(b2[4]*b2[4]-b2[4]*(10.0e-1+4/54.324e-1)) > epsf ) e(5);
+ if (fabs(b2[8]/b2[8]*b2[9]/b2[9]-b2[10]+b2[10]-1.0) > epsf ) e(6);
+ if ( fabs(b2[5]-b2[4]-1/5.4324 ) > epsf ) e(7);
+ for ( i=0; i<20 ; i += 1 ) b3[i] = 10.0e-1+i/54.324e-1;
+ if (fabs(b3[4]*b3[4]-b3[4]*(10.0e-1+4/54.324e-1)) > epsd ) e(8);
+ if (fabs(b3[8]*b3[9]/b3[8]/b3[9]+b3[10]-b3[10]-1.0) > epsd ) e(9);
+ if (fabs(b3[10]+b3[18]-2*b3[14]) > epsd ) e(10);
+#endif
+}
+
+
+/****************************************************************/
+
+
+
+test6()
+/* mixed local and global */
+{ int li,b1[20];
+#ifndef NOFLOAT
+ double b3[10],xxd,epsd;
+#endif
+ t = 6; pct++;
+#ifndef NOFLOAT
+ epsd = 1e-14;
+#endif
+ li = 6; i = li ;
+ if ( i != 6 ) e(1);
+ i = 6; li = i;
+ if ( i != li ) e(2);
+ if ( i % li ) e(3);
+ i=li=i=li=i=li=i=i=i=li=j;
+ if ( i != li || i != j ) e(4);
+ for ( i=li=0; i<20 ; i=li ) { b1[li]= (li+1)*(i+1) ; li++; }
+ if ( b1[9] != a1[10] ) e(5);
+ if ( b1[7]/a1[4] != a1[2] ) e(6);
+ li = i = 121;
+ if ( b1[10] != i && a1[11]!= li ) e(7);
+#ifndef NOFLOAT
+ for ( li=0 ; li<10; li++ ) b3[li]= 1.0e0 + li/54.324e-1;
+ if ( fabs(b3[9]-a3[9]) > epsd ) e(8);
+ if ( fabs(8/54.324e-1 - b3[9]+a3[1] ) > epsd ) e(9);
+#endif
+}
+
+/***************************************************************/
+
+
+test7()
+/*global records */
+{ t=7; pct++;
+ r1.c1= 'x';r1.i=40;r1.j=50;
+#ifndef NOFLOAT
+ r1.aaa=3.0;r1.bbb=4.0;
+#endif
+ r2.c1=r1.c1;
+ r2.i= 50;
+ r2.j=40;
+#ifndef NOFLOAT
+ r2.aaa=4.0;r2.bbb=5.0;
+#endif
+ if (r1.c1 != 'x' || r1.i != 40 ) e(1);
+#ifndef NOFLOAT
+ if ( r1.aaa != 3.0 ) e(1);
+#endif
+ i = 25;j=75;
+ if (r1.i != 40 || r2.i != 50 ) e(2);
+ if ( r2.j != 40 || r1.j != 50 ) e(3);
+ if ( (r1.c1 + r2.c1)/2 != 'x' ) e(4);
+#ifndef NOFLOAT
+ if ( r1.aaa*r1.aaa+r2.aaa*r2.aaa != r2.bbb*r2.bbb) e(5);
+#endif
+ r1.i = 34; if ( i!=25 ) e(6);
+}
+
+
+/****************************************************************/
+
+
+test8()
+/*local records */
+{ struct tp2 s1,s2;
+ t=8; pct++;
+ s1.c1= 'x';s1.i=40;s1.j=50;
+#ifndef NOFLOAT
+ s1.aaa=3.0;s1.bbb=4.0;
+#endif
+ s2.c1=s1.c1;
+ s2.i= 50;
+ s2.j=40;
+#ifndef NOFLOAT
+ s2.aaa=4.0;s2.bbb=5.0;
+#endif
+ if (s1.c1 != 'x' || s1.i != 40 ) e(1);
+#ifndef NOFLOAT
+ if ( s1.aaa != 3.0 ) e(1);
+#endif
+ i = 25;j=75;
+ if (s1.i != 40 || s2.i != 50 ) e(2);
+ if ( s2.j != 40 || s1.j != 50 ) e(3);
+ if ( (s1.c1 + s2.c1)/2 != 'x' ) e(4);
+#ifndef NOFLOAT
+ if ( s1.aaa*s1.aaa+s2.aaa*s2.aaa != s2.bbb*s2.bbb) e(5);
+#endif
+ s1.i = 34; if ( i!=25 ) e(6);
+}
+
+
+
+/***********************************************************************/
+test9()
+/*global pointers */
+{ t=9; pct++;
+ p1=alloc( sizeof *p1 );
+ p2=alloc( sizeof *p2);
+ p3=alloc(sizeof *p3);
+ *p1 = 1066;
+ if ( *p1 != 1066 ) e(1);
+ p3->i = 1215;
+ if ( p3->i != 1215 ) e(2);
+ p2->val = 1566;
+ if ( p2->val != 1566 || p2->next ) e(3);
+ if ( a1 != &a1[0] ) e(4);
+ p1 = a1;
+ if ( ++p1 != &a1[1] ) e(5);
+ head = 0;
+ for (i=0;i<=100;i += 1)
+ { tail = alloc(sizeof *p2);
+ tail->val = 100+i;tail->next = head;
+ head = tail;
+ }
+ if ( tail->val != 200 || tail->next->val != 199 ) e(6);
+ if ( tail->next->next->next->next->next->val != 195) e(7);
+ tail->next->next->next->next->next->val = 1;
+ if ( tail->next->next->next->next->next->val != 1) e(8);
+ i = 27;
+ if ( *&i != 27 ) e(9);
+ if ( &*&*&*&i != &i ) e(10);
+ p1 = &i;i++;
+ if ( p1 != &i ) e(11);
+}
+
+/*****************************************************************/
+test10()
+/*local pointers */
+{ struct tp2 *pp3;
+ struct node *pp2,*ingang,*uitgang;
+ int *pp1;
+ int b1[20];
+ t=10; pct++;
+ pp1=alloc( sizeof *pp1 );
+ pp2=alloc( sizeof *p2);
+ pp3=alloc(sizeof *pp3);
+ *pp1 = 1066;
+ if ( *pp1 != 1066 ) e(1);
+ pp3->i = 1215;
+ if ( pp3->i != 1215 ) e(2);
+ pp2->val = 1566;
+ if ( pp2->val != 1566 || p2->next ) e(3);
+ if ( b1 != &b1[0] ) e(4);
+ pp1 = b1;
+ if ( ++pp1 != &b1[1] ) e(5);
+ ingang = 0;
+ for (i=0;i<=100;i += 1)
+ { uitgang = alloc(sizeof *pp2);
+ uitgang->val = 100+i;uitgang->next = ingang;
+ ingang = uitgang;
+ }
+ if ( uitgang->val != 200 || uitgang->next->val != 199 ) e(6);
+ if ( uitgang->next->next->next->next->next->val != 195 ) e(7);
+ uitgang->next->next->next->next->next->val = 1;
+ if ( uitgang->next->next->next->next->next->val != 1) e(8);
+}
+
+/***************************************************************/
+
+#ifndef NOFLOAT
+test11()
+/* real arithmetic */
+{
+ double epsd; float epsf;
+ t = 11; pct++; epsf = 1e-7; epsd = 1e-16;
+ xf = 1.50 ; yf = 3.00 ; zf = 0.10;
+ xd = 1.50 ; yd = 3.00 ; zd = 0.10;
+ if ( fabs(1.0 + 1.0 - 2.0 ) > epsd ) e(1);
+ if ( fabs( 1e10-1e10 ) > epsd ) e(2);
+ if ( fabs( 1.0e+5*1.0e+5-100e+8 ) > epsd ) e(3);
+ if ( fabs( 10.0/3.0*3.0/10.0-100e-2 ) > epsd ) e(4);
+ if ( 0.0e0 != 0 ) e(5);
+ if ( fabs( 32767.0 - 32767 ) > epsd ) e(6);
+ if ( fabs( 1.0+2+5+3.0e0+7.5e+1+140e-1-100.0 ) > epsd ) e(7);
+ if ( fabs(-1+(-1)+(-1.0)+(-1.0e0)+(-1.0e-0)+(-1e0)+6 ) > epsd ) e(8);
+ if ( fabs(5.0*yf*zf-xf) > epsf ) e(9);
+ if ( fabs(5.0*yd*zd-xd) > epsd ) e(10);
+ if ( fabs(yd*yd - (2.0*xd)*(2.0*xd) ) > epsd ) e(11);
+ if ( fabs(yf*yf - (2.0*xf)*(2.0*xf) ) > epsf ) e(12);
+ if ( fabs( yd*yd+zd*zd+2.0*yd*zd-(yd+zd)*(zd+yd) ) > epsd ) e(13);
+ if ( fabs( yf*yf+zf*zf+2.0*yf*zf-(yf+zf)*(zf+yf) ) > epsf ) e(14);
+ xf=1.10;yf=1.20;
+ if ( yd<xd ) e(15);
+ if ( yd<=xd ) e(16);
+ if ( yd==xd ) e(17);
+ if ( xd>=yd ) e(18);
+ if ( yd<xd ) e(19);
+ if ( fabs(yd-xd-1.5) > epsd ) e(20);
+}
+#endif
+
+
+/*****************************************************************/
--- /dev/null
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ */
+
+char rcs_id[] = "$Id$" ;
+
+/* This program can be used to test C-compilers */
+
+
+int t, ect, tct;
+
+
+/**********************************************************************/
+/*
+ * Testing basic function calls
+ *
+ */
+
+
+
+main()
+{
+ tct = 0;
+ ect = 0;
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ printf("End of test program, %d tests completed, %d errors detected\n",
+ tct,ect);
+ return 0 ;
+}
+
+
+
+
+e(n)
+int n;
+{
+ ect++;
+ printf("Error %d in test%d \n",n,t);
+}
+
+
+
+
+one()
+{
+ return(1);
+}
+
+
+
+
+two()
+{
+ return(2);
+}
+
+
+
+
+three()
+{
+ return(3);
+}
+
+
+
+
+four()
+{
+ return(4);
+}
+
+
+
+
+five()
+{
+ return(5);
+}
+
+
+
+
+plus()
+{
+ return ( one() + two() + three() + four() + five() );
+}
+
+
+
+
+multipl()
+{
+ return( one() * two() * three() * four() * five() );
+}
+
+
+
+
+subtr()
+{
+ return( - one() - two() - three() - four() - five() );
+}
+
+
+
+
+test1()
+{
+ int i;
+ int count;
+
+ t = 1;
+ tct++;
+ if ( one() != 1 ) e(1);
+ if ( two() != 2 ) e(2);
+ if ( three() != 3 ) e(3);
+ if ( four() != 4 ) e(4);
+ if ( five() != 5 ) e(5);
+ if ( (one() + two()) != 3 ) e(6);
+ if ( ((((((one() + two())))))) != 3) e(7);
+ if ( (one() * three()) != 3) e(8);
+ if (( (four() + three()) * two()) != 14) e(9);
+ if ( (four() + four()) != (two() * four()) ) e(10);
+ if ( (four() - four()) / three() ) e(11);
+ if (( four() + 3 * 12 - ( one() * two() * 2 ) ) != 36 ) e(12);
+ if ( one() & two() & four() & three() ) e(13);
+ if ( !( three() && two() ) ) e(14);
+ for (i=0; i<8; i++)
+ {
+ count = one() + two() + three() + four();
+ count = count * one();
+ count = count * two() - one() - two() - three() - four();
+ }
+ if (count != 10) e(15);
+ if ( !one() ) e(16);
+ if ( plus() != 15 ) e(17);
+ if ( multipl() != 120 ) e(18);
+ if ( subtr() != -15 ) e(19);
+ if ( -subtr() != plus() ) e(18);
+ if ( -subtr() != plus() ) e(21);
+}
+
+
+
+
+echo(a)
+int a;
+{
+ return ( a );
+}
+
+
+
+
+min(a,b)
+int a,b;
+{
+ if ( a < b )
+ return(a);
+ return(b);
+}
+
+
+
+
+max1(a,b)
+int a,b;
+{
+ if ( a < b )
+ return(b);
+ return(a);
+}
+
+
+
+
+max2(a,b)
+int a,b;
+{
+ return ( ( a < b ? b : a ) );
+}
+
+
+
+
+test2()
+{
+ int i,j;
+ int a,b;
+
+ t = 2;
+ tct++;
+ if ( echo(1) != 1 ) e(1);
+ if ( echo(3) != 3 ) e(2);
+ if ( echo(0) ) e(3);
+ if ( echo(2) + echo(3) != echo(5) ) e(4);
+ if ( echo( 2 + 3 ) != 5 ) e(5);
+ if ( echo ( 1 + 2 + 3 + 4 + 5 ) != 10 + echo(5) ) e(6);
+ if (( echo( 2<<1 ) ) != 4 ) e(7);
+ if ( echo( 2 >> 1 ) != 1 ) e(8);
+ if ( echo( 1 << 4 ) != echo( 2 << 3 ) ) e(9);
+ if ( echo( echo(4) ) != echo(4) ) e(10);
+ if (( echo ( echo ( echo( echo ( echo ( 3 ) ) ) ) ) ) != 3 ) e(11);
+ if ( echo( echo( echo(2+3-4+echo(4)*echo(2))) ) != 9 ) e(12);
+ if ( min(1,2) != 1) e(13);
+ if (min(0,45) != 0) e(14);
+ if (min(45,0) != 0) e(15);
+ if (min(-72,-100) != -100) e(16);
+ if (min(-100,-72) != -100) e(17);
+ if (min(1<<3,2<<3) != (1<<3) ) e(18);
+ if ( min( echo(3), echo(3) ) != echo (echo(3)) ) e(19);
+ if ( max1('a','b') != 'b' ) e(20);
+ if ( max1('b','a') != 'b' ) e(21);
+ if ( max1(-3,54+2) != ( -3 < 54+2 ? 54+2 : -3 ) ) e(22);
+ if (max1('a'+'b'+34,'a'*2) != max2('a'*2,'a'+'b'+34)) e(23);
+ if (max1(345/23,4) != max1( echo(345/23), 4) ) e(24);
+ if ( max1( max1(2,3), max1(2,3) ) != max1(2,3) ) e(25);
+ for (i=3; i<5; i++)
+ if ((max1(i,-i)) != i) e(26);
+ for (j=min('a',34); j<max2('a',34); j++)
+ {
+ if ( j<min(max1('a',34),min('a',34)) ) e(27);
+ if ( j>max1(min(34,'a'),max2(34,'a')) ) e(28);
+ }
+ a=b= -32768;
+ if ( min(echo(a),a) != a) e(29);
+ if ( max1(echo(b),max1(b,b)) != b) e(30);
+}
+
+
+
+
+sum(k)
+int k;
+{
+ if (k<=0)
+ return(0);
+ return(k+sum(k-1));
+}
+
+
+
+
+formula(k)
+int k;
+{
+ if (k<=0)
+ return(0);
+ return ( ((((( (k*(k+1))/2 ))))) );
+}
+
+
+
+
+test3()
+{
+ int k;
+ int count;
+
+ t = 3;
+ tct++;
+ count=0;
+ if ( sum(-4) != 0 ) e(1);
+ if ( sum(0) != 0 ) e(2);
+ if ( sum(2) != 3 ) e(3);
+ if ( sum(10) != 55 ) e(4);
+ if ( sum(34) != formula(34) ) e(5);
+ if ( sum(101) != formula(101) ) e(6);
+ if ( sum( sum(11) ) != formula( formula(11) ) ) e(7);
+ if ( sum( sum(11) ) != formula( sum(11) ) ) e(8);
+ if ( sum( sum( sum(4) )) != sum ( formula ( sum( 4) )) ) e(9);
+ for (k = sum(-45); k<sum('a'); k += sum('b') )
+ if (count++) e(10);
+ if ( echo( sum ( formula( five() ))) != formula ( sum(5) ) ) e(11);
+}
+
+
+
+
+test4()
+{
+ int i,j,k,l,m;
+ int a[50];
+ int b[1][2][3][4][5];
+
+ t = 4;
+ tct++;
+ b[0][1][2][3][4] = one();
+ if ( b[0][1][2][3][4] != 1) e(1);
+ if ( b[0][one()][two()][three()][four()] != 1) e(2);
+ if ( b[0][one()][five()-3][one()+2][four()] != b[0][1][2][2*2-1][4]) e(3);
+ for (i=0; i<50; i++)
+ a[i] = i+1;
+ if (a[one()-1] != one()) e(4);
+ if (echo(a[4]) != 5) e(5);
+ if ( echo( a[ echo(6) ] ) != 7 ) e(6);
+ if ( a[a[a[0]]] != 3 ) e(7);
+ for (i=11; i<22; i++)
+ if ( echo( a[i+echo('b'-'a'-1)] ) != i+1) e(8);
+ for (i=0; i<1; i++)
+ for (j=0; j<2; j++)
+ for (k=0; k<3; k++)
+ for (l=0; l<4; l++)
+ for (m=0; m<5; m++)
+ b[echo(i)][echo(j)][echo(k)][l][echo(m)] = j*k*l*m;
+ for (i=3; i; --i)
+ for (j=4; j; --j)
+ if (b[0][max1( max1(0,0), 1)][2][i][j] != 1*2*echo(i)*j ) e(9);
+}
+
+
+
+
+/* More testing */
+
+
+func(sw,i)
+int sw; /* switch selector */
+int i; /* value to be returned */
+{
+ int a[10];
+
+ switch(sw)
+ {
+ case 0: return(-i);
+ break;
+ case 1: return ( echo(i*i) - (i-1)*i );
+ break;
+ case 2: return ( 2*func(0,i) );
+ break;
+ case 3: a[0] = 3;
+ a[3] = 1;
+ a[1] = 8;
+ a[8] = i;
+ return( 3*a[a[a[a[0]]]] );
+ }
+ return(-32768);
+}
+
+
+
+
+/* testing function arguments */
+
+
+
+
+f1(i,j)
+int i,j;
+{
+ return( i!=j );
+}
+
+
+
+f2(ptr)
+int *ptr;
+{
+ int *locptr;
+
+ locptr = ptr;
+ return ( *ptr | *locptr );
+}
+
+
+
+swap(a,b)
+int *a,*b;
+{
+ int temp;
+
+ temp = *a;
+ *a = *b;
+ *b = temp;
+}
+
+
+
+test5()
+{
+ int k,l;
+ int *ptr;
+
+ t = 5;
+ tct++;
+ for (k = -6353; k < -6003; k++)
+ if (f1(k,k+3-echo(3))) e(1);
+ k = 'a' - 723;
+ ptr = &k;
+ if ( f2(ptr) != f2(&k) ) e(3);
+ if ( f2(ptr) + f2(&k) != 2*k ) e(4);
+ if ( f1(*ptr,*ptr) ) e(5);
+ if ( f1(*ptr,k) ) e(6);
+ if ( f1( f2(&k), *ptr ) ) e(7);
+ k = l=28;
+ swap(&k,&l);
+ if ( k != l ) e(8);
+ *ptr = k;
+ swap(&k,ptr);
+ if ( k != *ptr ) e(9);
+ l = -5;
+ k = 'h';
+ ptr = &k;
+ swap(ptr,&l);
+ if ( l != 'h' ) e(10);
+ if ( k != -5 ) e(11);
+ if ( *ptr != -5 ) e(12);
+ if ( ptr != &k ) e(13);
+}
+
+
+
+icount(i)
+int i;
+{
+ return(i+1);
+}
+
+
+
+test6()
+{
+ int i;
+
+ tct++;
+ t=6;
+ for (i=0; i<10; i++)
+ if (func(0,i) != -i) e(i);
+ for (i=10; i<20; i++)
+ if ( -func(2,i) != 2*i) e(i);
+ if (func(func(0,0),0) != 0) e(20);
+ if (func(-func(0,1),32) != 32) e(21);
+ if (max1(32767,10) != max2(32767,10)) e(22);
+ if (func(3,10) != 30) e(22);
+ if (icount(1)!=2) e(23);
+ if (icount(2)!=3) e(24);
+ if (icount(32766) != 32767) e(25);
+ if (icount((int)-32768) != -32767) e(26);
+ if (icount(icount(1)) != 3) e(27);
+ if ( icount( (int)&i ) != (int)&i + 1 ) e(28) ;
+ if (icount(icount(icount(icount(icount(icount(icount(icount(0))))))))!=8) e(29);
+}
basedir=`pwd`
-DIRS=". gcc-testsuite gcc-testsuite/ieee langshootout"
+DIRS=". langshootout ack gcc-testsuite gcc-testsuite/ieee"
test -n "$1" && DIRS="$1"
for dir in $DIRS; do