local $package::VERSION should now actually work
Tatsuhiko Miyagawa [Sun, 26 Jun 2011 05:12:29 +0000 (22:12 -0700)]
Signed-off-by: David Golden <dagolden@cpan.org>

lib/Module/Metadata.pm
t/lib/0.1/Foo.pm [new file with mode: 0644]
t/lib/0.2/Foo.pm [new file with mode: 0644]
t/version.t [new file with mode: 0644]

index 9d60226..c2dd51d 100644 (file)
@@ -517,9 +517,9 @@ sub _evaluate_version_line {
     use version;
     no strict;
 
-    local $sigil$var;
-    \$$var=undef;
       \$vsub = sub {
+        local $sigil$var;
+        \$$var=undef;
         $line;
         \$$var
       };
diff --git a/t/lib/0.1/Foo.pm b/t/lib/0.1/Foo.pm
new file mode 100644 (file)
index 0000000..f1ecaca
--- /dev/null
@@ -0,0 +1,3 @@
+package Foo;
+$Foo::VERSION = '0.1';
+1;
diff --git a/t/lib/0.2/Foo.pm b/t/lib/0.2/Foo.pm
new file mode 100644 (file)
index 0000000..8f8ef06
--- /dev/null
@@ -0,0 +1,3 @@
+package Foo;
+$Foo::VERSION = '0.2';
+1;
diff --git a/t/version.t b/t/version.t
new file mode 100644 (file)
index 0000000..4acc358
--- /dev/null
@@ -0,0 +1,22 @@
+use strict;
+use Test::More;
+use Module::Metadata;
+use lib "t/lib/0.2";
+
+plan tests => 4;
+
+require Foo;
+is $Foo::VERSION, 0.2;
+
+my $meta = Module::Metadata->new_from_module("Foo", inc => [ "t/lib/0.1" ] );
+is $meta->version, 0.1;
+
+is $Foo::VERSION, 0.2;
+
+ok eval "use Foo 0.2; 1";
+
+
+
+
+
+