Mercurial > octave-libtiff
annotate test/parser.tst @ 31197:1604c8812b67
Tiff: added numberOfDirectories method.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Thu, 01 Sep 2022 01:56:20 +0200 |
parents | 796f54d4ddbf |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30031
diff
changeset
|
3 ## Copyright (C) 2010-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27490
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
11218
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 ## |
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24339
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
11218
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24339
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
11218
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 ## 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
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
11218
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 ## |
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 ## 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
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24339
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
11218
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
13237
diff
changeset
|
26 ## 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
|
27 ## We need many more tests here! |
11218
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
19451
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
29 ## Test cell construction operator {} |
11218
0910020c5ab6
add omitted file from previous change
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 %!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
|
31 %!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
|
32 %!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
|
33 %!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
|
34 %!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
|
35 %!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
|
36 %!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
|
37 %!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
|
38 |
19451
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
39 ## bug #43113 using null comma-separated list in constructor |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
40 %!test |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
41 %! z = cell (1,2,3,0,5); |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
42 %! assert ({1, z{:}, 2}, {1, 2}); |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
43 %! assert ({1; z{:}; 2}, {1; 2}); |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
44 %! assert ({1 2; z{:}; 3 4}, {1, 2; 3 4}); |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
45 %! assert ({1 2; 5 z{:} 6; 3 4}, {1, 2; 5 6; 3 4}); |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
18492
diff
changeset
|
46 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
47 ## 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
|
48 ## 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
|
49 ## down to "statement operators" (lowest). |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
50 ## |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
51 ## Level 13 (parentheses and indexing) |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
52 ## Overrides all other levels |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
53 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
54 %! a.b = 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
55 %! assert (a. b++, 1); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
56 %! assert (a.b, 2); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
57 %! clear a; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
58 %! a.b = [0 1]; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
59 %! b = 2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
60 %! assert (a.b', [0;1]); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
61 %! 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
|
62 %! 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
|
63 %! 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
|
64 %! 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
|
65 %! 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
|
66 %! 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
|
67 %! 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
|
68 %! a.b = [1 2]; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
69 %! assert (a. b&&0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
70 %! assert (a. b||0, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
71 %! a.b += a. b*2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
72 %! 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
|
73 ## 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
|
74 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
75 %! a = [3 5]; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
76 %! assert (2.^a ++, [8 32]); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
77 %! assert (a, [4 6]); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
78 %! assert (a--', [4; 6]); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
79 %! assert (a, [3 5]); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
80 %! a = 0; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
81 %! assert (!a --, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
82 %! assert (-a ++, 1); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
83 %! assert (3*a ++, 0); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
84 %! assert (a++-2, -1); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
85 %! assert (1:a ++, 1:2); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
86 %! assert (4>a++, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
87 %! a = [0 -1]; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
88 %! 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
|
89 %! 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
|
90 %! a = 0; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
91 %! assert (1 && a ++, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
92 %! assert (0 || a --, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
93 %! a = 5; b = 2; |
29900
da6e5914ddaf
handle all binary operators the same when detecting command syntax (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
94 %! b += a ++; |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
95 %! assert (b, 7); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
96 |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
97 ## Level 11 (transpose and exponentiation) |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
98 %!test |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17420
diff
changeset
|
99 %! a = 2; |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
100 %! assert (2 ^a++, 4); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
101 %! assert (a, 3); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
102 %! assert (2 ^--a ^2, 16); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
103 %! assert (a, 2); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
104 %! assert (2 ^++a, 8); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
105 %! assert (a, 3); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
106 %! assert (a' ^2, 9); |
28916
ec591c500fa4
maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents:
28583
diff
changeset
|
107 %! assert (2 ^sin (0), 1); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
108 %! assert (-2 ^2, -4);; |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
109 %! assert (2 ^+1 ^3, 8); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
110 %! assert (2 ^-1 ^3, 0.125); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
111 %! assert (2 ^~0 ^2, 4); |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
112 %! assert (!0 ^0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
113 %! assert (2*3 ^2, 18); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
114 %! assert (2+3 ^2, 11); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
115 %! 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
|
116 %! assert (3>2 ^2, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
117 %! assert (1&0 ^0, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
118 %! assert (0|0 ^0, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
119 %! assert (1&&0 ^0, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
120 %! assert (0||0 ^0, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
121 %! a = 3; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
122 %! a *= 0 ^0; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
123 %! assert (a, 3); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
124 ## 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
|
125 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
126 %! a = 2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
127 %! assert (++ a*3, 9); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
128 %! assert (-- a-2, 0); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
129 %! assert (a, 2); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
130 %! assert (! a-2, -2); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
131 %! 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
|
132 %! a = [1 0]; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
133 %! 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
|
134 %! a = 0; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
135 %! assert (++ a&1, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
136 %! assert (-- a|0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
137 %! assert (-- a&&1, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
138 %! assert (++ a||0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
139 %! a = 3; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
140 %! a *= ++a; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
141 %! assert (a, 16); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
142 ## 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
|
143 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
144 %! assert (3+4 * 5, 23); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
145 %! 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
|
146 %! assert (3>1 * 5, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
147 %! assert (1&1 * 0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
148 %! assert (1|1 * 0, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
149 %! assert (1&&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, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
151 %! a = 3; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
152 %! a /= a * 2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
153 %! assert (a, 0.5); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
154 ## 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
|
155 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
156 %! 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
|
157 %! assert (3>1 + 5, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
158 %! assert (1&1 - 1, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
159 %! assert (0|1 - 2, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
160 %! assert (1&&1 - 1, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
161 %! assert (0||1 - 2, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
162 %! a = 3; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
163 %! a *= 1 + 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
164 %! assert (a, 6); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
165 ## Level 7 (colon) |
12518
9f926b9f83cc
Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
166 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
167 %! 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
|
168 %! 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
|
169 %! 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
|
170 %! assert (-1: 3&&1, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
171 %! assert (-1: 3||0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
172 %! a = [1:3]; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
173 %! a += 3 : 5; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
174 %! 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
|
175 ## Level 6 (relational) |
12518
9f926b9f83cc
Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
176 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
177 %! assert (0 == -1&0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
178 %! assert (1 == -1|0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
179 %! assert (0 == -1&&0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
180 %! assert (1 == -1||0, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
181 %! a = 2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
182 %! a *= 3 > 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
183 %! assert (a, 2); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
184 ## 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
|
185 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
186 %! assert (0 & 1|1, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
187 %! 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
|
188 %! assert (0 & 1||1, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
189 %! a = 2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
190 %! a *= 3 & 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
191 %! assert (a, 2); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
192 ## 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
|
193 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
194 %! 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
|
195 %! 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
|
196 %! a = 2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
197 %! a *= 0 | 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
198 %! assert (a, 2); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
199 ## Level 3 (logical and) |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
200 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
201 %! assert (0 && 1||1, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
202 %! a = 2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
203 %! a *= 3 && 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
204 %! assert (a, 2); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
205 ## Level 2 (logical or) |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
206 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
207 %! a = 2; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
208 %! a *= 0 || 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
209 %! assert (a, 2); |
12518
9f926b9f83cc
Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
210 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
211 ## 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
|
212 ## 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
|
213 |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
214 ## 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
|
215 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
216 %! a.b1 = 2; |
28916
ec591c500fa4
maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents:
28583
diff
changeset
|
217 %! assert (a.(strcat ('b','1'))++, 2); |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
218 %! assert (a.b1, 3); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
219 %! 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
|
220 %! 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
|
221 %! b = 1:5; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
222 %! 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
|
223 %! 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
|
224 ## 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
|
225 ## 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
|
226 ## 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
|
227 %!test |
30031
cf60f8f636f6
Start deprecation of Fortran exponentiation operator.
Rik <rik@octave.org>
parents:
29900
diff
changeset
|
228 %! assert (2^3^2, 64); |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
229 %! 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
|
230 %! 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
|
231 %! assert (3*4i'.', 0 - 12i); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
232 %! assert (3*4i.'.', 0 + 12i); |
17420
577a19afdaf5
maint: Backed out changeset f81401b6b1f7.
Rik <rik@octave.org>
parents:
17419
diff
changeset
|
233 %! assert (2^-4^3, (1/16)^3); |
577a19afdaf5
maint: Backed out changeset f81401b6b1f7.
Rik <rik@octave.org>
parents:
17419
diff
changeset
|
234 %! assert (2^+4^3, 16^3); |
577a19afdaf5
maint: Backed out changeset f81401b6b1f7.
Rik <rik@octave.org>
parents:
17419
diff
changeset
|
235 %! assert (2^~0^2, 4); |
17419
f81401b6b1f7
parser.tst: known bug #33304 as xtest
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17313
diff
changeset
|
236 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
237 ## 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
|
238 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
239 %! assert (+-+1, -1); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
240 %! a = -1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
241 %! assert (!++a, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
242 %! assert (a, 0); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
243 %! assert (-~a, -1); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
244 %! assert (!~--a, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
245 %! assert (a, -1); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
246 ## 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
|
247 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
248 %! 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
|
249 %! 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
|
250 %! 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
|
251 %! 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
|
252 ## 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
|
253 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
254 %! 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
|
255 ## Level 7 (colon) |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
256 ## 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
|
257 ## with second colon operator. |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
258 ## Level 6 (relational) |
12518
9f926b9f83cc
Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
259 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
260 %! 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
|
261 %! 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
|
262 %! 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
|
263 ## 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
|
264 ## 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
|
265 ## and operation is associative. |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
266 ## 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
|
267 ## 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
|
268 ## and operation is associative. |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
269 ## 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
|
270 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
271 %! a = 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
272 %! assert (1 && 0 && ++a, false); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
273 %! assert (a, 1); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
274 ## Level 2 (logical or) |
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
275 %!test |
17313
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
276 %! a = 1; |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
277 %! assert (0 || 1 || ++a, true); |
1e1d42f0f332
parser.tst: Re-indent and add tests for bug #33304.
Rik <rik@octave.org>
parents:
16755
diff
changeset
|
278 %! assert (a, 1); |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12518
diff
changeset
|
279 ## Level 1 (assignment) |
12518
9f926b9f83cc
Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
280 %!test |
9f926b9f83cc
Add operator precedence tests to fixed list of parser tests.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
281 %! 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
|
282 %! 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
|
283 %! 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
|
284 |
20588
e34692daf663
Extend parser to accept '_' in numbers.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
285 ## Test extended number format which allows '_' as NOP character |
e34692daf663
Extend parser to accept '_' in numbers.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
286 %!assert (123_456, 123456) |
e34692daf663
Extend parser to accept '_' in numbers.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
287 %!assert (.123_456, .123456) |
e34692daf663
Extend parser to accept '_' in numbers.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
288 %!assert (123_456.123_456, 123456.123456) |
28583
96e7dc4c2214
improve Matlab compatibility for binary and hexadecimal constants
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
289 %!assert (0xAB_CD, uint16 (43981)) |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21076
diff
changeset
|
290 %!assert (2e0_1, 20) |
20588
e34692daf663
Extend parser to accept '_' in numbers.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
291 |
20589
7c0e10f035bd
Extend parser to accept binary constants that begin with '0b' or '0B'.
Rik <rik@octave.org>
parents:
20588
diff
changeset
|
292 ## Test binary constants |
28583
96e7dc4c2214
improve Matlab compatibility for binary and hexadecimal constants
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
293 %!assert (0b101, uint8 (5)) |
20589
7c0e10f035bd
Extend parser to accept binary constants that begin with '0b' or '0B'.
Rik <rik@octave.org>
parents:
20588
diff
changeset
|
294 %!assert (0B1100_0001, 0xC1) |
28583
96e7dc4c2214
improve Matlab compatibility for binary and hexadecimal constants
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
295 %!assert (class (0b1), "uint8") |
20589
7c0e10f035bd
Extend parser to accept binary constants that begin with '0b' or '0B'.
Rik <rik@octave.org>
parents:
20588
diff
changeset
|
296 |
21636
a3a412dee704
* parser.tst: Add BIST tests for 64-bit integer literal support (bug #47690)
Mike Miller <mtmiller@octave.org>
parents:
21580
diff
changeset
|
297 ## Test range of large binary and hexadecimal literals |
28583
96e7dc4c2214
improve Matlab compatibility for binary and hexadecimal constants
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
298 %!assert (0x8000_0000_0000_0000, uint64 (2^63)) |
96e7dc4c2214
improve Matlab compatibility for binary and hexadecimal constants
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
299 %!assert (0xFFFF_FFFF_FFFF_FFFF, uint64 (2^64)) |
96e7dc4c2214
improve Matlab compatibility for binary and hexadecimal constants
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
300 %!assert (0b10000000_0000000_000000000_00000000_00000000_00000000_00000000_00000000, uint64 (2^63)) |
96e7dc4c2214
improve Matlab compatibility for binary and hexadecimal constants
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
301 %!assert (0b11111111_1111111_111111111_11111111_11111111_11111111_11111111_11111111, uint64 (2^64)) |
21636
a3a412dee704
* parser.tst: Add BIST tests for 64-bit integer literal support (bug #47690)
Mike Miller <mtmiller@octave.org>
parents:
21580
diff
changeset
|
302 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
13237
diff
changeset
|
303 ## 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
|
304 |
13237
1bfca2bbea8b
fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents:
12689
diff
changeset
|
305 %!test |
1bfca2bbea8b
fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents:
12689
diff
changeset
|
306 %! 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
|
307 %! 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
|
308 |
1bfca2bbea8b
fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents:
12689
diff
changeset
|
309 %!test |
1bfca2bbea8b
fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents:
12689
diff
changeset
|
310 %! 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
|
311 %! 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
|
312 |
16755
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16030
diff
changeset
|
313 ## 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
|
314 ## 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
|
315 ## intended. |
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16030
diff
changeset
|
316 %!test |
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16030
diff
changeset
|
317 %! 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
|
318 %! assert (xyz, 1); |
17624
b92242ad316f
parser.tst: Remove comments about bug #33304 which has been fixed.
Rik <rik@octave.org>
parents:
17622
diff
changeset
|
319 |
18246
1f072ae35ede
fix parsing of single quote after continuation and comment (bug #41048)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
320 %!test |
19670
e5facc6eec13
Silence warning messages in %!test code.
Rik <rik@octave.org>
parents:
19451
diff
changeset
|
321 %! warning ("off", "Octave:num-to-str", "local"); |
18246
1f072ae35ede
fix parsing of single quote after continuation and comment (bug #41048)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
322 %! a = [97 ... % comment |
1f072ae35ede
fix parsing of single quote after continuation and comment (bug #41048)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
323 %! 'b']; |
1f072ae35ede
fix parsing of single quote after continuation and comment (bug #41048)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
324 %! assert (a, 'ab'); |
18492
e4c319ed2414
Fix regression, allow space-separated cell array of function handles (bug #41569)
Mike Miller <mtmiller@ieee.org>
parents:
18246
diff
changeset
|
325 |
e4c319ed2414
Fix regression, allow space-separated cell array of function handles (bug #41569)
Mike Miller <mtmiller@ieee.org>
parents:
18246
diff
changeset
|
326 ## Check that a cell array containing function handles is parsed |
e4c319ed2414
Fix regression, allow space-separated cell array of function handles (bug #41569)
Mike Miller <mtmiller@ieee.org>
parents:
18246
diff
changeset
|
327 ## correctly with or without commas. |
e4c319ed2414
Fix regression, allow space-separated cell array of function handles (bug #41569)
Mike Miller <mtmiller@ieee.org>
parents:
18246
diff
changeset
|
328 %!test |
e4c319ed2414
Fix regression, allow space-separated cell array of function handles (bug #41569)
Mike Miller <mtmiller@ieee.org>
parents:
18246
diff
changeset
|
329 %! a = {1, @sin, 2, @cos}; |
e4c319ed2414
Fix regression, allow space-separated cell array of function handles (bug #41569)
Mike Miller <mtmiller@ieee.org>
parents:
18246
diff
changeset
|
330 %! b = {1 @sin 2 @cos}; |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
331 %! assert (a, b); |
20775
cd50ce72fa24
parser.tst: Add test for resolved bug #46534.
Rik <rik@octave.org>
parents:
20589
diff
changeset
|
332 |
21076
b433f9990452
strip trailing whitespace from files
John W. Eaton <jwe@octave.org>
parents:
20775
diff
changeset
|
333 ## Maybe unnecessary, but check that further changes to parser don't |
20775
cd50ce72fa24
parser.tst: Add test for resolved bug #46534.
Rik <rik@octave.org>
parents:
20589
diff
changeset
|
334 ## invalidate error handling (bug #46534). |
cd50ce72fa24
parser.tst: Add test for resolved bug #46534.
Rik <rik@octave.org>
parents:
20589
diff
changeset
|
335 #!error <vertical dimensions mismatch \(1x2 vs 1x1\)> z = [1, 2; 3] |
24338
1212ffc13d24
Fix concatenation of empty char matrices with other strings (bug #52542).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
336 |
23788
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
337 %!test |
28916
ec591c500fa4
maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents:
28583
diff
changeset
|
338 %! f = @(s,t=toeplitz (s),u=t(x=2:end-1,x)=32)t; |
23788
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
339 %! assert (f (1), 1); |
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
340 %! assert (f (1, 2), 2); |
24339 | 341 |
24338
1212ffc13d24
Fix concatenation of empty char matrices with other strings (bug #52542).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
342 ## FIXME: We need a sequence of concatenation tests since this seems |
1212ffc13d24
Fix concatenation of empty char matrices with other strings (bug #52542).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
343 ## to be a frequently reported source of incompatibilities w/Matlab |
1212ffc13d24
Fix concatenation of empty char matrices with other strings (bug #52542).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
344 ## Check concatenation of empty char matrices (bug #52542) |
1212ffc13d24
Fix concatenation of empty char matrices with other strings (bug #52542).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
345 %!assert (double ([char(ones(0,3)); 'A']), 65) |
1212ffc13d24
Fix concatenation of empty char matrices with other strings (bug #52542).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
346 %!assert (double ([char(ones(0,3)); char(ones(2,0)); 'A']), 65) |
25753
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
347 |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
348 %!test <*54465> |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
349 %! x = 0; |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
350 %! if (! 0 || (x = 1)) |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
351 %! endif |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
352 %! assert (x == 0); |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
353 |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
354 %!function x = matlab_short_circuit () |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
355 %! x = 0; |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
356 %! if (! 0 | (x = 1)) |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
357 %! endif |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
358 %!endfunction |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
359 %!test <*54465> |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
360 %! fail ("x = matlab_short_circuit ()", "warning", "Matlab-style short-circuit operation performed for operator |"); |
b5dc88246c02
disable compound binary operator optimization (bug #54465)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
361 %! assert (x == 0); |
27489
c2c9185d3389
Issue warning when range expression contains a complex number (bug #56959).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
362 |
c2c9185d3389
Issue warning when range expression contains a complex number (bug #56959).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
363 %!test <*56959> |
27490
19ba2619d746
More informative warning message when range expression has a complex number (bug #56959).
Rik <rik@octave.org>
parents:
27489
diff
changeset
|
364 %! fail ("i:5", "warning", "imaginary part of complex colon arguments is ignored"); |
19ba2619d746
More informative warning message when range expression has a complex number (bug #56959).
Rik <rik@octave.org>
parents:
27489
diff
changeset
|
365 %! fail ("1:5*i", "warning", "imaginary part of complex colon arguments is ignored"); |
19ba2619d746
More informative warning message when range expression has a complex number (bug #56959).
Rik <rik@octave.org>
parents:
27489
diff
changeset
|
366 %! fail ("1:i:5", "warning", "imaginary part of complex colon arguments is ignored"); |
27489
c2c9185d3389
Issue warning when range expression contains a complex number (bug #56959).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
367 |