My $0.02:
Very nice integration of IO::Capture.
I think this is very promising, but all the start(), stop() calls seem overly repetitive to me.
Agreed.
What about refactoring it into a set of test functions that handle it for the user automatically? Just quickly off the cuff, what about a test module (Test::Output? Test::Print? ) that provided functions like this:
stdout_is { fcn() } $string, "comment"; # exact stdout_like { fcn() } qr/regex/, "comment"; # regex match stdout_count { fcn() } qr/regex/, $count, "comment"; # number of matches stdout_found { fcn() } qr/regex/, [EMAIL PROTECTED], "comment"; # list of matches
To make sure that I understand you correctly, you're proposing something whose interface would look like this?
use Test::Print qw(stdout_count stdout_found);
my $regex = qr/English:.*?French:.*?Spanish:/s; stdout_count(print_week([EMAIL PROTECTED]), $regex, 7, "correct number of forms printed to screen");
$regex = qr/French:\s+(.*?)\n/s; my @predicted = qw| Lundi Mardi Mercredi Jeudi Vendredi Samedi Dimanche |; stdout_found(print_week([EMAIL PROTECTED]), $regex, @predicted, "all predicted matches found");
This interface would replace calls to functions/methods of three different modules (Test::More, IO::Capture::Stdout and TestAuxiliary) with calls to functions of just one module.
It's definitely promising. OTOH, there's something to be said for having functions that just return values which plug in nicely as arguments to Test::More functions.
This emerged as a side project to a side project, so I don't have time to think this through fully right now. But let's hear what other Test-conscious Perl hackers have to say.
David, thanks for taking the time to study this.
jimk