#!/bin/java bsh.Interpreter

source("TestHarness.bsh");

/**
	I'm just taking a shotgun approach here... we need better tests.
*/

a=5;
a*=2;
assert(a==10);

assert( (255 ^ 128) == 127 );
a=0xff;
a^=128;
assert(a==127);

assert( 13%10 == 3 );

// booleans comparison
assert ( true == true );
assert ( false == false );
assert ( true != false );
assert ( !(true == false) );

// instanceof and null
assert( !(null instanceof String) );
assert( isEvalError("true instanceof 5") );
assert( isEvalError("true instanceof true") );
assert( isEvalError("new Object() instanceof 5") );
assert( isEvalError("new Object() instanceof true") );
assert( isEvalError("5 instanceof true") );
assert( isEvalError("null instanceof null") );
a="foo";
assert( isEvalError("a instanceof null") );
assert( a instanceof String );

// void
assert( void == void );
assert( void != null );
assert( undefinedVariable == void );
def="foo";
assert( def != void );
// hmm... direct values compared?
assert( "foo" != void );

// instanceof and void
assert( isEvalError("void instanceof 5") );
assert( isEvalError("new Object() instanceof void") );
assert( isEvalError("null instanceof void") );

/*
	Uncomment these if we start enforcing operations on primitive/non-prim
*/

/*
	// can't compare void with primitive
	assert( isEvalError("5 != void") );
	assert( isEvalError("void != 5") );
	assert( isEvalError("true != void") );
	assert( isEvalError("void != true") );
	assert( isEvalError("void != false") );

	// can't compare boolean to anything but boolean
	assert( isEvalError("true != null") );
	assert( isEvalError("null != false") );
	assert( isEvalError("null != true") );
	assert( isEvalError("true == null") );
	assert( isEvalError("null == true") );
	assert( isEvalError("true == new Object()") );
	assert( isEvalError("true != new Object()") );
	assert( isEvalError("new Object() != false") );
	assert( isEvalError("true == 5") );
	assert( isEvalError("true != 5") );
	assert( isEvalError("5 != false") );
*/

complete();

