Mercurial > octave
annotate test/bug-61201.tst @ 31221:f5755dbacd8d
maint: merge stable to default
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Wed, 31 Aug 2022 22:04:02 +0200 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
30203
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 ######################################################################## |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30324
diff
changeset
|
3 ## Copyright (C) 2010-2022 The Octave Project Developers |
30203
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 ## |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 ## |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 ## |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 ## (at your option) any later version. |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 ## |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 ## GNU General Public License for more details. |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 ## |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 ## |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 ######################################################################## |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 %!function lineno = test_conditional_lines (type) |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 %! lineno = -42; |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 %! warning ("error", "Octave:possible-matlab-short-circuit-operator", "local"); |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 %! try |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 %! switch (type) |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 %! case "while" |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 %! k = 0; |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 %! while (k < 2 & true) ## line 8 |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 %! k++; |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 %! endwhile |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 %! case "until" |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 %! k = 0; |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 %! do |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 %! k++; |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 %! until (k > 2 & true); ## line 15, but see below... |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 %! case "if" |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 %! k = 2; |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 %! if (k < 2 & true) ## line 18 |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 %! endif |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 %! case "elseif" |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 %! k = 2; |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 %! if (false) |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 %! elseif (k < 2 & true) ## line 23 |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 %! endif |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 %! endswitch |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 %! catch (ex) |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 %! lineno = ex.stack(1).line; |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 %! end_try_catch |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 %!endfunction |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 |
30324 | 56 %!assert<*61201> (test_conditional_lines ("while"), 8) |
30203
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 |
30324 | 58 %!assert<*61201> (test_conditional_lines ("if"), 18) |
30203
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
30324 | 60 %!assert<*61201> (test_conditional_lines ("elseif"), 23) |
30203
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 ## Because the DO-UNTIL statement is not part of Matlab it is not |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 ## eligible for Matlab-style short-circuit behavior in Octave. |
30324 | 64 %!assert<*61201> (test_conditional_lines ("until"), -42) |