Do not try to load a feature bundle when doing "no VERSION"
[p5sagit/p5-mst-13.2.git] / dist / Storable / t / tied_items.t
CommitLineData
7a6a85bf 1#!./perl
7a6a85bf 2#
3# Copyright (c) 1995-2000, Raphael Manfredi
4#
9e21b3d0 5# You may redistribute only under the same terms as Perl 5, as specified
6# in the README file that comes with the distribution.
7a6a85bf 7#
7a6a85bf 8
9#
10# Tests ref to items in tied hash/array structures.
11#
12
13sub BEGIN {
48c887dd 14 unshift @INC, 't';
9f233367 15 require Config; import Config;
0c384302 16 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
9f233367 17 print "1..0 # Skip: Storable was not built\n";
18 exit 0;
19 }
372cb964 20 require 'st-dump.pl';
7a6a85bf 21}
22
23sub ok;
24$^W = 0;
25
26print "1..8\n";
27
28use Storable qw(dclone);
29
30$h_fetches = 0;
31
32sub H::TIEHASH { bless \(my $x), "H" }
33sub H::FETCH { $h_fetches++; $_[1] - 70 }
34
35tie %h, "H";
36
37$ref = \$h{77};
38$ref2 = dclone $ref;
39
40ok 1, $h_fetches == 0;
41ok 2, $$ref2 eq $$ref;
42ok 3, $$ref2 == 7;
43ok 4, $h_fetches == 2;
44
45$a_fetches = 0;
46
47sub A::TIEARRAY { bless \(my $x), "A" }
48sub A::FETCH { $a_fetches++; $_[1] - 70 }
49
50tie @a, "A";
51
52$ref = \$a[78];
53$ref2 = dclone $ref;
54
55ok 5, $a_fetches == 0;
56ok 6, $$ref2 eq $$ref;
57ok 7, $$ref2 == 8;
fd69380d 58# a bug in 5.12 and earlier caused an extra FETCH
59ok 8, $a_fetches == 2 || $a_fetches == 3 ;