#! /usr/bin/perl use strict ; # Need to change these defintions and use statements # If the name has a ::, as in OddWins::Random # The Perl module chould be stored in OddWins/Random # That is, replace the ::'s, with /'s use OddWins::Random ; my $ClassNamePlayer = 'OddWins::Random' ; print "Runnng test on ${ClassNamePlayer}.\n" ; { print "Should 'print' as a HASH\n" ; my $playerT = $ClassNamePlayer->new(11, 5) ; print " ${playerT}\n\n" ; } print 'Testing initial opponentTakes ' . "with board size of 11 and max moves of 5\n" ; foreach my $arg ( 1, 5, 'a', 0, 6 ) { my $playerT = $ClassNamePlayer->new(11, 5) ; my $r = $playerT->opponentTakes($arg) ; print " ${arg} --> ${r}\n" ; } print "Testing two consecutive initial opponentTakes of 1\n" ; { my $playerT = $ClassNamePlayer->new(11, 5) ; my $r = $playerT->opponentTakes(1) ; print " 1 --> ${r}\n" ; $r = $playerT->opponentTakes(1) ; print " 1 --> ${r}\n"; } print "Testing two consecutive initial myTakes\n" ; { my $playerT = $ClassNamePlayer->new(11, 5) ; my $r = $playerT->myTakes() ; print " 1 --> ${r}\n" ; $r = $playerT->myTakes() ; print " 1 --> ${r}\n"; } print "Testing taking too many by opponent\n" ; { my $playerT = $ClassNamePlayer->new(11, 5) ; my $r = 1 ; while ($r>0) { $r = $playerT->opponentTakes(5) ; print " OpponentTakes 5 --> ${r}\n" ; if ($r>0) { $r = $playerT->myTakes() ; print " MyTakes --> ${r}\n"; } } }