1#-*-cperl-*- 2# Before `make install' is performed this script should be runnable with 3# `make test'. After `make install' it should work as `perl test.pl' 4 5######################### 6 7use warnings; 8use strict; 9 10use lib qw( ../../lib ../lib lib ); #Just in case we are testing it in-place 11 12use Test::More tests => 303; 13 14BEGIN { 15 use_ok( 'Algorithm::Evolutionary::Op::String_Mutation' ); 16}; 17 18use Algorithm::Evolutionary::Individual::String; 19 20my $number_of_chars = 32; 21my $indi = new Algorithm::Evolutionary::Individual::String [ qw( A B C D E F) ], 22 $number_of_chars; 23 24my $sm = new Algorithm::Evolutionary::Op::String_Mutation; 25isa_ok( $sm, 'Algorithm::Evolutionary::Op::String_Mutation' ); 26 27my $result; 28for ( 1..100 ) { 29 $result = $sm->apply( $indi ); 30 isnt( $result->{'_str'}, $indi->{'_str'}, 31 $result->{'_str'}." differs from ". $indi->{'_str'}); 32 33} 34 35$sm = new Algorithm::Evolutionary::Op::String_Mutation $number_of_chars / 4; 36isa_ok( $sm, 'Algorithm::Evolutionary::Op::String_Mutation' ); 37 38for ( 1..100 ) { 39 $result = $sm->apply( $indi ); 40 isnt( $result->{'_str'}, $indi->{'_str'}, 41 $result->{'_str'}." differs from ". $indi->{'_str'}); 42 43} 44 45$indi->{'_str'} = 'BBBB'; 46$sm = new Algorithm::Evolutionary::Op::String_Mutation; 47for ( 1..100 ) { 48 $result = $sm->apply( $indi ); 49 isnt( $result->{'_str'}, $indi->{'_str'}, 50 $result->{'_str'}." differs from ". $indi->{'_str'}); 51 52} 53