Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Being more Assert-ive with Perl

by kappa (Chaplain)
on Sep 17, 2004 at 15:33 UTC ( [id://391813]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Being more Assert-ive with Perl
in thread Being more Assert-ive with Perl

Hm. Imagine a tool that takes all our declared contracts and composes a huge test suite that tries to test whether each contract is respected in our code, say, by feeding a series of valid and invalid data and turning off all runtime contract checks.

E.g. I declare that my complex compute_graviton_phasor_coefficient sub wants to take a positive prime number as argument. Now I'd like to get a test that will run it against random numbers and testing that it dies in the right places.

And, putting dreams aside, I'm going now to read about specification testing and try Test::LectroTest :)

Replies are listed 'Best First'.
Re^4: Being more Assert-ive with Perl
by stvn (Monsignor) on Sep 17, 2004 at 15:42 UTC
    Hm. Imagine a tool that takes all our declared contracts and composes a huge test suite that tries to test whether each contract is respected in our code, say, by feeding a series of valid and invalid data and turning off all runtime contract checks.

    I like the idea of a tool, but why turn off all runtime contract checks? Wouldn't you want them in there to catch the errors?

    And, putting dreams aside, I'm going now to read about specification testing and try Test::LectroTest :)

    Me too, Test::LectroTest looks very cool.

    -stvn
      I like the idea of a tool, but why turn off all runtime contract checks? Wouldn't you want them in there to catch the errors?

      What's the point of testing the code below with something but positive numbers?

      is_numeric($_[0]) && $_[0] > 0 or die "Invalid input, give me a positi +ve number\n"; # is_numeric taken from perlfaq4

      This check is here for a reason and we'd like to test the reasoning. Will it die horribly trying to multiply a hashref by two or taking a square root of -100? Will it just plain lie?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://391813]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-23 20:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found