Mercurial > hg > octave-nkf
annotate test/for.tst @ 16681:d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
* lex.ll ("'"): Always begin a character string if at the beginning of
a statement.
* oct-parse.in.yy (stmt_begin): New non-terminal.
(anon_fcn_handle, if_cmd_list1, elseif_clause, switch_case,
loop_command): Use it.
* pt-fcn-handle.cc, for.tst, if.tst, switch.tst, while.tst:
New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 May 2013 16:21:32 -0400 |
parents | b1283d4c06c2 |
children | 57fad64de019 |
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 | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
22 %! __printf_assert__ ("%d", i); |
5590 | 23 %! end |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
24 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
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 | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
30 %! __printf_assert__ ("%d", i); |
5590 | 31 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
32 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
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] | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
38 %! __printf_assert__ ("%d", i); |
5590 | 39 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
40 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
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] | |
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/octave.test/for/for-5.m | |
53 %!test | |
54 %! for i = I | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
55 %! __printf_assert__ ("%d", imag (i)); |
5590 | 56 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
57 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
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 | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
63 %! __printf_assert__ ("%d", imag (i)); |
5590 | 64 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
65 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
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 | |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
71 %! __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
|
72 %! __printf_assert__ ("%d", imag (i(2,1))); |
5590 | 73 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
74 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
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 |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
83 %! __printf_assert__ ("%d", i); |
5590 | 84 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
85 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
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 |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
94 %! __printf_assert__ ("%d", i); |
5590 | 95 %! endfor |
16019
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
96 %! __printf_assert__ ("\n"); |
5b2126a8c84f
install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents:
14138
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; |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
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 | |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
112 |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
113 %% test parsing of single-quoted character string appearing at the |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
114 %% beginning of a for loop |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
115 %!test |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
116 %! 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
|
117 %! 'foo'; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
118 %! endfor |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16213
diff
changeset
|
119 %! assert (i, 5); |