[Moose-commits] r7142 - in Mouse/trunk: . lib lib/Mouse t

sartak at code2.0beta.co.uk sartak at code2.0beta.co.uk
Mon Dec 22 02:23:02 GMT 2008


Author: sartak
Date: 2008-12-21 18:23:01 -0800 (Sun, 21 Dec 2008)
New Revision: 7142

Added:
   Mouse/trunk/t/038-main.t
Modified:
   Mouse/trunk/
   Mouse/trunk/Changes
   Mouse/trunk/lib/Mouse.pm
   Mouse/trunk/lib/Mouse/Role.pm
   Mouse/trunk/t/037-dont-load-test-exception.t
Log:
 r77731 at onn:  sartak | 2008-12-21 21:22:50 -0500
 Test that we don't export sugar into main



Property changes on: Mouse/trunk
___________________________________________________________________
Name: svk:merge
   - 08e7d58d-de06-4458-8c15-335e402ab116:/local/Mouse:77728
08e7d58d-de06-4458-8c15-335e402ab116:/local/Mouse-trunk:61565
3efe9002-19ed-0310-8735-a98156148065:/Mouse/branches/shika-based:6997
   + 08e7d58d-de06-4458-8c15-335e402ab116:/local/Mouse:77731
08e7d58d-de06-4458-8c15-335e402ab116:/local/Mouse-trunk:61565
3efe9002-19ed-0310-8735-a98156148065:/Mouse/branches/shika-based:6997

Modified: Mouse/trunk/Changes
===================================================================
--- Mouse/trunk/Changes	2008-12-21 23:16:08 UTC (rev 7141)
+++ Mouse/trunk/Changes	2008-12-22 02:23:01 UTC (rev 7142)
@@ -1,8 +1,8 @@
 Revision history for Mouse
 
 0.15
+    * Don't export Mouse's sugar into the package 'main'
 
-
 0.14 Sat Dec 20 16:53:05 2008
     * POD fix
 

Modified: Mouse/trunk/lib/Mouse/Role.pm
===================================================================
--- Mouse/trunk/lib/Mouse/Role.pm	2008-12-21 23:16:08 UTC (rev 7141)
+++ Mouse/trunk/lib/Mouse/Role.pm	2008-12-22 02:23:01 UTC (rev 7142)
@@ -67,10 +67,19 @@
 sub excludes { confess "Mouse::Role does not currently support 'excludes'" }
 
 sub import {
+    my $class = shift;
+
     strict->import;
     warnings->import;
 
     my $caller = caller;
+
+    # we should never export to main
+    if ($caller eq 'main') {
+        warn qq{$class does not export its sugar to the 'main' package.\n};
+        return;
+    }
+
     my $meta = Mouse::Meta::Role->initialize(caller);
 
     no strict 'refs';

Modified: Mouse/trunk/lib/Mouse.pm
===================================================================
--- Mouse/trunk/lib/Mouse.pm	2008-12-21 23:16:08 UTC (rev 7141)
+++ Mouse/trunk/lib/Mouse.pm	2008-12-22 02:23:01 UTC (rev 7142)
@@ -85,6 +85,12 @@
 
     my $caller = caller;
 
+    # we should never export to main
+    if ($caller eq 'main') {
+        warn qq{$class does not export its sugar to the 'main' package.\n};
+        return;
+    }
+
     my $meta = Mouse::Meta::Class->initialize($caller);
     $meta->superclasses('Mouse::Object')
         unless $meta->superclasses;

Modified: Mouse/trunk/t/037-dont-load-test-exception.t
===================================================================
--- Mouse/trunk/t/037-dont-load-test-exception.t	2008-12-21 23:16:08 UTC (rev 7141)
+++ Mouse/trunk/t/037-dont-load-test-exception.t	2008-12-22 02:23:01 UTC (rev 7142)
@@ -1,3 +1,4 @@
+package Foo;
 use strict;
 use warnings;
 use Test::More tests => 1;

Added: Mouse/trunk/t/038-main.t
===================================================================
--- Mouse/trunk/t/038-main.t	                        (rev 0)
+++ Mouse/trunk/t/038-main.t	2008-12-22 02:23:01 UTC (rev 7142)
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN {
+    eval "use Test::Output;";
+    plan skip_all => "Test::Output is required for this test" if $@;
+    plan tests => 2;
+}
+
+stderr_is(
+    sub { package main; eval 'use Mouse' },
+    "Mouse does not export its sugar to the 'main' package.\n",
+    'Mouse warns when loaded from the main package',
+);
+
+stderr_is(
+    sub { package main; eval 'use Mouse::Role' },
+    "Mouse::Role does not export its sugar to the 'main' package.\n",
+    'Mouse::Role warns when loaded from the main package',
+);
+




More information about the Moose-commits mailing list