Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Along those lines, I'd suggest streamlining it even more and submitting it as a test file (i.e. use Test::More instead of print. For example:

use strict; use warnings; use Test::More tests => 3; use bignum; sub xe{ $_[0]*log($_[0])+log(atan2(1,1)*8*$_[0])/2 + 1/(12*$_[0]) - 1/(360*($_[0]**3)) + 1/(1260*($_[0]**5)); } my ($m, $n, $r) = ( 2**96, 3*(10**6), 1*(10**6) ); my $e=exp(xe($m-$n)+xe($m-$r)-xe($m)-xe($m-$n-$r)); is( $e , 1, '$e should equal 1' ); is( 1-$e , 0, '1-$e should equal 0' ); is( 1-"$e" , 0, '1-"$e" should equal 0' );

Gives:

1..3 ok 1 - $e should equal 1 not ok 2 - 1-$e should equal 0 # Failed test (bigtest.pl at line 17) # got: '1' # expected: '0' ok 3 - 1-"$e" should equal 0 # Looks like you failed 1 test of 3.

That's even easier for a module author to work with.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.


In reply to Re^3: Help me make a test case for Math::BigFloat by xdg
in thread Help me make a test case for Math::BigFloat by fizbin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-03-28 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found