Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Pod::Coverage for helper classes

by Discipulus (Canon)
on Feb 02, 2021 at 07:48 UTC ( [id://11127802]=note: print w/replies, xml ) Need Help??


in reply to Pod::Coverage for helper classes

Hello GrandFather,

not a solution but maybe something helpfull. You know I'm not an expert, just writing my first serious modules, but why your other classes are not in their own files? The assumption My::Module lives in @INC/My/Module.pm is a convention so widely used that at the end is a rule and a limitation. It seems Pod::Coverage too assumes this design. ( PS if your modules works fine why to care about Pod::Coverage ? ;)

That said I looked at source and pod_from comes from Pod::Find that describe itself with: NOTE: This module is considered legacy;

You can use sub Pod::Coverage::TRACE_ALL] () { 1 } to show where Pod::Coverage looks and, yes, I hacked it to force looking in the current file with pod_from => 'podcovtest.pm' but it fails requiring the package: requiring 'Segment' require failed with Can't locate Segment.pm in @INC

A semplified example (you forgot to return true ;) inside the file podcovtest.pm

use strict; use warnings; package Segment; sub new { 1 } sub Describe { 1 } package podcovtest; sub new { 1 } sub Describe { 1 } sub Pod::Coverage::TRACE_ALL () { 1 } use Pod::Coverage; foreach my $pkg ( qw( Segment podcovtest ) ){ my $pc = Pod::Coverage->new(package => $pkg, pod_from => 'podc +ovtest.pm'); print qq(OK $pkg\n) if $pc->coverage == 1; } 1; =pod =head1 NAME Segment =head2 Describe =head1 NAME podcovtest =head2 new =head2 Describe =head1 VERSION =head1 USAGE =item C<new(%params)> C<new(...)> creates a new ELF::File object and parses the Program Head +er table and the Section Header table. =item C<Describe()> C<Describe()> returns a multi-line string describing the ELF file head +er contents. =cut

and its output:

>perl -I . -Mpodcovtest -e 1 getting pod location for 'Segment' parsing 'podcovtest.pm' requiring 'Segment' require failed with Can't locate Segment.pm in @INC (you may need to i +nstall the Segment module) (@INC contains: . C:/EX_D/ulisseDUE/perl5. +26.64bit/perl/site/lib/MSWin32-x64-multi-thread C:/EX_D/ulisseDUE/per +l5.26.64bit/perl/site/lib C:/EX_D/ulisseDUE/perl5.26.64bit/perl/vendo +r/lib C:/EX_D/ulisseDUE/perl5.26.64bit/perl/lib) at (eval 8) line 1. Use of uninitialized value in numeric eq (==) at podcovtest.pm line 19 +. getting pod location for 'podcovtest' parsing 'podcovtest.pm' requiring 'podcovtest' walking symbols tying shoelaces $VAR1 = bless( { 'package' => 'podcovtest', 'nonwhitespace' => undef, 'private' => [ qr/^_/, qr/^(un)?import$/, qr/^DESTROY$/, qr/^AUTOLOAD$/, qr/^bootstrap$/, qr/^\(/, qr/^(TIE( SCALAR | ARRAY | HASH | HAND +LE ) | FETCH | STORE | UNTIE | FETCHSIZE | STORESIZE | POP | PUSH | SHIFT | UNSHIFT | SPLICE | DELETE | EXISTS | EXTEND | CLEAR | FIRSTKEY | NEXTKEY | PRINT | PR +INTF | WRITE | READLINE | GETC | READ | CLOSE | BINMODE | OPEN | EOF | FILENO | SEEK | TELL | SCALAR )$/x, qr/^( MODIFY | FETCH )_( REF | SCALAR +| ARRAY | HASH | CODE | GLOB | FORMAT | IO)_ATTRIBUTES $/x, qr/^CLONE(_SKIP)?$/ ], 'trustme' => [], 'pod_from' => 'podcovtest.pm', 'symbols' => { 'new' => 1, 'Describe' => 1 } }, 'Pod::Coverage' ); OK podcovtest

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Pod::Coverage for helper classes
by GrandFather (Saint) on Feb 02, 2021 at 08:34 UTC
    "why your other classes are not in their own files?"

    From my OP: "I could move the helpers out into other module files, but that gets pretty silly for some of the helper classes.". Some of the helper classes are very small and it is something of a pain to spin up a new module just to provide three methods in a helper class where each method is only a few lines long. It is also a pain during development to flip back and forth between different files as I evolve the design. None of these are show stopper reasons, but they add up to "I'd rather have the helpers in the main module file.".

    "PS if your modules works fine why to care about Pod::Coverage"

    My module doesn't yet "work fine" - I'm still writing it and I like to check code and documentation coverage as I write the code and even write tests for code I haven't written yet in some cases. Even if this were a complete working module, I'd still be concerned that tests, code coverage and documentation coverage were all up to snuff so that I can maintain the module with confidence.

    "you forgot to return true ;"

    From OP: "In outline the file looks something like"

    You may be interested to note that '...' is the yada yada statement. It is useful as a place holder for code yet to be written. It compiles correctly, but generates an error if executed. Kinda useful in code that isn't fleshed out yet. You can write a place holder sub and write tests against it which will fail until the ... is replaced by real code.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11127802]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (None)
    As of 2024-04-25 01:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found