File: 06_static.t

package info (click to toggle)
libinline-java-perl 0.58~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 964 kB
  • ctags: 684
  • sloc: perl: 4,717; java: 2,844; makefile: 35
file content (84 lines) | stat: -rw-r--r-- 1,453 bytes parent folder | download
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use strict ;
use Test ;

use Inline Config => 
           DIRECTORY => './_Inline_test';

use Inline(
	Java => 'DATA',
) ;


BEGIN {
	plan(tests => 10) ;
}


# Methods
ok(p06::types6->get("key"), undef) ;
my $t = new p06::types6("key", "value") ;

{
	ok($t->get("key"), "value") ;
	
	# Members
	ok($p06::types6::i == 5) ;
	$p06::types6::i = 7 ;
	ok($t->{i} == 7) ;
	
	my $t2 = new p06::types6("key2", "value2") ;
	my $hm = $p06::types6::hm ;
	$p06::types6::hm = undef ;
	ok(p06::types6->get($hm, "key2"), "value2") ;
	
	$p06::types6::hm = $hm ;
	ok($t2->get("key2"), "value2") ;
	
	# Calling an instance method without an object reference
	eval {p06::types6->set()} ; ok($@, qr/must be called from an object reference/) ;

	# Put in back like before...
	$p06::types6::i = 5 ;
	ok($p06::types6::i == 5) ;
	my $tt = new p06::types6("key", undef) ;
	ok($tt->get("key"), undef) ;
}

# Since $types::hm was returned to the Perl space, it was registered in the object 
# HashMap.
ok($t->__get_private()->{proto}->ObjectCount(), 2) ;


__END__

__Java__


// package test 
package p06 ;


import java.util.* ;


public class types6 {
	public static int i = 5 ;
	public static HashMap hm = new HashMap() ;

	public types6(String k, String v){
		hm.put(k, v) ;
	}

	public static String get(String k){
		return (String)hm.get(k) ; 
	}

	public static String get(HashMap h, String k){
		return (String)h.get(k) ; 
	}

	public String set(){
		return "set" ;
	}
}