[libinline-java-perl] 118/398: Initial revision
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 9004f4b0579457e0634f29794b81375c74b93763
Author: Patrick LeBoutillier <patl at cpan.org>
Date: Fri Dec 7 14:44:19 2001 +0000
Initial revision
---
t/12_exceptions.t | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 155 insertions(+)
diff --git a/t/12_exceptions.t b/t/12_exceptions.t
new file mode 100644
index 0000000..f5d4bd8
--- /dev/null
+++ b/t/12_exceptions.t
@@ -0,0 +1,155 @@
+use strict ;
+use Test ;
+
+use Inline Config =>
+ DIRECTORY => './_Inline_test';
+
+use Inline(
+ Java => 'DATA',
+) ;
+
+use Inline::Java qw(caught) ;
+
+
+BEGIN {
+ plan(tests => 8) ;
+}
+
+
+my $t = new t9(0) ;
+
+{
+ my $msg = '' ;
+ eval {
+ $t->f() ;
+ } ;
+ if ($@){
+ if (Inline::Java::caught("java.io.IOException")){
+ $msg = $@->getMessage() . "io" ;
+ }
+ elsif (Inline::Java::caught("java.lang.Exception")){
+ $msg = $@->getMessage() ;
+ }
+ else {
+ die $@ ;
+ }
+ } ;
+ ok($msg, "from fio") ;
+
+ $msg = '' ;
+ eval {
+ $t->f() ;
+ } ;
+ if ($@){
+ if (caught("java.lang.Throwable")){
+ $msg = $@->getMessage() ;
+ }
+ elsif (caught("java.io.IOException")){
+ $msg = $@->getMessage() . "io" ;
+ }
+ else {
+ die $@ ;
+ }
+ }
+ ok($msg, "from f") ;
+
+
+ $msg = '' ;
+ eval {
+ die("not e\n") ;
+ } ;
+ if ($@){
+ if (caught("java.lang.Exception")){
+ $msg = $@->getMessage() ;
+ }
+ else {
+ $msg = $@ ;
+ }
+ }
+ ok($msg, "not e\n") ;
+
+
+ my $e = $t->f2() ;
+ ok($e->getMessage(), "from f2") ;
+
+
+ $msg = '' ;
+ eval {
+ my $t2 = new t9(1) ;
+ } ;
+ if ($@){
+ if (caught("java.lang.Exception")){
+ $msg = $@->getMessage() ;
+ }
+ else{
+ die $@ ;
+ }
+ }
+ ok($msg, "from const") ;
+
+ # Undeclared exception, java.lang.NullPointerException
+ $msg = '' ;
+ eval {
+ my $t2 = new t9(0) ;
+ $t2->len(undef) ;
+ } ;
+ if ($@){
+ if (caught("java.lang.NullPointerException")){
+ $msg = "null" ;
+ }
+ else {
+ die $@ ;
+ }
+ }
+ ok($msg, "null") ;
+
+ # Undeclared exception, java.lang.NullPointerException
+ $msg = '' ;
+ eval {
+ my $t2 = new t9(0) ;
+ $t2->len(undef) ;
+ } ;
+ if ($@){
+ if (caught("java.lang.Exception")){
+ $msg = "null" ;
+ }
+ else{
+ die $@ ;
+ }
+ }
+ ok($msg, "null") ;
+
+ # Make sure the last exception is not lying around...
+ $@ = undef ;
+}
+
+ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
+
+
+__END__
+
+__Java__
+
+
+import java.io.* ;
+
+class t9 {
+ public t9(boolean t) throws Exception {
+ if (t){
+ throw new Exception("from const") ;
+ }
+ }
+
+ public String f() throws IOException {
+ throw new IOException("from f") ;
+ }
+
+ public IOException f2() {
+ return new IOException("from f2") ;
+ }
+
+ public int len(String s) {
+ return s.length() ;
+ }
+}
+
--
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