First test submission and comment correction

From: Date: Tue, 05 May 2009 23:41:59 +0000
Subject: First test submission and comment correction
Groups: php.internals 
Request: Send a blank email to internals+get-43854@lists.php.net to get a copy of this message
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. 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.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

« previous php.internals (#43854) next »