in reply to Re^2: Testing Random Code
in thread Testing Random Code
Your approach to testing for digit usage seems ok to me, as the more condensed ways of doing it might be harder for a maintainer to follow. I would probably do this:
My only issue with the original test was that with more tests being added you need to accumulate more stats as you go, which adds complexity to the test script. I prefer to keep tests in neat little compartments when possible.my %unused = map {$_=>1} (0..9); for my $item (@items) { last unless %unused; delete $unused{$_} for split '', $item; } if (%unused) { fail(sprintf "Unused digits: %s", join(',',keys %unused)); } else { ok(1,"All digits used"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Testing Random Code
by Ovid (Cardinal) on Sep 19, 2006 at 12:20 UTC | |
by jwkrahn (Abbot) on Sep 19, 2006 at 14:32 UTC |