// read in a file full of tests for us to run // verify that our data is correct by testing it // report any errors var fileForReading = new File( WhoAmI().parent.toString() + "/ReadFileForInput.txt" ); var myArray = []; var pass = 0; var errors = 0; // read in all my data from the file if ( fileForReading.exists ) { if ( fileForReading.open("r") ) { while ( ! fileForReading.eof ) { myArray.push( eval( fileForReading.readln() ) ); } fileForReading.close(); } else { alert( 'Found it but I could not open it.' ); } } else { alert( 'Could not locate file: ' + fileForReading.toString() ); } // run some tests on it for ( i in myArray ) { if ( myArray[i][0] + myArray[i][1] != myArray[i][2] ) { errors++; } else { pass++; } if ( typeof myArray[i][3] != 'string' ) { errors++; } else { pass++; } } if ( errors + pass != myArray.length * 2 ) { errors++; } // report test results if ( errors ) { alert( 'bad test: ' + errors ); } else { alert( 'pass' ); } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// function WhoAmI() { var where; try { var FORCEERROR = FORCERRROR; } catch( err ) { where = File(err.fileName); } return where; }