Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ChrisDolan (2855)

ChrisDolan
  (email not shown publicly)
http://www.chrisdolan.net/

Journal of ChrisDolan (2855)

Sunday November 18, 2007
01:49 PM

Improvement to "Cool hack: annotating compatibility in test"

[ #34920 ]

In my last journal entry, I described a trick using subroutine attributes to annotate the compatibility version of a test in a test suite. I discovered that my trick didn't work for subclasses. This is a correction to make it work in that scenario.


sub Introduced : ATTR(CODE) {
      my ($class, $symbol, $code_ref, $attr, $introduced_version) = @_;
      # Wrap the sub in a version test
      no warnings 'redefine';
      *{$symbol} = sub {
            no strict 'refs';
            local
${$class.'::TODO'} = $_[0]->_compatible($introduced_version);
            $code_ref->(@_);
      };
}

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.