Re: First test submission and comment correction
| From: | Christopher Jones | Date: | Fri, 15 May 2009 16:48:47 +0000 |
| Subject: | Re: First test submission and comment correction | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-43991@lists.php.net to get a copy of this message | ||
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-- Email: christopher.jones@oracle.com Twitter: http://twitter.com/ghrd--- ext/standard/array.c 13 Feb 2009 22:34:15 -0000 1.308.2.21.2.37.2.53 +++ ext/standard/array.c 5 May 2009 22:56:53 -0000@@ -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