Merge pull request #83 from heytrav/master
pod, local $@ and Test::Routine snippets
This commit is contained in:
commit
b347b12dcf
1
AUTHORS
1
AUTHORS
@ -34,3 +34,4 @@ marutanm
|
|||||||
msanders
|
msanders
|
||||||
Povilas Balzaravičius Pawka
|
Povilas Balzaravičius Pawka
|
||||||
Dmitry Dementev
|
Dmitry Dementev
|
||||||
|
Travis Holton
|
||||||
|
@ -47,10 +47,11 @@ snippet xunless
|
|||||||
${1:expression} unless ${2:condition};${3}
|
${1:expression} unless ${2:condition};${3}
|
||||||
# Try/Except
|
# Try/Except
|
||||||
snippet eval
|
snippet eval
|
||||||
|
local $@;
|
||||||
eval {
|
eval {
|
||||||
${1:# do something risky...}
|
${1:# do something risky...}
|
||||||
};
|
};
|
||||||
if ($@) {
|
if (my $e = $@) {
|
||||||
${2:# handle failure...}
|
${2:# handle failure...}
|
||||||
}
|
}
|
||||||
# While Loop
|
# While Loop
|
||||||
@ -133,19 +134,19 @@ snippet begin
|
|||||||
|
|
||||||
# call package function with some parameter
|
# call package function with some parameter
|
||||||
snippet pkgmv
|
snippet pkgmv
|
||||||
__PACKAGE__->${1:package_method}(${2:var});
|
__PACKAGE__->${1:package_method}(${2:var})
|
||||||
|
|
||||||
# call package function without a parameter
|
# call package function without a parameter
|
||||||
snippet pkgm
|
snippet pkgm
|
||||||
__PACKAGE__->${1:package_method}();
|
__PACKAGE__->${1:package_method}()
|
||||||
|
|
||||||
# call package "get_" function without a parameter
|
# call package "get_" function without a parameter
|
||||||
snippet pkget
|
snippet pkget
|
||||||
__PACKAGE__->get_${1:package_method}();
|
__PACKAGE__->get_${1:package_method}()
|
||||||
|
|
||||||
# call package function with a parameter
|
# call package function with a parameter
|
||||||
snippet pkgetv
|
snippet pkgetv
|
||||||
__PACKAGE__->get_${1:package_method}(${2:var});
|
__PACKAGE__->get_${1:package_method}(${2:var})
|
||||||
|
|
||||||
# complex regex
|
# complex regex
|
||||||
snippet qrx
|
snippet qrx
|
||||||
@ -214,6 +215,15 @@ snippet psub
|
|||||||
|
|
||||||
${2:Summary....}
|
${2:Summary....}
|
||||||
|
|
||||||
|
# Heading for inline subroutine pod
|
||||||
|
snippet psubi
|
||||||
|
=head2 ${1:MethodName}
|
||||||
|
|
||||||
|
${2:Summary...}
|
||||||
|
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
# Subroutine signature
|
# Subroutine signature
|
||||||
snippet parg
|
snippet parg
|
||||||
@ -257,7 +267,7 @@ snippet moosecl
|
|||||||
package ${1:ClassName};
|
package ${1:ClassName};
|
||||||
|
|
||||||
use Moose;
|
use Moose;
|
||||||
#extends ${2:# ParentClass};
|
#extends '${2:# ParentClass}';
|
||||||
|
|
||||||
${6:# body of class}
|
${6:# body of class}
|
||||||
|
|
||||||
@ -300,7 +310,7 @@ snippet override
|
|||||||
# use test classes
|
# use test classes
|
||||||
snippet tuse
|
snippet tuse
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use Test::Deep;
|
use Test::Deep ();
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
|
|
||||||
# local test lib
|
# local test lib
|
||||||
@ -316,7 +326,7 @@ snippet trunner
|
|||||||
use ${1:test_class};
|
use ${1:test_class};
|
||||||
$1->runtests();
|
$1->runtests();
|
||||||
|
|
||||||
#testclass
|
# Test::Class-style test
|
||||||
snippet tsub
|
snippet tsub
|
||||||
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
|
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
|
||||||
my $self = shift;
|
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
|
#prep test method
|
||||||
snippet tprep
|
snippet tprep
|
||||||
|
Loading…
x
Reference in New Issue
Block a user