Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.6.0

Request #15963 Allow the inclusion of an external doctest file
Submitted: 2009-03-01 09:52 UTC
From: sofia Assigned: izi
Status: Closed Package: Testing_DocTest
PHP Version: 5.2.5 OS: irrelvant
Roadmaps: (Not assigned)    

 [2009-03-01 09:52 UTC] sofia (sofia cardita)
Description: ------------ Hi David, I added the ability to include standalone doctest files. I changed the Parser/Default.php to allow for this, the changes are mainly the addition of the constant KW_DOCTEST_FILE (line 61) and the methods _hasStandaloneDoctest and _handleStandaloneDoctest() (lines 426-468). The method _extractCodeBlocs was also edited (lines 406-412). Usage: /** * <code> * //test-file: atestfile.txt * </code> */ The test file line should be the only line in the code block, all other lines will be ignored. Of course, it's possible to continue to do this: /** * add function. * * @access public * @param mixed $a * @param mixed $b * @return void * *<code> * //doctest: add * echo simplemath::add(3,2); * // expects: * // 5 *</code> * <code> * //test-file: abigtestcase.txt * </code> * <code> //test-file: anothertestfile.txt </code> */ A test case file's contents would be regular doctest code, eg. //doctest: add echo simplemath::add(3,2)."\n"; echo simplemath::add(5,2); // expects: // 5 // 7 This is nice when there are too many test cases or when test cases are too big. It lessens the clutter on the code itself. Cheers! - Sofia Test script: --------------- Expected result: ---------------- Actual result: --------------


 [2009-03-01 09:54 UTC] sofia (sofia cardita)
The following patch has been added/updated: Patch Name: add-standalone-testfiles URL: patch add-standalone-testfiles
 [2009-03-01 15:18 UTC] izi (David Jean Louis)
-Status: Open +Status: Closed -Assigned To: +Assigned To: izi
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Great job Sofia, thanks ! I just changed some cosmetic things and added the ability to parse external files that are enclosed with <?php ?> tags (this allows to have external tests with syntax coloration :) ). Commited: