Merge pull request #83 from heytrav/master

pod, local $@ and Test::Routine snippets
This commit is contained in:
Honza Pokorny 2012-03-11 11:36:27 -07:00
commit b347b12dcf
2 changed files with 25 additions and 8 deletions

View File

@ -34,3 +34,4 @@ marutanm
msanders
Povilas Balzaravičius Pawka
Dmitry Dementev
Travis Holton

View File

@ -47,10 +47,11 @@ snippet xunless
${1:expression} unless ${2:condition};${3}
# Try/Except
snippet eval
local $@;
eval {
${1:# do something risky...}
};
if ($@) {
if (my $e = $@) {
${2:# handle failure...}
}
# While Loop
@ -133,19 +134,19 @@ snippet begin
# call package function with some parameter
snippet pkgmv
__PACKAGE__->${1:package_method}(${2:var});
__PACKAGE__->${1:package_method}(${2:var})
# call package function without a parameter
snippet pkgm
__PACKAGE__->${1:package_method}();
__PACKAGE__->${1:package_method}()
# call package "get_" function without a parameter
snippet pkget
__PACKAGE__->get_${1:package_method}();
__PACKAGE__->get_${1:package_method}()
# call package function with a parameter
snippet pkgetv
__PACKAGE__->get_${1:package_method}(${2:var});
__PACKAGE__->get_${1:package_method}(${2:var})
# complex regex
snippet qrx
@ -214,6 +215,15 @@ snippet psub
${2:Summary....}
# Heading for inline subroutine pod
snippet psubi
=head2 ${1:MethodName}
${2:Summary...}
=cut
# Subroutine signature
snippet parg
@ -257,7 +267,7 @@ snippet moosecl
package ${1:ClassName};
use Moose;
#extends ${2:# ParentClass};
#extends '${2:# ParentClass}';
${6:# body of class}
@ -300,7 +310,7 @@ snippet override
# use test classes
snippet tuse
use Test::More;
use Test::Deep;
use Test::Deep ();
use Test::Exception;
# local test lib
@ -316,7 +326,7 @@ snippet trunner
use ${1:test_class};
$1->runtests();
#testclass
# Test::Class-style test
snippet tsub
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
my $self = shift;
@ -324,6 +334,12 @@ snippet tsub
}
# Test::Routine-style test
snippet trsub
test ${1:test_name} => { description => '${2:Description of test.}'} => sub {
my ($self) = @_;
${3:# test code}
};
#prep test method
snippet tprep