Add super mutations
This commit is contained in:
parent
9aeeb7899d
commit
08eb381c37
4 changed files with 87 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
# v0.2.9 2013-01-01
|
||||
|
||||
* [feature] Mutate instance and global variable assignments
|
||||
* [feature] Mutate super calls
|
||||
|
||||
[Compare v0.2.8..v0.2.9](https://github.com/mbj/mutant/compare/v0.2.8...v0.2.9)
|
||||
|
||||
# v0.2.8 2012-12-29
|
||||
|
||||
* [feature] Do not mutate argument or local variable names beginning with an underscore
|
||||
|
|
|
@ -83,6 +83,7 @@ require 'mutant/mutator/node/literal/regex'
|
|||
require 'mutant/mutator/node/literal/nil'
|
||||
require 'mutant/mutator/node/block'
|
||||
require 'mutant/mutator/node/while'
|
||||
require 'mutant/mutator/node/super'
|
||||
require 'mutant/mutator/node/send'
|
||||
require 'mutant/mutator/node/assignment'
|
||||
require 'mutant/mutator/node/define'
|
||||
|
|
39
lib/mutant/mutator/node/super.rb
Normal file
39
lib/mutant/mutator/node/super.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
|
||||
class ZSuper < self
|
||||
|
||||
handle(Rubinius::AST::ZSuper)
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_node(Rubinius::AST::Super, new(Rubinius::AST::ActualArguments))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Super < self
|
||||
handle(Rubinius::AST::Super)
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_node(Rubinius::AST::ZSuper)
|
||||
emit_attribute_mutations(:arguments)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
spec/unit/mutant/mutator/node/super/mutation_spec.rb
Normal file
40
spec/unit/mutant/mutator/node/super/mutation_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator, 'super' do
|
||||
|
||||
context 'super no arguments' do
|
||||
let(:source) { 'super' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'super()'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'super with explicit empty arguments' do
|
||||
let(:source) { 'super()' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'super'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'super with arguments' do
|
||||
let(:source) { 'super(foo, bar)' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'super'
|
||||
mutations << 'super()'
|
||||
mutations << 'super(foo)'
|
||||
mutations << 'super(bar)'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue