Lookup ref further tests and examples (#1918)

* Extract LookupRef\INDEX() into index() method of LookupRef\Matrix class
Additional tests
* Bugfix for returning a column using INDEX()
* Some improvements to ROW() and COLUMN()
* Simplify some of the INDEX() logic, eliminating redundant code
This commit is contained in:
Mark Baker
2021-03-11 22:34:47 +01:00
committed by GitHub
parent 499ce61cf7
commit 2259de578b
12 changed files with 343 additions and 86 deletions
@@ -21,6 +21,7 @@ class IndexTest extends TestCase
public function testINDEX($expectedResult, ...$args): void
{
$result = LookupRef::INDEX(...$args);
// var_dump($result);
self::assertEquals($expectedResult, $result);
}
+71 -1
View File
@@ -54,7 +54,7 @@ return [
-1,
],
[
'#VALUE!', // Expected
'#REF!', // Expected
// Input
[
'20' => ['R' => 1, 'S' => 3],
@@ -63,6 +63,16 @@ return [
2,
10,
],
[
'#REF!', // Expected
// Input
[
'20' => ['R' => 1, 'S' => 3],
'21' => ['R' => 2, 'S' => 4],
],
10,
2,
],
[
4, // Expected
// Input
@@ -87,4 +97,64 @@ return [
'21' => ['R' => 2],
],
],
[
'Pears',
[
['Apples', 'Lemons'],
['Bananas', 'Pears'],
],
2,
2,
],
[
'Bananas',
[
['Apples', 'Lemons'],
['Bananas', 'Pears'],
],
2,
1,
],
[
3,
[
[4, 6],
[5, 3],
[6, 9],
[7, 5],
[8, 3],
],
5,
2,
],
[
[4 => [8, 3]],
[
[4, 6],
[5, 3],
[6, 9],
[7, 5],
[8, 3],
],
5,
0,
],
[
[
[6],
[3],
[9],
[5],
[3],
],
[
[4, 6],
[5, 3],
[6, 9],
[7, 5],
[8, 3],
],
0,
2,
],
];
+7
View File
@@ -17,6 +17,13 @@ return [
[[10], [11], [12]],
'C10:D12',
],
[
4,
[
4 => ['B' => 'B5', 'C' => 'C5', 'D' => 'D5'],
5 => ['B' => 'B5', 'C' => 'C5', 'D' => 'D5'],
],
],
[
[[10], [11], [12]],
'Sheet1!C10:C12',