Fixing up Math::Primality – Part 1

Math::Primality is my one and only CPAN module, a result of my Google Summer of Code work almost two years ago. I was surprised about 10 months ago to get an email requesting features – I can’t believe someone is actually using this stuff! Well, I’ve put it off for a while so this weekend instead of doing homework I finally knocked out a few things on my todo list.

The main feature is more test coverage. We implemented some optimizations – for numbers of certain sizes there are actually simpler conditions to check. This optimization results in a speedup but the test suite no longer actually exercised some of the more complex code. To fix this, I had to find specific numbers that would exercise each condition. I use Devel::Cover and prove to check exactly what code was being exercised:

1) cover -delete

Not strictly necessary, but it’ll delete any previous coverage statistics

2) PERL5OPT=-MDevel::Cover prove -Ilib t/*.t

This runs prove, adds the ‘lib’ directory to my search path, and tells it to run every test in the t/ directory. Including Devel::Cover will automatically generate the coverage statistics.

3) cover

This will take the output and generate some pretty HTML. Each line is annotated with coverage statistics, and each conditional statement is annotated with how many different combinations of statements it has been tested with.

I’ve also converted the README to POD because GitHub supports rendering POD inline. Finally, I’ve run the entire module through perltidy (configuration from http://www.leifove.com/2011/02/why-i-use-perltidy-or-why-coding-style.html) to beautify the setup.

Next steps: run Perl::Critic and convert the distribution to use Dist::Zila. After that, I will begin work on Math::Primality::AKS.

Posted in Uncategorized | Comments Off on Fixing up Math::Primality – Part 1

Comments are closed.