Mercurial > hg > octave-nkf
annotate test/switch.tst @ 18547:85d31344fb23 stable rc-3-8-1-2
3.8.1 release candidate 2
* configure.ac (OCTAVE_VERSION): Bump to 3.8.1-rc2.
(OCTAVE_MINOR_VERSION): Bump to 1-rc2.
(OCTAVE_RELEASE_DATE): Set to 2014-02-14.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 17 Feb 2014 02:20:39 -0500 |
parents | d63878346099 |
children | 4197fc428c7d |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17309
diff
changeset
|
1 ## Copyright (C) 2006-2013 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 %! |
17309
5a65b2cc9508
test: Add tests for 'end' form of 'endfor', 'endif', etc.
Rik <rik@octave.org>
parents:
17174
diff
changeset
|
24 %! ## "end" is part of test, check not using "endswitch" |
5a65b2cc9508
test: Add tests for 'end' form of 'endfor', 'endif', etc.
Rik <rik@octave.org>
parents:
17174
diff
changeset
|
25 %! switch (0) case 1 x = a; case 2 x = b; otherwise x = c; end |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
26 %! 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
|
27 %! 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
|
28 %! 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
|
29 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
30 %! assert (x == c && y == a && z == b && p == c); |
5590 | 31 |
32 %!test | |
33 %! a = 1; | |
34 %! b = 2; | |
35 %! c = 3; | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
36 %! |
5590 | 37 %! 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
|
38 %! |
5590 | 39 %! k = 1; |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
40 %! |
5590 | 41 %! for i = 0:3 |
42 %! switch (i) | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
43 %! case a |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
44 %! 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
|
45 %! case b |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
46 %! 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
|
47 %! otherwise |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
48 %! 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
|
49 %! endswitch |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
50 %! k++; |
5590 | 51 %! endfor |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
52 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
53 %! assert (all (x == [3, 1, 2, 3])); |
5590 | 54 |
55 %!test | |
56 %! a = 1; | |
57 %! b = 2; | |
58 %! c = 3; | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
59 %! |
5590 | 60 %! 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
|
61 %! |
5590 | 62 %! k = 1; |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
63 %! |
5590 | 64 %! 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
|
65 %! switch (i) |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
66 %! case a |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
67 %! 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
|
68 %! endswitch |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
69 %! k++; |
5590 | 70 %! endfor |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
71 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
72 %! assert (all (x == [0, 1, 0, 0])); |
5590 | 73 |
11353
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
74 %!test |
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
75 %! a = 1; |
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
76 %! |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
77 %! switch (1) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
78 %! otherwise |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
79 %! a = 2; |
11353
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
80 %! endswitch |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
81 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
82 %! 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
|
83 |
cbf58e4b5f4e
Add test for switch statement with otherwise clause, but no cases.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
84 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
85 %!error <syntax error> eval ("switch endswitch") |
5590 | 86 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
87 %!error <syntax error> eval ("switch case endswitch") |
5590 | 88 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
89 %!error <syntax error> eval ("switch 1 default 1; endswitch") |
5590 | 90 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
91 %% 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
|
92 %% 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
|
93 %!test |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
94 %! switch (1) |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
95 %! case 1 |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
96 %! 'foo'; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
97 %! x = 13; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
98 %! endswitch |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16215
diff
changeset
|
99 %! assert (x, 13); |