From: Vincent Pit Date: Mon, 4 Aug 2008 23:04:31 +0000 (+0200) Subject: Add support for localtime and caller X-Git-Tag: v0.02~12 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=dc163e7b80d5d2afe1a1ac7b6674d99d7040d861;p=perl%2Fmodules%2FSub-Nary.git Add support for localtime and caller --- diff --git a/lib/Sub/Nary.pm b/lib/Sub/Nary.pm index e658fd7..861f9e5 100644 --- a/lib/Sub/Nary.pm +++ b/lib/Sub/Nary.pm @@ -204,6 +204,8 @@ $ops{$_} = 1 for qw/padsv/; $ops{$_} = 'list' for qw/padav/; $ops{$_} = 'list' for qw/padhv rv2hv/; $ops{$_} = 'list' for qw/padany flip match entereval readline/; +$ops{caller} = sub { my @a = caller 0; scalar @a }->(); +$ops{localtime} = do { my @a = localtime; scalar @a }; sub enter { my ($self, $cv) = @_; diff --git a/t/20-return.t b/t/20-return.t index fc85334..087813e 100644 --- a/t/20-return.t +++ b/t/20-return.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 49; +use Test::More tests => 51; use Sub::Nary; @@ -72,6 +72,9 @@ my @tests = ( [ sub { eval 'return 1, 2' }, 'list' ], [ sub { return <$x> }, 'list' ], + + [ sub { return caller 0 }, sub { my @a = caller 0; scalar @a }->() ], + [ sub { return localtime }, do { my @a = localtime; scalar @a } ], ); my $i = 1; diff --git a/t/21-list.t b/t/21-list.t index 9adca6a..a9b1fdd 100644 --- a/t/21-list.t +++ b/t/21-list.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 35; +use Test::More tests => 37; use Sub::Nary; @@ -60,6 +60,9 @@ my @tests = ( [ sub { eval '1, 2' }, 'list' ], [ sub { <$x> }, 'list' ], + + [ sub { caller 0 }, sub { my @a = caller 0; scalar @a }->() ], + [ sub { localtime }, do { my @a = localtime; scalar @a } ], ); my $i = 1;