Conversation
Girgias
left a comment
There was a problem hiding this comment.
I'd rather split this test into multiple ones because trying to verify that 200 iterations of a foreach is corret is just unreasonable.
a7dd7b0 to
c64920f
Compare
|
Is splitting reference-value data into a separate test appropriate? I added descriptions to each iteration to make the test results easier to review. |
| $array_compare = array ( | ||
| 4, | ||
| "4", | ||
| 4.00, | ||
| "b", | ||
| "5", | ||
| -2, | ||
| -2.0, | ||
| -2.98989, | ||
| "-.9", | ||
| "True", | ||
| "", | ||
| [], | ||
| NULL, | ||
| "ab", | ||
| "abcd", | ||
| 0.0, | ||
| -0, | ||
| "abcd\x00abcd\x00abcd", | ||
| Sample::A, | ||
| Sample::B, | ||
| ); |
There was a problem hiding this comment.
Why not have a dictionary where the key describes the value? So you don't need the "get_type" thing...
| //strict option OFF | ||
| var_dump(in_array($compare,$array)); | ||
| //strict option ON | ||
| var_dump(in_array($compare,$array,TRUE)); | ||
| //strict option OFF | ||
| var_dump(in_array($compare,$array,FALSE)); |
There was a problem hiding this comment.
| //strict option OFF | |
| var_dump(in_array($compare,$array)); | |
| //strict option ON | |
| var_dump(in_array($compare,$array,TRUE)); | |
| //strict option OFF | |
| var_dump(in_array($compare,$array,FALSE)); | |
| echo "in_array() strict=true\n"; | |
| var_dump(in_array($compare, $array, true)); | |
| echo "in_array() strict=false\n"; | |
| var_dump(in_array($compare, $array, false)); |
| $refVar7 = True; | ||
| $array = [&$refVar2, &$refVar, &$refVar3, &$refVar4, &$refVar5, &$refVar6, &$refVar7]; | ||
|
|
||
| $array_compare = array ( |
There was a problem hiding this comment.
The current name seems to imply this is the array we are comparing against, not the one that contains the test value.
| $array_compare = array ( | |
| $values = array ( |
There was a problem hiding this comment.
This test is already to long. Yes I know this is a test that has existed for a long time. But the guidelines that have existed forever now is for them to be small see https://php.github.io/php-src/miscellaneous/writing-tests.html#how-big-is-a-test-case
So I'd rather really split this massive test into smaller ones and even move them into a in_array sub folder so one can just run these tests.
Added more detailed descriptions to test iterations so it’s clear what the input is for each iteration. Additionally, I added a new test cases for an arrays containing references and enums.