Add regexp mutation for \Z -> \z
This commit is contained in:
parent
8d4cea5920
commit
57d393ead3
5 changed files with 26 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 16
|
||||
total_score: 1303
|
||||
total_score: 1306
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -3,4 +3,6 @@ Mutant::Meta::Example.add :regexp_eos_ob_eol_anchor do
|
|||
|
||||
singleton_mutations
|
||||
regexp_mutations
|
||||
|
||||
mutation '/\z/'
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue