Java
=>
'DATA'
,
STUDY
=> [
'java.util.HashMap'
,
'java.lang.String'
],
AUTOSTUDY
=> 1,
) ;
my
$t
= new types7() ;
{
my
$t1
= new t17() ;
is(
$t
->func(5),
"int"
) ;
is(
$t
->func(coerce(
"char"
, 5)),
"char"
) ;
is(
$t
->func(55),
"int"
) ;
is(
$t
->func(
"str"
),
"string"
) ;
is(
$t
->func(coerce(
"java.lang.StringBuffer"
,
"str"
)),
"stringbuffer"
) ;
is(
$t
->f(
$t
->{hm}),
"hashmap"
) ;
is(
$t
->f(cast(
"java.lang.Object"
,
$t
->{hm})),
"object"
) ;
is(
$t
->f([
"a"
,
"b"
,
"c"
]),
"string[]"
) ;
is(
$t
->f([
"12.34"
,
"45.67"
]),
"double[]"
) ;
is(
$t
->f(coerce(
"java.lang.Object"
, [
'a'
],
"[Ljava.lang.String;"
)),
"object"
) ;
eval
{
$t
->func(
$t1
)} ; like($@,
qr/Can't find any signature/
) ;
eval
{
$t
->func(cast(
"int"
,
$t1
))} ; like($@,
qr/Can't cast (.*) to a int/
) ;
my
$t2
= new t27() ;
is(
$t2
->f(
$t2
),
"t1"
) ;
is(
$t1
->f(
$t2
),
"t1"
) ;
is(
$t2
->f(
$t1
),
"t2"
) ;
is(
$t2
->f(cast(
"t17"
,
$t2
)),
"t2"
) ;
is(
$t2
->f(
$t1
),
"t2"
) ;
is(
$t2
->{i}, 7) ;
is(
$t2
->{j}, 3.1416) ;
eval
{
$t2
->{j} =
"string"
} ; like($@,
qr/Can't convert/
) ;
my
$al
=
$t1
->get_al() ;
is(
$t1
->count(
$al
), 0) ;
my
$hm
= new java::util::HashMap() ;
$hm
->put(
'key'
,
'value'
) ;
my
$a
=
$hm
->entrySet()->toArray() ;
foreach
my
$e
(@{
$a
}){
is(cast(
'java.util.Map$Entry'
,
$e
)->getKey(),
'key'
) ;
}
my
$str
= new java::lang::String(
'test'
) ;
is(
$str
,
'test'
) ;
}
is(
$t
->__get_private()->{proto}->ObjectCount(), 1) ;