File: import3.bsh

package info (click to toggle)
bsh 2.0b4-15
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 4,212 kB
  • sloc: java: 23,430; xml: 4,500; sh: 139; makefile: 30
file content (43 lines) | stat: -rw-r--r-- 1,014 bytes parent folder | download | duplicates (11)
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();