Changeset 3ba84c in git
- Timestamp:
- Apr 6, 1998, 1:09:14 PM (25 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- a40e7b27cf6f5cba26e2f3aeecc7c3219181a5f7
- Parents:
- fa842032519085fea6da2813d2d35f50f4b93491
- Location:
- factory/ftest
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/ftest/fbinops.m4
rfa8420 r3ba84c 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fbinops.m4,v 1. 4 1998-03-31 10:23:59schmidt Exp $ */2 /* $Id: fbinops.m4,v 1.5 1998-04-06 11:05:17 schmidt Exp $ */ 3 3 4 4 ftestSetNameOfGame( fbinops, `" … … 161 161 ftestDivideTest( const CanonicalForm & f, const CanonicalForm & g, const CanonicalForm & quot ) 162 162 { 163 if ( ! ((quot*g)+(f%g)-f).isZero() ) { 163 CanonicalForm rem = f % g; 164 if ( ! ((quot*g)+rem-f).isZero() ) { 164 165 ftestError( CheckError, "f != (f/g)*g+(f%%g)\n" ); 165 166 return Failed; 167 } else if ( f.inBaseDomain() && g.inBaseDomain() && getCharacteristic() == 0 168 && (rem < 0 || rem > abs( g )) ) { 169 // check euclidean division in Z 170 ftestError( CheckError, "!(0 <= f%g < abs(g))\n" ); 171 return Failed; 172 } else if ( f.inPolyDomain() || g.inPolyDomain() ) { 173 // check euclidean division in R[x] 174 Variable x = (mvar( f ) >= mvar( g )) ? mvar( f ) : mvar( g ); 175 if ( rem.isZero() || degree( rem, x ) < degree( g, x ) ) 176 return Passed; 177 else { 178 ftestError( CheckError, "degree(rem) >= degree(g)\n" ); 179 return Failed; 180 } 166 181 } else 167 182 return Passed; … … 187 202 ftestError( CheckError, "f != (f/g)*g+(f%%g)\n" ); 188 203 return Failed; 204 } else if ( f.inBaseDomain() && g.inBaseDomain() && getCharacteristic() == 0 205 && (rem < 0 || rem > abs( g )) ) { 206 // check euclidean division in Z 207 ftestError( CheckError, "!(0 <= f%g < abs(g))\n" ); 208 return Failed; 209 } else if ( f.inPolyDomain() || g.inPolyDomain() ) { 210 // check euclidean division in R[x] 211 Variable x = (mvar( f ) >= mvar( g )) ? mvar( f ) : mvar( g ); 212 if ( rem.isZero() || degree( rem, x ) < degree( g, x ) ) 213 return Passed; 214 else { 215 ftestError( CheckError, "degree(rem) >= degree(g)\n" ); 216 return Failed; 217 } 189 218 } else 190 219 return Passed; -
factory/ftest/ftest_io.cc
rfa8420 r3ba84c 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: ftest_io.cc,v 1.1 2 1998-03-31 10:36:02schmidt Exp $ */2 /* $Id: ftest_io.cc,v 1.13 1998-04-06 11:08:28 schmidt Exp $ */ 3 3 4 4 //{{{ docu … … 22 22 // 23 23 24 //{{{ CanonicalForm ftestGetCanonicalForm ( const char * canFormSpec ) 25 //{{{ docu 26 // 27 // ftestGetCanonicalForm() - read a canonical form from canFormSpec, 28 // return it. 29 // 30 //}}} 31 CanonicalForm 32 ftestGetCanonicalForm ( const char * canFormSpec ) 33 { 34 const char * stringF = canFormSpec; 35 stringF = ftestSkipBlancs( stringF ); 36 37 // check for a single minus 38 if ( stringF[0] == '-' ) { 39 const char * tokenCursor = ftestSkipBlancs( stringF+1 ); 40 24 //{{{ void ftestReadString ( const char * canFormSpec, CanonicalForm & f ) 25 //{{{ docu 26 // 27 // ftestReadString() - read canonical form `f' from `canFormSpec'. 28 // 29 //}}} 30 void 31 ftestReadString ( const char * canFormSpec, CanonicalForm & f ) 32 { 33 canFormSpec = ftestSkipBlancs( canFormSpec ); 34 35 // check for a single minus and read from stdin 36 if ( *canFormSpec == '-' ) { 37 const char * tokenCursor = ftestSkipBlancs( canFormSpec+1 ); 41 38 if ( ! *tokenCursor ) { 42 CanonicalForm f;43 39 cin >> f; 44 return f;40 return; 45 41 } 46 42 } 47 43 48 // get string to read canonical form from 49 if ( *stringF == '$' ) { 50 const char * tokenCursor = ftestSkipBlancs( stringF+1 ); 51 // read canonical form from environment 52 stringF = getenv( tokenCursor ); 53 if ( ! stringF ) 54 ftestError( CanFormSpecError, 55 "no environment variable `$%s' set\n", 56 tokenCursor ); 44 // create terminated CanonicalForm 45 char * terminatedSpec = new char[ strlen( canFormSpec )+2 ]; 46 char * cursor = terminatedSpec; 47 while ( *canFormSpec ) { 48 switch ( *canFormSpec ) { 49 case '.': *cursor = '*'; break; 50 case '{': *cursor = '('; break; 51 case '}': *cursor = ')'; break; 52 default: *cursor = *canFormSpec; break; 53 } 54 canFormSpec++; cursor++; 57 55 } 58 59 // create terminated CanonicalForm 60 int i = strlen( stringF ); 61 char * terminatedStringF = new char[i+2]; 62 char * stringCursor = terminatedStringF; 63 while ( *stringF ) { 64 switch ( *stringF ) { 65 case '.': *stringCursor = '*'; break; 66 case '{': *stringCursor = '('; break; 67 case '}': *stringCursor = ')'; break; 68 default: *stringCursor = *stringF; break; 69 } 70 stringF++; stringCursor++; 71 } 72 *stringCursor++ = ';'; 73 *stringCursor = '\0'; 74 75 // read f and return it 76 CanonicalForm f; 77 istrstream( terminatedStringF ) >> f; 78 delete [] terminatedStringF; 79 return f; 80 } 81 //}}} 82 83 //{{{ Variable ftestGetVariable ( const char * stringVariable ) 84 //{{{ docu 85 // 86 // ftestGetVariable() - read a variable from stringVariable, 87 // return it. 88 // 89 //}}} 90 Variable 91 ftestGetVariable ( const char * stringVariable ) 92 { 93 Variable v; 94 stringVariable = ftestSkipBlancs( stringVariable ); 95 96 if ( isalpha( *stringVariable ) ) 97 v = Variable( *stringVariable ); 98 else if ( isdigit( *stringVariable ) ) 56 *cursor++ = ';'; 57 *cursor = '\0'; 58 59 // read f from string 60 istrstream( terminatedSpec ) >> f; 61 delete [] terminatedSpec; 62 } 63 //}}} 64 65 //{{{ void ftestReadString ( const char * varSpec, Variable & v ) 66 //{{{ docu 67 // 68 // ftestReadString() - read variable `v' from `varSpec'. 69 // 70 //}}} 71 void 72 ftestReadString ( const char * varSpec, Variable & v ) 73 { 74 varSpec = ftestSkipBlancs( varSpec ); 75 76 if ( isalpha( *varSpec ) ) 77 v = Variable( *varSpec ); 78 else if ( isdigit( *varSpec ) ) 99 79 v = Variable(); 100 80 else 101 81 ftestError( CommandlineError, 102 "variable expected at `%s'\n", stringVariable ); 103 104 stringVariable = ftestSkipBlancs( stringVariable+1 ); 105 if ( *stringVariable ) 106 ftestError( CommandlineError, 107 "extra characters after var spec `%s'\n", stringVariable ); 108 109 return v; 110 } 111 //}}} 112 113 //{{{ int ftestGetint ( const char * stringInt ) 114 //{{{ docu 115 // 116 // ftestGetint() - read an integer from stringInt, 117 // return it. 118 // 119 //}}} 120 int 121 ftestGetint ( const char * stringInt ) 82 "variable expected at `%s'\n", varSpec ); 83 84 varSpec = ftestSkipBlancs( varSpec+1 ); 85 if ( *varSpec ) 86 ftestError( CommandlineError, 87 "extra characters after var spec `%s'\n", varSpec ); 88 } 89 //}}} 90 91 //{{{ void ftestReadString ( const char * intSpec, int & i ) 92 //{{{ docu 93 // 94 // ftestReadString() - read integer `i' from `intSpec'. 95 // 96 //}}} 97 void 98 ftestReadString ( const char * intSpec, int & i ) 122 99 { 123 100 const char * tokenCursor; 124 101 125 i nt i = (int)strtol( stringInt, (char**)&tokenCursor, 0 );102 i = (int)strtol( intSpec, (char**)&tokenCursor, 0 ); 126 103 127 104 // do error checks 128 if ( stringInt == tokenCursor ) 129 ftestError( CommandlineError, 130 "integer expected at `%s'\n", stringInt ); 131 132 stringInt = ftestSkipBlancs( tokenCursor ); 133 if ( *stringInt ) 134 ftestError( CommandlineError, 135 "extra characters after int spec `%s'\n", stringInt ); 136 137 return i; 138 } 139 //}}} 140 141 //{{{ bool ftestGetbool ( const char * stringBool ) 142 //{{{ docu 143 // 144 // ftestGetbool() - read an boolean from stringBool, 145 // return it. 146 // 147 //}}} 148 bool 149 ftestGetbool ( const char * stringBool ) 150 { 151 const char * tokenCursor; 152 153 bool b; 105 if ( intSpec == tokenCursor ) 106 ftestError( CommandlineError, 107 "integer expected at `%s'\n", intSpec ); 108 109 // check for extra characters after skipping blancs 110 intSpec = ftestSkipBlancs( tokenCursor ); 111 if ( *intSpec ) 112 ftestError( CommandlineError, 113 "extra characters after int spec `%s'\n", intSpec ); 114 } 115 //}}} 116 117 //{{{ void ftestReadString ( const char * boolSpec, bool & b ) 118 //{{{ docu 119 // 120 // ftestReadString() - read boolean `b' from `boolSpec'. 121 // 122 //}}} 123 void 124 ftestReadString ( const char * boolSpec, bool & b ) 125 { 154 126 // skip blancs 155 stringBool = ftestSkipBlancs( stringBool);127 boolSpec = ftestSkipBlancs( boolSpec ); 156 128 157 129 // look for "true" or "false" 158 tokenCursor = ftestSubStr( "true", stringBool);159 if ( stringBool!= tokenCursor )130 const char * tokenCursor = ftestSubStr( "true", boolSpec ); 131 if ( boolSpec != tokenCursor ) 160 132 b = true; 161 133 else { 162 tokenCursor = ftestSubStr( "false", stringBool);134 tokenCursor = ftestSubStr( "false", boolSpec ); 163 135 b = false; 164 136 } 165 137 166 138 // do error checks 167 if ( stringBool == tokenCursor ) 168 ftestError( CommandlineError, 169 "bool expected at `%s'\n", stringBool ); 170 171 // check for extra characters 172 stringBool = ftestSkipBlancs( tokenCursor ); 173 if ( *stringBool ) 174 ftestError( CommandlineError, 175 "extra characters after bool spec `%s'\n", stringBool ); 176 177 return b; 139 if ( boolSpec == tokenCursor ) 140 ftestError( CommandlineError, 141 "bool expected at `%s'\n", boolSpec ); 142 143 // check for extra characters after skipping blancs 144 boolSpec = ftestSkipBlancs( tokenCursor ); 145 if ( *boolSpec ) 146 ftestError( CommandlineError, 147 "extra characters after bool spec `%s'\n", boolSpec ); 178 148 } 179 149 //}}} … … 232 202 } 233 203 //}}} 204 205 //{{{ void ftestPrintResult ( const char * resultName, const bool result ) 206 //{{{ docu 207 // 208 // ftestPrintResult() - print a boolean. 209 // 210 //}}} 211 void 212 ftestPrintResult ( const char * resultName, const bool result ) 213 { 214 const char * stringResult = result ? "true" : "false"; 215 216 if ( ftestPrintResultFlag ) 217 cout << "Result:\t\t" << resultName << ": " << stringResult << endl; 218 else if ( ! ftestPrintFlag ) 219 cout << stringResult << endl; 220 } 221 //}}} -
factory/ftest/ftest_io.h
rfa8420 r3ba84c 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: ftest_io.h,v 1. 6 1998-03-11 16:11:01schmidt Exp $ */2 /* $Id: ftest_io.h,v 1.7 1998-04-06 11:08:44 schmidt Exp $ */ 3 3 4 4 #ifndef INCL_FTEST_IO_H … … 13 13 #include <factory.h> 14 14 15 CanonicalForm ftestGetCanonicalForm ( const char * canFormSpec ); 16 Variable ftestGetVariable ( const char * stringVariable ); 17 int ftestGetint ( const char * stringInt ); 18 bool ftestGetbool ( const char * stringBool ); 15 // functions to read objects from strings 16 void ftestRead ( const char *, CanonicalForm & ); 17 void ftestRead ( const char *, Variable & ); 18 void ftestRead ( const char *, int & ); 19 void ftestRead ( const char *, bool & ); 19 20 20 21 void ftestPrintResult ( const char * resultName, const CanonicalForm & result ); 21 22 void ftestPrintResult ( const char * resultName, const CFFList & result ); 22 23 void ftestPrintResult ( const char * resultName, const int result ); 24 void ftestPrintResult ( const char * resultName, const bool result ); 23 25 24 26 #endif /* ! INCL_FTEST_IO_H */ -
factory/ftest/ftest_util.cc
rfa8420 r3ba84c 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: ftest_util.cc,v 1.1 5 1998-03-11 16:11:06schmidt Exp $ */2 /* $Id: ftest_util.cc,v 1.16 1998-04-06 11:08:59 schmidt Exp $ */ 3 3 4 4 //{{{ docu … … 410 410 strncpy( mipoString, tokenString, mipoLen ); 411 411 mipoString[mipoLen] = '\0'; 412 mipo = ftestGetCanonicalForm( mipoString);412 ftestRead( mipoString, mipo ); 413 413 delete [] mipoString; 414 414 -
factory/ftest/ftest_util.m4
rfa8420 r3ba84c 1 dnl $Id: ftest_util.m4,v 1.1 6 1998-03-11 16:11:17schmidt Exp $1 dnl $Id: ftest_util.m4,v 1.17 1998-04-06 11:09:14 schmidt Exp $ 2 2 dnl 3 3 dnl ftest_util.m4 - m4 macros used by the factory test environment. … … 200 200 ``if ( argv[ optind ] ) { 201 201 ftestArgGiven$1= true; 202 $1= ftestGet'_stripTWS(`_ftestInType_$1')`( argv[ optind++ ]);202 ftestRead( argv[ optind++ ], $1); 203 203 } else 204 204 ftestError( CommandlineError, … … 207 207 `$#', `2', 208 208 ``if ( argv[ optind ] ) { 209 ftestArgGiven$1= true;210 $1 = ftestGet'_stripTWS(`_ftestInType_$1')`( argv[ optind++ ]);209 ftestArgGiven$1= true; 210 ftestRead( argv[ optind++ ], $1 ); 211 211 } else 212 212 $1 = '_qstripTWS(`$2')`;'', 213 213 ``if ( ftestSearchTaggedArg( argc, argv, optind, $3) ) { 214 215 $1 = ftestGet'_stripTWS(`_ftestInType_$1')`( argv[ optind++ ]);214 ftestArgGiven$1 = true; 215 ftestRead( argv[ optind++ ], $1 ); 216 216 } else 217 217 $1 = '_qstripTWS(`$2')`;'') -
factory/ftest/norm.m4
rfa8420 r3ba84c 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: norm.m4,v 1. 1 1998-03-11 17:56:11schmidt Exp $ */2 /* $Id: norm.m4,v 1.2 1998-04-06 11:05:03 schmidt Exp $ */ 3 3 4 4 ftestSetNameOfGame( norm, `" … … 45 45 46 46 // do the test! 47 ftestRun(48 if ( euclideanFlag )49 result = euclideanNorm( f ); 50 else51 result = maxNorm( f ); ); 47 if ( euclideanFlag ) { 48 ftestRun( result = euclideanNorm( f ); ); 49 } else { 50 ftestRun( result = maxNorm( f ); ); 51 } 52 52 53 53 // print results
Note: See TracChangeset
for help on using the changeset viewer.