[Israel.pm] problem with a test

moshe nahmias moshegrey at ubuntu.com
Sun Dec 30 13:24:24 PST 2012


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.
In this case the program worked but the test failed when I used the next
loop

if ( @user_input and -e $user_input[0] ) {
   while ( my $input = <> ) {
     _populate($input);
   }
}

The while loop worked well if I used to feed it with a file in @ARGV, but
if I try to do it with a test like this

my $file = /path/to/file

is_deeply(
  [ $module->input( $file ) ],
  [ "2012", "http://mail.perl.org.il/pipermail/perl/", "10" ],
  'Input method works with file input',
);

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)

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?

Moshe

On Sun, Dec 30, 2012 at 2:35 PM, sawyer x <xsawyerx at gmail.com> wrote:

> On Thu, Dec 27, 2012 at 10:39 PM, moshe nahmias <moshegrey at ubuntu.com>wrote:
>
>> Hi,
>>
>> OK, I solved it and you gave me the idea :)
>> The problem was that when I gave the file the program thought it as a
>> parameter and didn't know what to do with it, while waiting for user input
>> because of <>. So I thought may be if I will add an open file it will know
>> what to do and it solved the problem.
>>
>> The only thing I don't get is why then did it work if I use the full
>> program? Why the test doesn't work as the program or vice versa?
>>
>
> I'm sorry, I don't understand you.
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20121230/4ad51b26/attachment.htm 


More information about the Perl mailing list