File: fields1.bsh

package info (click to toggle)
bsh 2.0b4-20
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 4,224 kB
  • sloc: java: 23,431; xml: 4,500; sh: 139; makefile: 24
file content (51 lines) | stat: -rw-r--r-- 1,114 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
44
45
46
47
48
49
50
51
#!/bin/java bsh.Interpreter

source("TestHarness.bsh");

assert( System.out instanceof java.io.OutputStream );

assert( Fields.getFields().x == 5 );
assert( Fields.getFields().getFields2().x == 5 );

foo() {
	x=5;
	return this;
}

f=foo();
assert( f.x == 5 );

// field access chained to scripted method invocation
// This used to be broken
assert( foo().x == 5 );

// Assignment to throw away value.
foo().x=6;


//test ambiguity of field vs. method (there was a bug)

assert( Fields.getFields().ambigName.equals("field") );
assert( Fields.getFields().ambigName().equals("method") );

f=Fields.getFields();
assert( f.ambigName.equals("field") );
assert( f.ambigName().equals("method") );

// .class access
assert( Integer.class instanceof Class );
assert( Object [].class instanceof Class );
assert( Object [][][].class instanceof Class );
assert( boolean [][][].class instanceof Class );

cl1=String[][].class;
cl2=(new String[1][1]).getClass();
assert(cl1 == cl2);

Fields.staticField = true;
assert( Fields.staticField == true );
Fields.staticField = false;
assert( Fields.staticField == false);

complete();