Add mutation for $ -> \z
This commit is contained in:
parent
02ce31546e
commit
5922d927af
6 changed files with 38 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 16
|
||||
total_score: 1306
|
||||
total_score: 1312
|
||||
|
|
|
@ -93,6 +93,7 @@ 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/regexp/end_of_line_anchor'
|
||||
require 'mutant/mutator/node/literal'
|
||||
require 'mutant/mutator/node/literal/boolean'
|
||||
require 'mutant/mutator/node/literal/range'
|
||||
|
|
|
@ -40,6 +40,7 @@ module Mutant
|
|||
regexp_alternation_meta
|
||||
regexp_bol_anchor
|
||||
regexp_digit_type
|
||||
regexp_eol_anchor
|
||||
regexp_nondigit_type
|
||||
regexp_nonspace_type
|
||||
regexp_nonword_boundary_anchor
|
||||
|
|
21
lib/mutant/mutator/node/regexp/end_of_line_anchor.rb
Normal file
21
lib/mutant/mutator/node/regexp/end_of_line_anchor.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
module Regexp
|
||||
# Mutator for end of line anchor `$`
|
||||
class EndOfLineAnchor < Node
|
||||
handle(:regexp_eol_anchor)
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# Replace `$` with `\z`
|
||||
#
|
||||
# @return [undefined]
|
||||
def dispatch
|
||||
emit(s(:regexp_eos_anchor))
|
||||
end
|
||||
end # EndOfLineAnchor
|
||||
end # Regexp
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
8
meta/regexp/regexp_eol_anchor.rb
Normal file
8
meta/regexp/regexp_eol_anchor.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
Mutant::Meta::Example.add :regexp_eol_anchor do
|
||||
source '/$/'
|
||||
|
||||
singleton_mutations
|
||||
regexp_mutations
|
||||
|
||||
mutation '/\z/'
|
||||
end
|
6
meta/regexp/regexp_eos_anchor.rb
Normal file
6
meta/regexp/regexp_eos_anchor.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Mutant::Meta::Example.add :regexp_eos_anchor do
|
||||
source '/\z/'
|
||||
|
||||
singleton_mutations
|
||||
regexp_mutations
|
||||
end
|
Loading…
Reference in a new issue