Add mutations from /foo|bar/ -> /foo/ and /bar/

This commit is contained in:
John Backus 2016-08-14 15:58:08 -07:00
parent dd91f7c1b8
commit b196e08a44
No known key found for this signature in database
GPG key ID: 9A91898D0B0B2FBE
5 changed files with 28 additions and 1 deletions

View file

@ -1,3 +1,3 @@
---
threshold: 16
total_score: 1317
total_score: 1306

View file

@ -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'

View file

@ -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,

View 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

View file

@ -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