#!/bin/java bsh.Interpreter

source("TestHarness.bsh");

assert( System.out instanceof java.io.OutputStream );

assert( Fields.getFields().x == 5 );
assert( Fields.getFields().getFields2().x == 5 );

foo() {
	x=5;
	return this;
}

f=foo();
assert( f.x == 5 );

// field access chained to scripted method invocation
// This used to be broken
assert( foo().x == 5 );

// Assignment to throw away value.
foo().x=6;


//test ambiguity of field vs. method (there was a bug)

assert( Fields.getFields().ambigName.equals("field") );
assert( Fields.getFields().ambigName().equals("method") );

f=Fields.getFields();
assert( f.ambigName.equals("field") );
assert( f.ambigName().equals("method") );

// .class access
assert( Integer.class instanceof Class );
assert( Object [].class instanceof Class );
assert( Object [][][].class instanceof Class );
assert( boolean [][][].class instanceof Class );

cl1=String[][].class;
cl2=(new String[1][1]).getClass();
assert(cl1 == cl2);

Fields.staticField = true;
assert( Fields.staticField == true );
Fields.staticField = false;
assert( Fields.staticField == false);

complete();

