r55335 - in /branches/upstream/libany-moose-perl/current: ./ lib/Any/ t/ t/lib/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sat Apr 3 03:46:39 UTC 2010


Author: jawnsy-guest
Date: Sat Apr  3 03:46:32 2010
New Revision: 55335

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=55335
Log:
[svn-upgrade] Integrating new upstream version, libany-moose-perl (0.12)

Added:
    branches/upstream/libany-moose-perl/current/t/000-version.t
    branches/upstream/libany-moose-perl/current/t/005-aliases-moose.t
    branches/upstream/libany-moose-perl/current/t/005-aliases-mouse.t
    branches/upstream/libany-moose-perl/current/t/lib/
    branches/upstream/libany-moose-perl/current/t/lib/AnyMooseTest.pm
Removed:
    branches/upstream/libany-moose-perl/current/t/005-is_class_loaded-moose.t
    branches/upstream/libany-moose-perl/current/t/005-is_class_loaded-mouse.t
Modified:
    branches/upstream/libany-moose-perl/current/Changes
    branches/upstream/libany-moose-perl/current/LICENSE
    branches/upstream/libany-moose-perl/current/MANIFEST
    branches/upstream/libany-moose-perl/current/META.yml
    branches/upstream/libany-moose-perl/current/Makefile.PL
    branches/upstream/libany-moose-perl/current/README
    branches/upstream/libany-moose-perl/current/dist.ini
    branches/upstream/libany-moose-perl/current/lib/Any/Moose.pm

