[libinline-java-perl] 109/398: *** empty log message ***

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:42:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.55
in repository libinline-java-perl.

commit 71f216b0a414c21f57a7857e0d26207623d2552d
Author: Patrick LeBoutillier <patl at cpan.org>
Date:   Mon Sep 17 19:46:33 2001 +0000

    *** empty log message ***
---
 CHANGES           |  11 ++
 t/02_primitives.t | 296 +++++++++++++++++++++++++++---------------------------
 t/03_objects.t    |  90 +++++++++--------
 t/04_members.t    | 152 ++++++++++++++--------------
 t/05_arrays.t     | 202 +++++++++++++++++++++----------------
 t/06_static.t     |  54 ++++++----
 t/07_polymorph.t  |  71 +++++++------
 t/08_study.t      |  32 +++---
 8 files changed, 492 insertions(+), 416 deletions(-)

diff --git a/CHANGES b/CHANGES
index 397ee75..798a76d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,17 @@
 Revision history for Perl extension Inline::Java
 ------------------------------------------------
 
+0.30  Mon Sep 17 15:45:06 EDT 2001
+    - JVM server is now multi-threaded
+    - Added 'SHARED_JVM' option for mod_perl support
+    - Beefed up test suite
+
+0.23  Thu Aug 30 08:41:11 EDT 2001
+    - Added support for multiple Inline sections using a special notation
+      in the CLASSPATH.
+    - Added the 'fix' Makefile.PL option au automatically fix the Makefile
+      for Win95/98/Me.
+
 0.22  Fri Jun  1 13:31:35 EDT 2001
     - Fixed up Inline::Java to work with Inline 0.41
     - Added support for java.lang.Number as a primitive numeric type. Any
