[libtype-tiny-perl] 09/14: improve Eval::TypeTiny test cases

Jonas Smedegaard dr at jones.dk
Fri May 30 17:41:31 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.043_03
in repository libtype-tiny-perl.

commit cb732df39a59beb1ca3468a140a9167b5e99bf27
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date:   Tue May 6 21:04:30 2014 +0100

    improve Eval::TypeTiny test cases
---
 lib/Eval/TypeTiny.pm            |  7 +++++--
 t/20-unit/Eval-TypeTiny/basic.t | 10 +++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/Eval/TypeTiny.pm b/lib/Eval/TypeTiny.pm
index f055215..2850035 100644
--- a/lib/Eval/TypeTiny.pm
+++ b/lib/Eval/TypeTiny.pm
@@ -9,8 +9,11 @@ BEGIN {
 {
 	my $hlv;
 	sub HAS_LEXICAL_VARS () {
-		$hlv = !! eval { require Devel::LexAlias } unless defined $hlv;
-		return $hlv;
+		$hlv = !! eval {
+			require Devel::LexAlias;
+			exists(&Devel::LexAlias::lexalias);
+		} unless defined $hlv;
+		$hlv;
 	}
 }
 
diff --git a/t/20-unit/Eval-TypeTiny/basic.t b/t/20-unit/Eval-TypeTiny/basic.t
index b9d5e39..551e31e 100644
--- a/t/20-unit/Eval-TypeTiny/basic.t
+++ b/t/20-unit/Eval-TypeTiny/basic.t
@@ -111,7 +111,7 @@ is($external, 42, 'closing over variables really really really works!');
 			push @store, $_[0];
 			$self->SUPER::STORE(@_);
 		}
-		sub my_method { 42 }
+		sub method_of_mine { 42 }
 	}
 	
 	tie(my($var), 'MyTie');
@@ -119,7 +119,7 @@ is($external, 42, 'closing over variables really really really works!');
 	$var = 1;
 	
 	my $closure = eval_closure(
-		source       => 'sub { $xxx = $_[0]; tied($xxx)->my_method }',
+		source       => 'sub { $xxx = $_[0]; tied($xxx)->method_of_mine }',
 		environment  => { '$xxx' => \$var },
 		alias        => 1,
 	);
@@ -133,7 +133,7 @@ is($external, 42, 'closing over variables really really really works!');
 		alias        => 1,
 	);
 	
-	ok( $nother_closure->('my_method'), '... can');
+	ok( $nother_closure->('method_of_mine'), '... can');
 	ok(!$nother_closure->('your_method'), '... !can');
 
 	is_deeply(
@@ -145,7 +145,7 @@ is($external, 42, 'closing over variables really really really works!');
 	{
 		package OtherTie;
 		our @ISA = 'MyTie';
-		sub my_method { 666 }
+		sub method_of_mine { 666 }
 	}
 	
 	tie($var, 'OtherTie');
@@ -153,7 +153,7 @@ is($external, 42, 'closing over variables really really really works!');
 
 	untie($var);
 	my $e = exception { $closure->(5) };
-	like($e, qr{^Can't call method "my_method" on an undefined value}, '... can be untied');
+	like($e, qr{^Can't call method "method_of_mine" on an undefined value}, '... can be untied');
 }
 
 my $e = exception { eval_closure(source => 'sub { 1 ]') };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libtype-tiny-perl.git



More information about the Pkg-perl-cvs-commits mailing list