Mercurial > hg > octave-nkf
diff scripts/general/fieldnames.m @ 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 | fcd87f68af4f |
children | 0e1f5a750d00 |
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"))); +