Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Test::More how come?

by sem999 (Initiate)
on Jan 30, 2013 at 17:02 UTC ( #1016102=perlquestion: print w/ replies, xml ) Need Help??
sem999 has asked for the wisdom of the Perl Monks concerning the following question:

Test::More confuse me;

1. the code

#!/usr/local/bin/perl use Test::More; print "4 - 2 = " , ( 4 - 2 ) . "\n"; cmp_ok ( 4 - 2 , '==', 2, "maths works" ); print "\n"; print "-2.3 - -0.6 = " . ( -2.3 - -0.6 ) ."\n"; cmp_ok ( -2.3 - -0.6 , '==', -1.7, "maths works" ); done_testing();

2. the output

# ./p.pl 4 - 2 = 2 ok 1 - maths works -2.3 - -0.6 = -1.7 not ok 2 - maths works # Failed test 'maths works' # at ./p.pl line 13. # got: -1.7 # expected: -1.7 1..2 # Looks like you failed 1 test of 2.

Comment on Test::More how come?
Select or Download Code
Re: Test::More how come?
by tmharish (Friar) on Jan 30, 2013 at 17:10 UTC

    Generally STDOUT does not show up with make test

    You can use diag or print STDERR :

    #!/usr/local/bin/perl use Test::More; print STDERR "4 - 2 = " , ( 4 - 2 ) . "\n"; cmp_ok ( 4 - 2 , '==', 2, "maths works" ); print STDERR "\n"; print STDERR "-2.3 - -0.6 = " . ( -2.3 - -0.6 ) ."\n"; cmp_ok ( -2.3 - -0.6 , '==', -1.7, "maths works" ); done_testing();
      Sure, but don't you think the second test should PASS? have i made some really simple mistake but just can't see it??

        It'll work if you use eq instead of ==.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1016102]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-08-21 12:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (134 votes), past polls