Add mutations from /foo|bar/ -> /foo/ and /bar/
This commit is contained in:
parent
dd91f7c1b8
commit
b196e08a44
5 changed files with 28 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 16
|
||||
total_score: 1317
|
||||
total_score: 1306
|
||||
|
|
|
@ -91,6 +91,7 @@ require 'mutant/mutator/util/symbol'
|
|||
require 'mutant/mutator/node'
|
||||
require 'mutant/mutator/node/generic'
|
||||
require 'mutant/mutator/node/regexp'
|
||||
require 'mutant/mutator/node/regexp/alternation_meta'
|
||||
require 'mutant/mutator/node/regexp/character_type'
|
||||
require 'mutant/mutator/node/literal'
|
||||
require 'mutant/mutator/node/literal/boolean'
|
||||
|
|
|
@ -47,6 +47,7 @@ module Mutant
|
|||
regexp_nonspace_type
|
||||
regexp_word_boundary_anchor
|
||||
regexp_nonword_boundary_anchor
|
||||
regexp_alternation_meta
|
||||
]
|
||||
|
||||
# These nodes still need a dedicated mutator,
|
||||
|
|
21
lib/mutant/mutator/node/regexp/alternation_meta.rb
Normal file
21
lib/mutant/mutator/node/regexp/alternation_meta.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
module Regexp
|
||||
# Mutator for pipe in `/foo|bar/` regexp
|
||||
class AlternationMeta < Node
|
||||
handle(:regexp_alternation_meta)
|
||||
|
||||
private
|
||||
|
||||
# Dispatch mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
def dispatch
|
||||
children.each_index(&method(:delete_child))
|
||||
end
|
||||
end # AlternationMeta
|
||||
end # Regexp
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -3,4 +3,8 @@ Mutant::Meta::Example.add :regexp_alternation_meta do
|
|||
|
||||
singleton_mutations
|
||||
regexp_mutations
|
||||
|
||||
mutation '/\A(foo|bar)\z/'
|
||||
mutation '/\A(foo|baz)\z/'
|
||||
mutation '/\A(bar|baz)\z/'
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue