diff --git a/lib/mutant.rb b/lib/mutant.rb index 41450e46..44922526 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -10,36 +10,10 @@ require 'pp' # Library namespace module Mutant - - # Return deep clone of object - # - # @param [Object] object - # - # @return [Object] object - # - # @api private - # - def self.deep_clone(object) - Marshal.load(Marshal.dump(object)) - end - - # Check for ruby-1.8 mode - # - # @return [true] - # returns true if running under 1.8 mode - # - # @return [false] - # returns false otherwise - # - # @api private - # - def self.on_18? - RUBY_VERSION == '1.8.7' - end end require 'mutant/support/method_object' - +require 'mutant/helper' require 'mutant/random' require 'mutant/mutator' require 'mutant/mutation' diff --git a/lib/mutant/helper.rb b/lib/mutant/helper.rb new file mode 100644 index 00000000..5802bcd2 --- /dev/null +++ b/lib/mutant/helper.rb @@ -0,0 +1,37 @@ +module Mutant + # Module for support methods + # + # They would normally be defined on the root namespace. + # But it is easier to create the Zombie when there are no + # References to the root namespace name within the library. + # + module Helper + + # Return deep clone of object + # + # @param [Object] object + # + # @return [Object] object + # + # @api private + # + def self.deep_clone(object) + Marshal.load(Marshal.dump(object)) + end + + # Check for ruby-1.8 mode + # + # @return [true] + # returns true if running under 1.8 mode + # + # @return [false] + # returns false otherwise + # + # @api private + # + def self.on_18? + RUBY_VERSION == '1.8.7' + end + + end +end diff --git a/lib/mutant/loader.rb b/lib/mutant/loader.rb index 7bab3fe7..34865208 100644 --- a/lib/mutant/loader.rb +++ b/lib/mutant/loader.rb @@ -24,7 +24,7 @@ module Mutant # @api private # def initialize(root) - @root = Mutant.deep_clone(root) + @root = Helper.deep_clone(root) Rubinius.run_script(compiled_code) end diff --git a/lib/mutant/mutator.rb b/lib/mutant/mutator.rb index 928d155e..f46fde6c 100644 --- a/lib/mutant/mutator.rb +++ b/lib/mutant/mutator.rb @@ -44,7 +44,7 @@ module Mutant # @api private # def initialize(node, block) - @node, @block = Mutant.deep_clone(node), block + @node, @block = Helper.deep_clone(node), block IceNine.deep_freeze(@node) dispatch end diff --git a/lib/mutant/mutator/if_statement.rb b/lib/mutant/mutator/if_statement.rb index 33cead53..f248f65e 100644 --- a/lib/mutant/mutator/if_statement.rb +++ b/lib/mutant/mutator/if_statement.rb @@ -65,11 +65,11 @@ module Mutant # # @api private # - # Using '!' instead of :! since syntax highlighting in vim does not + # Using :'!' instead of :! since syntax highlighting in vim does not # capture literal symbol. # def invert(node) - if Mutant.on_18? + if Helper.on_18? return new(Rubinius::AST::Not,node) end diff --git a/lib/mutant/runner.rb b/lib/mutant/runner.rb index 33a6133c..eadac00d 100644 --- a/lib/mutant/runner.rb +++ b/lib/mutant/runner.rb @@ -55,9 +55,7 @@ module Mutant end @reporter = options.fetch(:reporter, Reporter::Null) - @errors = [] - run end diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/unit/mutant/mutator/if_statement/mutation_spec.rb b/spec/unit/mutant/mutator/if_statement/mutation_spec.rb index 140b3472..eaaa6b33 100644 --- a/spec/unit/mutant/mutator/if_statement/mutation_spec.rb +++ b/spec/unit/mutant/mutator/if_statement/mutation_spec.rb @@ -10,7 +10,7 @@ describe Mutant::Mutator, 'if statement' do mutants << 'if condition; true; else false; end' # Invert condition - if Mutant.on_18? + if Mutant::Helper.on_18? # Explicitly define ast as 18-mode does swap if and else on parsing when negation condition is # present in condition. mutants << [:if, [:not, [:call, [:self], :condition, [:arglist]]], [:true], [:false]]