Mercurial > hg > octave-nkf
changeset 19092:e6872e945553
fieldnames: return only field names of java objects instead of description.
* java/org/octave/ClassHelper.java (getFields): the method
java.lang.reflect.Field.toString() returns a string description of each field,
e.g., 'public static final double java.lang.Double.MAX_VALUE', instead of just
the name 'MAX_VALUE'. Fixed by using the correct method getName().
* general/fieldnames.m: adapt the tests to check for the name and extend for
when passing a java object instead of just the class name.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Tue, 08 Jul 2014 19:55:03 +0100 |
parents | df972b9d080a |
children | 93805f9256a9 |
files | scripts/general/fieldnames.m scripts/java/org/octave/ClassHelper.java |
diffstat | 2 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/fieldnames.m +++ b/scripts/general/fieldnames.m @@ -70,9 +70,13 @@ %! s = struct (); %! assert (fieldnames (s), cell (0, 1)); -## test Java classname -%!testif HAVE_JAVA +## test Java classname by passing classname +%!testif HAVE_JAVA %! names = fieldnames ("java.lang.Double"); -%! search = strfind (names, "java.lang.Double.MAX_VALUE"); -%! assert (! isempty ([search{:}])); +%! assert (any (strcmp (names, "MAX_VALUE"))); +## test Java classname by passing java object +%!testif HAVE_JAVA +%! names = fieldnames (javaObject ("java.lang.Double", 10)); +%! assert (any (strcmp (names, "MAX_VALUE"))); +