summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-04-05 21:41:05 -0500
committerJesse Luehrs <doy@tozt.net>2011-04-05 21:41:05 -0500
commitfc9b385dd96a0ae305986290eaf4ecb41a0e9015 (patch)
tree83ffe45e26139515aea969c305a578578b21c1d7
parent8710bef0298ccdf6ee97558aef63e34463410bc5 (diff)
downloadclass-refresh-fc9b385dd96a0ae305986290eaf4ecb41a0e9015.tar.gz
class-refresh-fc9b385dd96a0ae305986290eaf4ecb41a0e9015.zip
more tests
-rw-r--r--t/data/other-api/after/Foo.pm8
-rw-r--r--t/data/other-api/after/Foo/Bar.pm9
-rw-r--r--t/data/other-api/before/Foo.pm8
-rw-r--r--t/data/other-api/before/Foo/Bar.pm8
-rw-r--r--t/data/other-api/before/Foo/Baz.pm8
-rw-r--r--t/other-api.t59
6 files changed, 100 insertions, 0 deletions
diff --git a/t/data/other-api/after/Foo.pm b/t/data/other-api/after/Foo.pm
new file mode 100644
index 0000000..7efc12c
--- /dev/null
+++ b/t/data/other-api/after/Foo.pm
@@ -0,0 +1,8 @@
+package Foo;
+use Moose;
+
+sub other_meth { }
+
+no Moose;
+
+1;
diff --git a/t/data/other-api/after/Foo/Bar.pm b/t/data/other-api/after/Foo/Bar.pm
new file mode 100644
index 0000000..973e473
--- /dev/null
+++ b/t/data/other-api/after/Foo/Bar.pm
@@ -0,0 +1,9 @@
+package Foo::Bar;
+use Moose;
+
+sub other_meth { }
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
diff --git a/t/data/other-api/before/Foo.pm b/t/data/other-api/before/Foo.pm
new file mode 100644
index 0000000..7bad9b3
--- /dev/null
+++ b/t/data/other-api/before/Foo.pm
@@ -0,0 +1,8 @@
+package Foo;
+use Moose;
+
+sub meth { }
+
+no Moose;
+
+1;
diff --git a/t/data/other-api/before/Foo/Bar.pm b/t/data/other-api/before/Foo/Bar.pm
new file mode 100644
index 0000000..9a4fc5c
--- /dev/null
+++ b/t/data/other-api/before/Foo/Bar.pm
@@ -0,0 +1,8 @@
+package Foo::Bar;
+use Moose;
+
+sub meth { }
+
+no Moose;
+
+1;
diff --git a/t/data/other-api/before/Foo/Baz.pm b/t/data/other-api/before/Foo/Baz.pm
new file mode 100644
index 0000000..3f58ed0
--- /dev/null
+++ b/t/data/other-api/before/Foo/Baz.pm
@@ -0,0 +1,8 @@
+package Foo::Baz;
+use Moose;
+
+sub meth { }
+
+no Moose;
+
+1;
diff --git a/t/other-api.t b/t/other-api.t
new file mode 100644
index 0000000..7ab111d
--- /dev/null
+++ b/t/other-api.t
@@ -0,0 +1,59 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use Test::Requires 'Moose';
+use lib 't/lib';
+use Test::Class::Refresh;
+
+use Class::Refresh;
+
+my $dir = prepare_temp_dir_for('other-api');
+push @INC, $dir->dirname;
+
+require Foo;
+require Foo::Bar;
+
+Class::Refresh->refresh;
+
+is_deeply([Class::Refresh->modified_modules], [],
+ "got the right list of modified modules");
+
+sleep 2;
+update_temp_dir_for('other-api', $dir);
+
+is_deeply([sort Class::Refresh->modified_modules], ['Foo', 'Foo::Bar'],
+ "got the right list of modified modules");
+
+Class::Refresh->refresh;
+
+ok(Class::Load::is_class_loaded('Foo'), "Foo is loaded");
+
+Class::Refresh->unload_module('Foo');
+
+ok(!Class::Load::is_class_loaded('Foo'), "Foo is not loaded");
+ok(!Class::MOP::class_of('Foo'), "Foo no longer has a metaclass");
+ok(!exists $INC{'Foo.pm'}, "Foo isn't in \%INC");
+
+is_deeply([Class::Refresh->modified_modules], [],
+ "got the right list of modified modules");
+
+Class::Refresh->load_module('Foo');
+
+ok(Class::Load::is_class_loaded('Foo'), "Foo is loaded");
+ok(Class::MOP::class_of('Foo'), "Foo has a metaclass");
+ok(exists $INC{'Foo.pm'}, "Foo is in \%INC");
+
+is_deeply([Class::Refresh->modified_modules], [],
+ "got the right list of modified modules");
+
+my $meta = Class::MOP::class_of('Foo');
+Class::Refresh->refresh_module('Foo');
+
+ok(Class::Load::is_class_loaded('Foo'), "Foo is loaded");
+ok(Class::MOP::class_of('Foo'), "Foo has a metaclass");
+ok(exists $INC{'Foo.pm'}, "Foo is in \%INC");
+
+isnt($meta, Class::MOP::class_of('Foo'), "metaclass was reinitialized");
+
+done_testing;