weak ref support
[p5sagit/Data-Dumper-ToXS.git] / t / fixtures.pl
1 use strictures 1;
2 # disable the "Useless use of anonymous list ([]) in void context"
3 # warning so we can perl -c this file during development
4 no warnings 'void';
5 use Scalar::Util qw(weaken);
6 [
7   data_structure =>
8   {
9     sv_undef => undef,
10     sv_iv => 3,
11     sv_nv => 4.2,
12     sv_pv => "spoon",
13     ref_scalar => \"foo\nbar",
14     ref_array => [ 1, \undef, "73" ],
15   }
16 ],
17 [
18   cross_refs =>
19     do {
20       my ($x, $y, $z) = (\1, { two => 2 }, [ three => 3 ]);
21       +{
22         one => $x,
23         two => $y,
24         three => $z,
25         inner => {
26           one => $x,
27         },
28         inner2 => [
29           three => $z,
30         ]
31       };
32     }
33 ],
34 do { sub DDXSTest::foo { 'DDXSTest::foo' } () },
35 [
36   global_sub => { foo => \&DDXSTest::foo }
37 ],
38 [
39   weaken_1 => do {
40     my $x = 1;
41     my $y = [ \$x, \$x, \$x ];
42     weaken($y->[1]);
43     $y;
44   }
45 ],
46 [
47   weaken_0 => do {
48     my $x = 1;
49     my $y = [ \$x, \$x, \$x ];
50     weaken($y->[0]);
51     $y;
52   }
53 ]