Add mutations for super
This commit is contained in:
parent
08eb381c37
commit
36f1b8d0ec
5 changed files with 54 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
# v0.2.9 2013-01-01
|
||||
# v0.2.9 2013-01-02
|
||||
|
||||
* [feature] Mutate instance and global variable assignments
|
||||
* [feature] Mutate super calls
|
||||
|
|
|
@ -37,6 +37,8 @@ module Mutant
|
|||
handle(Rubinius::AST::OpAssign1)
|
||||
handle(Rubinius::AST::ConstantAccess)
|
||||
handle(Rubinius::AST::Yield)
|
||||
handle(Rubinius::AST::Begin)
|
||||
handle(Rubinius::AST::Rescue)
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -31,8 +31,22 @@ module Mutant
|
|||
#
|
||||
def dispatch
|
||||
emit_node(Rubinius::AST::ZSuper)
|
||||
emit_without_block
|
||||
emit_attribute_mutations(:block) if node.block
|
||||
emit_attribute_mutations(:arguments)
|
||||
end
|
||||
|
||||
# Emit without block mutation
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_without_block
|
||||
dup = dup_node
|
||||
dup.block = nil
|
||||
emit(dup)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|||
gem.extra_rdoc_files = %w[TODO LICENSE]
|
||||
gem.executables = [ 'mutant' ]
|
||||
|
||||
gem.add_runtime_dependency('to_source', '~> 0.2.6')
|
||||
gem.add_runtime_dependency('to_source', '~> 0.2.7')
|
||||
gem.add_runtime_dependency('ice_nine', '~> 0.6.0')
|
||||
gem.add_runtime_dependency('descendants_tracker', '~> 0.0.1')
|
||||
gem.add_runtime_dependency('backports', '~> 2.6')
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe Mutant::Mutator, 'super' do
|
||||
|
||||
context 'super no arguments' do
|
||||
context 'with no arguments' do
|
||||
let(:source) { 'super' }
|
||||
|
||||
let(:mutations) do
|
||||
|
@ -13,7 +13,7 @@ describe Mutant::Mutator, 'super' do
|
|||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'super with explicit empty arguments' do
|
||||
context 'with explicit empty arguments' do
|
||||
let(:source) { 'super()' }
|
||||
|
||||
let(:mutations) do
|
||||
|
@ -24,6 +24,21 @@ describe Mutant::Mutator, 'super' do
|
|||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'with explicit empty arguments and block' do
|
||||
let(:source) { 'super() { foo; bar }' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'super() { foo }'
|
||||
mutations << 'super() { bar }'
|
||||
mutations << 'super() { }'
|
||||
mutations << 'super()'
|
||||
mutations << 'super'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'super with arguments' do
|
||||
let(:source) { 'super(foo, bar)' }
|
||||
|
||||
|
@ -37,4 +52,22 @@ describe Mutant::Mutator, 'super' do
|
|||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'super with arguments and block' do
|
||||
let(:source) { 'super(foo, bar) { foo; bar }' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'super(foo, bar) { foo; }'
|
||||
mutations << 'super(foo, bar) { bar; }'
|
||||
mutations << 'super(foo, bar) { nil }'
|
||||
mutations << 'super(foo, bar)'
|
||||
mutations << 'super'
|
||||
mutations << 'super(foo) { foo; bar }'
|
||||
mutations << 'super(bar) { foo; bar }'
|
||||
mutations << 'super() { foo; bar }'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue