7017
|
1 ## Copyright (C) 2006, 2007 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 %% Automatically generated from DejaGNU files |
|
20 |
|
21 %% test/octave.test/for/for-1.m |
|
22 %!test |
|
23 %! for i = 1 |
|
24 %! printf_assert ("%d", i); |
|
25 %! end |
|
26 %! printf_assert ("\n"); |
|
27 %! assert(prog_output_assert("1")); |
|
28 |
|
29 %% test/octave.test/for/for-2.m |
|
30 %!test |
|
31 %! for i = 1:4 |
|
32 %! printf_assert ("%d", i); |
|
33 %! endfor |
|
34 %! printf_assert ("\n"); |
|
35 %! assert(prog_output_assert("1234")); |
|
36 |
|
37 %% test/octave.test/for/for-3.m |
|
38 %!test |
|
39 %! for i = [1,2,3,4] |
|
40 %! printf_assert ("%d", i); |
|
41 %! endfor |
|
42 %! printf_assert ("\n"); |
|
43 %! assert(prog_output_assert("1234")); |
|
44 |
|
45 %% test/octave.test/for/for-4.m |
|
46 %!test |
|
47 %! for i = [1,2;3,4] |
|
48 %! printf_assert ("%d", i(1,1)); |
|
49 %! printf_assert ("%d", i(2,1)); |
|
50 %! endfor |
|
51 %! printf_assert ("\n"); |
|
52 %! assert(prog_output_assert("1324")); |
|
53 |
|
54 %% test/octave.test/for/for-5.m |
|
55 %!test |
|
56 %! for i = I |
|
57 %! printf_assert ("%d", imag (i)); |
|
58 %! endfor |
|
59 %! printf_assert ("\n"); |
|
60 %! assert(prog_output_assert("1")); |
|
61 |
|
62 %% test/octave.test/for/for-6.m |
|
63 %!test |
|
64 %! for i = [1,2,3,4]*I |
|
65 %! printf_assert ("%d", imag (i)); |
|
66 %! endfor |
|
67 %! printf_assert ("\n"); |
|
68 %! assert(prog_output_assert("1234")); |
|
69 |
|
70 %% test/octave.test/for/for-7.m |
|
71 %!test |
|
72 %! for i = [1,2;3,4]*I |
|
73 %! printf_assert ("%d", imag (i(1,1))); |
|
74 %! printf_assert ("%d", imag (i(2,1))); |
|
75 %! endfor |
|
76 %! printf_assert ("\n"); |
|
77 %! assert(prog_output_assert("1324")); |
|
78 |
|
79 %% test/octave.test/for/for-8.m |
|
80 %!test |
|
81 %! for i = [1,2,3,4] |
|
82 %! if (i > 2) |
|
83 %! break; |
|
84 %! endif |
|
85 %! printf_assert ("%d", i); |
|
86 %! endfor |
|
87 %! printf_assert ("\n"); |
|
88 %! assert(prog_output_assert("12")); |
|
89 |
|
90 %% test/octave.test/for/for-9.m |
|
91 %!test |
|
92 %! for i = [1,2,3,4] |
|
93 %! if (i < 3) |
|
94 %! continue; |
|
95 %! endif |
|
96 %! printf_assert ("%d", i); |
|
97 %! endfor |
|
98 %! printf_assert ("\n"); |
|
99 %! assert(prog_output_assert("34")); |
|
100 |
6587
|
101 %!test |
|
102 %! a = [1,3;2,4]; |
|
103 %! j = 0; |
|
104 %! for i = cat (3, a, 4 + a) |
|
105 %! assert (i, [1;2] + 2*j++) |
|
106 %! endfor |
|
107 |
|
108 %!test |
|
109 %! a = {1,3;2,4}; |
6602
|
110 %! j = 0; |
6587
|
111 %! for i = cat (3, a, cellfun(@(x) 4 + x, a, 'UniformOutput', 0)) |
|
112 %! assert (i, {1 + 2*j; 2 + 2*j++}) |
|
113 %! endfor |