diff libinterp/octave-value/ov-class.cc @ 20063:107130a0490c

isa: check parent class of java objects (bug #42702) * libinterp/octave-value/ov-java.h, libinterp/octave-value/ov-java.cc (octave_java::is_instance_of): implement method since the one in the parent octave_class is not able to handle java. * libinterp/octave-value/ov-class.cc: add tests.
author Carnë Draug <carandraug@octave.org>
date Mon, 06 Apr 2015 04:55:56 +0100
parents 17d647821d61
children 075a5e2e1ba5
line wrap: on
line diff
--- a/libinterp/octave-value/ov-class.cc	Sun Apr 05 02:00:59 2015 -0300
+++ b/libinterp/octave-value/ov-class.cc	Mon Apr 06 04:55:56 2015 +0100
@@ -2052,6 +2052,15 @@
 %!assert (isa ({1, 2}, "cell"))
 %!assert (isa ({1, 2}, {"numeric", "integer", "cell"}), [false false true])
 
+%!testif HAVE_JAVA
+%! ## The first and last assert() are equal on purpose.  The assert() in
+%! ## the middle with an invalid class name will cause the java code to
+%! ## throw exceptions which we then must clear properly (or all other calls
+%! ## will fail).  So we test this too.
+%! assert (isa (javaObject ("java.lang.Double", 10), "java.lang.Number"))
+%! assert (isa (javaObject ("java.lang.Double", 10), "not_a_class"), false)
+%! assert (isa (javaObject ("java.lang.Double", 10), "java.lang.Number"))
+
 %!test
 %! a.b = 1;
 %! assert (isa (a, "struct"));