1#!/bin/java bsh.Interpreter 2 3boolean test_failed=false; 4boolean test_completed=false; 5boolean test_warning=false; 6String test_message=""; 7int test_flag = 0; 8 9assert( boolean condition ) 10{ 11 if ( !condition ) 12 { 13 super.test_message += "Test FAILED: " 14 +"Line: "+ this.namespace.getInvocationLine() 15 +" : "+this.namespace.getInvocationText() 16 +" : while evaluating file: "+getSourceFileInfo(); 17 print(super.test_message); 18 super.test_failed = true; 19 } 20} 21 22isEvalError( String text ) 23{ 24 boolean flag = false; 25 try { 26 // eval in the namespace of whomever sourced this file. 27 this.interpreter.eval( text, this.caller.namespace ); 28 } catch ( bsh.EvalError e ) { 29 flag = true; 30 } 31 return flag; 32} 33 34fail() { 35 assert(false); 36} 37 38warning( s ) { 39 print("WARNING: "+s); 40 super.test_warning=true; 41} 42 43complete() { 44 super.test_completed = true; 45 46 if ( super.test_failed ) 47 print( bsh.sourceFile + ": Complete: FAILED!"); 48 else 49 print( bsh.sourceFile + ": Completed ok."); 50} 51 52flag() { 53 return super.test_flag++; 54} 55 56