Add regexp mutation for \Z -> \z

This commit is contained in:
Daniel Gollahon 2016-10-09 16:36:46 -07:00
parent 8d4cea5920
commit 57d393ead3
No known key found for this signature in database
GPG key ID: B561636FDB951129
5 changed files with 26 additions and 1 deletions

View file

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

View file

@ -94,6 +94,7 @@ require 'mutant/mutator/node/regexp'
require 'mutant/mutator/node/regexp/alternation_meta'
require 'mutant/mutator/node/regexp/character_type'
require 'mutant/mutator/node/regexp/end_of_line_anchor'
require 'mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor'
require 'mutant/mutator/node/literal'
require 'mutant/mutator/node/literal/boolean'
require 'mutant/mutator/node/literal/range'

View file

@ -41,6 +41,7 @@ module Mutant
regexp_bol_anchor
regexp_digit_type
regexp_eol_anchor
regexp_eos_ob_eol_anchor
regexp_hex_type
regexp_nondigit_type
regexp_nonhex_type

View file

@ -0,0 +1,21 @@
module Mutant
class Mutator
class Node
module Regexp
# Mutator for end of line or before end of string anchor `\Z`
class EndOfStringOrBeforeEndOfLineAnchor < Node
handle(:regexp_eos_ob_eol_anchor)
# Emit mutations
#
# Replace `\Z` with `\z`
#
# @return [undefined]
def dispatch
emit(s(:regexp_eos_anchor))
end
end # EndOfLineAnchor
end # Regexp
end # Node
end # Mutator
end # Mutant

View file

@ -3,4 +3,6 @@ Mutant::Meta::Example.add :regexp_eos_ob_eol_anchor do
singleton_mutations
regexp_mutations
mutation '/\z/'
end