From 43a3a6d662f97d039fe9d02ddf10b89bfc6fd16e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 5 Apr 2011 22:16:04 -0500 Subject: test for changing global variables too --- t/basic.t | 11 +++++++++++ t/data/basic/after/Foo.pm | 3 +++ t/data/basic/before/Foo.pm | 3 +++ 3 files changed, 17 insertions(+) diff --git a/t/basic.t b/t/basic.t index 3388e8b..9b7eb8a 100644 --- a/t/basic.t +++ b/t/basic.t @@ -16,6 +16,9 @@ Class::Refresh->refresh; can_ok('Foo', 'meth'); ok(!Foo->can('other_meth'), "!Foo->can('other_meth')"); +is($Foo::FOO, 1, "package global exists"); +is($Foo::BAR, 2, "other package global exists"); +ok(!defined($Foo::BAZ), "third package global doesn't exist"); sleep 2; @@ -25,5 +28,13 @@ Class::Refresh->refresh; can_ok('Foo', 'other_meth'); ok(!Foo->can('meth'), "!Foo->can('meth')"); +{ local $TODO = "hrm, global access like this is resolved at compile time"; +is($Foo::FOO, 10, "package global exists with new value"); +ok(!defined($Foo::BAR), "other package global doesn't exist"); +is($Foo::BAZ, 30, "third package global exists"); +} +is(eval '$Foo::FOO', 10, "package global exists with new value"); +ok(!defined(eval '$Foo::BAR'), "other package global doesn't exist"); +is(eval '$Foo::BAZ', 30, "third package global exists"); done_testing; diff --git a/t/data/basic/after/Foo.pm b/t/data/basic/after/Foo.pm index b9c85eb..7c4342e 100644 --- a/t/data/basic/after/Foo.pm +++ b/t/data/basic/after/Foo.pm @@ -1,5 +1,8 @@ package Foo; +our $FOO = 10; +our $BAZ = 30; + sub other_meth { } 1; diff --git a/t/data/basic/before/Foo.pm b/t/data/basic/before/Foo.pm index 11641b4..33fcac4 100644 --- a/t/data/basic/before/Foo.pm +++ b/t/data/basic/before/Foo.pm @@ -1,5 +1,8 @@ package Foo; +our $FOO = 1; +our $BAR = 2; + sub meth { } 1; -- cgit v1.2.3-54-g00ecf