Skip to content
Permalink
Browse files

When disabling $LoadBlessed, return scalars not refs

  • Loading branch information...
perlpunk committed Jun 15, 2018
1 parent bc26979 commit 6cb4103bfeed82e4894ac84557d5973f106b08e8
Showing with 5 additions and 5 deletions.
  1. +1 −1 LibYAML/perl_libyaml.c
  2. +4 −4 test/load-blessed.t
@@ -441,7 +441,7 @@ load_scalar(perl_yaml_loader_t *loader)
if (loader->load_blessed)
scalar = sv_setref_pvn(newSV(0), class, string, strlen(string));
else
scalar = sv_setref_pvn(newSV(0), NULL, string, strlen(string));
scalar = newSVpvn(string, length);
SvUTF8_on(scalar);
if (anchor)
hv_store(loader->anchors, anchor, strlen(anchor), SvREFCNT_inc(scalar), 0);
@@ -25,20 +25,20 @@ local $YAML::XS::LoadBlessed = 0;
my $hash = Load $yaml;
cmp_ok(ref $hash->{local_array}, 'eq', 'ARRAY', "Array not blessed (local)");
cmp_ok(ref $hash->{local_hash}, 'eq', 'HASH', "Hash not blessed (local)");
cmp_ok(ref $hash->{local_scalar}, 'eq', 'SCALAR', "Scalar not blessed (local)");
cmp_ok(ref $hash->{local_scalar}, 'eq', '', "Scalar not blessed (local)");
cmp_ok(ref $hash->{array}, 'eq', 'ARRAY', "Array not blessed");
cmp_ok(ref $hash->{hash}, 'eq', 'HASH', "Hash not blessed");
cmp_ok(ref $hash->{regex}, 'eq', 'Regexp', "Regexp not blessed");
cmp_ok(ref $hash->{scalar}, 'eq', 'SCALAR', "Scalar not blessed");
cmp_ok(ref $hash->{scalar}, 'eq', '', "Scalar not blessed");

my $expected = {
local_array => ["a"],
local_hash => { a => 1 },
local_scalar => \"a",
local_scalar => "a",
hash => { a => 1 },
array => ["a"],
regex => qr{OK},
scalar => \"scalar",
scalar => "scalar",
};
if ($hash->{regex} =~ m/:OK/) {
$hash->{regex} = $expected->{regex};

0 comments on commit 6cb4103

Please sign in to comment.
You can’t perform that action at this time.