in reply to How to test caching?
use constant TEST_MODE => 1; sub foo ($) { my $arg = shift; state %cache; return $cache{$arg} if exists $cache{$arg}; if (TEST_MODE) { # ... something that would only run if cache failed } # ... }
Of course TEST_MODE needn't be a constant - it could be anything that detected this was running under a test harness. There was a node a while back about marking code as deprecated that would issue a warning during testing but would function normally in production. See RFC: Devel::Deprecate for possible ideas.
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |