source("TestHarness.bsh");
import bsh.Interpreter;

// Various commands aren't strictJava safe yet, so this has some trouble.
// Everything was working when tested.
/*
setStrictJava( false );
strictx=5;

setStrictJava( true );
int stricty1=5;
assert( isEvalError("stricty2=5;") );

setStrictJava( false );
stricty2=5;
*/

// loose
Interpreter loosei=new Interpreter();

// strict java
Interpreter stricti=new Interpreter();
stricti.setStrictJava(true);

loosei.set("a",5);
// strictjava still allows untyped external set
stricti.set("a",5);

loosei.eval("a=6");
// we can assign to pre-existing untype vars even in strict java mode
stricti.eval("a=6");

loosei.eval("int q2=5");
loosei.eval("q=5");

stricti.eval("int q2=5");
// error, untyped assignment
assert( isEvalError("stricti.eval(\"q=5\")") );
// error, untyped method arg
assert( isEvalError("stricti.eval(\"int foo(a) {} \")") );
// error, untyped return
assert( isEvalError("stricti.eval(\"foo(int a) {} \")") );
// error, untyped catch block
assert( isEvalError("stricti.eval(\"try{throw new Exception();}catch(e){}\")"));

complete();