Modified: branches/upstream/libany-moose-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/Changes?rev=55335&op=diff
==============================================================================
--- branches/upstream/libany-moose-perl/current/Changes (original)
+++ branches/upstream/libany-moose-perl/current/Changes Sat Apr  3 03:46:32 2010
@@ -1,3 +1,15 @@
+0.12  Fri 02 Apr 2010
+  * t/000-version.t for better diagnostics (tokuhirom)
+  * Slight performance improvements for is_class_loaded,
+      lazily loading Carp, etc (Sartak)
+  * Start some real documentation (Sartak)
+  * Document $ENV{ANY_MOOSE} (Sartak)
+    - fixes [rt.cpan.org #52339]
+  * Test that Moose is loaded, not CMOP (Sartak)
+    - fixes [rt.cpan.org #56093]
+  * Alias class_of and more functions (Sartak)
+    - requested by [rt.cpan.org #52275]
+
 0.11  Sun 19 Dec 2009
   * Support "use Any::Moose '::Util::TypeConstraints'" (gfx)
   * Support "no Any::Moose '::Util::TypeConstraints'" (gfx)

Modified: branches/upstream/libany-moose-perl/current/LICENSE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/LICENSE?rev=55335&op=diff
==============================================================================
--- branches/upstream/libany-moose-perl/current/LICENSE (original)
+++ branches/upstream/libany-moose-perl/current/LICENSE Sat Apr  3 03:46:32 2010
@@ -1,9 +1,9 @@
-This software is copyright (c) 2009 by Best Practical Solutions.
+This software is copyright (c) 2010 by Best Practical Solutions.
 
 This is free software; you can redistribute it and/or modify it under
-the same terms as perl itself.
-
-Terms of Perl itself
+the same terms as the Perl 5 programming language system itself.
+
+Terms of the Perl programming language system itself
 
 a) the GNU General Public License as published by the Free
    Software Foundation; either version 1, or (at your option) any
@@ -12,7 +12,7 @@
 
 --- The GNU General Public License, Version 1, February 1989 ---
 
-This software is Copyright (c) 2009 by Best Practical Solutions.
+This software is Copyright (c) 2010 by Best Practical Solutions.
 
 This is free software, licensed under:
 
@@ -270,7 +270,7 @@
 
 --- The Artistic License 1.0 ---
 
-This software is Copyright (c) 2009 by Best Practical Solutions.
+This software is Copyright (c) 2010 by Best Practical Solutions.
 
 This is free software, licensed under:
 

Modified: branches/upstream/libany-moose-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/MANIFEST?rev=55335&op=diff
==============================================================================
--- branches/upstream/libany-moose-perl/current/MANIFEST (original)
+++ branches/upstream/libany-moose-perl/current/MANIFEST Sat Apr  3 03:46:32 2010
@@ -6,6 +6,7 @@
 README
 dist.ini
 lib/Any/Moose.pm
+t/000-version.t
 t/001-basic-moose.t
 t/001-basic-mouse.t
 t/002-other-modules-moose.t
@@ -13,8 +14,8 @@
 t/003-is_moose_loaded.t
 t/004-x-modules-moose.t
 t/004-x-modules-mouse.t
-t/005-is_class_loaded-moose.t
-t/005-is_class_loaded-mouse.t
+t/005-aliases-moose.t
+t/005-aliases-mouse.t
 t/010-use_mouse_roles.t
 t/011-use_moose_roles.t
 t/012-use_moose_util.t
@@ -22,5 +23,6 @@
 t/020-strict.t
 t/100-canonicalize-fragments.t
 t/101-localize-errvar.t
+t/lib/AnyMooseTest.pm
 t/release-pod-coverage.t
 t/release-pod-syntax.t

Modified: branches/upstream/libany-moose-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/META.yml?rev=55335&op=diff
==============================================================================
--- branches/upstream/libany-moose-perl/current/META.yml (original)
+++ branches/upstream/libany-moose-perl/current/META.yml Sat Apr  3 03:46:32 2010
@@ -6,13 +6,17 @@
   - 'Stevan Little <stevan at iinteractive.com>'
   - 'Tokuhiro Matsuno <tokuhirom at gmail.com>'
   - 'Goro Fuji <gfuji at cpan.org>'
-generated_by: 'Dist::Zilla version 1.093400'
+build_requires: {}
+configure_requires:
+  ExtUtils::MakeMaker: 6.31
+generated_by: 'Dist::Zilla version 2.100921'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
   version: 1.4
 name: Any-Moose
+recommends: {}
 requires:
   Mouse: 0.40
   perl: 5.006_002
-version: 0.11
+version: 0.12

Modified: branches/upstream/libany-moose-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/Makefile.PL?rev=55335&op=diff
==============================================================================
--- branches/upstream/libany-moose-perl/current/Makefile.PL (original)
+++ branches/upstream/libany-moose-perl/current/Makefile.PL Sat Apr  3 03:46:32 2010
@@ -4,19 +4,38 @@
 
  BEGIN { require 5.006_002; } 
 
-use ExtUtils::MakeMaker;
+use ExtUtils::MakeMaker 6.31;
 
-WriteMakefile(
-  DISTNAME  => 'Any-Moose',
-  NAME      => 'Any::Moose',
-  AUTHOR    => "Shawn\ M\ Moore\ \<sartak\@bestpractical\.com\>\,\ Florian\ Ragwitz\ \<rafl\@debian\.org\>\,\ Stevan\ Little\ \<stevan\@iinteractive\.com\>\,\ Tokuhiro\ Matsuno\ \<tokuhirom\@gmail\.com\>\,\ Goro\ Fuji\ \<gfuji\@cpan\.org\>",
-  ABSTRACT  => "use\ Moose\ or\ Mouse\ modules",
-  VERSION   => '0.11',
-  EXE_FILES => [ qw() ],
-  (eval { ExtUtils::MakeMaker->VERSION(6.31) } ? (LICENSE => 'perl') : ()),
-  PREREQ_PM    => {
-    "Mouse" => '0.40',
-  },
-  test => {TESTS => 't/*.t'}
-);
 
+
+my %WriteMakefileArgs = (
+                       'test' => {
+                                   'TESTS' => 't/*.t'
+                                 },
+                       'NAME' => 'Any::Moose',
+                       'DISTNAME' => 'Any-Moose',
+                       'CONFIGURE_REQUIRES' => {
+                                                 'ExtUtils::MakeMaker' => '6.31'
+                                               },
+                       'AUTHOR' => 'Shawn M Moore <sartak at bestpractical.com>, Florian Ragwitz <rafl at debian.org>, Stevan Little <stevan at iinteractive.com>, Tokuhiro Matsuno <tokuhirom at gmail.com>, Goro Fuji <gfuji at cpan.org>',
+                       'BUILD_REQUIRES' => {},
+                       'ABSTRACT' => 'use Moose or Mouse modules',
+                       'EXE_FILES' => [],
+                       'VERSION' => '0.12',
+                       'PREREQ_PM' => {
+                                        'Mouse' => '0.40'
+                                      },
+                       'LICENSE' => 'perl'
+                     );
+
+
+delete $WriteMakefileArgs{BUILD_REQUIRES}
+  unless eval { ExtUtils::MakeMaker->VERSION(6.56) };
+
+delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
+  unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
+
+WriteMakefile(%WriteMakefileArgs);
+
+
+

Modified: branches/upstream/libany-moose-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/README?rev=55335&op=diff
==============================================================================
--- branches/upstream/libany-moose-perl/current/README (original)
+++ branches/upstream/libany-moose-perl/current/README Sat Apr  3 03:46:32 2010
@@ -1,12 +1,13 @@
 
 
-This archive contains the distribution Any-Moose, version
-0.11:
+This archive contains the distribution Any-Moose,
+version 0.12:
 
   use Moose or Mouse modules
 
-This software is copyright (c) 2009 by Best Practical Solutions.
+This software is copyright (c) 2010 by Best Practical Solutions.
 
 This is free software; you can redistribute it and/or modify it under
-the same terms as perl itself.
+the same terms as the Perl 5 programming language system itself.
 
+

Modified: branches/upstream/libany-moose-perl/current/dist.ini
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/dist.ini?rev=55335&op=diff
==============================================================================
--- branches/upstream/libany-moose-perl/current/dist.ini (original)
+++ branches/upstream/libany-moose-perl/current/dist.ini Sat Apr  3 03:46:32 2010
@@ -1,5 +1,5 @@
 name    = Any-Moose
-version = 0.11
+version = 0.12
 author  = Shawn M Moore <sartak at bestpractical.com>
 author  = Florian Ragwitz <rafl at debian.org>
 author  = Stevan Little <stevan at iinteractive.com>

Modified: branches/upstream/libany-moose-perl/current/lib/Any/Moose.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/lib/Any/Moose.pm?rev=55335&op=diff
==============================================================================
--- branches/upstream/libany-moose-perl/current/lib/Any/Moose.pm (original)
+++ branches/upstream/libany-moose-perl/current/lib/Any/Moose.pm Sat Apr  3 03:46:32 2010
@@ -1,14 +1,46 @@
 package Any::Moose;
-our $VERSION = '0.11';
+BEGIN {
+  $Any::Moose::VERSION = '0.12';
+}
 # ABSTRACT: use Moose or Mouse modules
 
 use 5.006_002;
 use strict;
 use warnings;
 
-use Carp ();
-
-our $PREFERRED = $ENV{'ANY_MOOSE'};
+# decide which backend to use
+our $PREFERRED;
+do {
+    local $@;
+    if ($ENV{ANY_MOOSE}) {
+        $PREFERRED = $ENV{'ANY_MOOSE'};
+        warn "ANY_MOOSE is not set to Moose or Mouse"
+            unless $PREFERRED eq 'Moose'
+                || $PREFERRED eq 'Mouse';
+
+        # if we die here, then perl gives "unknown error" which doesn't tell
+        # you what the problem is at all. argh.
+        if ($PREFERRED eq 'Moose' && !eval { require Moose }) {
+            warn "\$ANY_MOOSE is set to Moose but we cannot load it";
+        }
+        elsif ($PREFERRED eq 'Mouse' && !eval { require Mouse }) {
+            warn "\$ANY_MOOSE is set to Mouse but we cannot load it";
+        }
+    }
+    elsif (_is_moose_loaded()) {
+        $PREFERRED = 'Moose';
+    }
+    elsif (eval { require Mouse }) {
+        $PREFERRED = 'Mouse';
+    }
+    elsif (eval { require Moose }) {
+        $PREFERRED = 'Moose';
+    }
+    else {
+        require Carp;
+        warn "Unable to locate Mouse or Moose in INC";
+    }
+};
 
 sub import {
     my $self = shift;
@@ -55,7 +87,12 @@
            . '$module->unimport();';
         $@;
    };
-   Carp::croak("Cannot unimport Any::Moose: $e") if $e;
+
+   if ($e) {
+        require Carp;
+        Carp::croak("Cannot unimport Any::Moose: $e");
+   }
+
    return;
 }
 
@@ -116,7 +153,10 @@
            . '$module->import(@{ $options->{imports} });';
         $@;
     };
