Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

(jeffa) Re: RFC: Seconds2English

by jeffa (Bishop)
on Jul 18, 2003 at 21:19 UTC ( [id://275756]=note: print w/replies, xml ) Need Help??


in reply to RFC: Seconds2English

From your __END__ block:

Tests - not sure what to test, you tried to break it as you wrote it
Too bad you didn't "document" the process of breaking your code ... you would have already finished that requirement. * Tis better to write the test suite along side the code instead of waiting until you are "finished". I sure wish that i had ...

*of course, testing is never finished

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: RFC: Seconds2English
by Limbic~Region (Chancellor) on Jul 18, 2003 at 21:27 UTC
    jeffa,
    Ok - for example:
  • Ensuring that there was an even numbered list if assigning to a hash
  • Ensuring that division by 0 would not happen
  • Ensuring that a variable looked like a number before performing a numerical operation on it
  • Ensuring that if someone passes a bad option to the get routine it gets trapped in an eval

    These are the types of things that I did - how would I incorporate them into a test. I was under the impression that tests were designed to make sure your code works the same on someone else's platform and version of Perl as you coded it???

    Cheers and thanks - L~R

      First off, read chromatic's Introduction to Testing article at perl.com if you already haven't.

      You test your interface and make sure that you get the expected results. Tests for the items that you mentioned are 'user errors' ... you write validation code for that instead. While i am sure that is possible to incorporate such 'contracts' into a test suite ... i am not sure that they belong there. Probably better is to pass some function an argument that would cause an illegal division by 0, and then test that the right error code or message was returned instead.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-24 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found