From fc9b385dd96a0ae305986290eaf4ecb41a0e9015 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 5 Apr 2011 21:41:05 -0500 Subject: more tests --- t/data/other-api/after/Foo.pm | 8 ++++++ t/data/other-api/after/Foo/Bar.pm | 9 ++++++ t/data/other-api/before/Foo.pm | 8 ++++++ t/data/other-api/before/Foo/Bar.pm | 8 ++++++ t/data/other-api/before/Foo/Baz.pm | 8 ++++++ t/other-api.t | 59 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 t/data/other-api/after/Foo.pm create mode 100644 t/data/other-api/after/Foo/Bar.pm create mode 100644 t/data/other-api/before/Foo.pm create mode 100644 t/data/other-api/before/Foo/Bar.pm create mode 100644 t/data/other-api/before/Foo/Baz.pm create mode 100644 t/other-api.t 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; -- cgit v1.2.3-54-g00ecf