Very nice write-up by pemungkah above.
Just wanted to add one more thing: when you challange a test with a lot of different inputs I recommend defining the input and expected output in a data structure, such as an array of hashes like this:
my @tests = (
{
desc => "a file with wrong permissions can be repaired",
test_file => {
{ permission => "111",
contents => "some string"
},
is_valid => 0,
is_repairable => 1,
},
{ desc => "an invalid file that can not be repaired throws an error"
+
# ADD DATA HERE
}
);
Now it becomes much easier to test all those different cases in a loop that creates each of those files, gives it the permissions and maybe writes some content into it and then runs the tests for file validity and/or repairability (is that even a word?) on each one in turn without having to copy and paste the test code for each case.
You would feed the is_valid and is_repairable flags into the actual tests to decide which is the correct outcome and the desc would be the description printed by the tests. Adding another case is then as easy as adding another block of definitions to the above datastructure.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.