File: import.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 (31 lines) | stat: -rw-r--r-- 944 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
#!/bin/java bsh.Interpreter

source("TestHarness.bsh");

// run() creates a sub interpreter
result = run("Data/import_aux1.bsh");
assert( result.myClassVisible );

// imports in the run are not leaked to us
assert( this.namespace.getClass("MyClass") == null );

// As you would expect, source does give us the imports of the source file
source("Data/import_aux1.bsh");
assert( this.namespace.getClass("MyClass") != null );

// Child run()s do not inherit the imports!
// Is this correct behavior or broken?
result = run("Data/import_aux2.bsh");
if ( !result.myClassVisible ) {
	//warning("Child run()s do not inherit their parent's imports");
}

// Subsequent sourcing of course should see the previous imports
source("Data/import_aux2.bsh");
assert( myClassVisible );

// test for specific bug...
// the bug would cause a stack overflow here and probably stop the VM
assert( isEvalError("import NoSuchClass; NoSuchClass foo;") );

complete();