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

Re^3: RFC: How did I do writing my first test?

by jcb (Vicar)
on Sep 27, 2020 at 02:33 UTC ( #11122254=note: print w/replies, xml ) Need Help??


in reply to Re^2: RFC: How did I do writing my first test?
in thread RFC: How did I do writing my first test?

This is why you should write full-coverage testsuites — in the course of testing every path, you are likely to find edge cases that you had not recognized before.

For this particular problem, the easiest solution, assuming that you chomp each input line is to put the code that adds before and after strings in an unless (m/^$/) block. (If you do not chomp the input, change the regex match to m[^$/$], quickly tested here with perl -e 'while (<>) { print "empty\n" if m[^$/$] }' and typing some sample input.)

Replies are listed 'Best First'.
Re^4: RFC: How did I do writing my first test?
by stevieb (Canon) on Sep 28, 2020 at 01:51 UTC
    "This is why you should write full-coverage testsuites in the course of testing every path, you are likely to find edge cases that you had not recognized before."

    An API (or any code) should have tests written before, during and after completion. Especially after the documentation is completed, to verify.

    You're right about the edge cases. They get found in testing, and then become tests themselves.

    If one doesn't find issues when running their test suites against their code after significant updates, the test suite is insufficient.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2021-01-15 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?