summaryrefslogtreecommitdiffstats
path: root/scilab/modules
diff options
context:
space:
mode:
authorSamuel GOUGEON <sgougeon@free.fr>2020-11-13 01:53:21 +0100
committerClément David <clement.david@esi-group.com>2021-04-28 17:46:20 +0200
commit0dd6b782ada56441259ef3f756ef5ecd0f6b783f (patch)
tree460fd08d8b2cfa5f2d513946e13da7f120e9945c /scilab/modules
parent1c7afa75c642b22f896f7c3373485b79a181e591 (diff)
downloadscilab-0dd6b782ada56441259ef3f756ef5ecd0f6b783f.zip
scilab-0dd6b782ada56441259ef3f756ef5ecd0f6b783f.tar.gz
* Bug 16592 fixed: | and & between complex and boolean or []
http://bugzilla.scilab.org/16592 Change-Id: I6e40de20fcaa68e293c3a36837bca1fa85eaf81b
Diffstat (limited to 'scilab/modules')
-rw-r--r--scilab/modules/ast/tests/unit_tests/and.dia.ref226
-rw-r--r--scilab/modules/ast/tests/unit_tests/and.tst37
-rw-r--r--scilab/modules/ast/tests/unit_tests/or.dia.ref82
-rw-r--r--scilab/modules/ast/tests/unit_tests/or.tst32
-rw-r--r--scilab/modules/overloading/macros/%b_g_s.sci14
-rw-r--r--scilab/modules/overloading/macros/%b_h_s.sci14
-rw-r--r--scilab/modules/overloading/macros/%s_g_s.sci10
-rw-r--r--scilab/modules/overloading/macros/%s_h_b.sci14
-rw-r--r--scilab/modules/overloading/macros/%s_h_s.sci10
9 files changed, 125 insertions, 314 deletions
diff --git a/scilab/modules/ast/tests/unit_tests/and.dia.ref b/scilab/modules/ast/tests/unit_tests/and.dia.ref
deleted file mode 100644
index 9d89abd..0000000
--- a/scilab/modules/ast/tests/unit_tests/and.dia.ref
+++ /dev/null
@@ -1,226 +0,0 @@
1// ============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
4//
5// This file is distributed under the same license as the Scilab package.
6// ============================================================================
7//
8// <-- CLI SHELL MODE -->
9empty = [];
10r = 2;
11R = [1,2;3,4];
12R3(:,:,1) = R;
13R3(:,:,2) = R';
14c = 1 + 2*%i;
15C = [1+2*%i,2+4*%i;3+6*%i,4+8*%i];
16C3(:,:,1) = C;
17C3(:,:,2) = C';
18e = eye();
19ec = (5+%i) * eye();
20p = 1 + %s - %s**2;
21pc = 1 + %s - %s**2 + ( 2 - 3 * %s + 4 * %s**2 ) * %i;
22P = [2*p, -3*p;4*p,-5*p];
23PC = [2*pc, -3*pc;4*pc,-5*pc];
24SP = sparse([1,2;4,5;3,10],[1,2,3]);
25SPC = sparse([1,2;4,5;3,10],[1,2,3]) * ( 1 + 4*%i);
26SPB = sparse([1,2;2,1],[%t;%t],[2,2]);
27i8 = int8(-8);
28ui8 = uint8(8);
29I8 = int8([-8 -16 ; -24 -32]);
30UI8 = uint8([8 16 ; 24 32]);
31I16 = int16([-16 -32 ; -48 -64]);
32UI16 = uint16([16 32 ; 48 64]);
33i16 = int16(-16);
34ui16 = uint16(16);
35i32 = int32(-32);
36ui32 = uint32(32);
37I32 = int32([-32 -64 ; -96 -128]);
38UI32 = uint32([32 64 ; 96 128]);
39str = "string";
40STR = ["string1" "string2";"string3" "string4"];
41b = %f;
42B = [%t %f;%f %t];
43assert_checkequal(empty & empty, []);
44assert_checkequal(empty & r, []);
45assert_checkequal(empty & R, []);
46assert_checkequal(empty & e, []);
47assert_checkequal(empty & b, %f);
48assert_checkequal(empty & B, [%t,%f;%f,%t]);
49assert_checkequal(r & empty, []);
50assert_checkequal(r & r, %t);
51assert_checkequal(r & R, [%t,%t;%t,%t]);
52assert_checkequal(r & e, %t);
53assert_checkequal(r & b, %f);
54assert_checkequal(r & B, [%t,%f;%f,%t]);
55assert_checkequal(R & empty, []);
56assert_checkequal(R & r, [%t,%t;%t,%t]);
57assert_checkequal(R & R, [%t,%t;%t,%t]);
58assert_checkequal(R & e, [%t,%t;%t,%t]);
59assert_checkequal(R & b, [%f,%f;%f,%f]);
60assert_checkequal(R & B, [%t,%f;%f,%t]);
61assert_checkequal(e & empty, []);
62assert_checkequal(e & r, %t);
63assert_checkequal(e & R, [%t,%t;%t,%t]);
64assert_checkequal(e & b, %f);
65assert_checkequal(e & B, [%t,%f;%f,%t]);
66assert_checkequal(b & empty, %f);
67assert_checkequal(b & r, %f);
68assert_checkequal(b & R, [%f,%f;%f,%f]);
69assert_checkequal(b & e, %f);
70assert_checkequal(b & b, %f);
71assert_checkequal(b & B, [%f,%f;%f,%f]);
72assert_checkequal(b & SPB, sparse([1,1], [%f], [2, 2]));
73assert_checkequal(B & empty, [%t,%f;%f,%t]);
74assert_checkequal(B & r, [%t,%f;%f,%t]);
75assert_checkequal(B & R, [%t,%f;%f,%t]);
76assert_checkequal(B & e, [%t,%f;%f,%t]);
77assert_checkequal(B & b, [%f,%f;%f,%f]);
78assert_checkequal(B & B, [%t,%f;%f,%t]);
79assert_checkequal(B & SPB, sparse([1,1], [%f], [2, 2]));
80assert_checkequal(SPB & b, sparse([1,1], [%f], [2, 2]));
81assert_checkequal(SPB & B, sparse([1,1], [%f], [2, 2]));
82assert_checkequal(SPB & SPB, sparse([1,2;2,1],[%t;%t],[2,2]));
83assert_checkequal(i8 & i8, int8(-8));
84assert_checkequal(i8 & I8, int8([-8,-16;-24,-32]));
85assert_checkequal(i8 & ui8, uint8(8));
86assert_checkequal(i8 & UI8, uint8([8,16;24,32]));
87assert_checkequal(i8 & i16, int16(-16));
88assert_checkequal(i8 & I16, int16([-16,-32;-48,-64]));
89assert_checkequal(i8 & ui16, uint16(16));
90assert_checkequal(i8 & UI16, uint16([16,32;48,64]));
91assert_checkequal(i8 & i32, int32(-32));
92assert_checkequal(i8 & I32, int32([-32,-64;-96,-128]));
93assert_checkequal(i8 & ui32, uint32(32));
94assert_checkequal(i8 & UI32, uint32([32,64;96,128]));
95assert_checkequal(I8 & i8, int8([-8,-16;-24,-32]));
96assert_checkequal(I8 & I8, int8([-8,-16;-24,-32]));
97assert_checkequal(I8 & ui8, uint8([8,0;8,0]));
98assert_checkequal(I8 & UI8, uint8([8,16;8,32]));
99assert_checkequal(I8 & i16, int16([-16,-16;-32,-32]));
100assert_checkequal(I8 & I16, int16([-16,-32;-64,-64]));
101assert_checkequal(I8 & ui16, uint16([16,16;0,0]));
102assert_checkequal(I8 & UI16, uint16([16,32;32,64]));
103assert_checkequal(I8 & i32, int32([-32,-32;-32,-32]));
104assert_checkequal(I8 & I32, int32([-32,-64;-96,-128]));
105assert_checkequal(I8 & ui32, uint32([32,32;32,32]));
106assert_checkequal(I8 & UI32, uint32([32,64;96,128]));
107assert_checkequal(ui8 & i8, uint8(8));
108assert_checkequal(ui8 & I8, uint8([8,0;8,0]));
109assert_checkequal(ui8 & ui8, uint8(8));
110assert_checkequal(ui8 & UI8, uint8([8,0;8,0]));
111assert_checkequal(ui8 & i16, uint16(0));
112assert_checkequal(ui8 & I16, uint16([0,0;0,0]));
113assert_checkequal(ui8 & ui16, uint16(0));
114assert_checkequal(ui8 & UI16, uint16([0,0;0,0]));
115assert_checkequal(ui8 & i32, uint32(0));
116assert_checkequal(ui8 & I32, uint32([0,0;0,0]));
117assert_checkequal(ui8 & ui32, uint32(0));
118assert_checkequal(ui8 & UI32, uint32([0,0;0,0]));
119assert_checkequal(UI8 & i8, uint8([8,16;24,32]));
120assert_checkequal(UI8 & I8, uint8([8,16;8,32]));
121assert_checkequal(UI8 & ui8, uint8([8,0;8,0]));
122assert_checkequal(UI8 & UI8, uint8([8,16;24,32]));
123assert_checkequal(UI8 & i16, uint16([0,16;16,32]));
124assert_checkequal(UI8 & I16, uint16([0,0;16,0]));
125assert_checkequal(UI8 & ui16, uint16([0,16;16,0]));
126assert_checkequal(UI8 & UI16, uint16([0,0;16,0]));
127assert_checkequal(UI8 & i32, uint32([0,0;0,32]));
128assert_checkequal(UI8 & I32, uint32([0,0;0,0]));
129assert_checkequal(UI8 & ui32, uint32([0,0;0,32]));
130assert_checkequal(UI8 & UI32, uint32([0,0;0,0]));
131assert_checkequal(i16 & i8, int16(-16));
132assert_checkequal(i16 & I8, int16([-16,-16;-32,-32]));
133assert_checkequal(i16 & ui8, uint16(0));
134assert_checkequal(i16 & UI8, uint16([0,16;16,32]));
135assert_checkequal(i16 & i16, int16(-16));
136assert_checkequal(i16 & I16, int16([-16,-32;-48,-64]));
137assert_checkequal(i16 & ui16, uint16(16));
138assert_checkequal(i16 & UI16, uint16([16,32;48,64]));
139assert_checkequal(i16 & i32, int32(-32));
140assert_checkequal(i16 & I32, int32([-32,-64;-96,-128]));
141assert_checkequal(i16 & ui32, uint32(32));
142assert_checkequal(i16 & UI32, uint32([32,64;96,128]));
143assert_checkequal(I16 & i8, int16([-16,-32;-48,-64]));
144assert_checkequal(I16 & I8, int16([-16,-32;-64,-64]));
145assert_checkequal(I16 & ui8, uint16([0,0;0,0]));
146assert_checkequal(I16 & UI8, uint16([0,0;16,0]));
147assert_checkequal(I16 & i16, int16([-16,-32;-48,-64]));
148assert_checkequal(I16 & I16, int16([-16,-32;-48,-64]));
149assert_checkequal(I16 & ui16, uint16([16,0;16,0]));
150assert_checkequal(I16 & UI16, uint16([16,32;16,64]));
151assert_checkequal(I16 & i32, int32([-32,-32;-64,-64]));
152assert_checkequal(I16 & I32, int32([-32,-64;-128,-128]));
153assert_checkequal(I16 & ui32, uint32([32,32;0,0]));
154assert_checkequal(I16 & UI32, uint32([32,64;64,128]));
155assert_checkequal(ui16 & i8, uint16(16));
156assert_checkequal(ui16 & I8, uint16([16,16;0,0]));
157assert_checkequal(ui16 & ui8, uint16(0));
158assert_checkequal(ui16 & UI8, uint16([0,16;16,0]));
159assert_checkequal(ui16 & i16, uint16(16));
160assert_checkequal(ui16 & I16, uint16([16,0;16,0]));
161assert_checkequal(ui16 & ui16, uint16(16));
162assert_checkequal(ui16 & UI16, uint16([16,0;16,0]));
163assert_checkequal(ui16 & i32, uint32(0));
164assert_checkequal(ui16 & I32, uint32([0,0;0,0]));
165assert_checkequal(ui16 & ui32, uint32(0));
166assert_checkequal(ui16 & UI32, uint32([0,0;0,0]));
167assert_checkequal(UI16 & i8, uint16([16,32;48,64]));
168assert_checkequal(UI16 & I8, uint16([16,32;32,64]));
169assert_checkequal(UI16 & ui8, uint16([0,0;0,0]));
170assert_checkequal(UI16 & UI8, uint16([0,0;16,0]));
171assert_checkequal(UI16 & i16, uint16([16,32;48,64]));
172assert_checkequal(UI16 & I16, uint16([16,32;16,64]));
173assert_checkequal(UI16 & ui16, uint16([16,0;16,0]));
174assert_checkequal(UI16 & UI16, uint16([16,32;48,64]));
175assert_checkequal(UI16 & i32, uint32([0,32;32,64]));
176assert_checkequal(UI16 & I32, uint32([0,0;32,0]));
177assert_checkequal(UI16 & ui32, uint32([0,32;32,0]));
178assert_checkequal(UI16 & UI32, uint32([0,0;32,0]));
179assert_checkequal(i32 & i8, int32(-32));
180assert_checkequal(i32 & I8, int32([-32,-32;-32,-32]));
181assert_checkequal(i32 & ui8, uint32(0));
182assert_checkequal(i32 & UI8, uint32([0,0;0,32]));
183assert_checkequal(i32 & i16, int32(-32));
184assert_checkequal(i32 & I16, int32([-32,-32;-64,-64]));
185assert_checkequal(i32 & ui16, uint32(0));
186assert_checkequal(i32 & UI16, uint32([0,32;32,64]));
187assert_checkequal(i32 & i32, int32(-32));
188assert_checkequal(i32 & I32, int32([-32,-64;-96,-128]));
189assert_checkequal(i32 & ui32, uint32(32));
190assert_checkequal(i32 & UI32, uint32([32,64;96,128]));
191assert_checkequal(I32 & i8, int32([-32,-64;-96,-128]));
192assert_checkequal(I32 & I8, int32([-32,-64;-96,-128]));
193assert_checkequal(I32 & ui8, uint32([0,0;0,0]));
194assert_checkequal(I32 & UI8, uint32([0,0;0,0]));
195assert_checkequal(I32 & i16, int32([-32,-64;-96,-128]));
196assert_checkequal(I32 & I16, int32([-32,-64;-128,-128]));
197assert_checkequal(I32 & ui16, uint32([0,0;0,0]));
198assert_checkequal(I32 & UI16, uint32([0,0;32,0]));
199assert_checkequal(I32 & i32, int32([-32,-64;-96,-128]));
200assert_checkequal(I32 & I32, int32([-32,-64;-96,-128]));
201assert_checkequal(I32 & ui32, uint32([32,0;32,0]));
202assert_checkequal(I32 & UI32, uint32([32,64;32,128]));
203assert_checkequal(ui32 & i8, uint32(32));
204assert_checkequal(ui32 & I8, uint32([32,32;32,32]));
205assert_checkequal(ui32 & ui8, uint32(0));
206assert_checkequal(ui32 & UI8, uint32([0,0;0,32]));
207assert_checkequal(ui32 & i16, uint32(32));
208assert_checkequal(ui32 & I16, uint32([32,32;0,0]));
209assert_checkequal(ui32 & ui16, uint32(0));
210assert_checkequal(ui32 & UI16, uint32([0,32;32,0]));
211assert_checkequal(ui32 & i32, uint32(32));
212assert_checkequal(ui32 & I32, uint32([32,0;32,0]));
213assert_checkequal(ui32 & ui32, uint32(32));
214assert_checkequal(ui32 & UI32, uint32([32,0;32,0]));
215assert_checkequal(UI32 & i8, uint32([32,64;96,128]));
216assert_checkequal(UI32 & I8, uint32([32,64;96,128]));
217assert_checkequal(UI32 & ui8, uint32([0,0;0,0]));
218assert_checkequal(UI32 & UI8, uint32([0,0;0,0]));
219assert_checkequal(UI32 & i16, uint32([32,64;96,128]));
220assert_checkequal(UI32 & I16, uint32([32,64;64,128]));
221assert_checkequal(UI32 & ui16, uint32([0,0;0,0]));
222assert_checkequal(UI32 & UI16, uint32([0,0;32,0]));
223assert_checkequal(UI32 & i32, uint32([32,64;96,128]));
224assert_checkequal(UI32 & I32, uint32([32,64;32,128]));
225assert_checkequal(UI32 & ui32, uint32([32,0;32,0]));
226assert_checkequal(UI32 & UI32, uint32([32,64;96,128]));
diff --git a/scilab/modules/ast/tests/unit_tests/and.tst b/scilab/modules/ast/tests/unit_tests/and.tst
index 3e6c624..2523443 100644
--- a/scilab/modules/ast/tests/unit_tests/and.tst
+++ b/scilab/modules/ast/tests/unit_tests/and.tst
@@ -1,11 +1,18 @@
1// ============================================================================ 1// ============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS 3// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
4// Copyright (C) 2020 - Samuel GOUGEON
4// 5//
5// This file is distributed under the same license as the Scilab package. 6// This file is distributed under the same license as the Scilab package.
6// ============================================================================ 7// ============================================================================
7// 8//
8// <-- CLI SHELL MODE --> 9// <-- CLI SHELL MODE -->
10// <-- NO CHECK REF -->
11//
12// <-- Short Description -->
13// Unitary tests of the & operator
14//
15// See also: or_and.tst
9 16
10empty = []; 17empty = [];
11r = 2; 18r = 2;
@@ -50,6 +57,8 @@ B = [%t %f;%f %t];
50assert_checkequal(empty & empty, []); 57assert_checkequal(empty & empty, []);
51assert_checkequal(empty & r, []); 58assert_checkequal(empty & r, []);
52assert_checkequal(empty & R, []); 59assert_checkequal(empty & R, []);
60assert_checkequal(empty & c, []);
61assert_checkequal(empty & C, []);
53assert_checkequal(empty & e, []); 62assert_checkequal(empty & e, []);
54assert_checkequal(empty & b, %f); 63assert_checkequal(empty & b, %f);
55assert_checkequal(empty & B, [%t,%f;%f,%t]); 64assert_checkequal(empty & B, [%t,%f;%f,%t]);
@@ -57,6 +66,8 @@ assert_checkequal(empty & B, [%t,%f;%f,%t]);
57assert_checkequal(r & empty, []); 66assert_checkequal(r & empty, []);
58assert_checkequal(r & r, %t); 67assert_checkequal(r & r, %t);
59assert_checkequal(r & R, [%t,%t;%t,%t]); 68assert_checkequal(r & R, [%t,%t;%t,%t]);
69assert_checkequal(r & c, %t);
70assert_checkequal(r & C, [%t,%t;%t,%t]);
60assert_checkequal(r & e, %t); 71assert_checkequal(r & e, %t);
61assert_checkequal(r & b, %f); 72assert_checkequal(r & b, %f);
62assert_checkequal(r & B, [%t,%f;%f,%t]); 73assert_checkequal(r & B, [%t,%f;%f,%t]);
@@ -64,19 +75,43 @@ assert_checkequal(r & B, [%t,%f;%f,%t]);
64assert_checkequal(R & empty, []); 75assert_checkequal(R & empty, []);
65assert_checkequal(R & r, [%t,%t;%t,%t]); 76assert_checkequal(R & r, [%t,%t;%t,%t]);
66assert_checkequal(R & R, [%t,%t;%t,%t]); 77assert_checkequal(R & R, [%t,%t;%t,%t]);
78assert_checkequal(R & c, [%t,%t;%t,%t]);
79assert_checkequal(R & C, [%t,%t;%t,%t]);
67assert_checkequal(R & e, [%t,%t;%t,%t]); 80assert_checkequal(R & e, [%t,%t;%t,%t]);
68assert_checkequal(R & b, [%f,%f;%f,%f]); 81assert_checkequal(R & b, [%f,%f;%f,%f]);
69assert_checkequal(R & B, [%t,%f;%f,%t]); 82assert_checkequal(R & B, [%t,%f;%f,%t]);
70 83
84assert_checkequal(c & empty, []);
85assert_checkequal(c & r, %t);
86assert_checkequal(c & R, [%t,%t;%t,%t]);
87assert_checkequal(c & c, %t);
88assert_checkequal(c & C, [%t,%t;%t,%t]);
89assert_checkequal(c & e, %t);
90assert_checkequal(c & b, %f);
91assert_checkequal(c & B, [%t,%f;%f,%t]);
92
93assert_checkequal(C & empty, []);
94assert_checkequal(C & r, [%t,%t;%t,%t]);
95assert_checkequal(C & R, [%t,%t;%t,%t]);
96assert_checkequal(C & c, [%t,%t;%t,%t]);
97assert_checkequal(C & C, [%t,%t;%t,%t]);
98assert_checkequal(C & e, [%t,%t;%t,%t]);
99assert_checkequal(C & b, [%f,%f;%f,%f]);
100assert_checkequal(C & B, [%t,%f;%f,%t]);
101
71assert_checkequal(e & empty, []); 102assert_checkequal(e & empty, []);
72assert_checkequal(e & r, %t); 103assert_checkequal(e & r, %t);
73assert_checkequal(e & R, [%t,%t;%t,%t]); 104assert_checkequal(e & R, [%t,%t;%t,%t]);
105assert_checkequal(e & c, %t);
106assert_checkequal(e & C, [%t,%t;%t,%t]);
74assert_checkequal(e & b, %f); 107assert_checkequal(e & b, %f);
75assert_checkequal(e & B, [%t,%f;%f,%t]); 108assert_checkequal(e & B, [%t,%f;%f,%t]);
76 109
77assert_checkequal(b & empty, %f); 110assert_checkequal(b & empty, %f);
78assert_checkequal(b & r, %f); 111assert_checkequal(b & r, %f);
79assert_checkequal(b & R, [%f,%f;%f,%f]); 112assert_checkequal(b & R, [%f,%f;%f,%f]);
113assert_checkequal(b & c, %f);
114assert_checkequal(b & C, [%f,%f;%f,%f]);
80assert_checkequal(b & e, %f); 115assert_checkequal(b & e, %f);
81assert_checkequal(b & b, %f); 116assert_checkequal(b & b, %f);
82assert_checkequal(b & B, [%f,%f;%f,%f]); 117assert_checkequal(b & B, [%f,%f;%f,%f]);
@@ -85,6 +120,8 @@ assert_checkequal(b & SPB, sparse([1,1], [%f], [2, 2]));
85assert_checkequal(B & empty, [%t,%f;%f,%t]); 120assert_checkequal(B & empty, [%t,%f;%f,%t]);
86assert_checkequal(B & r, [%t,%f;%f,%t]); 121assert_checkequal(B & r, [%t,%f;%f,%t]);
87assert_checkequal(B & R, [%t,%f;%f,%t]); 122assert_checkequal(B & R, [%t,%f;%f,%t]);
123assert_checkequal(B & c, [%t,%f;%f,%t]);
124assert_checkequal(B & C, [%t,%f;%f,%t]);
88assert_checkequal(B & e, [%t,%f;%f,%t]); 125assert_checkequal(B & e, [%t,%f;%f,%t]);
89assert_checkequal(B & b, [%f,%f;%f,%f]); 126assert_checkequal(B & b, [%f,%f;%f,%f]);
90assert_checkequal(B & B, [%t,%f;%f,%t]); 127assert_checkequal(B & B, [%t,%f;%f,%t]);
diff --git a/scilab/modules/ast/tests/unit_tests/or.dia.ref b/scilab/modules/ast/tests/unit_tests/or.dia.ref
deleted file mode 100644
index e9f89a7..0000000
--- a/scilab/modules/ast/tests/unit_tests/or.dia.ref
+++ /dev/null
@@ -1,82 +0,0 @@
1// ============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
4//
5// This file is distributed under the same license as the Scilab package.
6// ============================================================================
7//
8// <-- CLI SHELL MODE -->
9empty = [];
10r = 2;
11R = [1,2;3,4];
12R3(:,:,1) = R;
13R3(:,:,2) = R';
14c = 1 + 2*%i;
15C = [1+2*%i,2+4*%i;3+6*%i,4+8*%i];
16C3(:,:,1) = C;
17C3(:,:,2) = C';
18e = eye();
19ec = (5+%i) * eye();
20p = 1 + %s - %s**2;
21pc = 1 + %s - %s**2 + ( 2 - 3 * %s + 4 * %s**2 ) * %i;
22P = [2*p, -3*p;4*p,-5*p];
23PC = [2*pc, -3*pc;4*pc,-5*pc];
24SP = sparse([1,2;4,5;3,10],[1,2,3]);
25SPC = sparse([1,2;4,5;3,10],[1,2,3]) * ( 1 + 4*%i);
26SPB = sparse([1,2;2,1],[%t;%t],[2,2]);
27i8 = int8(-8);
28ui8 = uint8(8);
29I8 = int8([-8 -16 ; -24 -32]);
30UI8 = uint8([8 16 ; 24 32]);
31I16 = int16([-16 -32 ; -48 -64]);
32UI16 = uint16([16 32 ; 48 64]);
33i16 = int16(-16);
34ui16 = uint16(16);
35i32 = int32(-32);
36ui32 = uint32(32);
37I32 = int32([-32 -64 ; -96 -128]);
38UI32 = uint32([32 64 ; 96 128]);
39str = "string";
40STR = ["string1" "string2";"string3" "string4"];
41b = %f;
42B = [%t %f;%f %t];
43assert_checkequal(empty | empty, []);
44assert_checkequal(empty | r, []);
45assert_checkequal(empty | R, []);
46assert_checkequal(empty | e, []);
47assert_checkequal(empty | b, %t);
48assert_checkequal(empty | B, [%t %t;%t %t]);
49assert_checkequal(r | empty, []);
50assert_checkequal(r | r, %t);
51assert_checkequal(r | R, [%t,%t;%t,%t]);
52assert_checkequal(r | e, %t);
53assert_checkequal(r | b, %t);
54assert_checkequal(r | B, [%t,%t;%t,%t]);
55assert_checkequal(R | empty, []);
56assert_checkequal(R | r, [%t,%t;%t,%t]);
57assert_checkequal(R | R, [%t,%t;%t,%t]);
58assert_checkequal(R | e, [%t,%t;%t,%t]);
59assert_checkequal(R | b, [%t,%t;%t,%t]);
60assert_checkequal(R | B, [%t,%t;%t,%t]);
61assert_checkequal(e | empty, []);
62assert_checkequal(e | r, %t);
63assert_checkequal(e | R, [%t,%t;%t,%t]);
64assert_checkequal(e | b, %t);
65assert_checkequal(e | B, [%t,%t;%t,%t]);
66assert_checkequal(b | empty, %t);
67assert_checkequal(b | r, %t);
68assert_checkequal(b | R, [%t,%t;%t,%t]);
69assert_checkequal(b | e, %t);
70assert_checkequal(b | b, %f);
71assert_checkequal(b | B, [%t,%f;%f,%t]);
72assert_checkequal(b | SPB, sparse([1,2;2,1],[%t;%t],[2,2]));
73assert_checkequal(B | empty, [%t,%t;%t,%t]);
74assert_checkequal(B | r, [%t,%t;%t,%t]);
75assert_checkequal(B | R, [%t,%t;%t,%t]);
76assert_checkequal(B | e, [%t,%t;%t,%t]);
77assert_checkequal(B | b, [%t,%f;%f,%t]);
78assert_checkequal(B | B, [%t,%f;%f,%t]);
79assert_checkequal(B | SPB, sparse([1,1;1,2;2,1;2,2],[%t;%t;%t;%t],[2,2]));
80assert_checkequal(SPB | b, sparse([1,2;2,1],[%t;%t],[2,2]));
81assert_checkequal(SPB | B, sparse([1,1;1,2;2,1;2,2],[%t;%t;%t;%t],[2,2]));
82assert_checkequal(SPB | SPB, sparse([1,2;2,1],[%t;%t],[2,2]));
diff --git a/scilab/modules/ast/tests/unit_tests/or.tst b/scilab/modules/ast/tests/unit_tests/or.tst
index 5e0d2cc..f3bb35f 100644
--- a/scilab/modules/ast/tests/unit_tests/or.tst
+++ b/scilab/modules/ast/tests/unit_tests/or.tst
@@ -1,11 +1,13 @@
1// ============================================================================ 1// ============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS 3// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
4// Copyright (C) 2020 - Samuel GOUGEON
4// 5//
5// This file is distributed under the same license as the Scilab package. 6// This file is distributed under the same license as the Scilab package.
6// ============================================================================ 7// ============================================================================
7// 8//
8// <-- CLI SHELL MODE --> 9// <-- CLI SHELL MODE -->
10// <-- NO CHECK REF -->
9 11
10empty = []; 12empty = [];
11r = 2; 13r = 2;
@@ -51,6 +53,8 @@ B = [%t %f;%f %t];
51assert_checkequal(empty | empty, []); 53assert_checkequal(empty | empty, []);
52assert_checkequal(empty | r, []); 54assert_checkequal(empty | r, []);
53assert_checkequal(empty | R, []); 55assert_checkequal(empty | R, []);
56assert_checkequal(empty | c, []);
57assert_checkequal(empty | C, []);
54assert_checkequal(empty | e, []); 58assert_checkequal(empty | e, []);
55assert_checkequal(empty | b, %t); 59assert_checkequal(empty | b, %t);
56assert_checkequal(empty | B, [%t %t;%t %t]); 60assert_checkequal(empty | B, [%t %t;%t %t]);
@@ -58,6 +62,8 @@ assert_checkequal(empty | B, [%t %t;%t %t]);
58assert_checkequal(r | empty, []); 62assert_checkequal(r | empty, []);
59assert_checkequal(r | r, %t); 63assert_checkequal(r | r, %t);
60assert_checkequal(r | R, [%t,%t;%t,%t]); 64assert_checkequal(r | R, [%t,%t;%t,%t]);
65assert_checkequal(r | c, %t);
66assert_checkequal(r | C, [%t,%t;%t,%t]);
61assert_checkequal(r | e, %t); 67assert_checkequal(r | e, %t);
62assert_checkequal(r | b, %t); 68assert_checkequal(r | b, %t);
63assert_checkequal(r | B, [%t,%t;%t,%t]); 69assert_checkequal(r | B, [%t,%t;%t,%t]);
@@ -65,19 +71,43 @@ assert_checkequal(r | B, [%t,%t;%t,%t]);
65assert_checkequal(R | empty, []); 71assert_checkequal(R | empty, []);
66assert_checkequal(R | r, [%t,%t;%t,%t]); 72assert_checkequal(R | r, [%t,%t;%t,%t]);
67assert_checkequal(R | R, [%t,%t;%t,%t]); 73assert_checkequal(R | R, [%t,%t;%t,%t]);
74assert_checkequal(R | c, [%t,%t;%t,%t]);
75assert_checkequal(R | C, [%t,%t;%t,%t]);
68assert_checkequal(R | e, [%t,%t;%t,%t]); 76assert_checkequal(R | e, [%t,%t;%t,%t]);
69assert_checkequal(R | b, [%t,%t;%t,%t]); 77assert_checkequal(R | b, [%t,%t;%t,%t]);
70assert_checkequal(R | B, [%t,%t;%t,%t]); 78assert_checkequal(R | B, [%t,%t;%t,%t]);
71 79
80assert_checkequal(c | empty, []);
81assert_checkequal(c | r, %t);
82assert_checkequal(c | R, [%t,%t;%t,%t]);
83assert_checkequal(c | c, %t);
84assert_checkequal(c | C, [%t,%t;%t,%t]);
85assert_checkequal(c | e, %t);
86assert_checkequal(c | b, %t);
87assert_checkequal(c | B, [%t,%t;%t,%t]);
88
89assert_checkequal(C | empty, []);
90assert_checkequal(C | r, [%t,%t;%t,%t]);
91assert_checkequal(C | R, [%t,%t;%t,%t]);
92assert_checkequal(C | c, [%t,%t;%t,%t]);
93assert_checkequal(C | C, [%t,%t;%t,%t]);
94assert_checkequal(C | e, [%t,%t;%t,%t]);
95assert_checkequal(C | b, [%t,%t;%t,%t]);
96assert_checkequal(C | B, [%t,%t;%t,%t]);
97
72assert_checkequal(e | empty, []); 98assert_checkequal(e | empty, []);
73assert_checkequal(e | r, %t); 99assert_checkequal(e | r, %t);
74assert_checkequal(e | R, [%t,%t;%t,%t]); 100assert_checkequal(e | R, [%t,%t;%t,%t]);
101assert_checkequal(e | c, %t);
102assert_checkequal(e | C, [%t,%t;%t,%t]);
75assert_checkequal(e | b, %t); 103assert_checkequal(e | b, %t);
76assert_checkequal(e | B, [%t,%t;%t,%t]); 104assert_checkequal(e | B, [%t,%t;%t,%t]);
77 105
78assert_checkequal(b | empty, %t); 106assert_checkequal(b | empty, %t);
79assert_checkequal(b | r, %t); 107assert_checkequal(b | r, %t);
80assert_checkequal(b | R, [%t,%t;%t,%t]); 108assert_checkequal(b | R, [%t,%t;%t,%t]);
109assert_checkequal(b | c, %t);
110assert_checkequal(b | C, [%t,%t;%t,%t]);
81assert_checkequal(b | e, %t); 111assert_checkequal(b | e, %t);
82assert_checkequal(b | b, %f); 112assert_checkequal(b | b, %f);
83assert_checkequal(b | B, [%t,%f;%f,%t]); 113assert_checkequal(b | B, [%t,%f;%f,%t]);
@@ -86,6 +116,8 @@ assert_checkequal(b | SPB, sparse([1,2;2,1],[%t;%t],[2,2]));
86assert_checkequal(B | empty, [%t,%t;%t,%t]); 116assert_checkequal(B | empty, [%t,%t;%t,%t]);
87assert_checkequal(B | r, [%t,%t;%t,%t]); 117assert_checkequal(B | r, [%t,%t;%t,%t]);
88assert_checkequal(B | R, [%t,%t;%t,%t]); 118assert_checkequal(B | R, [%t,%t;%t,%t]);
119assert_checkequal(B | c, [%t,%t;%t,%t]);
120assert_checkequal(B | C, [%t,%t;%t,%t]);
89assert_checkequal(B | e, [%t,%t;%t,%t]); 121assert_checkequal(B | e, [%t,%t;%t,%t]);
90assert_checkequal(B | b, [%t,%f;%f,%t]); 122assert_checkequal(B | b, [%t,%f;%f,%t]);
91assert_checkequal(B | B, [%t,%f;%f,%t]); 123assert_checkequal(B | B, [%t,%f;%f,%t]);
diff --git a/scilab/modules/overloading/macros/%b_g_s.sci b/scilab/modules/overloading/macros/%b_g_s.sci
new file mode 100644
index 0000000..97491a1
--- /dev/null
+++ b/scilab/modules/overloading/macros/%b_g_s.sci
@@ -0,0 +1,14 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2020 - Samuel GOUGEON
3//
4// This file is hereby licensed under the terms of the GNU GPL v2.0,
5// pursuant to article 5.3.4 of the CeCILL v.2.1.
6// This file was originally licensed under the terms of the CeCILL v2.1,
7// and continues to be available under such terms.
8// For more information, see the COPYING file which you should have received
9// along with this program.
10
11function res = %b_g_s(b1, s2)
12 // bool | complex
13 res = b1 | (s2<>0);
14endfunction
diff --git a/scilab/modules/overloading/macros/%b_h_s.sci b/scilab/modules/overloading/macros/%b_h_s.sci
new file mode 100644
index 0000000..4f7526a
--- /dev/null
+++ b/scilab/modules/overloading/macros/%b_h_s.sci
@@ -0,0 +1,14 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2020 - Samuel GOUGEON
3//
4// This file is hereby licensed under the terms of the GNU GPL v2.0,
5// pursuant to article 5.3.4 of the CeCILL v.2.1.
6// This file was originally licensed under the terms of the CeCILL v2.1,
7// and continues to be available under such terms.
8// For more information, see the COPYING file which you should have received
9// along with this program.
10
11function res = %b_h_s(b1, s2)
12 // boolean & complex
13 res = b1 & (s2<>0);
14endfunction
diff --git a/scilab/modules/overloading/macros/%s_g_s.sci b/scilab/modules/overloading/macros/%s_g_s.sci
index 3b986b3..bde6995 100644
--- a/scilab/modules/overloading/macros/%s_g_s.sci
+++ b/scilab/modules/overloading/macros/%s_g_s.sci
@@ -1,8 +1,8 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) INRIA 2// Copyright (C) INRIA
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises 3// Copyright (C) 2012 - 2016 - Scilab Enterprises
5// Copyright (C) 2016 - Scilab Enterprises - Pierre-Aimé AGNEL 4// Copyright (C) 2016 - Scilab Enterprises - Pierre-Aimé AGNEL
5// Copyright (C) 2020 - Samuel GOUGEON
6// 6//
7// This file is hereby licensed under the terms of the GNU GPL v2.0, 7// This file is hereby licensed under the terms of the GNU GPL v2.0,
8// pursuant to article 5.3.4 of the CeCILL v.2.1. 8// pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -11,7 +11,11 @@
11// For more information, see the COPYING file which you should have received 11// For more information, see the COPYING file which you should have received
12// along with this program. 12// along with this program.
13 13
14function res=%s_g_s(s1,s2) 14function res = %s_g_s(s1,s2)
15 // Logical operand on complex numbers 15 // Logical operand on complex numbers
16 res = (s1<>0) | (s2<>0); 16 if s1==[] | s2==[] then
17 res = []
18 else
19 res = (s1<>0) | (s2<>0);
20 end
17endfunction 21endfunction
diff --git a/scilab/modules/overloading/macros/%s_h_b.sci b/scilab/modules/overloading/macros/%s_h_b.sci
new file mode 100644
index 0000000..f46e9b2
--- /dev/null
+++ b/scilab/modules/overloading/macros/%s_h_b.sci
@@ -0,0 +1,14 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2020 - Samuel GOUGEON
3//
4// This file is hereby licensed under the terms of the GNU GPL v2.0,
5// pursuant to article 5.3.4 of the CeCILL v.2.1.
6// This file was originally licensed under the terms of the CeCILL v2.1,
7// and continues to be available under such terms.
8// For more information, see the COPYING file which you should have received
9// along with this program.
10
11function res = %s_h_b(s1, b2)
12 // complex & boolean
13 res = (s1<>0) & b2;
14endfunction
diff --git a/scilab/modules/overloading/macros/%s_h_s.sci b/scilab/modules/overloading/macros/%s_h_s.sci
index 7b7ef39..0106355 100644
--- a/scilab/modules/overloading/macros/%s_h_s.sci
+++ b/scilab/modules/overloading/macros/%s_h_s.sci
@@ -1,8 +1,8 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) INRIA 2// Copyright (C) INRIA
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises 3// Copyright (C) 2012 - 2016 - Scilab Enterprises
5// Copyright (C) 2016 - Scilab Enterprises - Pierre-Aimé AGNEL 4// Copyright (C) 2016 - Scilab Enterprises - Pierre-Aimé AGNEL
5// Copyright (C) 2020 - Samuel GOUGEON
6// 6//
7// This file is hereby licensed under the terms of the GNU GPL v2.0, 7// This file is hereby licensed under the terms of the GNU GPL v2.0,
8// pursuant to article 5.3.4 of the CeCILL v.2.1. 8// pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -11,7 +11,11 @@
11// For more information, see the COPYING file which you should have received 11// For more information, see the COPYING file which you should have received
12// along with this program. 12// along with this program.
13 13
14function res=%s_h_s(s1,s2) 14function res = %s_h_s(s1,s2)
15 // Logical operand on complex numbers 15 // Logical operand on complex numbers
16 res = (s1<>0) & (s2<>0); 16 if s1==[] | s2==[] then
17 res = []
18 else
19 res = (s1<>0) & (s2<>0);
20 end
17endfunction 21endfunction