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 99d03582a61b00c583e1a69b62b6c615a58bd90d
Author: Patrick LeBoutillier <p...@cpan.org>
Date:   Wed Dec 12 16:11:20 2001 +0000

    Initial revision
---
 t/13_callbacks.t | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 131 insertions(+)

diff --git a/t/13_callbacks.t b/t/13_callbacks.t
new file mode 100644
index 0000000..04c70d8
--- /dev/null
+++ b/t/13_callbacks.t
@@ -0,0 +1,131 @@
+use strict ;
+use Test ;
+
+use Inline Config => 
+           DIRECTORY => './_Inline_test';
+
+use Inline (
+       Java => 'DATA',
+       PORT => 7891,
+       STARTUP_DELAY => 20,    
+) ;
+
+use Inline::Java qw(caught) ;
+
+
+BEGIN {
+       print STDERR "\nWARNING: Callbacks are still experimental and are 
possibly unstable!\n" ;
+       print STDERR "WARNING: Callback API can still change and might not be 
backwards compatible!\n" ;
+
+       plan(tests => 9) ;
+}
+
+my $t = new t10() ;
+
+{
+       eval {
+               ok($t->add(5, 6), 11) ;
+               ok($t->add_via_perl(5, 6), 11) ;
+               ok($t->mul(5, 6), 30) ;
+               ok($t->mul_via_perl(5, 6), 30) ;
+               ok($t->silly_mul(3, 2), 6) ;
+               ok($t->silly_mul_via_perl(3, 2), 6) ;
+
+               ok(add_via_java(3, 4), 7) ;
+               ok($t->add_via_perl_via_java(3, 4), 7) ;
+       } ;
+       if ($@){
+               if (caught("java.lang.Throwable")){
+                       $@->printStackTrace() ;
+                       die("Caught Java Exception") ;
+               }
+               else{
+                       die $@ ;
+               }
+       }
+}
+
+ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
+
+
+sub add {
+       my $i = shift ;
+       my $j = shift ;
+
+       return $i + $j ;
+}
+
+
+sub mul {
+       my $i = shift ;
+       my $j = shift ;
+
+       return $i * $j ;
+}
+
+
+sub add_via_java {
+       my $i = shift ;
+       my $j = shift ;
+
+       return $t->add($i, $j) ;
+}
+
+__END__
+
+__Java__
+
+
+import java.io.* ;
+
+class t10 extends InlineJavaPerlCaller {
+       public t10() {
+       }
+
+       public int add(int a, int b){
+               return a + b ;
+       }
+
+       public int mul(int a, int b){
+               return a * b ;
+       }
+
+       public int silly_mul(int a, int b){
+               int ret = 0 ;
+               for (int i = 0 ; i < b ; i++){
+                       ret = add(ret, a) ;
+               }
+               return a * b ;
+       }
+
+       public int silly_mul_via_perl(int a, int b) throws 
InlineJavaPerlCallerException {
+               int ret = 0 ;
+               for (int i = 0 ; i < b ; i++){
+                       ret = add_via_perl(ret, a) ;
+               }
+               return a * b ;
+       }
+
+
+       public int add_via_perl(int a, int b) throws 
InlineJavaPerlCallerException {
+               String val = (String)CallPerl("main", "add", 
+                       new Object [] {new Integer(a), new Integer(b)}) ;
+
+               return new Integer(val).intValue() ;
+       }
+
+       public int mul_via_perl(int a, int b) throws 
InlineJavaPerlCallerException {
+               String val = (String)CallPerl("main", "mul", 
+                       new Object [] {new Integer(a), new Integer(b)}) ;
+
+               return new Integer(val).intValue() ;
+       }
+
+       public int add_via_perl_via_java(int a, int b) throws 
InlineJavaPerlCallerException {
+               String val = (String)CallPerl("main", "add_via_java", 
+                       new Object [] {new Integer(a), new Integer(b)}) ;
+
+               return new Integer(val).intValue() ;
+       }
+}
+

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

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to