free_mutant/spec/unit/mutant/mutator/node/block_spec.rb
Markus Schirp caf6c368d0 Remove indeterministic mutations
A mutation test that passes/fails on code today should also pass/fail on
the same code tomorrow.

* Closes #173
* Closes #127
* Closes #27
2014-05-10 14:37:25 +00:00

83 lines
1.9 KiB
Ruby

# encoding: utf-8
require 'spec_helper'
describe Mutant::Mutator, 'block' do
context 'with block' do
let(:source) { 'foo() { a; b }' }
let(:mutations) do
mutations = []
mutations << 'foo { a }'
mutations << 'foo { b }'
mutations << 'foo {}'
mutations << 'foo { raise }'
mutations << 'foo { a; nil }'
mutations << 'foo { nil; b }'
mutations << 'foo'
mutations << 'nil'
end
it_should_behave_like 'a mutator'
end
context 'with block args' do
let(:source) { 'foo { |a, b| }' }
let(:mutations) do
mutations = []
mutations << 'foo'
mutations << 'foo { |a, b| raise }'
mutations << 'foo { |a, b__mutant__| }'
mutations << 'foo { |a__mutant__, b| }'
mutations << 'foo { |a| }'
mutations << 'foo { |b| }'
mutations << 'foo { || }'
mutations << 'nil'
end
it_should_behave_like 'a mutator'
end
context 'with block pattern args' do
let(:source) { 'foo { |(a, b), c| }' }
let(:mutations) do
mutations = []
mutations << 'foo { || }'
mutations << 'foo { |a, b, c| }'
mutations << 'foo { |(a, b), c| raise }'
mutations << 'foo { |(a), c| }'
mutations << 'foo { |(b), c| }'
mutations << 'foo { |(a, b)| }'
mutations << 'foo { |c| }'
mutations << 'foo { |(a__mutant__, b), c| }'
mutations << 'foo { |(a, b__mutant__), c| }'
mutations << 'foo { |(a, b), c__mutant__| }'
mutations << 'foo'
mutations << 'nil'
end
it_should_behave_like 'a mutator'
end
context 'with mini block pattern arg' do
let(:source) { 'foo { |(a)| }' }
let(:mutations) do
mutations = []
mutations << 'foo { || }'
mutations << 'foo { |a| }'
mutations << 'foo { |(a)| raise }'
mutations << 'foo { |(a__mutant__)| }'
mutations << 'foo'
mutations << 'nil'
end
it_should_behave_like 'a mutator'
end
end