I've included the code below:
package abcd; use strict; use warnings; $|++; sub log { my $method = shift; my $time = localtime(time); my $args = @_ ? (' ' . join(', ', @_) . ' ') : ''; warn "$time: $method($args)\n"; } ----------------- # t/001_log.t # - verify log() works use strict; use warnings; $|++; use Test::More; use IO::Scalar; plan tests => 4; my $CLASS = 'abcd'; use_ok( $CLASS ); my $log; close STDERR; tie *STDERR, 'IO::Scalar', \$log; my $ref = \&abcd::log; $log = ''; $ref->( 'foo' ); like( "$log", qr!^\w{3} \w{3} \d\d \d\d:\d\d:\d\d \d{4}: foo\(\)\n$! ) +; $log = ''; $ref->( 'foo', 'bar' ); like( "$log", qr!^\w{3} \w{3} \d\d \d\d:\d\d:\d\d \d{4}: foo\( bar \)\ +n$! ); $log = ''; $ref->( 'foo', 'bar', 'baz' ); like( "$log", qr!^\w{3} \w{3} \d\d \d\d:\d\d:\d\d \d{4}: foo\( bar, ba +z \)\n$! ) ;
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
In reply to Devel::Cover not finding a test? by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |