diff options
Diffstat (limited to 't')
-rw-r--r-- | t/basic.t | 12 | ||||
-rw-r--r-- | t/data/basic/after/Bar.pm | 5 |
2 files changed, 17 insertions, 0 deletions
@@ -2,8 +2,10 @@ use strict; use warnings; use Test::More; +use Test::Fatal; use lib 't/lib'; use Test::Class::Refresh; +use Try::Tiny; use Class::Refresh; @@ -37,4 +39,14 @@ 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"); +try { require Bar } catch { "We expect this to fail, that's alright and happens sometimes" }; +Class::Refresh->refresh; +ok(exists $INC{'Bar.pm'}, "Failed package \$INC value exists"); +ok(!defined $INC{'Bar.pm'}, "Failed package \$INC value is not defined after failed load"); + +# Now do the same thing to validate that there's no error in repopulating %CACHE +isnt(exception{ Class::Refresh->refresh }, "Second refresh is not an error"); +ok(exists $INC{'Bar.pm'}, "Failed package \$INC value exists: second attempt"); +ok(!defined $INC{'Bar.pm'}, "Failed package \$INC value is not defined after failed load: second attempt"); + done_testing; diff --git a/t/data/basic/after/Bar.pm b/t/data/basic/after/Bar.pm new file mode 100644 index 0000000..06875fb --- /dev/null +++ b/t/data/basic/after/Bar.pm @@ -0,0 +1,5 @@ +package Bar; + +use Bar::Fake; + +1; |