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
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--
Testarray_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--
*** Testingarray_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
--
Email: christopher.jones@oracle.com
Twitter: http://twitter.com/ghrd
Christopher Jones wrote:
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.phpLet 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
Hi Chris,
Thanks for accepting and the feedback.
Following on from the successful NorthWestUG testfest, I'm continuing to
focus on SPL and currently have 24 tests awaiting review in the
testfest SVN repo (with the CREDITS section :) ). Once this repo is
shutdown (in June?) I'd like to find out more about test review process
with the view to applying for a CVS account.
Also, thanks to Pierre for answering some zend_parse_parameters
questions the other night.
Regards,
Simon Westcott
Simon Westcott wrote:
Thanks for accepting and the feedback.
Following on from the successful NorthWestUG testfest, I'm continuing to
focus on SPL and currently have 24 tests awaiting review in the
testfest SVN repo (with the CREDITS section :) ). Once this repo is
shutdown (in June?) I'd like to find out more about test review process
with the view to applying for a CVS account.
That's really excellent.
Do you think you'll start to look at PHP bugs too?
Chris
Also, thanks to Pierre for answering some zend_parse_parameters
questions the other night.
--
Email: christopher.jones@oracle.com
Twitter: http://twitter.com/ghrd