-    Carp::croak("Cannot import Any::Moose: $e") if $e;
+    if ($e) {
+        require Carp;
+        Carp::croak("Cannot import Any::Moose: $e");
+    }
     return;
 }
 
@@ -135,45 +175,24 @@
 
     return $fragment if $backer =~ /^Moose/;
 
-    if (!$PREFERRED) {
-        local $@;
-        if (_is_moose_loaded()) {
-            $PREFERRED = 'Moose';
-        }
-        elsif (eval { require Mouse }) {
-            $PREFERRED = 'Mouse';
-        }
-        elsif (eval { require Moose }) {
-            $PREFERRED = 'Moose';
-        }
-        else {
-            require Carp;
-            Carp::confess("Unable to locate Mouse or Moose in INC");
-        }
-    }
-
     $fragment =~ s/^Moose/Mouse/ if mouse_is_preferred();
     return $fragment;
 }
 
-sub load_class {
-    my ($class_name) = @_;
-    return Class::MOP::load_class($class_name) if moose_is_preferred();
-    return Mouse::load_class($class_name);
-}
-
-sub is_class_loaded {
-    my ($class_name) = @_;
-    return Class::MOP::is_class_loaded($class_name) if moose_is_preferred();
-    return Mouse::is_class_loaded($class_name);
+for my $name (qw/load_class is_class_loaded class_of get_metaclass_by_name get_all_metaclass_instances get_all_metaclass_names/) {
+    no strict 'refs';
+    *{__PACKAGE__."::$name"} = moose_is_preferred()
+        ? *{"Class::MOP::$name"}
+        : *{"Mouse::Util::$name"};
 }
 
 sub moose_is_preferred { $PREFERRED eq 'Moose' }
 sub mouse_is_preferred { $PREFERRED eq 'Mouse' }
 
-sub _is_moose_loaded { exists $INC{'Class/MOP.pm'} }
+sub _is_moose_loaded { exists $INC{'Moose.pm'} }
 
 sub is_moose_loaded {
+    require Carp;
     Carp::carp("Any::Moose::is_moose_loaded is deprecated. Please use Any::Moose::moose_is_preferred instead");
     goto \&_is_moose_loaded;
 }
@@ -209,21 +228,24 @@
 
 =head1 VERSION
 
-version 0.11
+version 0.12
 
 =head1 SYNOPSIS
 
+
 =head2 BASIC
 
+
     package Class;
 
-    # uses Moose if it's loaded, Mouse otherwise
+    # uses Moose if it's loaded or demanded, Mouse otherwise
     use Any::Moose;
 
     # cleans the namespace up
     no Any::Moose;
 
 =head2 OTHER MODULES
+
 
     package Other::Class;
     use Any::Moose;
@@ -232,7 +254,16 @@
     # Mouse::Util::TypeConstraints otherwise.
     use Any::Moose '::Util::TypeConstraints';
 
+=head2 ROLES
+
+
+    package My::Sorter;
+    use Any::Moose 'Role';
+
+    requires 'cmp';
+
 =head2 COMPLEX USAGE
+
 
     package My::Meta::Class;
     use Any::Moose;
@@ -245,7 +276,7 @@
         '::Util' => ['does_role'],
     );
 
