[svn:parrot] r36564 - in trunk: src/pmc t/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Wed Feb 11 00:54:52 UTC 2009


Author: chromatic
Date: Wed Feb 11 00:54:51 2009
New Revision: 36564
URL: https://trac.parrot.org/parrot/changeset/36564

Log:
[PMC] Removed a check in NameSpace PMC which prevented the addition of Subs to
a namespace if they were declared in PIR with :anon, even when inserting them
with a name directly later with set_global.  See TT #56.  Now you can insert
them in a namespace later.

Modified:
   trunk/src/pmc/namespace.pmc
   trunk/t/pmc/namespace.t

Modified: trunk/src/pmc/namespace.pmc
==============================================================================
--- trunk/src/pmc/namespace.pmc	Wed Feb 11 00:44:34 2009	(r36563)
+++ trunk/src/pmc/namespace.pmc	Wed Feb 11 00:54:51 2009	(r36564)
@@ -94,10 +94,6 @@
         add_to_class(interp, nsinfo, classobj, method_name, value);
     }
 
-    /* If it's anonymous, we're done. */
-    if (PObj_get_FLAGS(value) & SUB_FLAG_PF_ANON)
-        return 1;
-
     return 0;
 }
 

Modified: trunk/t/pmc/namespace.t
==============================================================================
--- trunk/t/pmc/namespace.t	Wed Feb 11 00:44:34 2009	(r36563)
+++ trunk/t/pmc/namespace.t	Wed Feb 11 00:54:51 2009	(r36564)
@@ -1,17 +1,17 @@
 #! perl
-# Copyright (C) 2001-2008, The Perl Foundation.
+# Copyright (C) 2001-2009, The Perl Foundation.
 # $Id$
 
 use strict;
 use warnings;
 use lib qw( . lib ../lib ../../lib );
 use Test::More;
-use Parrot::Test tests => 66;
+use Parrot::Test tests => 67;
 use Parrot::Config;
 
 =head1 NAME
 
-t/pmc/namespace.t - test the NameSpace PMC as described in PDD21.
+t/pmc/namespace.t - test the NameSpace PMC as described in PDD 21.
 
 =head1 SYNOPSIS
 
@@ -1789,6 +1789,30 @@
 1
 OUT
 
+pir_error_output_like( <<'CODE', <<'OUT', 'adding :anon sub to a namespace, TT #56' );
+.namespace ['Foo']
+.sub main :main
+    .const 'Sub' $P0 = 'bar'
+
+    set_global 'ok', $P0
+    $P1 = get_global 'ok'
+    say $P1
+    $S0 = ok()
+    say $S0
+    $S0 = nok()
+    say $S0
+.end
+
+.namespace []
+.sub 'nok' :anon :subid('bar')
+    .return( 'ok 1' )
+.end
+CODE
+/
+ok 1
+Could not find non-existent sub nok/
+OUT
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4


More information about the parrot-commits mailing list