Skip to content

Commit

Permalink
[pmc]: fix export_to when passed a hash with a null value (code + test)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@18537 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
particle committed May 14, 2007
1 parent a26e641 commit cf259ef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/pmc/namespace.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,15 @@ NOTE: exporting 'default' set of items is not yet implemented.
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)) {
Expand Down
26 changes: 25 additions & 1 deletion t/pmc/namespace.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use strict;
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
Expand Down Expand Up @@ -802,6 +802,30 @@ a_foo
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
Expand Down

0 comments on commit cf259ef

Please sign in to comment.