diff --git a/t/02_primitives.t b/t/02_primitives.t
index 360c445..11d04a2 100644
--- a/t/02_primitives.t
+++ b/t/02_primitives.t
@@ -10,158 +10,162 @@ use Inline(
 
 
 BEGIN {
-	plan(tests => 106) ;
+	plan(tests => 107) ;
 }
 
 
-my $t = new types() ;
-
-my $max = undef ;
-my $min = undef ;
-
-$max = 127 ;
-$min = -128 ;
-ok($t->_byte(undef) == 1) ;
-ok($t->_byte(0) == 1) ;
-ok($t->_byte($max - 1) == $max) ;
-ok($t->_byte("$min") == $min + 1) ;
-eval {$t->_byte($max + 1)} ; ok($@, qr/out of range/) ;
-eval {$t->_byte($min - 1)} ; ok($@, qr/out of range/) ;
-ok($t->_Byte(undef) == 0) ;
-ok($t->_Byte(0) == 0) ;
-ok($t->_Byte($max) == $max) ;
-ok($t->_Byte("$min") == $min) ;
-eval {$t->_Byte($max + 1)} ; ok($@, qr/out of range/) ;
-eval {$t->_Byte($min - 1)} ; ok($@, qr/out of range/) ;
-
-$max = 32767 ;
-$min = -32768 ;
-ok($t->_short(undef) == 1) ;
-ok($t->_short(0) == 1) ;
-ok($t->_short($max - 1) == $max) ;
-ok($t->_short("$min") == $min + 1) ;
-eval {$t->_short($max + 1)} ; ok($@, qr/out of range/) ;
-eval {$t->_short($min - 1)} ; ok($@, qr/out of range/) ;
-ok($t->_Short(undef) == 0) ;
-ok($t->_Short(0) == 0) ;
-ok($t->_Short($max) == $max) ;
-ok($t->_Short("$min") == $min) ;
-eval {$t->_Short($max + 1)} ; ok($@, qr/out of range/) ;
-eval {$t->_Short($min - 1)} ; ok($@, qr/out of range/) ;
-
-$max = 2147483647 ;
-$min = -2147483648 ;
-ok($t->_int(undef) == 1) ;
-ok($t->_int(0) == 1) ;
-ok($t->_int($max - 1) == $max) ;
-ok($t->_int("$min") == $min + 1) ;
-eval {$t->_int($max + 1)} ; ok($@, qr/out of range/) ;
-eval {$t->_int($min - 1)} ; ok($@, qr/out of range/) ;
-ok($t->_Integer(undef) == 0) ;
-ok($t->_Integer(0) == 0) ;
-ok($t->_Integer($max) == $max) ;
-ok($t->_Integer("$min") == $min) ;
-eval {$t->_Integer($max + 1)} ; ok($@, qr/out of range/) ;
-eval {$t->_Integer($min - 1)} ; ok($@, qr/out of range/) ;
-
-$max = 2147483647 ;
-$min = -2147483648 ;
-ok($t->_long(undef) == 1) ;
-ok($t->_long(0) == 1) ;
-ok($t->_long($max - 1) == $max) ;
-ok($t->_long("$min") == $min + 1) ;
-eval {$t->_long($max + 1)} ; ok($@, qr/out of range/) ;
-eval {$t->_long($min - 1)} ; ok($@, qr/out of range/) ;
-ok($t->_Long(undef) == 0) ;
-ok($t->_Long(0) == 0) ;
-ok($t->_Long($max) == $max) ;
-ok($t->_Long("$min") == $min) ;
-eval {$t->_Long($max + 1)} ; ok($@, qr/out of range/) ;
-eval {$t->_Long($min - 1)} ; ok($@, qr/out of range/) ;
-
-$max = 3.4028235e38 ;
-$min = -3.4028235e38 ;
-ok($t->_float(undef) == 1) ;
-ok($t->_float(0) == 1) ;
-ok($t->_float($max - 1) == $max) ;
-ok($t->_float("$min") == $min + 1) ;
-eval {$t->_float($max + $max)} ; ok($@, qr/out of range/) ;
-eval {$t->_float($min + $min)} ; ok($@, qr/out of range/) ;
-ok($t->_Float(undef) == 0) ;
-ok($t->_Float(0) == 0) ;
-ok($t->_Float($max) == $max) ;
-ok($t->_Float("$min") == $min) ;
-eval {$t->_Float($max + $max)} ; ok($@, qr/out of range/) ;
-eval {$t->_Float($min + $min)} ; ok($@, qr/out of range/) ;
-
-$max = 3.4028235e38 ;
-$min = -3.4028235e38 ;
-ok($t->_double(undef) == 1) ;
-ok($t->_double(0) == 1) ;
-ok($t->_double($max - 1) == $max) ;
-ok($t->_double("$min") == $min + 1) ;
-eval {$t->_double($max + $max)} ; ok($@, qr/out of range/) ;
-eval {$t->_double($min + $min)} ; ok($@, qr/out of range/) ;
-ok($t->_Double(undef) == 0) ;
-ok($t->_Double(0) == 0) ;
-ok($t->_Double($max) == $max) ;
-ok($t->_Double("$min") == $min) ;
-eval {$t->_Double($max + $max)} ; ok($@, qr/out of range/) ;
-eval {$t->_Double($min + $min)} ; ok($@, qr/out of range/) ;
-
-# Number is forced to Double
-$max = 3.4028235e38 ;
-$min = -3.4028235e38 ;
-ok($t->_Number(undef) == 0) ;
-ok($t->_Number(0) == 0) ;
-ok($t->_Number($max) == $max) ;
-ok($t->_Number("$min") == $min) ;
-eval {$t->_Number($max + $max)} ; ok($@, qr/out of range/) ;
-eval {$t->_Number($min + $min)} ; ok($@, qr/out of range/) ;
-
-ok(! $t->_boolean(undef)) ;
-ok(! $t->_boolean(0)) ;
-ok(! $t->_boolean("")) ;
-ok($t->_boolean("true")) ;
-ok($t->_boolean(1)) ;
-ok(! $t->_Boolean(undef)) ; 
-ok(! $t->_Boolean(0)) ; 
-ok(! $t->_Boolean("")) ; 
-ok($t->_Boolean("true")) ; 
-ok($t->_Boolean(1)) ; 
-
-ok($t->_char(undef), "\0") ;
-ok($t->_char(0), "0") ;
-ok($t->_char("1"), '1') ;
-eval {$t->_char("10")} ; ok($@, qr/Can't convert/) ;
-ok($t->_Character(undef), "\0") ;
-ok($t->_Character(0), "0") ;
-ok($t->_Character("1"), '1') ;
-eval {$t->_Character("10")} ; ok($@, qr/Can't convert/) ;
-
-ok($t->_String(undef), undef) ;
-ok($t->_String(0), "0") ;
-ok($t->_String("string"), 'string') ;
-ok($t->_StringBuffer(undef), undef) ;
-ok($t->_StringBuffer(0), "0") ;
-ok($t->_StringBuffer("stringbuffer"), 'stringbuffer') ;
-
-# Test if scalars can pass as java.lang.Object.
-# They should be converted to strings.
-ok($t->_Object(undef), undef) ;
-ok($t->_Object(0), "0") ;
-ok($t->_Object(666) == 666) ;
-ok($t->_Object("object"), 'object') ;
-
-
-
-
-__END__
+my $t = new types2() ;
+
+{
+	my $max = undef ;
+	my $min = undef ;
+	
+	$max = 127 ;
+	$min = -128 ;
+	ok($t->_byte(undef) == 1) ;
+	ok($t->_byte(0) == 1) ;
+	ok($t->_byte($max - 1) == $max) ;
+	ok($t->_byte("$min") == $min + 1) ;
+	eval {$t->_byte($max + 1)} ; ok($@, qr/out of range/) ;
+	eval {$t->_byte($min - 1)} ; ok($@, qr/out of range/) ;
+	ok($t->_Byte(undef) == 0) ;
+	ok($t->_Byte(0) == 0) ;
+	ok($t->_Byte($max) == $max) ;
+	ok($t->_Byte("$min") == $min) ;
+	eval {$t->_Byte($max + 1)} ; ok($@, qr/out of range/) ;
+	eval {$t->_Byte($min - 1)} ; ok($@, qr/out of range/) ;
+	
+	$max = 32767 ;
+	$min = -32768 ;
+	ok($t->_short(undef) == 1) ;
+	ok($t->_short(0) == 1) ;
+	ok($t->_short($max - 1) == $max) ;
+	ok($t->_short("$min") == $min + 1) ;
+	eval {$t->_short($max + 1)} ; ok($@, qr/out of range/) ;
+	eval {$t->_short($min - 1)} ; ok($@, qr/out of range/) ;
+	ok($t->_Short(undef) == 0) ;
+	ok($t->_Short(0) == 0) ;
+	ok($t->_Short($max) == $max) ;
+	ok($t->_Short("$min") == $min) ;
+	eval {$t->_Short($max + 1)} ; ok($@, qr/out of range/) ;
+	eval {$t->_Short($min - 1)} ; ok($@, qr/out of range/) ;
+	
+	$max = 2147483647 ;
+	$min = -2147483648 ;
+	ok($t->_int(undef) == 1) ;
+	ok($t->_int(0) == 1) ;
+	ok($t->_int($max - 1) == $max) ;
+	ok($t->_int("$min") == $min + 1) ;
+	eval {$t->_int($max + 1)} ; ok($@, qr/out of range/) ;
+	eval {$t->_int($min - 1)} ; ok($@, qr/out of range/) ;
+	ok($t->_Integer(undef) == 0) ;
+	ok($t->_Integer(0) == 0) ;
+	ok($t->_Integer($max) == $max) ;
+	ok($t->_Integer("$min") == $min) ;
+	eval {$t->_Integer($max + 1)} ; ok($@, qr/out of range/) ;
+	eval {$t->_Integer($min - 1)} ; ok($@, qr/out of range/) ;
+	
+	$max = 2147483647 ;
+	$min = -2147483648 ;
+	ok($t->_long(undef) == 1) ;
+	ok($t->_long(0) == 1) ;
+	ok($t->_long($max - 1) == $max) ;
+	ok($t->_long("$min") == $min + 1) ;
+	eval {$t->_long($max + 1)} ; ok($@, qr/out of range/) ;
+	eval {$t->_long($min - 1)} ; ok($@, qr/out of range/) ;
+	ok($t->_Long(undef) == 0) ;
+	ok($t->_Long(0) == 0) ;
+	ok($t->_Long($max) == $max) ;
+	ok($t->_Long("$min") == $min) ;
+	eval {$t->_Long($max + 1)} ; ok($@, qr/out of range/) ;
+	eval {$t->_Long($min - 1)} ; ok($@, qr/out of range/) ;
+	
+	$max = 3.4028235e38 ;
+	$min = -3.4028235e38 ;
+	ok($t->_float(undef) == 1) ;
+	ok($t->_float(0) == 1) ;
+	ok($t->_float($max - 1) == $max) ;
+	ok($t->_float("$min") == $min + 1) ;
+	eval {$t->_float($max + $max)} ; ok($@, qr/out of range/) ;
+	eval {$t->_float($min + $min)} ; ok($@, qr/out of range/) ;
+	ok($t->_Float(undef) == 0) ;
+	ok($t->_Float(0) == 0) ;
+	ok($t->_Float($max) == $max) ;
+	ok($t->_Float("$min") == $min) ;
+	eval {$t->_Float($max + $max)} ; ok($@, qr/out of range/) ;
+	eval {$t->_Float($min + $min)} ; ok($@, qr/out of range/) ;
+	
+	$max = 3.4028235e38 ;
+	$min = -3.4028235e38 ;
+	ok($t->_double(undef) == 1) ;
+	ok($t->_double(0) == 1) ;
+	ok($t->_double($max - 1) == $max) ;
+	ok($t->_double("$min") == $min + 1) ;
+	eval {$t->_double($max + $max)} ; ok($@, qr/out of range/) ;
+	eval {$t->_double($min + $min)} ; ok($@, qr/out of range/) ;
+	ok($t->_Double(undef) == 0) ;
+	ok($t->_Double(0) == 0) ;
+	ok($t->_Double($max) == $max) ;
+	ok($t->_Double("$min") == $min) ;
+	eval {$t->_Double($max + $max)} ; ok($@, qr/out of range/) ;
+	eval {$t->_Double($min + $min)} ; ok($@, qr/out of range/) ;
+	
+	# Number is forced to Double
+	$max = 3.4028235e38 ;
+	$min = -3.4028235e38 ;
+	ok($t->_Number(undef) == 0) ;
+	ok($t->_Number(0) == 0) ;
+	ok($t->_Number($max) == $max) ;
+	ok($t->_Number("$min") == $min) ;
+	eval {$t->_Number($max + $max)} ; ok($@, qr/out of range/) ;
+	eval {$t->_Number($min + $min)} ; ok($@, qr/out of range/) ;
+	
+	ok(! $t->_boolean(undef)) ;
+	ok(! $t->_boolean(0)) ;
+	ok(! $t->_boolean("")) ;
+	ok($t->_boolean("true")) ;
+	ok($t->_boolean(1)) ;
+	ok(! $t->_Boolean(undef)) ; 
+	ok(! $t->_Boolean(0)) ; 
+	ok(! $t->_Boolean("")) ; 
+	ok($t->_Boolean("true")) ; 
+	ok($t->_Boolean(1)) ; 
+	
+	ok($t->_char(undef), "\0") ;
+	ok($t->_char(0), "0") ;
+	ok($t->_char("1"), '1') ;
+	eval {$t->_char("10")} ; ok($@, qr/Can't convert/) ;
+	ok($t->_Character(undef), "\0") ;
+	ok($t->_Character(0), "0") ;
+	ok($t->_Character("1"), '1') ;
+	eval {$t->_Character("10")} ; ok($@, qr/Can't convert/) ;
+	
+	ok($t->_String(undef), undef) ;
+	ok($t->_String(0), "0") ;
+	ok($t->_String("string"), 'string') ;
+	ok($t->_StringBuffer(undef), undef) ;
+	ok($t->_StringBuffer(0), "0") ;
+	ok($t->_StringBuffer("stringbuffer"), 'stringbuffer') ;
+	
+	# Test if scalars can pass as java.lang.Object.
+	# They should be converted to strings.
+	ok($t->_Object(undef), undef) ;
+	ok($t->_Object(0), "0") ;
+	ok($t->_Object(666) == 666) ;
+	ok($t->_Object("object"), 'object') ;
+}
+
+ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
+
+
+
+
+__DATA__
 
 __Java__
 
-class types {
-	public types(){
+class types2 {
+	public types2(){
 	}
 
 	public byte _byte(byte b){
diff --git a/t/03_objects.t b/t/03_objects.t
index ba92536..d89af16 100644
--- a/t/03_objects.t
+++ b/t/03_objects.t
@@ -10,42 +10,46 @@ use Inline(
 
 
 BEGIN {
-	plan(tests => 13) ;
+	plan(tests => 14) ;
 }
 
 
 # Create some objects
-my $t = new types() ;
-
-my $obj1 = new obj1() ;
-eval {my $obj2 = new obj2()} ; ok($@, qr/No public constructor/) ;
-my $obj11 = new obj11() ;
-
-ok($t->_obj1(undef), undef) ;
-ok($t->_obj1($obj1)->get_data(), "obj1") ;
-ok($t->_obj11($obj11)->get_data(), "obj11") ;
-ok($t->_obj1($obj11)->get_data(), "obj11") ;
-eval {$t->_int($obj1)} ; ok($@, qr/Can't convert (.*) to primitive int/) ;
-eval {$t->_obj11($obj1)} ; ok($@, qr/is not a kind of/) ;
-
-# Receive an unbound object and send it back
-my $unb = $t->get_unbound() ;
-ok($t->send_unbound($unb), "al_elem") ;
-
-# Unexisting method
-eval {$t->toto()} ; ok($@, qr/No public method/) ;
-
-# Method on unbound object
-eval {$unb->toto()} ; ok($@, qr/Can't call method/) ;
-
-# Incompatible prototype, 1 signature
-eval {$t->_obj1(5)} ; ok($@, qr/Can't convert/) ;
-
-# Incompatible prototype, >1 signature
-eval {$t->__obj1(5)} ; ok($@, qr/Can't find any signature/) ;
+my $t = new types3() ;
+
+{
+	my $obj1 = new obj13() ;
+	eval {my $obj2 = new obj23()} ; ok($@, qr/No public constructor/) ;
+	my $obj11 = new obj113() ;
+	
+	ok($t->_obj1(undef), undef) ;
+	ok($t->_obj1($obj1)->get_data(), "obj1") ;
+	ok($t->_obj11($obj11)->get_data(), "obj11") ;
+	ok($t->_obj1($obj11)->get_data(), "obj11") ;
+	eval {$t->_int($obj1)} ; ok($@, qr/Can't convert (.*) to primitive int/) ;
+	eval {$t->_obj11($obj1)} ; ok($@, qr/is not a kind of/) ;
+	
+	# Receive an unbound object and send it back
+	my $unb = $t->get_unbound() ;
+	ok($t->send_unbound($unb), "al_elem") ;
+	
+	# Unexisting method
+	eval {$t->toto()} ; ok($@, qr/No public method/) ;
+	
+	# Method on unbound object
+	eval {$unb->toto()} ; ok($@, qr/Can't call method/) ;
+	
+	# Incompatible prototype, 1 signature
+	eval {$t->_obj1(5)} ; ok($@, qr/Can't convert/) ;
+	
+	# Incompatible prototype, >1 signature
+	eval {$t->__obj1(5)} ; ok($@, qr/Can't find any signature/) ;
+	
+	# Return a scalar hidden in an object.
+	ok($t->_olong(), 12345) ;
+}
 
-# Return a scalar hidden in an object.
-ok($t->_olong(), 12345) ;
+ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
 
 
 __END__
@@ -55,10 +59,10 @@ __Java__
 import java.util.* ;
 
 
-class obj1 {
+class obj13 {
 	String data = "obj1" ;
 
-	public obj1() {
+	public obj13() {
 	}
 
 	public String get_data(){
@@ -66,10 +70,10 @@ class obj1 {
 	}
 }
 
-class obj11 extends obj1 {
+class obj113 extends obj13 {
 	String data = "obj11" ;
 
-	public obj11() {
+	public obj113() {
 	}
 
 	public String get_data(){
@@ -78,10 +82,10 @@ class obj11 extends obj1 {
 }
 
 
-class obj2 {
+class obj23 {
 	String data = "obj2" ;
 
-	obj2() {
+	obj23() {
 	}
 
 	public String get_data(){
@@ -90,8 +94,8 @@ class obj2 {
 }
 
 
-class types {
-	public types(){
+class types3 {
+	public types3(){
 	}
 
 	public int _int(int i){
@@ -102,22 +106,22 @@ class types {
 		return o ;
 	}
 
-	public obj1 _obj1(obj1 o){
+	public obj13 _obj1(obj13 o){
 		return o ;
 	}
 
 
-	public obj1 __obj1(obj1 o, int i){
+	public obj13 __obj1(obj13 o, int i){
 		return o ;
 	}
 
 
-	public obj1 __obj1(obj1 o){
+	public obj13 __obj1(obj13 o){
 		return o ;
 	}
 
 
-	public obj11 _obj11(obj11 o){
+	public obj113 _obj11(obj113 o){
 		return o ;
 	}
 
diff --git a/t/04_members.t b/t/04_members.t
index 20e57e6..aca5725 100644
--- a/t/04_members.t
+++ b/t/04_members.t
@@ -10,79 +10,83 @@ use Inline(
 
 
 BEGIN {
-	plan(tests => 27) ;
+	plan(tests => 28) ;
 }
 
 
-my $t = new types() ;
-
-$t->{_byte} = 123 ;
-ok($t->{_byte} == 123) ;
-$t->{_Byte} = 123 ;
-ok($t->{_Byte} == 123) ;
-
-$t->{_short} = 123 ;
-ok($t->{_short} == 123) ;
-$t->{_Short} = 123 ;
-ok($t->{_Short} == 123) ;
-
-$t->{_int} = 123 ;
-ok($t->{_int} == 123) ;
-$t->{_Integer} = 123 ;
-ok($t->{_Integer} == 123) ;
-
-$t->{_long} = 123 ;
-ok($t->{_long} == 123) ;
-$t->{_Long} = 123 ;
-ok($t->{_Long} == 123) ;
-
-$t->{_float} = 123.456 ;
-ok($t->{_float} == 123.456) ;
-$t->{_Float} = 123.456 ;
-ok($t->{_Float} == 123.456) ;
-
-$t->{_double} = 123.456 ;
-ok($t->{_double} == 123.456) ;
-$t->{_Double} = 123.456 ;
-ok($t->{_Double} == 123.456) ;
-
-$t->{_boolean} = 1 ;
-ok($t->{_boolean}) ;
-$t->{_Boolean} = 1 ;
-ok($t->{_Boolean}) ;
-
-$t->{_char} = "a" ;
-ok($t->{_char}, "a") ;
-$t->{_Character} = "a" ;
-ok($t->{_Character}, "a") ;
-
-$t->{_String} = "string" ;
-ok($t->{_String}, "string") ;
-$t->{_StringBuffer} = "stringbuffer" ;
-ok($t->{_StringBuffer}, "stringbuffer") ;
-
-my $obj1 = new obj1() ;
-$t->{_Object} = $obj1 ;
-ok($t->{_Object}->get_data(), "obj1") ;
-$t->{_Object} = "object" ;
-ok($t->{_Object}, "object") ;
-
-$t->{_Object} = undef ;
-ok($t->{_Object}, undef) ;
-$t->{_int} = undef ;
-ok($t->{_int} == 0) ;
-
-# Receive an unbound object and try to call a member
-my $unb = $t->get_unbound() ;
-eval {$unb->{toto} = 1} ; ok($@, qr/Can't set member/) ;
-eval {my $a = $unb->{toto}} ; ok($@, qr/Can't get member/) ;
-
-# Unexisting member
-eval {$t->{toto} = 1} ; ok($@, qr/No public member/) ;
-eval {my $a = $t->{toto}} ; ok($@, qr/No public member/) ;
-
-# Incompatible type
-eval {$t->{_long} = $obj1} ; ok($@, qr/Can't convert/) ;
+my $t = new types4() ;
+
+{
+	$t->{_byte} = 123 ;
+	ok($t->{_byte} == 123) ;
+	$t->{_Byte} = 123 ;
+	ok($t->{_Byte} == 123) ;
+	
+	$t->{_short} = 123 ;
+	ok($t->{_short} == 123) ;
+	$t->{_Short} = 123 ;
+	ok($t->{_Short} == 123) ;
+	
+	$t->{_int} = 123 ;
+	ok($t->{_int} == 123) ;
+	$t->{_Integer} = 123 ;
+	ok($t->{_Integer} == 123) ;
+	
+	$t->{_long} = 123 ;
+	ok($t->{_long} == 123) ;
+	$t->{_Long} = 123 ;
+	ok($t->{_Long} == 123) ;
+	
+	$t->{_float} = 123.456 ;
+	ok($t->{_float} == 123.456) ;
+	$t->{_Float} = 123.456 ;
+	ok($t->{_Float} == 123.456) ;
+	
+	$t->{_double} = 123.456 ;
+	ok($t->{_double} == 123.456) ;
+	$t->{_Double} = 123.456 ;
+	ok($t->{_Double} == 123.456) ;
+	
+	$t->{_boolean} = 1 ;
+	ok($t->{_boolean}) ;
+	$t->{_Boolean} = 1 ;
+	ok($t->{_Boolean}) ;
+	
+	$t->{_char} = "a" ;
+	ok($t->{_char}, "a") ;
+	$t->{_Character} = "a" ;
+	ok($t->{_Character}, "a") ;
+	
+	$t->{_String} = "string" ;
+	ok($t->{_String}, "string") ;
+	$t->{_StringBuffer} = "stringbuffer" ;
+	ok($t->{_StringBuffer}, "stringbuffer") ;
+	
+	my $obj1 = new obj14() ;
+	$t->{_Object} = $obj1 ;
+	ok($t->{_Object}->get_data(), "obj1") ;
+	$t->{_Object} = "object" ;
+	ok($t->{_Object}, "object") ;
+	
+	$t->{_Object} = undef ;
+	ok($t->{_Object}, undef) ;
+	$t->{_int} = undef ;
+	ok($t->{_int} == 0) ;
+	
+	# Receive an unbound object and try to call a member
+	my $unb = $t->get_unbound() ;
+	eval {$unb->{toto} = 1} ; ok($@, qr/Can't set member/) ;
+	eval {my $a = $unb->{toto}} ; ok($@, qr/Can't get member/) ;
+	
+	# Unexisting member
+	eval {$t->{toto} = 1} ; ok($@, qr/No public member/) ;
+	eval {my $a = $t->{toto}} ; ok($@, qr/No public member/) ;
+	
+	# Incompatible type
+	eval {$t->{_long} = $obj1} ; ok($@, qr/Can't convert/) ;
+}
+
+ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
 
 __END__
 
@@ -90,10 +94,10 @@ __Java__
 
 import java.util.* ;
 
-class obj1 {
+class obj14 {
 	String data = "obj1" ;
 
-	public obj1() {
+	public obj14() {
 	}
 
 	public String get_data(){
@@ -102,7 +106,7 @@ class obj1 {
 }
 
 
-class types {
+class types4 {
 	public byte _byte ;
 	public Byte _Byte ;
 	public short _short ;
@@ -123,7 +127,7 @@ class types {
 	public StringBuffer _StringBuffer ;
 	public Object _Object ;
 
-	public types(){
+	public types4(){
 	}
 
 	public ArrayList get_unbound(){
diff --git a/t/05_arrays.t b/t/05_arrays.t
index c505017..87c9103 100644
--- a/t/05_arrays.t
+++ b/t/05_arrays.t
@@ -9,104 +9,134 @@ use Inline(
 ) ;
 
 BEGIN {
-	plan(tests => 40) ;
+	plan(tests => 42) ;
 }
 
 
-my $t = new types() ;
-
-ok($t->_byte([12, 34, 56])->[0] == 123) ;
-ok($t->_Byte([12, 34, 56])->[1] == 34) ;
-ok($t->_short([12, 34, 56])->[0] == 123) ;
-ok($t->_Short([12, 34, 56])->[1] == 34) ;
-ok($t->_int([12, 34, 56])->[0] == 123) ;
-ok($t->_Integer([12, 34, 56])->[1] == 34) ;
-ok($t->_long([12, 34, 56])->[0] == 123) ;
-ok($t->_Long([12, 34, 56])->[1] == 34) ;
-ok($t->_float([12.34, 5.6, 7])->[0] == 123.456) ;
-ok($t->_Float([12.34, 5.6, 7])->[1] == 5.6) ;
-ok($t->_double([12.34, 5.6, 7])->[0] == 123.456) ;
-ok($t->_Double([12.34, 5.6, 7])->[1] == 5.6) ;
-ok($t->_boolean([1, 0, "tree"])->[0]) ;
-ok(! $t->_Boolean([1, 0])->[1]) ;
-ok($t->_char(['a', 'b', 'c'])->[0], "A") ;
-ok($t->_Character(['a', 'b', 'c'])->[1], 'b') ;
-ok($t->_String(["bla", "ble", "bli"])->[0], "STRING") ;
-ok($t->_StringBuffer(["bla", "ble", "bli"])->[0], "STRINGBUFFER") ;
-
-ok($t->_Object(undef), undef) ;
-my $a = $t->_Object([1, "two", $t]) ;
-ok($a->[0], "1") ;
-ok($a->[1], "two") ;
-ok(UNIVERSAL::isa($a->[2], "main::types")) ;
-ok($a->[2]->{data}->[1], "a") ;
-$a->[2]->{data} = ["1", "2"] ;
-ok($a->[2]->{data}->[1], 2) ;
-
-# Try some multidimensional arrays.
-$a = $t->_StringString([
-	["00", "01"],
-	["10", "11"]
-]) ;
-ok($a->[1]->[0], "10") ;
-
-# Try some incomplete multidimensional arrays.
-$a = $t->_StringString([
-	[undef, "01", "02"],
-	[undef, "11"],
-	undef,
-]) ;
-ok($a->[1]->[0], undef) ;
-
-
-my $b = $a->[1] ;
-ok($t->_String($b)->[0], "STRING") ;
-
-# Arrays of other arrays
-$a = $t->_StringString([
-	$a->[0],
-]) ;
-ok($a->[0]->[2], "02") ;
-
-# This is one of the things that won't work. 
-# Try passing an array as an Object.
-eval {$t->_o(["a", "b", "c"])} ; ok($@, qr/Can't create Java array/) ;
-ok($t->_o(Inline::Java::cast(
-	"java.lang.Object", 
-	["a", "b", "c"], 
-	"[Ljava.lang.String;"))->[0], "a") ;
-$t->{o} = Inline::Java::cast(
-	"java.lang.Object", 
-	["a", "b", "c"], 
-	"[Ljava.lang.String;") ;
-ok($t->{o}->[0], "a") ;
-$t->{o} = $t->{i} ;
-ok($t->{o}->[0], "1") ;
-
-# Mixed types
-eval {$t->_int(["3", "3456", "cat"])} ; ok($@, qr/Can't convert/) ;
-ok($t->_Object(["3", "3456", "cat"])->[2], 'cat') ; 
-
-# Badly constructed array
-eval {$t->_int(["3", [], "cat"])} ; ok($@, qr/Java array contains mixed types/) ;
-eval {$t->_StringString([["3"], "string"])} ; ok($@, qr/Java array contains mixed types/) ;
-
-# Invalid operations on arrays.
-eval {@{$b} = ()} ; ok($@, qr/Operation CLEAR/) ;
-eval {pop @{$b}} ; ok($@, qr/Operation POP/) ;
-eval {shift @{$b}} ; ok($@, qr/Operation SHIFT/) ;
-eval {splice(@{$b}, 0, 1)} ; ok($@, qr/Operation SPLICE/) ;
+my $t = new types5() ;
+
+{
+	ok($t->_byte([12, 34, 56])->[0] == 123) ;
+	ok(eq_array($t->_Byte([12, 34, 56]), [12, 34, 56])) ;
+	ok($t->_short([12, 34, 56])->[0] == 123) ;
+	ok(eq_array($t->_Short([12, 34, 56]), [12, 34, 56])) ;
+	ok($t->_int([12, 34, 56])->[0] == 123) ;
+	ok(eq_array($t->_Integer([12, 34, 56]), [12, 34, 56])) ;
+	ok($t->_long([12, 34, 56])->[0] == 123) ;
+	ok(eq_array($t->_Long([12, 34, 56]), [12, 34, 56])) ;
+	ok($t->_float([12.34, 5.6, 7])->[0] == 123.456) ;
+	ok(eq_array($t->_Float([12.34, 5.6, 7]), [12.34, 5.6, 7])) ;
+	ok($t->_double([12.34, 5.6, 7])->[0] == 123.456) ;
+	ok(eq_array($t->_Double([12.34, 5.6, 7]), [12.34, 5.6, 7])) ;
+	ok($t->_boolean([1, 0, "tree"])->[0]) ;
+	ok($t->_Boolean([1, 0])->[0]) ;
+	ok(! $t->_Boolean([1, 0])->[1]) ;
+	ok($t->_char(['a', 'b', 'c'])->[0], "A") ;
+	ok(eq_array($t->_Character(['a', 'b', 'c']), ['a', 'b', 'c'], 1)) ;
+	ok($t->_String(["bla", "ble", "bli"])->[0], "STRING") ;
+	ok($t->_StringBuffer(["bla", "ble", "bli"])->[0], "STRINGBUFFER") ;
+	
+	ok($t->_Object(undef), undef) ;
+	my $a = $t->_Object([1, "two", $t]) ;
+	ok($a->[0], "1") ;
+	ok($a->[1], "two") ;
+	ok(UNIVERSAL::isa($a->[2], "main::types5")) ;
+	ok($a->[2]->{data}->[1], "a") ;
+	$a->[2]->{data} = ["1", "2"] ;
+	ok($a->[2]->{data}->[1], 2) ;
+	
+	# Try some multidimensional arrays.
+	$a = $t->_StringString([
+		["00", "01"],
+		["10", "11"]
+	]) ;
+	ok($a->[1]->[0], "10") ;
+	
+	# Try some incomplete multidimensional arrays.
+	$a = $t->_StringString([
+		[undef, "01", "02"],
+		[undef, "11"],
+		undef,
+	]) ;
+	ok($a->[1]->[0], undef) ;
+	
+	
+	my $b = $a->[1] ;
+	ok($t->_String($b)->[0], "STRING") ;
+	
+	# Arrays of other arrays
+	$a = $t->_StringString([
+		$a->[0],
+	]) ;
+	ok($a->[0]->[2], "02") ;
+	
+	# This is one of the things that won't work. 
+	# Try passing an array as an Object.
+	eval {$t->_o(["a", "b", "c"])} ; ok($@, qr/Can't create Java array/) ;
+	ok($t->_o(Inline::Java::cast(
+		"java.lang.Object", 
+		["a", "b", "c"], 
+		"[Ljava.lang.String;"))->[0], "a") ;
+	$t->{o} = Inline::Java::cast(
+		"java.lang.Object", 
+		["a", "b", "c"], 
+		"[Ljava.lang.String;") ;
+	ok($t->{o}->[0], "a") ;
+	$t->{o} = $t->{i} ;
+	ok($t->{o}->[0], "1") ;
+	
+	# Mixed types
+	eval {$t->_int(["3", "3456", "cat"])} ; ok($@, qr/Can't convert/) ;
+	ok($t->_Object(["3", "3456", "cat"])->[2], 'cat') ; 
+	
+	# Badly constructed array
+	eval {$t->_int(["3", [], "cat"])} ; ok($@, qr/Java array contains mixed types/) ;
+	eval {$t->_StringString([["3"], "string"])} ; ok($@, qr/Java array contains mixed types/) ;
+	
+	# Invalid operations on arrays.
+	eval {@{$b} = ()} ; ok($@, qr/Operation CLEAR/) ;
+	eval {pop @{$b}} ; ok($@, qr/Operation POP/) ;
+	eval {shift @{$b}} ; ok($@, qr/Operation SHIFT/) ;
+	eval {splice(@{$b}, 0, 1)} ; ok($@, qr/Operation SPLICE/) ;
+}
+
+ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
+
+
+sub eq_array {
+	my $a1 = shift ;
+	my $a2 = shift ;
+	my $eq = shift || 0 ;
+
+	if (scalar(@{$a1}) != scalar(@{$a2})){
+		return 0 ;
+	}
+
+	my $ok = 1 ;
+	for (0..$#{$a1}){
+		if ($eq){
+			$ok = ($a1->[$_] eq $a2->[$_]) ;
+		}
+		else{
+			$ok = ($a1->[$_] == $a2->[$_]) ;
+		}
+		last unless $ok ;
+	}
+	
+	return $ok ;
+}
+
 
 __END__
 
 __Java__
 
 
-class types {
+class types5 {
 	public Object o ;
 	public int i[] = {1, 2, 3} ;
 	public String data[] = {"d", "a", "t", "a"} ;
-	public types(){
+	public types5(){
 	}
 
 	public byte[] _byte(byte b[]){
diff --git a/t/06_static.t b/t/06_static.t
index 9ffda02..2ce7d11 100644
--- a/t/06_static.t
+++ b/t/06_static.t
@@ -10,29 +10,43 @@ use Inline(
 
 
 BEGIN {
-	plan(tests => 7) ;
+	plan(tests => 10) ;
 }
 
 
 # Methods
-ok(types->get("key"), undef) ;
-my $t = new types("key", "value") ;
-ok($t->get("key"), "value") ;
-
-# Members
-ok($types::i == 5) ;
-$types::i = 7 ;
-ok($t->{i} == 7) ;
-
-my $t2 = new types("key2", "value2") ;
-my $hm = $types::hm ;
-ok(types->get($hm, "key2"), "value2") ;
-
-$types::hm = $hm ;
-ok($t2->get("key2"), "value2") ;
+ok(types6->get("key"), undef) ;
+my $t = new types6("key", "value") ;
+
+{
+	ok($t->get("key"), "value") ;
+	
+	# Members
+	ok($types6::i == 5) ;
+	$types6::i = 7 ;
+	ok($t->{i} == 7) ;
+	
+	my $t2 = new types6("key2", "value2") ;
+	my $hm = $types6::hm ;
+	$types6::hm = undef ;
+	ok(types6->get($hm, "key2"), "value2") ;
+	
+	$types6::hm = $hm ;
+	ok($t2->get("key2"), "value2") ;
+	
+	# Calling an instance method without an object reference
+	eval {types6->set()} ; ok($@, qr/must be called from an object reference/) ;
+
+	# Put in back like before...
+	$types6::i = 5 ;
+	ok($types6::i == 5) ;
+	my $tt = new types6("key", undef) ;
+	ok($tt->get("key"), undef) ;
+}
 
-# Calling an instance method without an object reference
-eval {types->set()} ; ok($@, qr/must be called from an object reference/) ;
+# Since $types::hm was returned to the Perl space, it was registered in the object 
+# HashMap.
+ok($t->__get_private()->{proto}->ObjectCount(), 2) ;
 
 
 __END__
@@ -43,11 +57,11 @@ __Java__
 import java.util.* ;
 
 
-class types {
+class types6 {
 	public static int i = 5 ;
 	public static HashMap hm = new HashMap() ;
 
-	public types(String k, String v){
+	public types6(String k, String v){
 		hm.put(k, v) ;
 	}
 
diff --git a/t/07_polymorph.t b/t/07_polymorph.t
index 0911270..00c2d6d 100644
--- a/t/07_polymorph.t
+++ b/t/07_polymorph.t
@@ -12,35 +12,40 @@ use Inline::Java qw(cast) ;
 
 
 BEGIN {
-	plan(tests => 16) ;
+	plan(tests => 17) ;
 }
 
 
-my $t = new types() ;
-my $t1 = new t1() ;
-
-ok($t->func(5), "int") ;
-ok($t->func(cast("char", 5)), "char") ;
-ok($t->func(55), "int") ;
-ok($t->func("str"), "string") ;
-ok($t->func(cast("java.lang.StringBuffer", "str")), "stringbuffer") ;
-
-ok($t->f($t->{hm}), "hashmap") ;
-ok($t->f(cast("java.lang.Object", $t->{hm})), "object") ;
-
-ok($t->f(["a", "b", "c"]), "string[]") ;
-
-ok($t->f(["12.34", "45.67"]), "double[]") ;
-ok($t->f(cast("java.lang.Object", ['a'], "[Ljava.lang.String;")), "object") ;
-
-eval {$t->func($t1)} ; ok($@, qr/Can't find any signature/) ;
-eval {$t->func(cast("int", $t1))} ; ok($@, qr/Can't convert (.*) to primitive int/) ;
+my $t = new types7() ;
+
+{
+	my $t1 = new t17() ;
+	
+	ok($t->func(5), "int") ;
+	ok($t->func(cast("char", 5)), "char") ;
+	ok($t->func(55), "int") ;
+	ok($t->func("str"), "string") ;
+	ok($t->func(cast("java.lang.StringBuffer", "str")), "stringbuffer") ;
+	
+	ok($t->f($t->{hm}), "hashmap") ;
+	ok($t->f(cast("java.lang.Object", $t->{hm})), "object") ;
+	
+	ok($t->f(["a", "b", "c"]), "string[]") ;
+	
+	ok($t->f(["12.34", "45.67"]), "double[]") ;
+	ok($t->f(cast("java.lang.Object", ['a'], "[Ljava.lang.String;")), "object") ;
+	
+	eval {$t->func($t1)} ; ok($@, qr/Can't find any signature/) ;
+	eval {$t->func(cast("int", $t1))} ; ok($@, qr/Can't convert (.*) to primitive int/) ;
+	
+	my $t2 = new t27() ;
+	ok($t2->f($t2), "t1") ;
+	ok($t1->f($t2), "t1") ;
+	ok($t2->f($t1), "t2") ;
+	ok($t2->f(cast("t17", $t2)), "t2") ;
+}
 
-my $t2 = new t2() ;
-ok($t2->f($t2), "t1") ;
-ok($t1->f($t2), "t1") ;
-ok($t2->f($t1), "t2") ;
-ok($t2->f(cast("t1", $t2)), "t2") ;
+ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
 
 
 __END__
@@ -50,30 +55,30 @@ __Java__
 
 import java.util.* ;
 
-class t1 {
-	public t1(){
+class t17 {
+	public t17(){
 	}
 
-	public String f(t2 o){
+	public String f(t27 o){
 		return "t1" ;
 	}
 }
 
 
-class t2 extends t1 {
-	public t2(){
+class t27 extends t17 {
+	public t27(){
 	}
 
-	public String f(t1 o){
+	public String f(t17 o){
 		return "t2" ;
 	}
 }
 
 
-class types {
+class types7 {
 	public HashMap hm = new HashMap() ;
 
-	public types(){
+	public types7(){
 	}
 
 	public String func(String o){
diff --git a/t/08_study.t b/t/08_study.t
index 6f7b6a0..e4365aa 100644
--- a/t/08_study.t
+++ b/t/08_study.t
@@ -17,28 +17,32 @@ use Inline::Java qw(study_classes) ;
 
 
 BEGIN {
-	plan(tests => 8) ;
+	plan(tests => 9) ;
 }
 
-
 study_classes([
 	't.types', 
 	't.no_const'
 ]) ;
 
 my $t = new study::t::types() ;
-ok($t->func(), "study") ;
-ok($t->hm()->get("key"), "value") ;
 
-my $nc = new study::t::no_const() ;
-ok($nc->{i}, 5) ;
+{
+	ok($t->func(), "study") ;
+	ok($t->hm()->get("key"), "value") ;
+	
+	my $nc = new study::t::no_const() ;
+	ok($nc->{i}, 5) ;
+	
+	my $a = new study::a8() ;
+	ok($a->{i}, 50) ;
+	ok($a->truth()) ;
+	ok($a->sa()->[1], 'titi') ;
+	ok($a->sb()->[0]->get('toto'), 'titi') ;
+	ok($a->sb()->[1]->get('error'), undef) ;
+}
 
-my $a = new study::a() ;
-ok($a->{i}, 50) ;
-ok($a->truth()) ;
-ok($a->sa()->[1], 'titi') ;
-ok($a->sb()->[0]->get('toto'), 'titi') ;
-ok($a->sb()->[1]->get('error'), undef) ;
+ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
 
 
 __DATA__
@@ -47,10 +51,10 @@ __Java__
 
 import java.util.* ;
 
-class a {
+class a8 {
 	public int i = 50 ;
 	
-	public a(){
+	public a8(){
 	}
 
 	public boolean truth(){

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libinline-java-perl.git



More information about the Pkg-perl-cvs-commits mailing list