Vim::Helper::Test - Plugin for switching between test and implementation files.
Provides keybindings that take you between test files and module files.
In your config file:
use Vim::Helper qw/ Test /; Test { from_mod => sub { my ( $filename, $modname, @modparts ) = @_; return 't/' . join( "-" => @modparts ) . ".t"; }, from_test => sub { my ( $filename, $modname, @modparts ) = @_; $filename =~ s{^t/}{}; $filename =~ s{^.*/t/}{}; $filename =~ s{\.t$}{}; my ( @parts ) = split '-', $filename; return join( '/' => @parts ) . '.pm'; }, };
Takes the module filename and returns the test file name.
Takes the test filename and returns the module file name.
None
How to get the test filename from a module file. Default is to take the package name, change the '::' to '-', and append '.t', it then looks for the file in 't/'. So Foo::Bar should be 't/Foo-Bar.t'.
A custom function would look like this:
sub { my ( $filename, $modname, @modparts ) = @_; ... return $new_filename; }
$filename will always be the files name. $modname is read from the top of the file, and @modparts contains each section of the module name split on '::'. If the file cannot be read an error is thrown, so it must be valid and contain a package declaration.
How to get the module filename from a test file. Default is to take the test filename, change '-' to '/', and strip off the directory and '.t'. The search path for the module is whatever is provided to LoadMod, or @INC if none LoadMod was not confgiured.
$filename will always be the files name. $modname is read from the top of the file, and @modparts contains each section of the module name split on '::'. Unlike the from_mod function, $modname may be undefined, and no declaration is required in the test files.
Key binding for moving from module to test.
Key binding for moving from test to module.
Chad Granum exodist7@gmail.com
Copyright (C) 2012 Chad Granum
Vim-Helper is free software; Standard perl licence.
Vim-Helper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
To install Vim::Helper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Vim::Helper
CPAN shell
perl -MCPAN -e shell install Vim::Helper
For more information on module installation, please visit the detailed CPAN module installation guide.