Repository navigation
feat: perch coverage mutates method calls, literals and chains like Stryker - #350
Closed
jbrown9513 wants to merge 2 commits into
Closed
jbrown9513 wants to merge 2 commits into
jbrown9513 wants to merge 2 commits into
Conversation
…tterns as Stryker does The mutant table stopped at operators, conditions, literals, statement calls and bodies; a method's own calls were never touched, so a test that never checks a filter was never found. mutants.js now swaps a method for its opposite or drops it from a chain in every language's own names, empties list and object literals and fills empty ones, makes an optional chain unconditional, blanks an arrow function, edits regular expressions, forces ternary and loop conditions, turns every assignment operator, and makes ?? an &&.
Contributor
Author
Contributor
|
Perch Scan: no issues in 40 methods at |
The method tables were plain objects, so a call to a name Object has a property for, toString, valueOf, constructor, hasOwnProperty, found that property and handed a function to Buffer.from. The tables have no prototype now.
Contributor
Author
|
Folded into #355. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The mutant table stopped at operators, conditions, literals, statement calls and bodies: a method's own calls were never touched.
items.filter(x => x.ok).map(…)got no mutant, so a test that never checks the filter was never found. Stryker mutates all of it.src/mutants.jsnow makes the rest of Stryker's set, in every language perch reads:methodstartsWithtoendsWith,toUpperCasetotoLowerCase,mintomax,everytosome;.trim(),.filter(…),.sort(),.slice(…),.reverse()gone. Each language's own names: Python'sstripandsorted(…), Ruby'supcaseandselect {…}, Kotlin'suppercaseandsorted(), Swift'shasPrefix, Go'sstrings.ToUpperandstrings.TrimSpace(…), Rust'sto_uppercaseand.rev(), C#'sWhere(…)andOrderBy, Scala'sforalland.sorted, PHP'sstrtoupperandarray_filter(…), Lua'sstring.upper, C++'sstd::minandstd::any_of. Only a method that gives back its receiver's kind is dropped, so the edit compiles wherever the language checks types.collection[1, 2]to[],{ a: 1 }to{},{1}toset(),[]int{1, 2}to[]int{},new int[]{1, 2}tonew int[]{},vec![1, 2]tovec![]. An empty list is filled,[]to["perch was here"], where the language lets it stand alone. Kotlin'slistOf()and Swift's[]have no type of their own and are left alone.chaininga?.btoa.b,a?.()toa(), Ruby'sa&.btoa.b, PHP's?->to->, Kotlin's?.to!!., C#'sa?.btoa.b.lambdaundefined.regex+becomes*and back, a?goes,\dbecomes\D,\wand\slikewise,[^a]becomes[a], each its own mutant. JavaScript and Ruby literals.conditionforordoloop's, forced false.update*=and/=,%=to*=,<<=and>>=,&=and|=,&&=and||=,??=to&&=, Python's//=.logic??becomes&&, where&&takes any value.string""to"perch was here".The mutants for a method call are read off each grammar's own shape: a member call in JavaScript, Python, Java, Go, Rust, C++, Lua and PHP; a navigation suffix in Kotlin and Swift; the receiver on the call itself in Ruby; a field access with no parentheses in Scala. A dropped call is described as
the call to \trim` removed, and the test to add names it:Add a test that fails when `filter` is not called on line 12.`On the shop fixture the count goes from 27 mutants to 28. On perch, 20,374 mutants become 32,822: 1,387 method swaps and drops, 2,249 collections, 2,011 arrow functions, 709 pattern edits, and the rest ternaries, loops and assignment operators; the score reads 27% where it read 28%.
Closes #349