Skip to content

Commit be57361

Browse files
author
MarkBaker
committed
Additional unit tests for array/scalar operations
1 parent 5ea78ae commit be57361

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public function providerArrayArithmetic(): array
9393
'={2,3} + {4;5}',
9494
[[6, 7], [7, 8]],
9595
],
96+
'Addition: square matrix 2x2 + scalar' => [
97+
'={1,2;3,4} + 1',
98+
[[2, 3], [4, 5]],
99+
],
96100
'Addition: square matrix 2x2 + 2x2' => [
97101
'={1,2;3,4} + {-2,4;-6,8}',
98102
[[-1, 6], [-3, 12]],
@@ -126,6 +130,10 @@ public function providerArrayArithmetic(): array
126130
'={2,3} - {4;5}',
127131
[[-2, -1], [-3, -2]],
128132
],
133+
'Subtraction: square matrix 2x2 - scalar' => [
134+
'={1,2;3,4} - 1',
135+
[[0, 1], [2, 3]],
136+
],
129137
'Subtraction: square matrix 2x2 - 2x2' => [
130138
'={1,2;3,4} - {-2,4;-6,8}',
131139
[[3, -2], [9, -4]],
@@ -159,6 +167,10 @@ public function providerArrayArithmetic(): array
159167
'={1,2;3,4} * {-2,4;-6,8}',
160168
[[-2, 8], [-18, 32]],
161169
],
170+
'Multiplication: square matrix 2x2 * scalar' => [
171+
'={1,2;3,4} * 2',
172+
[[2, 4], [6, 8]],
173+
],
162174
'Multiplication: row vector * row vector' => [
163175
'={1,2,3} * {4,5,6}',
164176
[[4, 10, 18]],
@@ -192,6 +204,10 @@ public function providerArrayArithmetic(): array
192204
'={1,2;3,4} / {-2,4;-6,8}',
193205
[[-0.5, 0.5], [-0.5, 0.5]],
194206
],
207+
'Division: square matrix 2x2 / scalar' => [
208+
'={1,2;3,4} / 0.5',
209+
[[2, 4], [6, 8]],
210+
],
195211
'Division: row vector / row vector' => [
196212
'={1,2,3} / {4,5,6}',
197213
[[0.25, 0.4, 0.5]],
@@ -225,6 +241,10 @@ public function providerArrayArithmetic(): array
225241
'={1,2;3,4} ^ {-2,4;-6,8}',
226242
[[1, 16], [0.00137174211248, 65536]],
227243
],
244+
'Power: square matrix 2x2 ^ scalar' => [
245+
'={1,2;3,4} ^ 2',
246+
[[1, 4], [9, 16]],
247+
],
228248
'Power: row vector ^ row vector' => [
229249
'={1,2,3} ^ {4,5,6}',
230250
[[1, 32, 729]],
@@ -258,6 +278,15 @@ public function providerArrayArithmetic(): array
258278
'={"A",",B"} & {"C";";D"}',
259279
[['AC', ',BC'], ['A;D', ',B;D']],
260280
],
281+
'Concatenation: 2x2 matrix & scalar' => [
282+
'={"A","B";"C","D"} & "E"',
283+
[['AE', 'BE'], ['CE', 'DE']],
284+
],
285+
'Concatenation: scalar & 2x2 matrix' => [
286+
'="E" & {"A","B";"C","D"}',
287+
[['EA', 'EB'], ['EC', 'ED']],
288+
],
289+
261290
// Unary Negation
262291
'Unary Negation: square matrix - 2x2' => [
263292
'= - {-2,4;-6,8}',

0 commit comments

Comments
 (0)