View Issue Details

IDProjectCategoryView StatusLast Update
0001258XdebugUncategorizedpublic2016-02-23 20:25
Reporterasgrim Assigned Toderick  
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSUbuntuOS Version15.04
Product Version2.4.0rc3 
Fixed in Version2.4.0 
Summary0001258: Coverage does not cover case statements
Description

I have a switch statement that is fully tested, and all execution paths do not appear to be covered when viewed with PHP_CodeCoverage.

I queried on IRC, and a very kind and helpful Mr Rethans said "I probably don't overload the opcode - please submit a bug", so here it is!

I'm happy to try and create a proper reproducible test case if the provided code sample is not sufficient.

Steps To Reproduce

private function compileBinaryOp(Node\BinaryOp\AbstractBinaryOp $node, InputData $inputData)
{
$left = $this->compileNode($node->getLeft(), $inputData);
$right = $this->compileNode($node->getRight(), $inputData);

switch (get_class($node)) {
    case Node\BinaryOp\Equals::class:
        return $left == $right;
    case Node\BinaryOp\NotEquals::class:
        return $left != $right;
    case Node\BinaryOp\BooleanAnd::class:
        return $left && $right;
    case Node\BinaryOp\BooleanOr::class:
        return $left || $right;
    case Node\BinaryOp\GreaterThan::class:
        return $left > $right;
    case Node\BinaryOp\GreaterThanOrEqual::class:
        return $left >= $right;
    case Node\BinaryOp\LessThan::class:
        return $left < $right;
    case Node\BinaryOp\LessThanOrEqual::class:
        return $left <= $right;
    case Node\BinaryOp\In::class:
        return in_array($left, $right);
    case Node\BinaryOp\NotIn::class:
        return !in_array($left, $right);
    default:
        throw UnknownNodeType::fromNode($node);
}

}

TagsNo tags attached.
Attached Files
coverage.png (138,193 bytes)   
coverage.png (138,193 bytes)   
Operating SystemUbuntu 15.04
PHP Version7.0.0-7.0.4

Activities

robob4him

2016-02-15 22:34

reporter   ~0003495

Confirmed for 2.4.0rc4

derick

2016-02-23 20:25

administrator   ~0003515

Fixed for 2.4.0. Thanks for the report, and the PR with the test case!

Issue History

Date Modified Username Field Change
2016-01-20 18:33 asgrim New Issue
2016-01-20 18:33 asgrim File Added: coverage.png
2016-02-15 22:34 robob4him Note Added: 0003495
2016-02-23 20:25 derick Note Added: 0003515
2016-02-23 20:25 derick Status new => closed
2016-02-23 20:25 derick Assigned To => derick
2016-02-23 20:25 derick Resolution open => fixed
2016-02-23 20:25 derick Fixed in Version => 2.4.0
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized