File: 90leak.t

package info (click to toggle)
libobject-pad-perl 0.821-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 936 kB
  • sloc: ansic: 3,361; perl: 3,328; pascal: 28; makefile: 3
file content (65 lines) | stat: -rw-r--r-- 1,120 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl

use v5.18;
use warnings;

use Test2::V0;

BEGIN {
   plan skip_all => "Test::MemoryGrowth is not available" unless
      defined eval { require Test::MemoryGrowth };

   Test::MemoryGrowth->import;
}

use Object::Pad 0.800;

# RT132332
{
   class Example {
       # Needs at least one field member to trigger failures
       field $thing;
       # ... and we need to refer to it in a method as well
       ADJUST { $thing }
   }

   no_growth { Example->new };
}

{
   class WithContainerFields {
      field @array;
      field %hash;

      ADJUST {
         @array = ();
         %hash  = ();
      }
   }

   no_growth { WithContainerFields->new };
}

{
   use Object::Pad ':experimental(adjust_params)';

   class WithAdjustParams {
      field $_x;
      ADJUST :params ( :$x ) { $_x = $x; }
   }

   no_growth { WithAdjustParams->new( x => "the X value" ) }
      'named constructor param does not leak';
}

{
   class WithHashKeys :repr(keys) {
      field $f = "value";
      method x { $f = $f; }
   }

   no_growth { WithHashKeys->new->x }
      ':repr(keys) does not leak';
}

done_testing;