weaponregex.WeaponRegeX.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weapon-regex_2.12 Show documentation
Show all versions of weapon-regex_2.12 Show documentation
Weapon regeX mutates regular expressions for use in mutation testing.
The newest version!
package weaponregex
import weaponregex.internal.extension.RegexTreeExtension.RegexTreeMutator
import weaponregex.internal.parser.Parser
import weaponregex.model.mutation.{Mutant, TokenMutator}
import weaponregex.mutator.BuiltinMutators
import weaponregex.parser.{ParserFlavor, ParserFlavorJVM}
/** The API facade of Weapon regeX for Scala/JVM
*/
object WeaponRegeX {
/** Mutate using the given mutators in some specific mutation levels
* @param pattern
* Input regex string
* @param mutators
* Mutators to be used for mutation
* @param mutationLevels
* Target mutation levels. If this is `null`, the `mutators` will not be filtered.
* @return
* A `Right` of a sequence of [[weaponregex.model.mutation.Mutant]] if can be parsed, a `Left` with the error
* message otherwise
*/
def mutate(
pattern: String,
mutators: Seq[TokenMutator] = BuiltinMutators.all,
mutationLevels: Seq[Int] = null,
flavor: ParserFlavor = ParserFlavorJVM
): Either[String, Seq[Mutant]] = Parser(pattern, flavor) map (_.mutate(mutators, mutationLevels))
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy