I decided the Test::MockObect route was the easier way to go (I couldn't get Test::Expect and its dependencies to complile on my Windows system, and
jcwren's system already had T::MO installed)
That said, I implemented the Games::QuizTaker:IO module and inserted it into the test section, so that it looks like the following:
print"Question Number $question_number\n";
foreach $line(@{$$questions{$key}}){
Games::QuizTaker::IO->out(wrap ("","","$line\n"));
}
print"Your Answer: ";
$answer=Games::QuizTaker::IO->in;
chomp($answer);
Well, the
in method works fine, the
out method has a slight problem. When I run a simple test script inside my development folder, this is what I get for output:
Question Number 1
Games::QuizTaker::IOWhat popular operating system was created by a Fin
+nish computer science
student name Linus Torvalds?
Games::QuizTaker::IOA. Unix
Games::QuizTaker::IOB. Minux
Games::QuizTaker::IOC. Linux
Games::QuizTaker::IOD. Windows
Your Answer:
Any suggestions?
UPDATE:
I figured it out. I changed the call from Games::QuizTaker::IO->out to Games::QuizTaker::IO::out. That got rid of the module name in front of the answers. Now to get the test working :-)
TStanley
--------
People sleep peaceably in their beds at night only because rough men stand ready to do violence on their behalf. -- George Orwell
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.