[Israel.pm] problem with a test

sawyer x xsawyerx at gmail.com
Mon Dec 31 02:36:46 PST 2012

On Sun, Dec 30, 2012 at 11:24 PM, moshe nahmias <moshegrey at ubuntu.com>wrote:

> As far as I know the tests are supposed to work as any other
> script/programs so if the program works the test is supposed to work too.

Yes, and no.

A test provides a compartmentalized environment for running the application
code. That's the "yes" part.
However, this environment might be a bit different. Environment variables,
harness, etc. That's the "no" part.
It drifts more into the "yes" part though, so that's the good news. :)

> it doesn't work with the code like shown above if I write in the terminal
> ./input.t BUT if I write ./input.t something (any character at all) it pass
> the test.
> Why? What makes the difference? As far as I understand it there is no
> difference in the code on the program and on the test (if you want me to
> copy all the code till that point I can do it)

The problem is that you're using the diamond operator (<>), which is...
"magical" and DWIMmish.

> One more thing, I want to check for the possibility that the user will
> enter just one or two parameters in the input, but the object doesn't
> forget the parameters I got in, does that mean I have to make more objects
> ( or rewrite the data) or there is a better way?

You should separate the fetching of information from STDIN/ARGV and parsing
them. That would make it much easier to test.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20121231/4a26069f/attachment.htm 

More information about the Perl mailing list