Mercurial > hg > octave-lyh
annotate test/test_for.m @ 15902:858cbf6fc2ec stable rc-3-6-4-1
Bump version for 3.6.4-rc1
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 05 Jan 2013 19:46:27 -0500 |
parents | 72c96de7a403 |
children | 5b2126a8c84f |
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/octave.test/for/for-1.m |
20 %!test | |
21 %! for i = 1 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
22 %! printf_assert ("%d", i); |
5590 | 23 %! end |
24 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
25 %! assert (prog_output_assert ("1")); |
5590 | 26 |
27 %% test/octave.test/for/for-2.m | |
28 %!test | |
29 %! for i = 1:4 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
30 %! printf_assert ("%d", i); |
5590 | 31 %! endfor |
32 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
33 %! assert (prog_output_assert ("1234")); |
5590 | 34 |
35 %% test/octave.test/for/for-3.m | |
36 %!test | |
37 %! 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
|
38 %! printf_assert ("%d", i); |
5590 | 39 %! endfor |
40 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
41 %! assert (prog_output_assert ("1234")); |
5590 | 42 |
43 %% test/octave.test/for/for-4.m | |
44 %!test | |
45 %! 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
|
46 %! printf_assert ("%d", i(1,1)); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
47 %! printf_assert ("%d", i(2,1)); |
5590 | 48 %! endfor |
49 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
50 %! assert (prog_output_assert ("1324")); |
5590 | 51 |
52 %% test/octave.test/for/for-5.m | |
53 %!test | |
54 %! for i = I | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
55 %! printf_assert ("%d", imag (i)); |
5590 | 56 %! endfor |
57 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
58 %! assert (prog_output_assert ("1")); |
5590 | 59 |
60 %% test/octave.test/for/for-6.m | |
61 %!test | |
62 %! for i = [1,2,3,4]*I | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
63 %! printf_assert ("%d", imag (i)); |
5590 | 64 %! endfor |
65 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
66 %! assert (prog_output_assert ("1234")); |
5590 | 67 |
68 %% test/octave.test/for/for-7.m | |
69 %!test | |
70 %! for i = [1,2;3,4]*I | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
71 %! printf_assert ("%d", imag (i(1,1))); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
72 %! printf_assert ("%d", imag (i(2,1))); |
5590 | 73 %! endfor |
74 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
75 %! assert (prog_output_assert ("1324")); |
5590 | 76 |
77 %% test/octave.test/for/for-8.m | |
78 %!test | |
79 %! 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
|
80 %! if (i > 2) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
81 %! break; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
82 %! endif |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
83 %! printf_assert ("%d", i); |
5590 | 84 %! endfor |
85 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
86 %! assert (prog_output_assert ("12")); |
5590 | 87 |
88 %% test/octave.test/for/for-9.m | |
89 %!test | |
90 %! 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
|
91 %! if (i < 3) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
92 %! continue; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
93 %! endif |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
94 %! printf_assert ("%d", i); |
5590 | 95 %! endfor |
96 %! printf_assert ("\n"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
97 %! assert (prog_output_assert ("34")); |
5590 | 98 |
6587 | 99 %!test |
100 %! a = [1,3;2,4]; | |
101 %! j = 0; | |
102 %! for i = cat (3, a, 4 + a) | |
103 %! assert (i, [1;2] + 2*j++) | |
104 %! endfor | |
105 | |
106 %!test | |
107 %! a = {1,3;2,4}; | |
6602 | 108 %! j = 0; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
109 %! for i = cat (3, a, cellfun(@(x) 4 + x, a, "UniformOutput", 0)) |
6587 | 110 %! assert (i, {1 + 2*j; 2 + 2*j++}) |
111 %! endfor |