Subject: | [PATCH] Compatibility with CV-in-stash optimisation |
See <https://rt.perl.org/Ticket/Display.html?id=132252>.
This patch gets Variable::Magic’s test suite working with the new optimisation. I hope this can be applied soon, so that we can include the new memory savings in perl 5.28.
Subject: | open_zv9xpGU5.txt |
diff -rup Variable-Magic-0.61-vFSvfU/t/35-stash.t Variable-Magic-0.61-0/t/35-stash.t
--- Variable-Magic-0.61-vFSvfU/t/35-stash.t 2015-06-05 01:48:21.000000000 -0700
+++ Variable-Magic-0.61-0/t/35-stash.t 2017-10-17 19:58:59.000000000 -0700
@@ -114,9 +114,14 @@ cast %Hlagh::, $wiz;
eval q{ Hlagh->shoot() };
is $@, '', 'stash: valid method call ran fine';
- is_deeply \%mg, {
- fetch => [ qw<shoot> ],
- }, 'stash: valid method call';
+
+ # Typeglob reification may cause a store in 5.28+
+ is_deeply \%mg, keys %mg == 2
+ ? { fetch => [ qw<shoot> ],
+ store => [ qw<shoot> ],
+ }
+ : { fetch => [ qw<shoot> ], },
+ 'stash: valid method call';
}
{
diff -rup Variable-Magic-0.61-vFSvfU/t/lib/VPIT/TestHelpers.pm Variable-Magic-0.61-0/t/lib/VPIT/TestHelpers.pm
--- Variable-Magic-0.61-vFSvfU/t/lib/VPIT/TestHelpers.pm 2015-07-20 15:33:52.000000000 -0700
+++ Variable-Magic-0.61-0/t/lib/VPIT/TestHelpers.pm 2017-10-17 19:44:34.000000000 -0700
@@ -97,7 +97,9 @@ my $test_sub = sub {
}
my $glob = $stash->{$sub};
- return $glob ? *$glob{CODE} : undef;
+ return ref \$glob eq 'GLOB' ? *$glob{CODE}
+ : ref $glob eq 'CODE' ? $glob
+ : undef;
};
sub skip { $test_sub->('skip')->(@_) }