Fix potential SEGVs for OP_AELEMFAST on a lexical.
[p5sagit/Devel-Size.git] / t / code.t
index 65aca0e..ab5d514 100644 (file)
--- a/t/code.t
+++ b/t/code.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Test::More tests => 8;
+use Test::More tests => 10;
 use Devel::Size ':all';
 
 sub zwapp;
@@ -29,3 +29,14 @@ cmp_ok($anon_size, '>', 0, 'anonymous subroutines have a size');
 cmp_ok(length prototype $anon_proto, '>', 0, 'prototype has a length');
 cmp_ok($anon_proto_size, '>', $anon_size + length prototype $anon_proto,
        'prototypes add to the size');
+
+{
+    use vars '@b';
+    my $aelemfast_lex = total_size(sub {my @a; $a[0]});
+    my $aelemfast = total_size(sub {my @a; $b[0]});
+
+    cmp_ok($aelemfast_lex, '>', $anon_size,
+          'aelemfast for a lexical is handled correctly');
+    cmp_ok($aelemfast, '>', $aelemfast_lex,
+          'aelemfast for a package variable is larger');
+}