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

Re: How to Ask a Question (With Test::More) (repost, now with Sitedocclan approval.)

by BrowserUk (Pope)
on Aug 06, 2005 at 10:41 UTC ( #481468=note: print w/replies, xml ) Need Help??


in reply to How to Ask a Question (With Test::More)

How is this better than?

Why does this shappen?
#! perl -slw use strict; sub times7 { my $number = shift or die "no number"; return $number*7; } print "times7( $_ ) returned:", times7( $_ ) for 1, 2, 3, 0; __END__ P:\test>junk times7( 1 ) returned:7 times7( 2 ) returned:14 times7( 3 ) returned:21 no number at P:\test\junk.pl line 5.

Seems to me that you are trying to address peoples inability to explain their problem, but asking them to learn to use a module that they almost certainly know nothing about, and serves no good purpose but to complicate the issue?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
  • Comment on Re: How to Ask a Question (With Test::More) (repost, now with Sitedocclan approval.)
  • Download Code

Replies are listed 'Best First'.
Re^2: How to Ask a Question (With Test::More) (repost, now with Sitedocclan approval.)
by tphyahoo (Vicar) on Aug 06, 2005 at 10:49 UTC
    Point taken browseruk, but I still believe in my tutorial.

    I think testing is a whole mindset, and it is a mindset it would have done me good to pick up earlier in the learning curve. Being encouraged to do this early on would have been a good thing.

    Maybe the example I used could have been better though. You think it would be better if one of the tests fails, rather than just dying? I am thinking of changing my post along these lines.

      Quite frankly, I think that in most instances, it is simple better to allow Perl to detect these kind of trivial errors, It most times does a better job of reporting the nature of the problem than the programmer will:

      #! perl -slw use strict; sub times7 { return $_[ 0 ] * 7; } print "times7( $_ ) returned:", times7( $_ ) for 1, 2, 3, 0, undef, 'f +red'; __END__ P:\test>junk times7( 1 ) returned:7 times7( 2 ) returned:14 times7( 3 ) returned:21 times7( 0 ) returned:0 Use of uninitialized value in concatenation (.) or string at P:\test\j +unk.pl line 8. Use of uninitialized value in multiplication (*) at P:\test\junk.pl li +ne 5. times7( ) returned:0 Argument "fred" isn't numeric in multiplication (*) at P:\test\junk.pl + line 5. times7( fred ) returned:0


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://481468]
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: (5)
As of 2020-04-03 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (27 votes). Check out past polls.

    Notices?