Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring Mutation Test score back to 100% #1382

Open
Ocramius opened this issue Nov 24, 2023 · 6 comments
Open

Bring Mutation Test score back to 100% #1382

Ocramius opened this issue Nov 24, 2023 · 6 comments

Comments

@Ocramius
Copy link
Member

Seen in #1381 and #1380 ( https://github.com/Roave/BetterReflection/actions/runs/6983487200/job/19004937424?pr=1381#step:5:11665 )

Error: ] The minimum required MSI percentage should be 100%, but actual is      
         99.73%. Improve your tests!        
Escaped mutants:
================

1) /home/runner/work/BetterReflection/BetterReflection/src/Reflection/ReflectionFunctionAbstract.php:112    [M] GreaterThan

--- Original
+++ New
@@ @@
         $startLine = null;
         if ($node->hasAttribute('startLine')) {
             $startLine = $node->getStartLine();
-            assert($startLine > 0);
+            assert($startLine >= 0);
         }
         $endLine = null;
         if ($node->hasAttribute('endLine')) {


2) /home/runner/work/BetterReflection/BetterReflection/src/Reflection/ReflectionFunctionAbstract.php:118    [M] GreaterThan

--- Original
+++ New
@@ @@
         $endLine = null;
         if ($node->hasAttribute('endLine')) {
             $endLine = $node->getEndLine();
-            assert($endLine > 0);
+            assert($endLine >= 0);
         }
         $this->startLine = $startLine;
         $this->endLine = $endLine;


3) /home/runner/work/BetterReflection/BetterReflection/src/Reflection/ReflectionFunctionAbstract.php:507    [M] InstanceOf_

--- Original
+++ New
@@ @@
         if ($returnType === null) {
             return null;
         }
-        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
+        assert(true || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
         return ReflectionType::createFromNode($this->reflector, $this, $returnType);
     }
     /** @return list<ReflectionAttribute> */


4) /home/runner/work/BetterReflection/BetterReflection/src/Reflection/ReflectionFunctionAbstract.php:507    [M] InstanceOf_

--- Original
+++ New
@@ @@
         if ($returnType === null) {
             return null;
         }
-        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
+        assert($returnType instanceof Node\Identifier || true || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
         return ReflectionType::createFromNode($this->reflector, $this, $returnType);
     }
     /** @return list<ReflectionAttribute> */


5) /home/runner/work/BetterReflection/BetterReflection/src/Reflection/ReflectionFunctionAbstract.php:507    [M] InstanceOf_

--- Original
-        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
+        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || false);
         return ReflectionType::createFromNode($this->reflector, $this, $returnType);
     }
     /** @return list<ReflectionAttribute> */


9) /home/runner/work/BetterReflection/BetterReflection/src/Reflection/ReflectionFunctionAbstract.php:507    [M] LogicalOrAllSubExprNegation

--- Original
+++ New
@@ @@
         if ($returnType === null) {
             return null;
         }
-        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
+        assert(!$returnType instanceof Node\Identifier || !$returnType instanceof Node\Name || !$returnType instanceof Node\NullableType || !$returnType instanceof Node\UnionType || !$returnType instanceof Node\IntersectionType);
         return ReflectionType::createFromNode($this->reflector, $this, $returnType);
     }
     /** @return list<ReflectionAttribute> */

Not Covered mutants:
====================
Warning: Escaped Mutant for Mutator "GreaterThan":

--- Original
+++ New
@@ @@
         $startLine = null;
         if ($node->hasAttribute('startLine')) {
             $startLine = $node->getStartLine();
-            assert($startLine > 0);
+            assert($startLine >= 0);
         }
         $endLine = null;
         if ($node->hasAttribute('endLine')) {


Warning: Escaped Mutant for Mutator "GreaterThan":

--- Original
+++ New
@@ @@
         $endLine = null;
         if ($node->hasAttribute('endLine')) {
             $endLine = $node->getEndLine();


Warning: Escaped Mutant for Mutator "InstanceOf_":

--- Original
+++ New
@@ @@
         if ($returnType === null) {
             return null;
         }
-        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
+        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || true || $returnType instanceof Node\IntersectionType);
         return ReflectionType::createFromNode($this->reflector, $this, $returnType);
     }
     /** @return list<ReflectionAttribute> */


Warning: Escaped Mutant for Mutator "InstanceOf_":

--- Original
+++ New
@@ @@
         if ($returnType === null) {
             return null;
         }
-        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
+        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || true);
         return ReflectionType::createFromNode($this->reflector, $this, $returnType);
     }
     /** @return list<ReflectionAttribute> */


Warning: Escaped Mutant for Mutator "InstanceOf_":

--- Original
+++ New
@@ @@
         if ($returnType === null) {
             return null;
         }
-        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
+        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || false);
         return ReflectionType::createFromNode($this->reflector, $this, $returnType);
     }
     /** @return list<ReflectionAttribute> */


Warning: Escaped Mutant for Mutator "LogicalOrAllSubExprNegation":

--- Original
+++ New
@@ @@
         if ($returnType === null) {
             return null;
         }
-        assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType);
+        assert(!$returnType instanceof Node\Identifier || !$returnType instanceof Node\Name || !$returnType instanceof Node\NullableType || !$returnType instanceof Node\UnionType || !$returnType instanceof Node\IntersectionType);
         return ReflectionType::createFromNode($this->reflector, $this, $returnType);
     }
     /** @return list<ReflectionAttribute> */

Warning:  Dashboard report has not been sent: The current process is a pull request build
@kukulich
Copy link
Collaborator

I don't have better solution than: #1377 (comment) :(

@Ocramius
Copy link
Member Author

@kukulich we could also contribute upstream types, maybe 🤔

@staabm
Copy link
Contributor

staabm commented Mar 13, 2024

we could also contribute upstream types, maybe 🤔

I think this is what I did with nikic/PHP-Parser#985

@Ocramius
Copy link
Member Author

Nice :)

BTW, moving to PHP-Parser v5 already improved things a lot :)

@kukulich
Copy link
Collaborator

@staabm Is it possible to prepare PR with your PHPParser so we can see the difference? I'm just curious if it will work :)

@staabm
Copy link
Contributor

staabm commented Mar 13, 2024

@kukulich sure. here you are

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants