annotate scripts/miscellaneous/methods.m @ 32055:dfd2b1a268a0

Don't list non-public or hidden functions from methods() (bug #64066) * ov-classdef.cc (Fproperties): Use property name from property_map variable , which is already known, rather than calling get_name() method which causes cascade of multiple methods to be invoked. * ov-classdef.cc (F__methods__): Change function signature to return a flag "found" if input was a classdef class or instance. Add code to check "Access" and "Hidden" properties before including in list of methods. Add BIST test for __methods__. * methods.m: Use second output from __methods__ to determine whether __methods__ call was successful.
author Rik <rik@octave.org>
date Tue, 25 Apr 2023 18:09:29 -0700
parents 597f3ee61a48
children d98157d51a97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
3 ## Copyright (C) 2012-2023 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26974
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
7 ##
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
8 ## This file is part of Octave.
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24491
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24491
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
13 ## (at your option) any later version.
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
14 ##
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
18 ## GNU General Public License for more details.
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
19 ##
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24491
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
25
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20539
diff changeset
27 ## @deftypefn {} {} methods (@var{obj})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20539
diff changeset
28 ## @deftypefnx {} {} methods ("@var{classname}")
26767
ebf5ef76f56e methods.m: Add documentation for "-full" option.
Rik <rik@octave.org>
parents: 26766
diff changeset
29 ## @deftypefnx {} {} methods (@dots{}, "-full")
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20539
diff changeset
30 ## @deftypefnx {} {@var{mtds} =} methods (@dots{})
22167
6c94c7bd55e7 doc: Reword methods doc string for clarity
Mike Miller <mtmiller@octave.org>
parents: 21634
diff changeset
31 ## List the names of the public methods for the object @var{obj} or the
6c94c7bd55e7 doc: Reword methods doc string for clarity
Mike Miller <mtmiller@octave.org>
parents: 21634
diff changeset
32 ## named class @var{classname}.
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
33 ##
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
34 ## @var{obj} may be an Octave class object or a Java object.
22167
6c94c7bd55e7 doc: Reword methods doc string for clarity
Mike Miller <mtmiller@octave.org>
parents: 21634
diff changeset
35 ## @var{classname} may be the name of an Octave class or a Java class.
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
36 ##
26767
ebf5ef76f56e methods.m: Add documentation for "-full" option.
Rik <rik@octave.org>
parents: 26766
diff changeset
37 ## If the optional argument @qcode{"-full"} is given then Octave returns
ebf5ef76f56e methods.m: Add documentation for "-full" option.
Rik <rik@octave.org>
parents: 26766
diff changeset
38 ## full method signatures which include output type, name of method,
ebf5ef76f56e methods.m: Add documentation for "-full" option.
Rik <rik@octave.org>
parents: 26766
diff changeset
39 ## and the number and type of inputs.
ebf5ef76f56e methods.m: Add documentation for "-full" option.
Rik <rik@octave.org>
parents: 26766
diff changeset
40 ##
22167
6c94c7bd55e7 doc: Reword methods doc string for clarity
Mike Miller <mtmiller@octave.org>
parents: 21634
diff changeset
41 ## When called with no output arguments, @code{methods} prints the list of
6c94c7bd55e7 doc: Reword methods doc string for clarity
Mike Miller <mtmiller@octave.org>
parents: 21634
diff changeset
42 ## method names to the screen. Otherwise, the output argument @var{mtds}
6c94c7bd55e7 doc: Reword methods doc string for clarity
Mike Miller <mtmiller@octave.org>
parents: 21634
diff changeset
43 ## contains the list in a cell array of strings.
26767
ebf5ef76f56e methods.m: Add documentation for "-full" option.
Rik <rik@octave.org>
parents: 26766
diff changeset
44 ## @seealso{ismethod, properties, fieldnames}
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
45 ## @end deftypefn
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
46
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
47 function mtds = methods (obj, fullopt)
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
48
28789
28de41192f3c Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents: 27923
diff changeset
49 if (nargin < 1)
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
50 print_usage ();
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
51 endif
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
52
26761
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
53 havesigs = false;
26974
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
54 showsigs = false;
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
55 if (nargin == 2)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
56 if (! strcmp (fullopt, "-full"))
26974
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
57 error ("methods: invalid option");
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
58 endif
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
59 showsigs = true;
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
60 endif
26761
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
61
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
62 if (isobject (obj))
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
63 ## Call internal C++ function for Octave objects
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
64 mtds_list = __methods__ (obj);
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
65 elseif (ischar (obj))
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
66 ## Could be a classname for an Octave class or Java class.
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
67 ## Try Octave class first.
32055
dfd2b1a268a0 Don't list non-public or hidden functions from methods() (bug #64066)
Rik <rik@octave.org>
parents: 31706
diff changeset
68 [mtds_list, valid] = __methods__ (obj);
dfd2b1a268a0 Don't list non-public or hidden functions from methods() (bug #64066)
Rik <rik@octave.org>
parents: 31706
diff changeset
69 if (! valid)
15790
921912c92102 Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents: 15785
diff changeset
70 mtds_str = javaMethod ("getMethods", "org.octave.ClassHelper", obj);
16724
b7667fcb9fbc Substitute ostrsplit() for strsplit().
Ben Abbott <bpabbott@mac.com>
parents: 16403
diff changeset
71 mtds_list = ostrsplit (mtds_str, ';');
26768
3cbc3c741f81 methods.m: Return a column vector for Matlab compatibility.
Rik <rik@octave.org>
parents: 26767
diff changeset
72 mtds_list = mtds_list(:); # return a column vector for compatibility
26761
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
73 havesigs = true;
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
74 endif
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
75 elseif (isjava (obj))
26957
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
76 ## If obj is a String or a subclass of String, then get the methods of its
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
77 ## class name, not the methods of the class that may be named by the
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
78 ## content of the string.
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
79 if (isa (obj, "java.lang.String"))
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
80 klass = class (obj);
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
81 mtds_str = javaMethod ("getMethods", "org.octave.ClassHelper", klass);
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
82 else
20539
5d31cd795c21 methods.m: try Java class names if getMethods fails on Java objects (bug #46010)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 20158
diff changeset
83 mtds_str = javaMethod ("getMethods", "org.octave.ClassHelper", obj);
26957
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
84 endif
16724
b7667fcb9fbc Substitute ostrsplit() for strsplit().
Ben Abbott <bpabbott@mac.com>
parents: 16403
diff changeset
85 mtds_list = strsplit (mtds_str, ';');
26768
3cbc3c741f81 methods.m: Return a column vector for Matlab compatibility.
Rik <rik@octave.org>
parents: 26767
diff changeset
86 mtds_list = mtds_list(:); # return a column vector for compatibility
26761
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
87 havesigs = true;
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
88 else
26761
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
89 error ("methods: invalid input argument");
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
90 endif
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
91
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
92 if (havesigs && ! showsigs)
26956
7f86c097f29e methods.m: fix Java constructor post-processing with no package (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26953
diff changeset
93 ## Extract only the method name for ordinary class methods, delete the
7f86c097f29e methods.m: fix Java constructor post-processing with no package (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26953
diff changeset
94 ## return type and the argument list.
26766
c1d5a0a799b2 methods.m: Fix bug when function signature has spaces.
Rik <rik@octave.org>
parents: 26761
diff changeset
95 mtds_list = regexprep (mtds_list, '^(?:[^(]+) (\w+) ?\(.*$', '$1');
26956
7f86c097f29e methods.m: fix Java constructor post-processing with no package (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26953
diff changeset
96
7f86c097f29e methods.m: fix Java constructor post-processing with no package (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26953
diff changeset
97 ## Extract only the class name for class constructors, delete the optional
7f86c097f29e methods.m: fix Java constructor post-processing with no package (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26953
diff changeset
98 ## "org.example." package prefix and the argument list.
7f86c097f29e methods.m: fix Java constructor post-processing with no package (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26953
diff changeset
99 mtds_list = regexprep (mtds_list, '^(?:[\.\w]+\.)?(\w+) ?\(.*$', '$1');
7f86c097f29e methods.m: fix Java constructor post-processing with no package (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26953
diff changeset
100
26761
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
101 mtds_list = unique (mtds_list);
26953
6e01e5be8de3 methods.m: adapt method list post-processing to Java constructors (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26768
diff changeset
102 else
26956
7f86c097f29e methods.m: fix Java constructor post-processing with no package (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26953
diff changeset
103 ## Delete the "org.example." package prefix if present.
26953
6e01e5be8de3 methods.m: adapt method list post-processing to Java constructors (bug #55858)
Mike Miller <mtmiller@octave.org>
parents: 26768
diff changeset
104 mtds_list = regexprep (mtds_list, '^(?:[\.\w]+\.)(\w+ ?\(.*)$', '$1');
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
105 endif
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
106
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
107 if (nargout == 0)
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
108 classname = ifelse (ischar (obj), obj, class (obj));
21634
96518f623c91 Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents: 21633
diff changeset
109 printf ("Methods for class %s:\n", classname);
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
110 disp (list_in_columns (mtds_list));
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
111 else
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
112 mtds = mtds_list;
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
113 endif
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
114
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
115 endfunction
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
116
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
117
26974
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
118 ## test old-style @classname
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
119 %!test
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
120 %! mtds = methods ("ftp");
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
121 %! assert (mtds{1}, "ascii");
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
122
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
123 ## test Java classname
23405
32ec90068be5 use %!testif runtime tests to properly skip java tests
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
124 %!testif HAVE_JAVA; usejava ("jvm")
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
125 %! mtds = methods ("java.lang.Double");
26761
8554becefe1b handle -full argument for methods function (bug #55487)
John W. Eaton <jwe@octave.org>
parents: 26724
diff changeset
126 %! search = strfind (mtds, "valueOf");
15785
42cff4396de4 Add methods.m which extends methods() to work on Java objects.
Rik <rik@octave.org>
parents:
diff changeset
127 %! assert (! isempty ([search{:}]));
26724
84355b7b9521 allow methods function to work for classdef objects (bug #42510)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
128
26974
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
129 ## test Java classname with -full prototypes
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
130 %!testif HAVE_JAVA; usejava ("jvm")
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
131 %! mtds = methods ("java.lang.Double", "-full");
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
132 %! search = strfind (mtds, "java.lang.Double valueOf");
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
133 %! assert (! isempty ([search{:}]));
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
134
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
135 ## test that methods does the right thing when passed a String object
26957
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
136 %!testif HAVE_JAVA; usejava ("jvm") <*48758>
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
137 %! object = javaObject ("java.lang.String", "java.lang.Integer");
26974
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
138 %! assert (methods (object), methods ("java.lang.String"));
26957
0ffbc690b493 methods.m: always return String methods when passed a String (bug #48758)
Mike Miller <mtmiller@octave.org>
parents: 26956
diff changeset
139
26974
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
140 ## test classdef classname
26724
84355b7b9521 allow methods function to work for classdef objects (bug #42510)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
141 %!assert (methods ("inputParser"),
84355b7b9521 allow methods function to work for classdef objects (bug #42510)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
142 %! {"addOptional"; "addParamValue"; "addParameter";
84355b7b9521 allow methods function to work for classdef objects (bug #42510)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
143 %! "addRequired"; "addSwitch"; "add_missing"; "delete";
84355b7b9521 allow methods function to work for classdef objects (bug #42510)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
144 %! "disp"; "error"; "is_argname"; "parse"; "validate_arg";
84355b7b9521 allow methods function to work for classdef objects (bug #42510)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
145 %! "validate_name"});
26974
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
146
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
147 ## Test input validation
28886
d8318c12d903 test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents: 28789
diff changeset
148 %!error <Invalid call> methods ()
26974
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
149 %!error methods ("a", "b", "c")
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
150 %!error <invalid option> methods ("ftp", "option1")
aa50801747a9 methods.m: Add input validation and BIST tests for option argument (bug #55858).
Rik <rik@octave.org>
parents: 26957
diff changeset
151 %!error <invalid input argument> methods (1)