GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TEST2::UTIL::SUB (3)

.ds Aq ’

NAME

Test2::Util::Sub - Tools for inspecting and manipulating subs.

CONTENTS

DESCRIPTION

Utilities used by Test2::Tools to inspect and manipulate subroutines.

EXPORTS

All exports are optional, you must specify subs to import.
$name = sub_name(\&sub) Get the name of the sub.
my $hr = sub_info(\&code) This returns a hashref with information about the sub:



    {
        ref        => \&code,
        cobj       => $cobj,
        name       => "Some::Mod::code",
        file       => "Some/Mod.pm",
        package    => "Some::Mod",

        # Note: These have been adjusted based on guesswork.
        start_line => 22,
        end_line   => 42,
        lines      => [22, 42],

        # Not a bug, these lines are different!
        all_lines  => [23, 25, ..., 39, 41],
    };



$info->{ref} => \&code This is the original sub passed to sub_info().
$info->{cobj} => $cobj This is the c-object representation of the coderef.
$info->{name} => ‘‘Some::Mod::code’’ This is the name of the coderef, for anonymous coderefs this may end with __ANON__. Also note that the package ’main’ is special, and ’main::’ may be omitted.
$info->{file} => ‘‘Some/Mod.pm’’ The file in which the sub was defined.
$info->{package} => ‘‘Some::Mod’’ The package in which the sub was defined.
$info->{start_line} => 22
$info->{end_line} => 42
$info->{lines} => [22, 42] These 3 fields are the adjusted start line, end line, and array with both. It is important to note that these lines have been adjusted and may not be accurate.

The lines are obtained by walking the ops, as such the first line is the line of the first statement, and the last line is the line of the last statement. This means that in multi-line subs the lines are usually off by 1. The lines in these keys will be adjusted for you if it detects a multi-line sub.

$info->{all_lines} => [23, 25, ..., 39, 41] This is an array with the lines of every statement in the sub. unlike the other line fields, these have not been adjusted for you.

SOURCE

The source code repository for Test2-Suite can be found at http://github.com/Test-More/Test2-Suite/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>
Kent Fredric <kentnl@cpan.org>

COPYRIGHT

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TEST2::UTIL::SUB (3) 2016-03-20

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.