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
|
#!/bin/java bsh.Interpreter
// Givin' bsh its props ;)
source("TestHarness.bsh");
// {} syntax
b = new java.awt.Button();
print( b{"name"} );
b{"name"} = "MyButton!";
assert( b{"name"}.equals("MyButton!") );
// extended field style access
b.name = "Test";
assert( b.name.equals("Test") );
// for booleans support both getFoo() and isFoo() style
Float fl = new Float(1.0f);
assert( fl.infinite == false );
// Properties style auto-allocation of object scope relative to 'this' type
// references.
assert( foo == void );
foo.gee1.gee2.gee3 = true;
assert( foo.gee1.gee2.gee3 == true );
foo.bar.blah = true;
foo.bar.blah2 = true;
// Make sure we don't mask undefined static fields
assert( Fields instanceof bsh.ClassIdentifier );
assert( isEvalError("Fields.nonExistent=42") );
Fields.propTest = 42;
assert( Fields.propTest == 42 );
complete();
|