1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#!/bin/java bsh.Interpreter
/**
'super' refers to the parent context in which the method was evaluated,
*not* the caller's namespace.
*/
source("TestHarness.bsh");
// Test 1
foo() {
foocontext = this;
calledOutsideFoo( caller ) {
assert( super == foocontext );
assert( super != caller );
}
return this;
}
foo().calledOutsideFoo( this );
helper() {
foo().calledOutsideFoo( this );
}
helper();
// End Test 1
// Test 2
baseContext = this;
x=5;
bar( caller ) {
assert( super == baseContext );
assert( super != caller );
assert( super.x == 5 );
}
caller() {
this.x=99;
bar(this);
}
caller();
// End Test 2
complete();
|