Add unary operator expansions

This commit is contained in:
Markus Schirp 2012-12-08 01:04:43 +01:00
parent bc408d52d2
commit 88e1f0941c
3 changed files with 58 additions and 26 deletions

View file

@ -57,29 +57,33 @@ module Mutant
end
MAPPING = {
:'!~' => :nomatch_operator,
:'!=' => :inequality_operator,
:<=> => :spaceship_operator,
:=== => :case_equality_operator,
:[]= => :element_writer,
:[] => :element_reader,
:== => :equality_operator,
:<= => :less_than_or_equal_to_operator,
:>= => :greater_than_or_equal_to_operator,
:=~ => :match_operator,
:<< => :left_shift_operator,
:>> => :right_shift_operator,
:** => :exponentation_operator,
:* => :multiplication_operator,
:% => :modulo_operator,
:/ => :division_operator,
:| => :bitwise_or_operator,
:^ => :bitwise_xor_operator,
:& => :bitwise_and_operator,
:< => :less_than_operator,
:> => :greater_than_operator,
:+ => :addition_operator,
:- => :substraction_operator
:<=> => :spaceship_operator,
:=== => :case_equality_operator,
:[]= => :element_writer,
:[] => :element_reader,
:<= => :less_than_or_equal_to_operator,
:>= => :greater_than_or_equal_to_operator,
:~@ => :unary_match_operator,
:+@ => :unary_addition_operator,
:-@ => :unary_substraction_operator,
:== => :equality_operator,
:!~ => :nomatch_operator,
:!= => :inequality_operator,
:=~ => :match_operator,
:<< => :left_shift_operator,
:>> => :right_shift_operator,
:** => :exponentation_operator,
:* => :multiplication_operator,
:% => :modulo_operator,
:/ => :division_operator,
:| => :bitwise_or_operator,
:! => :negation_operator,
:^ => :bitwise_xor_operator,
:& => :bitwise_and_operator,
:< => :less_than_operator,
:> => :greater_than_operator,
:+ => :addition_operator,
:- => :substraction_operator
}
EXPANSIONS = {

View file

@ -2,7 +2,7 @@
Gem::Specification.new do |gem|
gem.name = 'mutant'
gem.version = '0.2.1'
gem.version = '0.2.2'
gem.authors = [ 'Markus Schirp' ]
gem.email = [ 'mbj@seonic.net' ]
gem.description = 'Mutation testing for ruby under rubinius'

View file

@ -16,6 +16,34 @@ describe Mutant::Strategy::Rspec::ExampleLookup, '#spec_file' do
it { should be_frozen }
end
context 'negation operator' do
let(:method_name) { :! }
let(:expected_spec_file) { 'negation_operator_spec.rb' }
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
end
context 'with unary match method' do
let(:method_name) { :~@ }
let(:expected_spec_file) { 'unary_match_operator_spec.rb' }
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
end
context 'with unary substraction method' do
let(:method_name) { :-@ }
let(:expected_spec_file) { 'unary_substraction_operator_spec.rb' }
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
end
context 'with unary addition method' do
let(:method_name) { :+@ }
let(:expected_spec_file) { 'unary_addition_operator_spec.rb' }
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
end
context 'with bitwise xor method' do
let(:method_name) { :^ }
let(:expected_spec_file) { 'bitwise_xor_operator_spec.rb' }
@ -136,7 +164,7 @@ describe Mutant::Strategy::Rspec::ExampleLookup, '#spec_file' do
end
context 'with nomatch operator method' do
let(:method_name) { :'!~' }
let(:method_name) { :!~ }
let(:expected_spec_file) { 'nomatch_operator_spec.rb' }
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
@ -150,7 +178,7 @@ describe Mutant::Strategy::Rspec::ExampleLookup, '#spec_file' do
end
context 'with inequality operator method' do
let(:method_name) { :'!=' }
let(:method_name) { :!= }
let(:expected_spec_file) { 'inequality_operator_spec.rb' }
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'