#!/bin/java bsh.Interpreter

boolean test_failed=false;
boolean test_completed=false;
boolean test_warning=false;
String test_message="";
int test_flag = 0;

assert( boolean condition ) 
{
	if ( !condition )
	{
        super.test_message += "Test FAILED: "
			+"Line: "+ this.namespace.getInvocationLine()
			+" : "+this.namespace.getInvocationText()
			+" : while evaluating file: "+getSourceFileInfo();
		print(super.test_message);
		super.test_failed = true;
	}
}

isEvalError( String text ) 
{
	boolean flag = false;
	try {
		// eval in the namespace of whomever sourced this file.
		this.interpreter.eval( text, this.caller.namespace );
	} catch ( bsh.EvalError e ) {
		flag = true;
	}
	return flag;
}

fail() {
	assert(false);
}

warning( s ) {
	print("WARNING: "+s);
	super.test_warning=true;
}

complete() {
	super.test_completed = true;

	if ( super.test_failed )
		print( bsh.sourceFile + ": Complete: FAILED!");
	else
		print( bsh.sourceFile + ": Completed ok.");
}

flag() {
	return super.test_flag++;
}

