Permalink
Browse files

0.09 with Import::Into logic almost working

  • Loading branch information...
ingydotnet authored and ingy@ingy.net committed Jun 19, 2012
1 parent 67da2e5 commit 4c99efb9e0df7fa47c0b7f28dbbca1999f9618a7
Showing with 45 additions and 17 deletions.
  1. +7 −0 Changes
  2. +7 −16 lib/perl5.pm
  3. +18 −0 t/lexical.t
  4. +12 −0 t/lib/perl5/tlex.pm
  5. +1 −1 t/version.t
View
@@ -1,4 +1,11 @@
---
+version: 0.09
+date:
+changes:
+- barefootcoder++ bluefeet++ and tobyink++ led to switching out Hook::LexWrap
+ with logic from Import::Into. Things are much cleaner now, and actually
+ export correctly (as far as we know :)
+---
version: 0.08
date: Tue Jul 19 06:33:06 PDT 2011
changes:
View
@@ -18,9 +18,8 @@ use strict;
use warnings;
use version 0.99 ();
-use Hook::LexWrap 0.24;
-our $VERSION = '0.08';
+our $VERSION = '0.09';
my $requested_perl_version = 0;
my $perl_version = 10;
@@ -93,7 +92,8 @@ sub importer {
my @imports = scalar(@_) ? @_ : $class->imports;
my @wrappers;
- my $important = sub {};
+ my $caller = caller(0); # maybe allow 'use perl5-foo package=>Bar'?
+ my $important = eval "package $caller; my \$sub = sub { shift->import(\@_) };";
while (@imports) {
my $name = shift(@imports);
@@ -102,21 +102,12 @@ sub importer {
my $arguments = (@imports and ref($imports[0]) eq 'ARRAY')
? shift(@imports) : undef;
- $important = wrap $important => post => sub {
- eval "use $name $version (); 1" or die $@;
- return if $arguments and not @$arguments;
- my $importee = $name->can('import') or return;
- @_ = ($name, @{$arguments || []});
-
- # XXX This hack seems to make Exporter happy in t/export.t
- # The answers lie within lexwrap and exporter. Need to dig deeper.
- $Exporter::ExportLevel = 2;
-
- goto &$importee;
- };
+ eval "require $name;"; # could be improved
+ $name->VERSION($version) if $version;
+ $name->$important(@{$arguments||[]});
}
- goto &$important;
+# goto &$important;
}
sub imports {
View
@@ -0,0 +1,18 @@
+use Test::More 0.88;
+use Test::Exception;
+use lib 't/lib';
+
+use perl5-tlex;
+
+
+eval '$f = 1';
+like $@, qr/requires explicit package name/, 'got strict';
+
+eval '6 + "fred"';
+like $@, qr/isn't numeric/, 'got fatal warnings';
+
+#eval 'try {die} catch {};';
+#is $@, '', 'try/catch syntax imported';
+
+
+done_testing;
View
@@ -0,0 +1,12 @@
+package perl5::tlex;
+use base 'perl5';
+
+sub imports
+{
+ strict => [qw(subs refs vars)],
+ warnings => [FATAL => 'all'], # easier to test
+ #TryCatch =>
+ # maybe more here later
+}
+
+1;
View
@@ -1,4 +1,4 @@
-use Test::More tests => 31;
+use Test::More tests => 30;
use lib 't/lib';
test_usage1($_) for split "\n", <<'';

0 comments on commit 4c99efb

Please sign in to comment.