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 %% test/octave.test/while/while-1.m |
|
20 %!test |
|
21 %! i = 0; |
|
22 %! while (eye (2)) |
|
23 %! i++; |
|
24 %! printf_assert ("%d\n", i); |
|
25 %! endwhile; |
|
26 %! assert(prog_output_assert("")); |
|
27 |
|
28 %% test/octave.test/while/while-2.m |
|
29 %!test |
|
30 %! i = 5; |
|
31 %! while (--i) |
|
32 %! printf_assert ("%d", i); |
|
33 %! endwhile |
|
34 %! printf_assert ("\n"); |
|
35 %! assert(prog_output_assert("4321")); |
|
36 |
|
37 %% test/octave.test/while/while-3.m |
|
38 %!test |
|
39 %! i = 5; |
|
40 %! while (i) |
|
41 %! i--; |
|
42 %! printf_assert ("%d", i); |
|
43 %! endwhile |
|
44 %! printf_assert ("\n"); |
|
45 %! assert(prog_output_assert("43210")); |
|
46 |
|
47 %% test/octave.test/while/while-4.m |
|
48 %!test |
|
49 %! i = 0; |
|
50 %! while (i++ < 20) |
|
51 %! if (i > 2) |
|
52 %! break; |
|
53 %! endif |
|
54 %! printf_assert ("%d", i); |
|
55 %! endwhile; |
|
56 %! printf_assert ("\n"); |
|
57 %! assert(prog_output_assert("12")); |
|
58 |
|
59 %% test/octave.test/while/while-5.m |
|
60 %!test |
|
61 %! i = 0; |
|
62 %! while (++i < 5) |
|
63 %! if (i < 3) |
|
64 %! continue; |
|
65 %! endif |
|
66 %! printf_assert ("%d", i); |
|
67 %! endwhile |
|
68 %! printf_assert ("\n"); |
|
69 %! assert(prog_output_assert("34")); |
|
70 |