[xdebug-dev] svn: /xdebug/trunk/ tests/bug00515.inc tests/bug00515.phpt xdebug_code_coverage.c

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Mon, 11 Jan 2010 23:23:08 +0000

derick Mon, 11 Jan 2010 23:23:08 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=3212

Log:
- Fixed bug #515: declare(ticks) statement confuses code coverage.

Changed paths:
    A xdebug/trunk/tests/bug00515.inc
    A xdebug/trunk/tests/bug00515.phpt
    U xdebug/trunk/xdebug_code_coverage.c

Added: xdebug/trunk/tests/bug00515.inc
===================================================================
--- xdebug/trunk/tests/bug00515.inc (rev 0)
+++ xdebug/trunk/tests/bug00515.inc 2010-01-11 23:23:08 UTC (rev 3212)
@@ -0,0 +1,21 @@
+<?php
+declare(ticks=1);
+class UncoveredLine
+{
+ private $_foo;
+
+ function __construct($foo)
+ {
+ if ($foo === 'bar') {
+ $this->_foo = $foo;
+ } else {
+ $this->_foo = null;
+ }
+ }
+
+ function getFoo()
+ {
+ return $this->_foo;
+ }
+}
+?>

Added: xdebug/trunk/tests/bug00515.phpt
===================================================================
--- xdebug/trunk/tests/bug00515.phpt (rev 0)
+++ xdebug/trunk/tests/bug00515.phpt 2010-01-11 23:23:08 UTC (rev 3212)
@@ -0,0 +1,57 @@
+--TEST--
+Test for bug #515: Dead Code Analysis for code coverage messed up with ticks.
+--SKIPIF--
+<?php if (!extension_loaded("xdebug")) print "skip"; ?>
+--INI--
+xdebug.default_enable=1
+xdebug.auto_trace=0
+xdebug.trace_options=0
+xdebug.trace_output_dir=/tmp
+xdebug.collect_params=1
+xdebug.collect_return=0
+xdebug.collect_assignments=0
+xdebug.auto_profile=0
+xdebug.profiler_enable=0
+xdebug.dump_globals=0
+xdebug.show_mem_delta=0
+xdebug.trace_format=0
+xdebug.extended_info=1
+--FILE--
+<?php
+ xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
+
+ include 'bug00515.inc';
+ $cc = xdebug_get_code_coverage();
+ array_shift($cc);
+ var_dump($cc);
+
+ xdebug_stop_code_coverage(false);
+?>
+--EXPECTF--
+array(1) {
+ ["%sbug00515.inc"]=>
+ array(11) {
+ [2]=>
+ int(1)
+ [4]=>
+ int(1)
+ [9]=>
+ int(-1)
+ [10]=>
+ int(-1)
+ [11]=>
+ int(-1)
+ [12]=>
+ int(-1)
+ [14]=>
+ int(-1)
+ [18]=>
+ int(-1)
+ [19]=>
+ int(-2)
+ [21]=>
+ int(1)
+ [22]=>
+ int(1)
+ }
+}

Modified: xdebug/trunk/xdebug_code_coverage.c
===================================================================
--- xdebug/trunk/xdebug_code_coverage.c 2010-01-11 23:20:45 UTC (rev 3211)
+++ xdebug/trunk/xdebug_code_coverage.c 2010-01-11 23:23:08 UTC (rev 3212)
@@ -316,6 +316,7 @@
                 && opcode.opcode != ZEND_VERIFY_ABSTRACT_CLASS
                 && opcode.opcode != ZEND_OP_DATA
                 && opcode.opcode != ZEND_ADD_INTERFACE
+ && opcode.opcode != ZEND_TICKS
         ) {
                 xdebug_count_line(fn, opcode.lineno, 1, deadcode TSRMLS_CC);
         }
Received on Mon Jan 11 2010 - 23:23:08 GMT

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