-    # uses MouseX::Types
+    # uses MouseX::Types or MooseX::Types
     use Any::Moose 'X::Types';
 
     # gives you the right class name depending on which Mo*se was loaded
@@ -253,14 +284,41 @@
 
 =head1 DESCRIPTION
 
-Actual documentation is forthcoming, once we solidify all the bits of the API.
-The examples above are very likely to continue working.
+
+Though we recommend that people generally use L<Moose>, we accept that Moose
+cannot yet be used for everything everywhere. People generally like the Moose
+sugar, so many people use L<Mouse>, a lightweight replacement for parts of
+Moose.
+
+
+Because Mouse strives for compatibility with Moose, it's easy to substitute one
+for the other. This module facilitates that substitution. By default, Mouse
+will be provided to libraries, unless Moose is already loaded -or-
+explicitly requested by the end-user. The end-user can force the decision
+of which backend to use by setting the environment variable C<ANY_MOOSE> to
+be C<Moose> or C<Mouse>.
+
+
+Note that the decision of which backend to use is made only once, so that if
+Any-Moose picks Mouse, then a third-party library loads Moose, anything else
+that uses Any-Moose will continue to pick Mouse.
+
+
+So, if you have to use L<Mouse>, please be considerate to the Moose fanboys
+(like myself!) and use L<Any-Moose> instead. C<:)>
 
 =head1 SEE ALSO
 
+
 L<Moose>
 
+
 L<Mouse>
+
+
+L<Squirrel> - a deprecated first-stab at Any-Moose-like logic. Its biggest
+fault was in making the decision of which backend to use every time it was
+used, rather than just once.
 
 =head1 AUTHORS
 
@@ -272,10 +330,10 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-This software is copyright (c) 2009 by Best Practical Solutions.
+This software is copyright (c) 2010 by Best Practical Solutions.
 
 This is free software; you can redistribute it and/or modify it under
-the same terms as perl itself.
+the same terms as the Perl 5 programming language system itself.
 
 =cut
 

Added: branches/upstream/libany-moose-perl/current/t/000-version.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/t/000-version.t?rev=55335&op=file
==============================================================================
--- branches/upstream/libany-moose-perl/current/t/000-version.t (added)
+++ branches/upstream/libany-moose-perl/current/t/000-version.t Sat Apr  3 03:46:32 2010
@@ -1,0 +1,21 @@
+use strict;
+use Test::More tests => 1;
+use_ok 'Any::Moose';
+
+show_version($_) for qw/
+    Mouse
+    MouseX::Types
+    Moose
+    Class::MOP
+    MooseX::Types
+/;
+
+sub show_version {
+    my $klass = shift;
+    if (eval "require $klass; 1;") {
+        no strict 'refs';
+        diag "$klass: " . ${"${klass}::VERSION"};
+    } else {
+        diag "$klass not found";
+    }
+}

Added: branches/upstream/libany-moose-perl/current/t/005-aliases-moose.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/t/005-aliases-moose.t?rev=55335&op=file
==============================================================================
--- branches/upstream/libany-moose-perl/current/t/005-aliases-moose.t (added)
+++ branches/upstream/libany-moose-perl/current/t/005-aliases-moose.t Sat Apr  3 03:46:32 2010
@@ -1,0 +1,48 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN { delete $ENV{ANY_MOOSE} }
+
+BEGIN {
+    eval 'require Moose;';
+    plan skip_all => 'Moose not available' if $@;
+    plan tests => 20;
+}
+
+package MyClass;
+use Any::Moose;
+
+package main;
+
+ok(Any::Moose::is_class_loaded('Moose'), 'Moose is loaded');
+ok(Any::Moose::is_class_loaded('MyClass'), 'MyClass is loaded');
+ok(!Any::Moose::is_class_loaded('NonexistentPackage'), 'NonexistentPackage is not loaded');
+
+push @INC, 't/lib';
+
+ok(!Any::Moose::is_class_loaded('AnyMooseTest'), 'AnyMooseTest not yet loaded');
+ok(Any::Moose::load_class('AnyMooseTest'), 'Loading AnyMooseTest');
+ok(Any::Moose::is_class_loaded('AnyMooseTest'), 'AnyMooseTest now loaded');
+
+is(eval { Any::Moose::load_class('NonexistentTest'); 1 }, undef, 'load_class on nonexistent module fails');
+ok(!Any::Moose::is_class_loaded('NonexistentTest'), 'and it is still not loaded');
+
+like(Any::Moose::class_of('MyClass'), qr/Moose::Meta::Class=HASH/, 'metaclass check');
+is(Any::Moose::class_of('NonexistentTest'), undef, 'class_of nonexistent class is undef');
+like(Any::Moose::class_of(MyClass->new), qr/Moose::Meta::Class=HASH/, 'metaclass check via object');
+
+like(Any::Moose::get_metaclass_by_name('MyClass'), qr/Moose::Meta::Class=HASH/, 'metaclass check');
+is(Any::Moose::get_metaclass_by_name('NonexistentTest'), undef, 'class_of nonexistent class is undef');
+is(Any::Moose::get_metaclass_by_name(MyClass->new), undef, 'get_metaclass_by_name via object returns undef');
+
+my %metaclasses = map { $_->name => $_ } Any::Moose::get_all_metaclass_instances();
+is($metaclasses{MyClass}, MyClass->meta);
+is($metaclasses{AnyMooseTest}, AnyMooseTest->meta);
+is($metaclasses{NonexistentTest}, undef);
+
+is((grep { $_ eq 'MyClass' } Any::Moose::get_all_metaclass_names()), 1);
+is((grep { $_ eq 'AnyMooseTest' } Any::Moose::get_all_metaclass_names()), 1);
+is((grep { $_ eq 'NonexistentTest' } Any::Moose::get_all_metaclass_names()), 0);
+

Added: branches/upstream/libany-moose-perl/current/t/005-aliases-mouse.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/t/005-aliases-mouse.t?rev=55335&op=file
==============================================================================
--- branches/upstream/libany-moose-perl/current/t/005-aliases-mouse.t (added)
+++ branches/upstream/libany-moose-perl/current/t/005-aliases-mouse.t Sat Apr  3 03:46:32 2010
@@ -1,0 +1,48 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN { delete $ENV{ANY_MOOSE} }
+
+BEGIN {
+    eval 'require Mouse;';
+    plan skip_all => 'Mouse not available' if $@;
+    plan tests => 20;
+}
+
+package MyClass;
+use Any::Moose;
+
+package main;
+
+ok(Any::Moose::is_class_loaded('Mouse'), 'Mouse is loaded');
+ok(Any::Moose::is_class_loaded('MyClass'), 'MyClass is loaded');
+ok(!Any::Moose::is_class_loaded('NonexistentPackage'), 'NonexistentPackage is not loaded');
+
+push @INC, 't/lib';
+
+ok(!Any::Moose::is_class_loaded('AnyMooseTest'), 'AnyMooseTest not yet loaded');
+ok(Any::Moose::load_class('AnyMooseTest'), 'Loading AnyMooseTest');
+ok(Any::Moose::is_class_loaded('AnyMooseTest'), 'AnyMooseTest now loaded');
+
+is(eval { Any::Moose::load_class('NonexistentTest'); 1 }, undef, 'load_class on nonexistent module fails');
+ok(!Any::Moose::is_class_loaded('NonexistentTest'), 'and it is still not loaded');
+
+like(Any::Moose::class_of('MyClass'), qr/Mouse::Meta::Class=HASH/, 'metaclass check');
+is(Any::Moose::class_of('NonexistentTest'), undef, 'class_of nonexistent class is undef');
+like(Any::Moose::class_of(MyClass->new), qr/Mouse::Meta::Class=HASH/, 'metaclass check via object');
+
+like(Any::Moose::get_metaclass_by_name('MyClass'), qr/Mouse::Meta::Class=HASH/, 'metaclass check');
+is(Any::Moose::get_metaclass_by_name('NonexistentTest'), undef, 'class_of nonexistent class is undef');
+is(Any::Moose::get_metaclass_by_name(MyClass->new), undef, 'get_metaclass_by_name via object returns undef');
+
+my %metaclasses = map { $_->name => $_ } Any::Moose::get_all_metaclass_instances();
+is($metaclasses{MyClass}, MyClass->meta);
+is($metaclasses{AnyMooseTest}, AnyMooseTest->meta);
+is($metaclasses{NonexistentTest}, undef);
+
+is((grep { $_ eq 'MyClass' } Any::Moose::get_all_metaclass_names()), 1);
+is((grep { $_ eq 'AnyMooseTest' } Any::Moose::get_all_metaclass_names()), 1);
+is((grep { $_ eq 'NonexistentTest' } Any::Moose::get_all_metaclass_names()), 0);
+

Added: branches/upstream/libany-moose-perl/current/t/lib/AnyMooseTest.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libany-moose-perl/current/t/lib/AnyMooseTest.pm?rev=55335&op=file
==============================================================================
--- branches/upstream/libany-moose-perl/current/t/lib/AnyMooseTest.pm (added)
+++ branches/upstream/libany-moose-perl/current/t/lib/AnyMooseTest.pm Sat Apr  3 03:46:32 2010
@@ -1,0 +1,9 @@
+package AnyMooseTest;
+use Any::Moose;
+
+has an_attribute => (
+    is => 'ro',
+);
+
+1;
+




More information about the Pkg-perl-cvs-commits mailing list