Mercurial > octave
annotate scripts/java/javachk.m @ 33658:b1d6e40ac737 stable tip
NEWS.9.md: Fix typo and minor formatting changes.
* etc/NEWS.9.md: Fix typo. Adjust whitespace. Use markdown syntax for code
snippets.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Wed, 05 Jun 2024 11:27:35 +0200 |
parents | 2e484f9f1f18 |
children |
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 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 ## Copyright (C) 2014-2024 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27484
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/>. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
7 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23405
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
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:
23405
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. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
14 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
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. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
19 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
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:
23405
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 ######################################################################## |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
25 |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
27 ## @deftypefn {} {@var{msg} =} javachk (@var{feature}) |
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
28 ## @deftypefnx {} {@var{msg} =} javachk (@var{feature}, @var{caller}) |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
29 ## Check for the presence of the Java @var{feature} in the current session. |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
30 ## Return an error structure if @var{feature} is not available, not enabled, |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
31 ## or not recognized. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
32 ## |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
33 ## Possible recognized features are: |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
34 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
35 ## @table @asis |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
36 ## @item @nospell{@qcode{"awt"}} |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
37 ## Abstract Window Toolkit for GUIs. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
38 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
39 ## @item @qcode{"desktop"} |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
40 ## Interactive desktop is running. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
41 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
42 ## @item @qcode{"jvm"} |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
43 ## Java Virtual Machine. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
44 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
45 ## @item @qcode{"swing"} |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
46 ## Swing components for lightweight GUIs. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
47 ## @end table |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
48 ## |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
49 ## If @var{feature} is not supported, a scalar struct with field |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
50 ## @qcode{"message"} and @qcode{"identifier"} is returned. The field |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
51 ## @qcode{"message"} contains an error message mentioning @var{feature} as |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
52 ## well as the optional user-specified @var{caller}. This structure is |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
53 ## suitable for passing in to the @code{error} function. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
54 ## |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
55 ## If @var{feature} is supported and available, an empty struct array is |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
56 ## returned with fields @qcode{"message"} and @qcode{"identifier"}. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
57 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
58 ## @code{javachk} determines if specific Java features are available in an |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
59 ## Octave session. This function is provided for scripts which may alter |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
60 ## their behavior based on the availability of Java or specific Java runtime |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
61 ## features. |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
62 ## |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
63 ## Compatibility Note: The feature @qcode{"desktop"} is never available since |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
64 ## Octave has no Java-based desktop. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
65 ## |
20160
03b9d17a2d95
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
66 ## @seealso{usejava, error} |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
67 ## @end deftypefn |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
68 |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
69 function msg = javachk (feature, caller = "") |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
70 |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
71 if (nargin < 1) |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
72 print_usage (); |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
73 elseif (! ischar (feature)) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
74 error ("javachk: FEATURE must be a string"); |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
75 elseif (! ischar (caller)) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
76 error ("javachk: CALLER must be a string"); |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
77 endif |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
78 |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
79 if (isempty (caller)) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
80 caller = "this function"; |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
81 endif |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
82 |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
83 msg = struct ("message", "", "identifier", ""); |
27436
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
84 |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
85 ## Check that Octave was compiled with Java support |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
86 chk = logical (__octave_config_info__ ("build_features").JAVA); |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
87 if (! chk) |
27436
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
88 msg.message = sprintf (["javachk: %s is not supported, " ... |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
89 "Octave was not compiled with Java support"], |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
90 caller); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
91 msg.identifier = "Octave:javachk:java-not-supported"; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
92 endif |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
93 |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
94 if (chk) |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
95 chk = false; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
96 ## For each feature, try methods() on a Java class of a feature |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
97 switch (feature) |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
98 case "awt" |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
99 try |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
100 dum = methods ("java.awt.Frame"); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
101 chk = true; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
102 end_try_catch |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
103 case "desktop" |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
104 ## Octave has no Java based GUI/desktop, leave chk = false |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
105 case "jvm" |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
106 try |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
107 dum = methods ("java.lang.Runtime"); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
108 chk = true; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
109 end_try_catch |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
110 case "swing" |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
111 try |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
112 dum = methods ("javax.swing.Popup"); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
113 chk = true; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
114 end_try_catch |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
115 otherwise |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
116 ## Unrecognized feature is the same as disabled feature |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
117 endswitch |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
118 |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
119 if (! chk) |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
120 msg.message = sprintf (['javachk: %s is not supported, Java feature '... |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
121 '"%s" is not available'], caller, feature); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
122 msg.identifier = "Octave:javachk:feature-not-available"; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
123 endif |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
124 |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
125 endif |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
126 |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
127 if (isempty (msg.message)) |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26607
diff
changeset
|
128 ## Compatibility: Matlab returns a 0x1 empty struct when javachk passes |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
129 msg = resize (msg, 0, 1); |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
130 endif |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
131 |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
132 endfunction |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
133 |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
134 |
28912
0de38a6ef693
maint: Use Octave convention of space after function name in scripts dir.
Rik <rik@octave.org>
parents:
28886
diff
changeset
|
135 %!testif ; ! __octave_config_info__ ().build_features.JAVA |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
136 %! msg = javachk ("desktop"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
137 %! assert (msg.message, "javachk: this function is not supported, Octave was not compiled with Java support"); |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
138 %! assert (msg.identifier, "Octave:javachk:java-not-supported"); |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
139 |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
140 %!testif HAVE_JAVA |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
141 %! msg = javachk ("desktop"); |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
142 %! assert (msg.message, 'javachk: this function is not supported, Java feature "desktop" is not available'); |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
143 %! assert (msg.identifier, "Octave:javachk:feature-not-available"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
144 |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
145 %!testif HAVE_JAVA |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
146 %! msg = javachk ("desktop", "Java DESKTOP"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
147 %! assert (msg.message, 'javachk: Java DESKTOP is not supported, Java feature "desktop" is not available'); |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
148 %! assert (msg.identifier, "Octave:javachk:feature-not-available"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
149 |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
150 %!testif HAVE_JAVA |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
151 %! msg = javachk ("nosuchfeature"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
152 %! assert (msg.message, 'javachk: this function is not supported, Java feature "nosuchfeature" is not available'); |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
153 %! assert (msg.identifier, "Octave:javachk:feature-not-available"); |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
154 |
23405
32ec90068be5
use %!testif runtime tests to properly skip java tests
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
155 %!testif HAVE_JAVA; usejava ("jvm") |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
156 %! stnul = resize (struct ("message", "", "identifier", ""), 0, 1); |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
157 %! assert (javachk ("jvm"), stnul); |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
158 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
159 ## 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
|
160 %!error <Invalid call> javachk () |
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
161 %!error <FEATURE must be a string> javachk (1) |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
162 %!error javachk ("jvm", 2) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
163 %!error javachk ("jvm", "feature", "ok") |