Add match all and match none mutations to regexp
This commit is contained in:
parent
4a79975284
commit
7ccbae8bd4
2 changed files with 18 additions and 13 deletions
|
@ -16,7 +16,22 @@ module Mutant
|
|||
#
|
||||
def dispatch
|
||||
emit_nil
|
||||
emit_new { new_self(Random.hex_string, node.options) }
|
||||
emit_self('') # match all
|
||||
emit_self('a\A') # match nothing
|
||||
emit_new { new_self(Random.hex_string) }
|
||||
end
|
||||
|
||||
# Return new Rubinius::AST::Regex
|
||||
#
|
||||
# @param [String] source
|
||||
#
|
||||
# @param [Integer] options
|
||||
# options of regexp, defaults to mutation subject node options
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
def new_self(source,options=nil)
|
||||
super(source,options || node.options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,8 @@ describe Mutant::Mutator::Literal, 'regex' do
|
|||
mutations = []
|
||||
mutations << 'nil'
|
||||
mutations << "/#{random_string}/"
|
||||
mutations << '//' # match all
|
||||
mutations << '/a\A/' # match nothing
|
||||
end
|
||||
|
||||
before do
|
||||
|
@ -18,16 +20,4 @@ describe Mutant::Mutator::Literal, 'regex' do
|
|||
let(:mutations) { base_mutations }
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
||||
context 'when source is empty regexp' do
|
||||
before do
|
||||
pending
|
||||
end
|
||||
|
||||
let(:source) { '//' }
|
||||
|
||||
let(:mutations) { base_mutations - [source.to_ast] }
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue