TStanley has asked for the wisdom of the Perl Monks concerning the following question:
eval{ require Test::More; }; if(@$){ BEGIN { $| = 1; print "1..11\n"; } END {print "not ok 1\n" unless $loaded;} use Games::QuizTaker; $loaded = 1; print"Loaded ................. ok 1\n"; $Q1=Games::QuizTaker->new(FileName=>"sampleqa",Score=>1); if($$Q1{_FileName} eq "sampleqa"){ print"{_FileName} ............ ok 2\n"; }else{ print"{_FileName} ............ not ok 2\n"; } if($$Q1{_Delimiter} eq "|"){ print"{_Delimiter} ........... ok 3\n"; }else{ print"{_Delimiter} ........... not ok 3\n"; } $Q2=Games::QuizTaker->new(FileName=>"sample.csv",Delimiter=>","); if($$Q2{_Delimiter} eq ","){ print"{_Delimiter} init ...... ok 4\n"; }else{ print"{_Delimiter} init ...... not ok 4\n"; } my %hash=(); my $refhash=$Q1->load(\%hash); my $Num=keys %$refhash; if($Num == 9){ print"Load function .......... ok 5\n"; }else{ print"Load function .......... not ok 5\n"; } my($ref1,$ref2,$ref3,$ref4)=$Q1->generate(\%hash); my $num=keys %{$ref1}; if($num == 9){ print"Generate function ...... ok 6\n"; }else{ print"Generate function ...... not ok 6\n"; } my $V=$Q2->get_VERSION; if($V=~/^\d\.\d{1,3}/){ print"Version function ....... ok 7\n"; }else{ print"Version function ....... not ok 7\n"; } my $Q3=Games::QuizTaker->new(FileName=>"sample.csv",Delimiter=>",",Ans +wer_Delimi ter=>"x"); my $del=$Q3->get_Answer_Delimiter; if($del eq "x"){ print"Answer_Delimiter init .. ok 8\n"; }else{ print"Answer_Delimiter init .. not ok 8\n"; } my $Max=$Q3->get_Max_Questions; if($Max == 0){ print"Max_Questions init ..... ok 9\n"; }else{ print"Max_Questions init ..... not ok\n"; } my $Final=$Q3->get_Score; if(! defined $Final) { print"Final Score default .... ok 10\n"; }else{ print"Final Score default .... not ok 10\n"; } my $Final2=$Q1->get_Score; if(defined $Final2){ print"Final Score set ........ ok 11\n"; }else{ print"Final Score set ........ not ok 11\n"; } }else{ require Test::More; BEGIN { use_ok('Games::QuizTaker', 'Games::QuizTaker loaded'); } $Q1=Games::QuizTaker->new(FileName=>"sampleqa",Score=>1); ok($$Q1{_FileName} eq "sampleqa", 'FileName set'); ok($$Q1{_Delimiter} eq "|", 'Default delimiter set'); $Q2=Games::QuizTaker->new(FileName=>"sample.csv",Delimiter=>","); ok($$Q2{_Delimiter} eq ",",'File Delimiter set'); my %hash=(); my $refhash=$Q1->load(\%hash); my $Num=keys %$refhash; ok($Num == 9,'Load Function'); my($ref1,$ref2,$ref3,$ref4)=$Q1->generate(\%hash); my $num=keys %{$ref1}; ok($num == 9,'Generate Function'); my $V=$Q2->get_VERSION; ok($V=~/^\d\.\d{1,3}/, 'VERSION Function'); my $Q3=Games::QuizTaker->new(FileName=>"sample.csv",Delimiter=>",",A +nswer_Delimiter=>"x"); my $del=$Q3->get_Answer_Delimiter; ok($del eq "x", 'Answer_Delimiter init'); my $Max=$Q3->get_Max_Questions; ok($Max == 0,'Max Questions init'); my $Final=$Q3->get_Score; ok(! defined $Final,'Default Final Score'); my $Final2=$Q1->get_Score; ok(defined $Final2, 'Set Final Score'); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Working with Test::More
by Abigail-II (Bishop) on Oct 29, 2003 at 15:38 UTC | |
|
Re: Working with Test::More
by adrianh (Chancellor) on Oct 29, 2003 at 16:36 UTC | |
by sfink (Deacon) on Oct 29, 2003 at 17:39 UTC | |
by adrianh (Chancellor) on Oct 30, 2003 at 17:01 UTC | |
by chromatic (Archbishop) on Oct 29, 2003 at 20:19 UTC | |
|
Re: Working with Test::More
by jZed (Prior) on Oct 29, 2003 at 16:13 UTC | |
by Abigail-II (Bishop) on Oct 29, 2003 at 16:17 UTC | |
by jZed (Prior) on Oct 29, 2003 at 16:31 UTC | |
by Abigail-II (Bishop) on Oct 29, 2003 at 16:51 UTC | |
|
Re: Working with Test::More
by TStanley (Canon) on Oct 29, 2003 at 23:28 UTC |