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
|
#!/bin/sh
#! The following hack allows java to reside anywhere in the path.
//bin/sh -c "exec java bsh.Interpreter $0 $*"; exit
source("TestHarness.bsh");
/**
Test import precedence rules. Disambiguate with a class import.
Several cases here, should probably make more test classes.
Tried them here once...
Without the disambiguating class import in Java this would cause a compile
time error. In bsh the *later* import takes precedence...
*/
// works
//import ambiguous.pkg1.*;
//import ambiguous.pkg2.*;
// works
import ambiguous.pkg2.*;
import ambiguous.pkg1.*;
// before disambiguation
// earlier import takes precedence
assert( new Foo().pkg.equals("pkg1") );
// Disambiguate with a class import
// Without this in Java the above would be a compile time error.
import ambiguous.pkg2.Foo;
// works
//import ambiguous.pkg1.*;
//import ambiguous.pkg2.*;
// works
//import ambiguous.pkg2.*;
//import ambiguous.pkg1.*;
// after disambiguation
assert( new Foo().pkg.equals("pkg2") );
complete();
|