Author: particle
Date: Mon May 14 08:45:23 2007
New Revision: 18537

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

Log:
[pmc]: fix export_to when passed a hash with a null value (code + test)

Modified: trunk/src/pmc/namespace.pmc
==============================================================================
--- trunk/src/pmc/namespace.pmc (original)
+++ trunk/src/pmc/namespace.pmc Mon May 14 08:45:23 2007
@@ -661,10 +661,15 @@
                     return;
                 }
 
-                dest_name = VTABLE_get_string_keyed_str(interp, what, 
src_name);
-                if (STRING_IS_NULL(dest_name) || STRING_IS_EMPTY(dest_name)) {
+                if (PMC_IS_NULL(VTABLE_get_pmc_keyed_str(interp, what, 
src_name))) {
                     dest_name = src_name;
                 }
+                else {
+                    dest_name = VTABLE_get_string_keyed_str(interp, what, 
src_name);
+                    if (STRING_IS_NULL(dest_name) || 
STRING_IS_EMPTY(dest_name)) {
+                        dest_name = src_name;
+                    }
+                }
 
                 object = VTABLE_get_pmc_keyed_str(interp, SELF, src_name);
                 if (PMC_IS_NULL(object)) {

Modified: trunk/t/pmc/namespace.t
==============================================================================
--- trunk/t/pmc/namespace.t     (original)
+++ trunk/t/pmc/namespace.t     Mon May 14 08:45:23 2007
@@ -6,7 +6,7 @@
 use warnings;
 use lib qw( . lib ../lib ../../lib );
 use Test::More;
-use Parrot::Test tests => 60;
+use Parrot::Test tests => 61;
 use Parrot::Config;
 
 =head1 NAME
@@ -802,6 +802,30 @@
 b_foo
 OUTPUT
 
+pir_output_is( <<"CODE", <<'OUTPUT', "export_to -- success with hash (null 
value)" );
+.HLL 'A', ''
+.sub main :main
+    a_foo()
+    load_bytecode "$temp_b.pir"
+    .local pmc nsr, nsa, nsb, ar, nul
+    nul = new .Null
+    ar  = new .Hash
+    ar["b_foo"] = nul
+    nsr = get_root_namespace
+    nsa = nsr['a']
+    nsb = nsr['b']
+    nsb."export_to"(nsa, ar)
+    b_foo()
+.end
+
+.sub a_foo
+    print "a_foo\\n"
+.end
+CODE
+a_foo
+b_foo
+OUTPUT
+
 pir_error_output_like( <<"CODE", <<'OUTPUT', "export_to -- success with hash 
(and value)" );
 .HLL 'A', ''
 .sub main :main

Reply via email to