annotate test/parser.tst @ 17313:1e1d42f0f332

parser.tst: Re-indent and add tests for bug #33304. * test/parser.tst: Use just a single space after '%!' before code. Add tests for left-to-right exponentiation operation.
author Rik <rik@octave.org>
date Wed, 21 Aug 2013 20:23:03 -0700
parents 787168f5f858
children f81401b6b1f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14131
diff changeset
1 ## Copyright (C) 2010-2012 John W. Eaton
11218
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 ## This file is part of Octave.
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 ##
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## your option) any later version.
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ## General Public License for more details.
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 13237
diff changeset
19 ## Tests for parser problems belong in this file.
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 13237
diff changeset
20 ## We need many more tests here!
11218
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 %!assert ({1 2 {3 4}}, {1,2,{3,4}})
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 %!assert ({1, 2 {3 4}}, {1,2,{3,4}})
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 %!assert ({1 2, {3 4}}, {1,2,{3,4}})
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 %!assert ({1 2 {3, 4}}, {1,2,{3,4}})
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 %!assert ({1, 2, {3 4}}, {1,2,{3,4}})
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 %!assert ({1 2,{3 4}}, {1,2,{3,4}})
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 %!assert ({1 2,{3,4}}, {1,2,{3,4}})
0910020c5ab6 add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 %!assert ({1,2,{3 4}}, {1,2,{3,4}})
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
30
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
31 ## Tests for operator precedence as documented in section 8.8 of manual
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
32 ## There are 13 levels of precedence from "parentheses and indexing" (highest)
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
33 ## down to "statement operators" (lowest).
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
34 ##
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
35 ## Level 13 (parentheses and indexing)
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
36 ## Overrides all other levels
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
37 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
38 %! a.b = 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
39 %! assert (a. b++, 1);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
40 %! assert (a.b, 2);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
41 %! clear a;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
42 %! a.b = [0 1];
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
43 %! b = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
44 %! assert (a.b', [0;1]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
45 %! assert (!a .b, logical ([1 0]));
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
46 %! assert (3*a .b, [0 3]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
47 %! assert (a. b-1, [-1 0]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
48 %! assert (a. b:3, 0:3);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
49 %! assert (a. b>0.5, logical ([0 1]));
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
50 %! assert (a. b&0, logical ([0 0]));
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
51 %! assert (a. b|0, logical ([0 1]));
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
52 %! a.b = [1 2];
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
53 %! assert (a. b&&0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
54 %! assert (a. b||0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
55 %! a.b += a. b*2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
56 %! assert (a.b, [3 6]);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
57 ## Level 12 (postfix increment and decrement)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
58 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
59 %! a = [3 5];
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
60 %! assert (2.^a ++, [8 32]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
61 %! assert (a, [4 6]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
62 %! assert (a--', [4; 6]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
63 %! assert (a, [3 5]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
64 %! a = 0;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
65 %! assert (!a --, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
66 %! assert (-a ++, 1);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
67 %! assert (3*a ++, 0);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
68 %! assert (a++-2, -1);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
69 %! assert (1:a ++, 1:2);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
70 %! assert (4>a++, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
71 %! a = [0 -1];
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
72 %! assert ([1 1] & a++, logical ([0 1]));
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
73 %! assert ([0 0] | a++, logical ([1 0]));
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
74 %! a = 0;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
75 %! assert (1 && a ++, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
76 %! assert (0 || a --, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
77 %! a = 5; b = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
78 %! b +=a ++;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
79 %! assert (b, 7);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
80
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
81 ## Level 11 (transpose and exponentiation)
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
82 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
83 %! assert (-2 ^2, -4);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
84 %! assert (!0 ^0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
85 %! assert (2*3 ^2, 18);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
86 %! assert (2+3 ^2, 11);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
87 %! assert ([1:10](1:2 ^2), [1 2 3 4]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
88 %! assert (3>2 ^2, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
89 %! assert (1&0 ^0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
90 %! assert (0|0 ^0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
91 %! assert (1&&0 ^0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
92 %! assert (0||0 ^0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
93 %! a = 3;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
94 %! a *= 0 ^0;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
95 %! assert (a, 3);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
96 ## Level 10 (unary plus/minus, prefix increment/decrement, not)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
97 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
98 %! a = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
99 %! assert (++ a*3, 9);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
100 %! assert (-- a-2, 0);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
101 %! assert (a, 2);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
102 %! assert (! a-2, -2);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
103 %! assert ([1:10](++ a:5), 3:5);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
104 %! a = [1 0];
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
105 %! assert (! a>=[1 0], [false true]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
106 %! a = 0;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
107 %! assert (++ a&1, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
108 %! assert (-- a|0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
109 %! assert (-- a&&1, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
110 %! assert (++ a||0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
111 %! a = 3;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
112 %! a *= ++a;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
113 %! assert (a, 16);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
114 ## Level 9 (multiply, divide)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
115 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
116 %! assert (3+4 * 5, 23);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
117 %! assert (5 * 1:6, [5 6]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
118 %! assert (3>1 * 5, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
119 %! assert (1&1 * 0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
120 %! assert (1|1 * 0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
121 %! assert (1&&1 * 0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
122 %! assert (1||1 * 0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
123 %! a = 3;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
124 %! a /= a * 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
125 %! assert (a, 0.5);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
126 ## Level 8 (add, subtract)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
127 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
128 %! assert ([2 + 1:6], 3:6);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
129 %! assert (3>1 + 5, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
130 %! assert (1&1 - 1, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
131 %! assert (0|1 - 2, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
132 %! assert (1&&1 - 1, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
133 %! assert (0||1 - 2, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
134 %! a = 3;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
135 %! a *= 1 + 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
136 %! assert (a, 6);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
137 ## Level 7 (colon)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
138 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
139 %! assert (5:-1: 3>4, [true false false]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
140 %! assert (1: 3&1, [true true true]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
141 %! assert (1: 3|0, [true true true]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
142 %! assert (-1: 3&&1, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
143 %! assert (-1: 3||0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
144 %! a = [1:3];
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
145 %! a += 3 : 5;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
146 %! assert (a, [4 6 8]);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
147 ## Level 6 (relational)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
148 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
149 %! assert (0 == -1&0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
150 %! assert (1 == -1|0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
151 %! assert (0 == -1&&0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
152 %! assert (1 == -1||0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
153 %! a = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
154 %! a *= 3 > 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
155 %! assert (a, 2);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
156 ## Level 5 (element-wise and)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
157 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
158 %! assert (0 & 1|1, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
159 %! assert ([0 1] & 1&&1, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
160 %! assert (0 & 1||1, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
161 %! a = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
162 %! a *= 3 & 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
163 %! assert (a, 2);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
164 ## Level 4 (element-wise or)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
165 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
166 %! assert ([0 1] | 1&&0, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
167 %! assert ([0 1] | 1||0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
168 %! a = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
169 %! a *= 0 | 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
170 %! assert (a, 2);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
171 ## Level 3 (logical and)
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
172 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
173 %! assert (0 && 1||1, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
174 %! a = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
175 %! a *= 3 && 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
176 %! assert (a, 2);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
177 ## Level 2 (logical or)
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
178 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
179 %! a = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
180 %! a *= 0 || 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
181 %! assert (a, 2);
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
182
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
183 ## Tests for operator precedence within each level where ordering should
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
184 ## be left to right except for postfix and assignment operators.
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
185
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
186 ## Level 13 (parentheses and indexing)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
187 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
188 %! a.b1 = 2;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
189 %! assert (a.(strcat('b','1'))++, 2);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
190 %! assert (a.b1, 3);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
191 %! b = {1 2 3 4 5};
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
192 %! assert (b{(a. b1 + 1)}, 4);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
193 %! b = 1:5;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
194 %! assert (b(a. b1 + 1), 4);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
195 %! assert ([2 3].^2', [4; 9]);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
196 ## Level 12 (postfix increment and decrement)
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
197 ## No tests possible since a++-- is not valid
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
198 ## Level 11 (transpose and exponentiation)
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
199 ## Note: Exponentiation should be left-to-right, but Octave does right-to-left.
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
200 ## See bug #33304.
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
201 %!test
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
202 %! assert (2^3**2, 64);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
203 %! assert ([2 3].^2.', [4;9]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
204 %! assert ([2 3].'.^2, [4;9]);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
205 %! assert (3*4i'.', 0 - 12i);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
206 %! assert (3*4i.'.', 0 + 12i);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
207 %! assert (2^-4^3, (1/16)^3);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
208 %! assert (2^+4^3, 16^3);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
209 %! assert (2^~0^2, 4);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
210
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
211 ## Note: Exponentiation should be left-to-right, but Octave does right-to-left.
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
212 ## See bug #33304.
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
213
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
214 ## Level 10 (unary plus/minus, prefix increment/decrement, not)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
215 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
216 %! assert (+-+1, -1);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
217 %! a = -1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
218 %! assert (!++a, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
219 %! assert (a, 0);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
220 %! assert (-~a, -1);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
221 %! assert (!~--a, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
222 %! assert (a, -1);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
223 ## Level 9 (multiply, divide)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
224 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
225 %! assert (3 * 4 / 5, 2.4);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
226 %! assert (3 ./ 4 .* 5, 3.75);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
227 %! assert (2 * 4 \ 6, 0.75);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
228 %! assert (2 .\ 4 .* 6, 12);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
229 ## Level 8 (add, subtract)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
230 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
231 %! assert (-3 - 4 + 1 + 3 * 2, 0);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
232 ## Level 7 (colon)
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
233 ## No tests possible because colon operator can't be combined
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
234 ## with second colon operator.
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
235 ## Level 6 (relational)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
236 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
237 %! assert (0 < 1 <= 0.5 == 0 >= 0.5 > 0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
238 %! assert (1 < 1 == 0 != 0, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
239 %! assert (1 < 1 == 0 ~= 0, true);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
240 ## Level 5 (element-wise and)
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
241 ## No tests possible. Only one operator (&) at this precedence level
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
242 ## and operation is associative.
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
243 ## Level 4 (element-wise or)
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
244 ## No tests possible. Only one operator (|) at this precedence level
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
245 ## and operation is associative.
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
246 ## Level 3 (logical and)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
247 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
248 %! a = 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
249 %! assert (1 && 0 && ++a, false);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
250 %! assert (a, 1);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
251 ## Level 2 (logical or)
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
252 %!test
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
253 %! a = 1;
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
254 %! assert (0 || 1 || ++a, true);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
255 %! assert (a, 1);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
256 ## Level 1 (assignment)
12518
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
257 %!test
9f926b9f83cc Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
258 %! a = 2; b = 5; c = 7;
17313
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
259 %! assert (a += b *= c += 1, 42);
1e1d42f0f332 parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents: 16755
diff changeset
260 %! assert (b == 40 && c == 8);
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12518
diff changeset
261
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 13237
diff changeset
262 ## Test creation of anonymous functions
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 13237
diff changeset
263
13237
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 12689
diff changeset
264 %!test
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 12689
diff changeset
265 %! af_in_cell = {@(x) [1 2]};
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 12689
diff changeset
266 %! assert (af_in_cell{1}(), [1, 2]);
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 12689
diff changeset
267
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 12689
diff changeset
268 %!test
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 12689
diff changeset
269 %! R = @(rot) [cos(rot) -sin(rot); sin(rot) cos(rot)];
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 12689
diff changeset
270 %! assert (R(pi/2), [cos(pi/2), -sin(pi/2); sin(pi/2),cos(pi/2)]);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 13237
diff changeset
271
16755
787168f5f858 tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents: 16030
diff changeset
272 ## Check that xyz is tagged as a variable in the parser. Both
787168f5f858 tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents: 16030
diff changeset
273 ## expressions must remain on one line for this test to work as
787168f5f858 tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents: 16030
diff changeset
274 ## intended.
787168f5f858 tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents: 16030
diff changeset
275 %!test
787168f5f858 tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents: 16030
diff changeset
276 %! xyz(1) = 1; xyz /= 1;
787168f5f858 tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents: 16030
diff changeset
277 %! assert (xyz, 1);