I asked about this in the CB but I messed up the question so I'm asking it here again, this time (hopefully) coherently. Plus, since I asked that question I found something that
works but I'd like to know if it's correct or I'm doing it all wrong
My overall goal is just learning about
Test::Simple and
Test::More.
My module:
#!/usr/bin/perl
package Mymodule;
use strict;
use warnings;
require Exporter;
our @ISA=qw(Exporter);
our @EXPORT_OK = qw( values );
sub values {
my $val1 = $_[0];
my $val2 = $_[1];
return ($val1, $val2);
}
1;
My test:
#!/usr/bin/perl
use strict;
use warnings;
use Mymodule qw( values );
use Test::More qw(no_plan);
BEGIN { use_ok('Mymodule', qw( values )) };
my $pig = 3;
my $cow = 4;
is( values($pig, $cow ), (3 and 4), "checking values" ) ;
The results look good:
ok 1 - use Mymodule;
ok 2 - checking values
1..2
The question is whether or not using the
(3 and 4) in the $expected position is the proper way to do this?
Here's how I thought it should work:
is( values($pig, $cow ), (3, 4), "checking values" ) ;
but fails:
ok 1 - use Mymodule;
Useless use of a constant in void context at ./mymodule.t line 12.
ok 2 - checking values
1..2
Any advice? Maybe stop worrying and be happy it works and move on. :)
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.