Add support for mutating start and end nodes for range literals

This commit is contained in:
Markus Schirp 2013-09-02 20:49:52 +02:00
parent 133713b4fd
commit 8bddef0171
2 changed files with 33 additions and 0 deletions

View file

@ -50,6 +50,7 @@ module Mutant
# @api private
#
def emit_upper_bound_mutations
emit__end_mutations
emit_self(NAN, _end)
end
@ -60,6 +61,7 @@ module Mutant
# @api private
#
def emit_lower_bound_mutations
emit_start_mutations
emit_self(start, INFINITY)
emit_self(start, NAN)
end

View file

@ -3,6 +3,13 @@
require 'spec_helper'
describe Mutant::Mutator::Node::Literal, 'range' do
before :each do
Mutant::Random.stub(:fixnum => random_fixnum)
end
let(:random_fixnum) { 5 }
context 'inclusive range literal' do
let(:source) { '1..100' }
@ -13,6 +20,18 @@ describe Mutant::Mutator::Node::Literal, 'range' do
mutations << '(0.0 / 0.0)..100'
mutations << '1..(1.0 / 0.0)'
mutations << '1..(0.0 / 0.0)'
mutations << '-1..100'
mutations << '5..100'
mutations << '0..100'
mutations << '2..100'
mutations << 'nil..100'
mutations << '1..nil'
mutations << '1..0'
mutations << '1..1'
mutations << '1..99'
mutations << '1..101'
mutations << '1..-100'
mutations << '1..5'
end
it_should_behave_like 'a mutator'
@ -28,6 +47,18 @@ describe Mutant::Mutator::Node::Literal, 'range' do
mutations << '(0.0 / 0.0)...100'
mutations << '1...(1.0 / 0.0)'
mutations << '1...(0.0 / 0.0)'
mutations << '-1...100'
mutations << '5...100'
mutations << '0...100'
mutations << '2...100'
mutations << 'nil...100'
mutations << '1...nil'
mutations << '1...0'
mutations << '1...1'
mutations << '1...99'
mutations << '1...101'
mutations << '1...-100'
mutations << '1...5'
end
it_should_behave_like 'a mutator'