summaryrefslogtreecommitdiff
path: root/dist/Data-Dumper/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-07-02 20:22:12 +0000
committerNicholas Clark <nick@ccl4.org>2021-07-05 06:11:04 +0000
commitb188a4d779908b10bb17b176e027059d72643dd6 (patch)
tree71792099d77817f44a39718ed3a4157498cf4bdc /dist/Data-Dumper/t
parent481038139af48e43684b8b3a31c605175c0f78c3 (diff)
downloadperl-b188a4d779908b10bb17b176e027059d72643dd6.tar.gz
Refactor the variable name code in Dumpxs to avoid repeated SvPV* calls.
This fixes a really subtle bug whereby Dumpxs would not recognise variable names if they were generated by references with string overloading, NVs, and potentially other strange things. Seems that no-one has ever hit this. Also eliminate the need for a large temporary scratch buffer by using sv_setpvf().
Diffstat (limited to 'dist/Data-Dumper/t')
-rw-r--r--dist/Data-Dumper/t/dumper.t23
1 files changed, 22 insertions, 1 deletions
diff --git a/dist/Data-Dumper/t/dumper.t b/dist/Data-Dumper/t/dumper.t
index 176a12731a..0204796899 100644
--- a/dist/Data-Dumper/t/dumper.t
+++ b/dist/Data-Dumper/t/dumper.t
@@ -15,7 +15,7 @@ $Data::Dumper::Sortkeys = 1;
$Data::Dumper::Pad = "#";
my $XS;
-my $TMAX = 498;
+my $TMAX = 504;
# Force Data::Dumper::Dump to use perl. We test Dumpxs explicitly by calling
# it direct. Out here it lets us knobble the next if to test that the perl
@@ -1920,3 +1920,24 @@ EOT
'glob purity, useqq: Dumpxs()',
$want);
}
+#############
+{
+ my $want = <<'EOT';
+#$3 = {};
+#$bang = [];
+EOT
+ {
+ package fish;
+
+ use overload '""' => sub { return "bang" };
+
+ sub new {
+ return bless qr//;
+ }
+ }
+ # 4.5/1.5 generates the *NV* 3.0, which doesn't set SVf_POK true in 5.20.0+
+ # overloaded strings never set SVf_POK true
+ TEST_BOTH(q(Data::Dumper->Dumpxs([{}, []], [4.5/1.5, fish->new()])),
+ 'names that are not simple strings: Dumpxs()',
+ $want);
+}