Permalink
Browse files

added deep_clone-method to one_point_crossover.rb and tests to tc_one…

…_point_crossover.rb
  • Loading branch information...
1 parent e6b3191 commit 5bac538d214eea4e3ad62d7ccbff1d2199da55f7 @rkoecher rkoecher committed Apr 5, 2011
@@ -28,6 +28,12 @@ module Recombinations
class OnePointCrossover
+ #Return a deep copy of this operator
+
+ def deep_clone
+ self.clone
+ end
+
def recombine(parent_one, parent_two)
child_one = parent_one.deep_clone
child_two = parent_two.deep_clone
@@ -25,7 +25,7 @@
require 'shoulda'
require 'evosynth'
-require './test/test_util/test_helper'
+require_relative '../../../test/test_util/test_helper'
class OnePointCrossoverTest < Test::Unit::TestCase
@@ -43,6 +43,12 @@ class OnePointCrossoverTest < Test::Unit::TestCase
@individual_two.genome.map! { |gene| false }
end
+ should "deep_clone returns a deep copy" do
+ my_clone = @recombination.deep_clone
+ assert_not_equal my_clone.object_id, @recombination.object_id
+ assert_kind_of EvoSynth::Recombinations::OnePointCrossover, my_clone
+ end
+
context "before one-point-crossover is executed" do
should "all genes of individual one should be true" do

0 comments on commit 5bac538

Please sign in to comment.