Add mutation for $ -> \z

This commit is contained in:
Daniel Gollahon 2016-10-09 15:48:00 -07:00
parent 02ce31546e
commit 5922d927af
No known key found for this signature in database
GPG key ID: B561636FDB951129
6 changed files with 38 additions and 1 deletions

View file

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

View file

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

View file

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

View 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

View file

@ -0,0 +1,8 @@
Mutant::Meta::Example.add :regexp_eol_anchor do
source '/$/'
singleton_mutations
regexp_mutations
mutation '/\z/'
end

View file

@ -0,0 +1,6 @@
Mutant::Meta::Example.add :regexp_eos_anchor do
source '/\z/'
singleton_mutations
regexp_mutations
end