[xdebug-dev] Bug 0000238: Incorrect code coverage

From: <noreply[@]lists.xdebug.org>
Date: Wed, 7 Feb 2007 15:01:15 +0100

The following NEW bug has been ADDED.
======================================================================
http://bugs.xdebug.org/bug_view_page.php?bug_id=0000238
======================================================================
Reporter: Arjen
Handler:
======================================================================
Project: Xdebug
Bug ID: 238
Category: Usage problems
Reproducibility: always
Severity: major
Priority: normal
Status: new
Operating System:
PHP Version: 5.2.0
Xdebug Version: 2.0.0rc2
======================================================================
Date Submitted: 2007-02-07 15:01 CET
Last Modified: 2007-02-07 15:01 CET
======================================================================
Summary: Incorrect code coverage
Description:
<?php

xdebug_start_code_coverage();

try {
        if(time() < 0)
                throw new Exception('lalala');
}
catch(Exception $e)
{
        echo "exception catched";
}

try {
        if(time() < 0)
        {
                throw new Exception('lalala');
        }
}
catch(Exception $e)
{
        echo "exception catched";
}

var_dump(xdebug_get_code_coverage());

array
  '/data/home/arjen/public_html/codecoverage.php' =>
    array
      6 => int 1
      7 => int 1
      9 => int 1
      15 => int 1
      16 => int 1
      20 => int 1
      25 => int 1

When short-style if-statements are used, the line 'throw new Exception(..)
is marked as executed. When curly brackets are used, the line is NOT marked
as executed. This is the expected behavior, as the exception is not thrown.
======================================================================

Bug History
Date Modified Username Field Change
======================================================================
2007-02-07 15:01Arjen New Bug
2007-02-07 15:01Arjen Bug Monitored: Arjen
======================================================================
Received on Wed Feb 07 2007 - 15:01:18 GMT

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