Simon Westcott wrote:
Hi,
I've just started to explore PHP's tests, reading through the docs on
qa.php.net, the wiki and a few blogs. Having gotten to a position where
I can run the tests and produce coverage reports I have my first
(simple) submission. It covers an edge case for array_multisort when an
empty array is provided.
Hi Simon,
Welcome!
I've merged these for you. I added an exit() block to the test. See
the Last bit section in http://qa.php.net/write-test.php
Let us know if you have any questions or if there's anyway we can help
you. What parts of PHP are you looking at now?
Chris
Test:
$ cat ext/standard/tests/array/array_multisort_variation11.phpt
--TEST--
Test array_multisort() function : usage variation - testing with empty
array
--FILE--
?php
/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [,
SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [,
SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
* Description: Sort multiple arrays at once similar to how ORDER BY
clause works in SQL
* Source code: ext/standard/array.c
* Alias to functions:
*/
echo *** Testing array_multisort() : Testing with empty array ***\n;
var_dump(array_multisort(array()));
?
===DONE===
--EXPECTF--
*** Testing array_multisort() : Testing with empty array ***
bool(true)
===DONE===
Whilst producing this simple test I spotted a mistake in a related
comment which appears to originate from bug 24897. A patch against
PHP-5.3 follows,
Index: ext/standard/array.c
===
RCS file: /repository/php-src/ext/standard/array.c,v
retrieving revision 1.308.2.21.2.37.2.53
diff -u -r1.308.2.21.2.37.2.53 array.c
--- ext/standard/array.c13 Feb 2009 22:34:15 -
1.308.2.21.2.37.2.53
+++ ext/standard/array.c5 May 2009 22:56:53 -
@@ -3789,7 +3789,7 @@
}
}
- /* If all arrays are empty or have only one entry, we don't need
to do anything. */
+ /* If all arrays are empty we don't need to do anything. */
if (array_size 1) {
for (k = 0; k MULTISORT_LAST; k++) {
efree(ARRAYG(multisort_flags)[k]);
I appreciate this a trivial stuff, but any constructive feedback is
welcome.
Regards,
Simon Westcott
--
Email: christopher.jo...@oracle.com
Twitter: http://twitter.com/ghrd
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php