Mercurial > hg > octave-nkf
annotate test/error.tst @ 19898:4197fc428c7d
maint: Update copyright notices for 2015.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 11 Feb 2015 14:19:08 -0500 |
parents | 93fbdbcb3349 |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19636
diff
changeset
|
1 ## Copyright (C) 2006-2015 John W. Eaton |
7016 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
19 ## Test %!error usage |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
20 |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
21 %!function g () |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
22 %! error ("foo"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
23 %!endfunction |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
24 %!function f () |
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
25 %! g (); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
26 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
27 %!error <foo> f () |
5590 | 28 |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
29 %!function g () |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
30 %! error ("foo\n"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
31 %!endfunction |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
32 %!function f () |
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
33 %! g |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
34 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
35 %!error <foo> f () |
5590 | 36 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
37 %!error error () |
5590 | 38 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
39 %!error <foo> error ("foo\n") |
5590 | 40 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
41 ## Test %!warning usage |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
42 |
5590 | 43 %!function g () |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
44 %! warning ("foo"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
45 %!endfunction |
5590 | 46 %!function f () |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
47 %! g; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
48 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
49 %!warning <foo> f () |
5590 | 50 |
51 %!test | |
52 %! st.identifier = "backtrace"; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
53 %! ws = warning ("query", "backtrace"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
54 %! warning ("on", "backtrace"); |
5590 | 55 %! st.state = "on"; |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
56 %! assert (warning ("query", "backtrace"), st); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
57 %! warning ("off", "backtrace"); |
5590 | 58 %! st.state = "off"; |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
59 %! assert (warning ("query", "backtrace"), st); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
60 %! warning (ws.state, "backtrace"); |
5590 | 61 |
19636
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
62 %!shared t1_opts, t2_opts, t1_id, t1_state, saved_opts, saved_id, saved_state |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
63 %! saved_opts = warning (); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
64 %! saved_id = {saved_opts.identifier}; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
65 %! saved_state = {saved_opts.state}; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
66 %! warning ("off", "all"); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
67 %! assert (warning (), struct ("identifier", {"all"}, "state", {"off"})); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
68 %! warning ("off", "all"); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
69 %! warning (saved_opts); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
70 %! t1_opts = struct ("identifier", {"foo:bar"}, "state", {"off"}); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
71 %! t1_id = {t1_opts.identifier}; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
72 %! t1_state = {t1_opts.state}; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
73 %! warning (t1_opts); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
74 %! t2_opts = struct ("identifier", [saved_id, t1_id], "state", [saved_state, t1_state]); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
75 %! assert (warning (), t2_opts); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
76 %! warning ("off", "all"); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
77 %! warning (saved_opts); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
78 |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
79 ## Bug 36393 |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
80 |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
81 %!test |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
82 %! w0 = warning; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
83 %! warnoffId = "MATLAB:singularMatrix"; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
84 %! warnstat = warning ("query", warnoffId); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
85 %! warnoff = warnstat; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
86 %! warnoff.state = "off"; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
87 %! warning (warnoff); %update warning status |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
88 %! warning (warnstat); %reset warning status |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
89 %! w = warning; |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
90 %! assert (w, w0); |
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
91 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
92 ## Test usage() function |
5590 | 93 |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
94 %!function g () |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
95 %! usage ("foo"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
96 %!endfunction |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
97 %!function f () |
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
98 %! g (); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
99 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
100 %!error <foo> f () |
5590 | 101 |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
102 %!function g () |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
103 %! usage ("foo"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
104 %!endfunction |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
105 %!function f () |
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
106 %! g |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
107 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
108 %!error <foo> f () |
5590 | 109 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
110 %!error usage () |
5590 | 111 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
112 %!error <foo> usage ("foo\n") |
5590 | 113 |