Mercurial > octave
annotate test/for.tst @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
1 ## Copyright (C) 2006-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
2 ## |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
3 ## See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
4 ## or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
5 ## |
7016 | 6 ## |
7 ## This file is part of Octave. | |
8 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23925
diff
changeset
|
9 ## Octave is free software: you can redistribute it and/or modify it |
7016 | 10 ## 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:
23925
diff
changeset
|
11 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 ## (at your option) any later version. |
7016 | 13 ## |
14 ## Octave is distributed in the hope that it will be useful, but | |
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## GNU General Public License for more details. |
7016 | 18 ## |
19 ## You should have received a copy of the GNU General Public License | |
20 ## 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:
23925
diff
changeset
|
21 ## <https://www.gnu.org/licenses/>. |
7016 | 22 |
5590 | 23 %!test |
24 %! for i = 1 | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
25 %! __printf_assert__ ("%d", i); |
17309
5a65b2cc9508
test: Add tests for 'end' form of 'endfor', 'endif', etc.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
26 %! end # "end" is part of test, check not using "endfor" |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
27 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
28 %! assert (__prog_output_assert__ ("1")); |
5590 | 29 |
30 %!test | |
31 %! for i = 1:4 | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
32 %! __printf_assert__ ("%d", i); |
5590 | 33 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
34 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
35 %! assert (__prog_output_assert__ ("1234")); |
5590 | 36 |
37 %!test | |
38 %! for i = [1,2,3,4] | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
39 %! __printf_assert__ ("%d", i); |
5590 | 40 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
41 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
42 %! assert (__prog_output_assert__ ("1234")); |
5590 | 43 |
44 %!test | |
45 %! for i = [1,2;3,4] | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
46 %! __printf_assert__ ("%d", i(1,1)); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
47 %! __printf_assert__ ("%d", i(2,1)); |
5590 | 48 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
49 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
50 %! assert (__prog_output_assert__ ("1324")); |
5590 | 51 |
52 %!test | |
53 %! for i = I | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
54 %! __printf_assert__ ("%d", imag (i)); |
5590 | 55 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
56 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
57 %! assert (__prog_output_assert__ ("1")); |
5590 | 58 |
59 %!test | |
60 %! for i = [1,2,3,4]*I | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
61 %! __printf_assert__ ("%d", imag (i)); |
5590 | 62 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
63 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
64 %! assert (__prog_output_assert__ ("1234")); |
5590 | 65 |
66 %!test | |
67 %! for i = [1,2;3,4]*I | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
68 %! __printf_assert__ ("%d", imag (i(1,1))); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
69 %! __printf_assert__ ("%d", imag (i(2,1))); |
5590 | 70 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
71 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
72 %! assert (__prog_output_assert__ ("1324")); |
5590 | 73 |
74 %!test | |
75 %! for i = [1,2,3,4] | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
76 %! if (i > 2) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
77 %! break; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
78 %! endif |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
79 %! __printf_assert__ ("%d", i); |
5590 | 80 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
81 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
82 %! assert (__prog_output_assert__ ("12")); |
5590 | 83 |
84 %!test | |
85 %! for i = [1,2,3,4] | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
86 %! if (i < 3) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
87 %! continue; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
88 %! endif |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
89 %! __printf_assert__ ("%d", i); |
5590 | 90 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
91 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
92 %! assert (__prog_output_assert__ ("34")); |
5590 | 93 |
6587 | 94 %!test |
95 %! a = [1,3;2,4]; | |
96 %! j = 0; | |
97 %! for i = cat (3, a, 4 + a) | |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
98 %! assert (i, [1;2] + 2*j++); |
6587 | 99 %! endfor |
100 | |
101 %!test | |
102 %! a = {1,3;2,4}; | |
6602 | 103 %! j = 0; |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
104 %! for i = cat (3, a, cellfun (@(x) 4 + x, a, "UniformOutput", 0)) |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
105 %! assert (i, {1 + 2*j; 2 + 2*j++}); |
6587 | 106 %! endfor |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
107 |
17309
5a65b2cc9508
test: Add tests for 'end' form of 'endfor', 'endif', etc.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
108 ## test parsing of single-quoted character string appearing at the |
5a65b2cc9508
test: Add tests for 'end' form of 'endfor', 'endif', etc.
Rik <rik@octave.org>
parents:
16937
diff
changeset
|
109 ## beginning of a for loop |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
110 %!test |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
111 %! for i = 1:5 |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
112 %! 'foo'; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
113 %! endfor |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
114 %! assert (i, 5); |
17311
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
115 |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
116 %!test |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
117 %! parfor i = 1 |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
118 %! __printf_assert__ ("%d", i); |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
119 %! end # "end" is part of test, check not using "endparfor" |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
120 %! __printf_assert__ ("\n"); |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
121 %! assert (__prog_output_assert__ ("1")); |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
122 |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
123 %!test |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
124 %! parfor i = 1:4 |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
125 %! __printf_assert__ ("%d", i); |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
126 %! endparfor |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
127 %! __printf_assert__ ("\n"); |
56404cdcb723
Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents:
17309
diff
changeset
|
128 %! assert (__prog_output_assert__ ("1234")); |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
129 |
26946
04e5cb5e2cb3
update bug status in tests
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
130 %!test <*50893> |
23563
614d71cdf614
maint: Strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
131 %! cnt = 0; |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
132 %! for k = zeros (0,3); |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
133 %! cnt++; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
134 %! endfor |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
135 %! assert (cnt, 0); |
23925
d64985eaf56d
Change failing BIST tests to pass with Octave-expected values.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
136 %! assert (k, zeros (0,3)); |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
137 |
26946
04e5cb5e2cb3
update bug status in tests
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
138 %!test <*50893> |
23563
614d71cdf614
maint: Strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
139 %! cnt = 0; |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
140 %! for k = zeros (3,0); |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
141 %! cnt++; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
142 %! endfor |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
143 %! assert (cnt, 0); |
23925
d64985eaf56d
Change failing BIST tests to pass with Octave-expected values.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
144 %! assert (k, zeros (3,0)); |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
145 |
26946
04e5cb5e2cb3
update bug status in tests
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
146 %!test <*50893> |
23563
614d71cdf614
maint: Strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
147 %! cnt = 0; |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
148 %! for k = zeros (3,0, "uint32"); |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
149 %! cnt++; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
150 %! endfor |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
151 %! assert (cnt, 0); |
23925
d64985eaf56d
Change failing BIST tests to pass with Octave-expected values.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
152 %! assert (k, zeros (3,0, "uint32")); |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
153 |
26946
04e5cb5e2cb3
update bug status in tests
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
154 %!test <*50893> |
23563
614d71cdf614
maint: Strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
155 %! cnt = 0; |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
156 %! for k = cell (0,3); |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
157 %! cnt++; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
158 %! endfor |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
159 %! assert (cnt, 0); |
23925
d64985eaf56d
Change failing BIST tests to pass with Octave-expected values.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
160 %! assert (k, cell (0,3)); |