Mercurial > hg > octave-nkf
annotate test/switch.tst @ 17174:c3c1ebfaa7dc
maint: Use common indentation for switch statement.
* scripts/general/interp1.m, scripts/geometry/delaunay.m,
scripts/help/__unimplemented__.m, scripts/image/cmunique.m,
scripts/miscellaneous/edit.m, scripts/optimization/fzero.m,
scripts/optimization/sqp.m, scripts/plot/__gnuplot_drawnow__.m,
scripts/plot/hidden.m, scripts/plot/legend.m, scripts/plot/print.m,
scripts/plot/printd.m, scripts/plot/private/__contour__.m,
scripts/plot/private/__fltk_print__.m,
scripts/plot/private/__gnuplot_print__.m,
scripts/plot/private/__go_draw_axes__.m,
scripts/plot/private/__print_parse_opts__.m, scripts/signal/periodogram.m,
scripts/sparse/bicg.m, test/slice.tst, test/switch.tst:
Use common indentation for switch statement.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 04 Aug 2013 15:11:34 -0700 |
parents | 57fad64de019 |
children | 5a65b2cc9508 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14131
diff
changeset
|
1 ## Copyright (C) 2006-2012 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 | |
5590 | 19 %!test |
20 %! a = 1; | |
21 %! b = 2; | |
22 %! c = 3; | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
23 %! |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
24 %! switch (0) case 1 x = a; case 2 x = b; otherwise x = c; endswitch |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
25 %! switch (1) case 1 y = a; case 2 y = b; otherwise y = c; endswitch |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
26 %! switch (2) case 1 z = a; case 2 z = b; otherwise z = c; endswitch |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
27 %! switch (3) case 1 p = a; case 2 p = b; otherwise p = c; endswitch |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
28 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
29 %! assert (x == c && y == a && z == b && p == c); |
5590 | 30 |
31 %!test | |
32 %! a = 1; | |
33 %! b = 2; | |
34 %! c = 3; | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
35 %! |
5590 | 36 %! x = zeros (1, 4); |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
37 %! |
5590 | 38 %! k = 1; |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
39 %! |
5590 | 40 %! for i = 0:3 |
41 %! switch (i) | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
42 %! case a |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
43 %! x(k) = a; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
44 %! case b |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
45 %! x(k) = b; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
46 %! otherwise |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
47 %! x(k) = c; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
48 %! endswitch |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
49 %! k++; |
5590 | 50 %! endfor |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
51 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
52 %! assert (all (x == [3, 1, 2, 3])); |
5590 | 53 |
54 %!test | |
55 %! a = 1; | |
56 %! b = 2; | |
57 %! c = 3; | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
58 %! |
5590 | 59 %! x = zeros (1, 4); |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
60 %! |
5590 | 61 %! k = 1; |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
62 %! |
5590 | 63 %! for i = 0:3 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
64 %! switch (i) |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
65 %! case a |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
66 %! x(k) = a; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
67 %! endswitch |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
68 %! k++; |
5590 | 69 %! endfor |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
70 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
71 %! assert (all (x == [0, 1, 0, 0])); |
5590 | 72 |
11353
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
73 %!test |
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
74 %! a = 1; |
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
75 %! |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
76 %! switch (1) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
77 %! otherwise |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
78 %! a = 2; |
11353
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
79 %! endswitch |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
80 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
81 %! assert (a == 2); |
11353
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
82 |
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
83 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
84 %!error <syntax error> eval ("switch endswitch") |
5590 | 85 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
86 %!error <syntax error> eval ("switch case endswitch") |
5590 | 87 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
88 %!error <syntax error> eval ("switch 1 default 1; endswitch") |
5590 | 89 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
90 %% test parsing of single-quoted character string appearing immediately |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
91 %% after a switch case |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
92 %!test |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
93 %! switch (1) |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
94 %! case 1 |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
95 %! 'foo'; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
96 %! x = 13; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
97 %! endswitch |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
98 %! assert (x, 13); |