#!/bin/java bsh.Interpreter

source("TestHarness.bsh");

int p=1;
{
	int p=2;
	{
		int p=3;
		pz=99;
		assert( p == 3 );
	}
	assert( p == 2 );
}
assert( p == 1 );
assert( pz == 99 );


/*
	Typed variable declarations inside a block should not leak out.
*/
boolean var = false;
for(int i=0; i<1; i++) {
   int var=1;
}
for(int i=0; i<1; i++) {
   String var="hello";
}
assert( var == false );

u=2;
int x=2;
int z1=2;
{
	assert(u==2);
	assert(super.u==2);
	u=3;
	assert(u==3);
	
	x=3;
	assert(x==3);
	
	int z=3;
	// bsh allows the redeclaration...
	// but the scope should be local
	int z1=5;
}
assert( u==3 );
assert( x==3 );

assert( z==void );
assert( z1==2 );

i=0;
while( i++ < 5 ) {
	int qz=5;
	assert( qz == 5);
}
assert( qz == void);

int i=0;
while( i < 5 ) {
	i++;
	int qz=5;
	assert( qz == 5);
}
assert( qz == void);

if ( true ) {
	assert( this == global );
	if ( true ) {
		assert( this == global );
	}
}

complete();
