Mercurial > octave
annotate scripts/general/isequal.m @ 23220:092078913d54
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 Feb 2017 12:58:07 -0500 |
parents | ef4d915df748 3ac9f9ecfae5 |
children | 606f3866cdb7 |
rev | line source |
---|---|
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
1 ## Copyright (C) 2005-2017 William Poetra Yoga Hadisoeseno |
5178 | 2 ## |
5181 | 3 ## This file is part of Octave. |
5178 | 4 ## |
7016 | 5 ## Octave is free software; you can redistribute it and/or modify it |
6 ## under the terms of the GNU General Public License as published by | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
8 ## (at your option) any later version. |
5181 | 9 ## |
7016 | 10 ## Octave is distributed in the hope that it will be useful, but |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## GNU General Public License for more details. |
5178 | 14 ## |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5178 | 18 |
5182 | 19 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
20 ## @deftypefn {} {} isequal (@var{x1}, @var{x2}, @dots{}) |
5550 | 21 ## Return true if all of @var{x1}, @var{x2}, @dots{} are equal. |
16935
a7b2fc7fe1a9
binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
22 ## @seealso{isequaln} |
5182 | 23 ## @end deftypefn |
5178 | 24 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
9899
diff
changeset
|
25 function retval = isequal (x1, varargin) |
5181 | 26 |
12604
132c89bb44e3
maint: Refactor general/isXXX.m scripts to put input validation first.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
27 if (nargin < 2) |
6046 | 28 print_usage (); |
5550 | 29 endif |
5181 | 30 |
12604
132c89bb44e3
maint: Refactor general/isXXX.m scripts to put input validation first.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
31 retval = __isequal__ (false, x1, varargin{:}); |
132c89bb44e3
maint: Refactor general/isXXX.m scripts to put input validation first.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
32 |
5178 | 33 endfunction |
5549 | 34 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
35 |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
36 ## test empty input |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
37 %!assert (isequal ([], []), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
38 %!assert (isequal ([], [], 1), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
39 %!assert (isequal ([], 1, []), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
40 %!assert (isequal (1, [], []), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
41 %!assert (isequal (1, [], []), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
42 |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
43 ## test size and shape |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
44 %!assert (isequal ([1,2,3,4], [1,2,3,4]), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
45 %!assert (isequal ([1;2;3;4], [1;2;3;4]), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
46 %!assert (isequal ([1,2,3,4], [1;2;3;4]), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
47 %!assert (isequal ([1,2,3,4], [1,2;3,4]), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
48 %!assert (isequal ([1,2,3,4], [1,3;2,4]), false) |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
49 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
50 %!test |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
51 %! A = 1:8; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
52 %! B = reshape (A, 2, 2, 2); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
53 %! assert (isequal (A, B), false); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
54 %!test |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
55 %! A = reshape (1:8, 2, 2, 2); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
56 %! B = A; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
57 %! assert (isequal (A, B), true); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
58 %!test |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
59 %! A = reshape (1:8, 2, 4); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
60 %! B = reshape (A, 2, 2, 2); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
61 %! assert (isequal (A, B), false); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
62 |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
63 ## test all numeric built-in primitives |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
64 %!assert (isequal (false, logical (0), char (0), |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
65 %! int8 (0), int16 (0), int32 (0), int64 (0), |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
66 %! uint8 (0), uint16 (0), uint32 (0), uint64 (0), |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
67 %! double (0), single (0), |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
68 %! double (complex (0,0)), single (complex (0,0))), |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
69 %! true) |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18786
diff
changeset
|
70 %!assert (isequal (true, logical (1), char (1), |
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18786
diff
changeset
|
71 %! int8 (1), int16 (1), int32 (1), int64 (1), |
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18786
diff
changeset
|
72 %! uint8 (1), uint16 (1), uint32 (1), uint64 (1), |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
73 %! double (1), single (1), |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
74 %! double (complex (1,0)), single (complex (1,0))), |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
75 %! true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
76 |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
77 ## test characters and strings |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
78 %!assert (isequal ('a', "a"), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
79 %!assert (isequal ("abab", ["a", "b", "a", "b"]), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
80 %!assert (isequal (["a","b","c","d"], ["a","b","c","d"]), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
81 %!assert (isequal (["test ";"strings"], ["test ";"strings"], |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
82 %! ["test ";"strings"]), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
83 %!assert (isequal (["a","b","c","d"], ["a";"b";"c";"d"]), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
84 |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
85 ## test function_handle |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
86 %!test |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
87 %! fcn = @(x) x.^2; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
88 %! assert (isequal (fcn, fcn), true); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
89 %! assert (isequal (fcn, @(x) x.^2), false); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
90 %! assert (isequal (@(x) x.^2, fcn), false); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
91 |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
92 ## test structures |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
93 %!assert (isequal (struct ([]),struct ([])), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
94 %!assert (isequal (struct ("a",1), struct ("a",1)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
95 %!assert (isequal (struct ("a",1), struct ("a",2)), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
96 %!assert (isequal (struct ("a",1), struct ("b",1)), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
97 %!assert (isequal (struct ("a",1,"b",2), struct ("a",1,"b",2)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
98 %!assert (isequal (struct ("a",1,"b",2), struct ("b",2,"a",1)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
99 %!assert (isequal (struct ("a",1,"b",2), struct ("a",1,"b",2), |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
100 %! struct ("a",1,"b",2)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
101 %!assert (isequal (struct ("a","abc","b",2), struct ("a","abc","b",2)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
102 |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
103 ## recursive structure |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18786
diff
changeset
|
104 %!test |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
105 %! x.a = "a1"; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
106 %! x.b.a = "ba1"; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
107 %! x.b.b = "bb1"; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
108 %! assert (isequal (x, x, x), true); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
109 %! y = x; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
110 %! y.b.b = "bb2"; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
111 %! assert (isequal (x, y), false); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
112 %! y = x; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
113 %! y.b = rmfield (y.b, "b"); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
114 %! y.b.b.a = "bba1"; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
115 %! assert (isequal (x, y), false); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
116 |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
117 ## test cells |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
118 %!assert (isequal (cell (1,1), cell (1,1)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
119 %!assert (isequal (cell (1,1), cell (1,2)), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
120 %!assert (isequal ({"a",1}, {"a",1}), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
121 %!assert (isequal ({"a",1}, {"a",2}), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
122 %!assert (isequal ({"a",1}, {"b",1}), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
123 %!assert (isequal ({"a",1,"b",2}, {"a",1,"b",2}), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
124 %!assert (isequal ({"a",1,"b",2}, {"b",2,"a",1}), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
125 %!assert (isequal ({"a",1,"b",2}, {"a",1,"b",2}, {"a",1,"b",2}), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
126 %!assert (isequal ({"a","abc","b",2}, {"a","abc","b",2}), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
127 %!assert (isequal ({"a","b","c","d"}, {"a","b","c","d"}), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
128 %!assert (isequal ({"a","b","c","d"}, {"a";"b";"c";"d"}), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
129 %!assert (isequal (["a","b","c","d"], {"a","b","c","d"}), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
130 |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
131 ## recursive cell |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
132 %!test |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
133 %! x = cell (1,3); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
134 %! x{1} = {[1], [1 2]}; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
135 %! x{2} = true; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
136 %! x{3} = {{"hello"}, {"world"}}; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
137 %! assert (isequal (x, x)); |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
138 %! y = x; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
139 %! y{3}{1}{1} = "goodbye"; |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
140 %! assert (isequal (x, y), false); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
141 |
17278
79d4b6089968
Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents:
16935
diff
changeset
|
142 ## test for sparse matrices |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
143 %!assert (isequal (sparse ([]), []), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
144 %!assert (isequal ([], sparse ([])), true) |
17278
79d4b6089968
Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents:
16935
diff
changeset
|
145 %!assert (isequal (sparse (0,1), sparse (0,1)), true) |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
146 %!assert (isequal (sparse (0,1), zeros (0,1)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
147 %!assert (isequal (sparse (2,2), sparse (2,2)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
148 %!assert (isequal (zeros (2,2), sparse (2,2)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
149 %!assert (isequal (speye (1), eye (1)), true) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
150 %!assert (isequal (eye (300), speye (300)), true) |
17278
79d4b6089968
Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents:
16935
diff
changeset
|
151 %!assert (isequal (sparse (0,1), sparse (1,0)), false) |
79d4b6089968
Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents:
16935
diff
changeset
|
152 |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
153 ## test NaN |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
154 %!assert (isequal (NaN, NaN), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
155 %!assert (isequal (NaN, Inf), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
156 %!assert (isequal (NaN, 1.0), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
157 %!assert (isequal ([1,2,NaN,4], [1,2,NaN,4]), false) |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18786
diff
changeset
|
158 %!assert (isequal (struct ("a",NaN,"b",2), struct ("a",NaN,"b",2), |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
159 %! struct ("a",NaN,"b",2)), false) |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
160 |
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
161 ## test input validation |
16935
a7b2fc7fe1a9
binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
162 %!error isequal () |
a7b2fc7fe1a9
binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
163 %!error isequal (1) |
18786
ff613b6a7b6f
Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
17744
diff
changeset
|
164 %!error isequal ([1,1]) |