File: methodselection.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 (44 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download | duplicates (10)
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
#!/bin/java bsh.Interpreter

source("TestHarness.bsh");

// test static method selection
assert( MethodSelection.get_static( (int)5 ) == Integer.TYPE );
assert( MethodSelection.get_static( (short)5 ) == Short.TYPE );
assert( MethodSelection.get_static( (long)5 ) == Long.TYPE );
assert( MethodSelection.get_static( (byte)5 ) == Byte.TYPE );
assert( MethodSelection.get_static( "foo" ) == String.class );
assert( MethodSelection.get_static( new Object() ) == Object.class );
assert( MethodSelection.get_static() == Void.TYPE);

// test dynamic method selection
m=new MethodSelection();
assert( m.get_dynamic( (int)5 ) == Integer.TYPE );
assert( m.get_dynamic( (short)5 ) == Short.TYPE );
assert( m.get_dynamic( (long)5 ) == Long.TYPE );
assert( m.get_dynamic( (byte)5 ) == Byte.TYPE );
assert( m.get_dynamic( "foo" ) == String.class );
assert( m.get_dynamic( new Object() ) == Object.class );
assert( m.get_dynamic() == Void.TYPE );

// bsh should recognize a less specific java compatible match over an
// extended (autoboxed, BeanShell specific, etc.) match 
// Should be Integer.class not primitive Integer.TYPE (both available) 
assert( m.get_dynamic( new Integer(4) ) == Integer.class );

// test constructor selection
m=new MethodSelection( (int)5 );
assert( m.constructedWith == Integer.TYPE );
m=new MethodSelection( (short)5 );
assert( m.constructedWith == Short.TYPE );
m=new MethodSelection( (long)5 );
assert( m.constructedWith == Long.TYPE );
m=new MethodSelection( (byte)5 );
assert( m.constructedWith == Byte.TYPE );
m=new MethodSelection( "foo" );
assert( m.constructedWith == String.class );
m=new MethodSelection( new Object() );
assert( m.constructedWith == Object.class );

complete();