[xdebug-dev] Bug 0000401: Code Coverage is wrong for if statement

From: <noreply[@]lists.xdebug.org>
Date: Fri, 22 Aug 2008 10:05:55 +0200

The following NEW bug has been ADDED.
======================================================================
http://bugs.xdebug.org/bug_view_page.php?bug_id=0000401
======================================================================
Reporter: sebastian
Handler:
======================================================================
Project: Xdebug
Bug ID: 401
Category: Feature/Change request
Reproducibility: always
Severity: minor
Priority: normal
Status: new
Operating System:
PHP Version: 5.2-dev
Xdebug Version: 2.1.0-dev
======================================================================
Date Submitted: 2008-08-22 10:05 CEST
Last Modified: 2008-08-22 10:05 CEST
======================================================================
Summary: Code Coverage is wrong for if statement
Description:
    1 <?php
    2 xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
    3
    4 if (false)
    5 print '*';
    6
    7 $codeCoverage = xdebug_get_code_coverage();
    8 xdebug_stop_code_coverage();
    9
   10 print_r($codeCoverage);

 This results in

   Array
   (
       [/home/sb/test.php] => Array
           (
               [5] => 1
               [7] => 1
           )
   )

 which is wrong as line 5 is not executed.

 Adding braces for the if() block changes things a bit:

    1 <?php
    2 xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
    3
    4 if (false) {
    5 print '*';
    6 }
    7
    8 $codeCoverage = xdebug_get_code_coverage();
    9 xdebug_stop_code_coverage();
   10
   11 print_r($codeCoverage);

 results in

   Array
   (
       [/home/sb/test.php] => Array
           (
               [4] => 1
               [8] => 1
           )
   )

======================================================================

Bug History
Date Modified Username Field Change
======================================================================
2008-08-22 10:05sebastian New Bug
2008-08-22 10:05sebastian Bug Monitored: sebastian
======================================================================
Received on Fri Aug 22 2008 - 10:05:57 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST