From: Kaare Rasmussen Date: Sat, 26 Nov 2011 20:00:30 +0000 (+0100) Subject: Fix RT bug #46086 X-Git-Tag: 0.27~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0f22810a8a14902c7724ea80a9951829e42ac8eb;p=gitmo%2FMooseX-Singleton.git Fix RT bug #46086 --- diff --git a/Changes b/Changes index d91e401..b78042f 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Perl extension MooseX-Singleton {{$NEXT}} + - Fix RT Bug #46086, "name used only once" (Thanks chisel for the patch and + the test 0.27 2011-05-19 diff --git a/lib/MooseX/Singleton/Role/Meta/Class.pm b/lib/MooseX/Singleton/Role/Meta/Class.pm index 2d606f4..beda2d1 100644 --- a/lib/MooseX/Singleton/Role/Meta/Class.pm +++ b/lib/MooseX/Singleton/Role/Meta/Class.pm @@ -34,6 +34,7 @@ override _construct_instance => sub { my $pkg = $class->name; no strict 'refs'; + no warnings 'once'; return ${"$pkg\::singleton"} = super; }; diff --git a/t/warnings_once.t b/t/warnings_once.t new file mode 100644 index 0000000..696cbe5 --- /dev/null +++ b/t/warnings_once.t @@ -0,0 +1,14 @@ +# test script for: https://rt.cpan.org/Ticket/Display.html?id=46086 +use Test::More qw(no_plan); +use Test::NoWarnings; + +BEGIN { + package OnlyUsedOnce; + use strict; + use warnings; + use MooseX::Singleton; +} + +BEGIN { OnlyUsedOnce->initialize; } + +my $s = OnlyUsedOnce->instance;