Skip to content
Browse files

Filter out rbx literals/nodes that Mutant doesn't support.

  • Loading branch information...
1 parent f182bb4 commit ffe4656139e00ff3d485ebe3531219ebad69cf2a @justinko justinko committed Feb 9, 2012
Showing with 16 additions and 19 deletions.
  1. +8 −8 lib/mutant/literal.rb
  2. +8 −11 lib/mutant/mutatee.rb
View
16 lib/mutant/literal.rb
@@ -1,7 +1,7 @@
module Mutant
class Literal
def self.literal_class(node)
- const_get(node.class.name.split('::').last)
+ const_get(node.class.basename)
end
def initialize(node)
@@ -13,39 +13,39 @@ def swap
@class.new(@node).swap
end
- class Base
+ class BaseLiteral
def initialize(node)
@node = node
end
end
- class FalseLiteral < Base
+ class FalseLiteral < BaseLiteral
def swap
Rubinius::AST::TrueLiteral.new(@node.line)
end
end
- class TrueLiteral < Base
+ class TrueLiteral < BaseLiteral
def swap
Rubinius::AST::FalseLiteral.new(@node.line)
end
end
- class SymbolLiteral < Base
+ class SymbolLiteral < BaseLiteral
def swap
@node.value = Random.symbol
@node
end
end
- class StringLiteral < Base
+ class StringLiteral < BaseLiteral
def swap
@node.string = Random.string
@node
end
end
- class Range < Base
+ class Range < BaseLiteral
def swap
range = Random.range
@node.start = Rubinius::AST::FixnumLiteral.new(@node.line, range.min)
@@ -54,7 +54,7 @@ def swap
end
end
- class LocalVariableAssignment < Base
+ class LocalVariableAssignment < BaseLiteral
def swap
@node.value = literal_class.new(@node.value.clone).swap
@node
View
19 lib/mutant/mutatee.rb
@@ -14,7 +14,9 @@ def initialize(implementation)
def_delegators :@implementation, :class_name, :method_name, :to_s
def clean
- body.array.delete_if {|literal| literal.is_a?(Rubinius::AST::NilLiteral) }
+ body.array.delete_if do |literal|
+ not Mutant::Literal.constants.include?(literal.class.basename)
+ end
end
def set_mutations
@@ -40,18 +42,13 @@ def body
end
def rbx_method
- @rbx_method ||= begin
+ @rbx_method ||=
case implementation.scope_type
- when :singleton
- SingletonMethod.new(
- implementation.constant.method(method_name)
- )
- when :instance
- InstanceMethod.new(
- implementation.constant.instance_method(method_name)
- )
+ when :singleton then SingletonMethod.new \
+ implementation.constant.method(method_name)
+ when :instance then InstanceMethod.new \
+ implementation.constant.instance_method(method_name)
end
- end
end
private

0 comments on commit ffe4656

Please sign in to comment.
Something went wrong with that request. Please try again.