[PATCH] Re: Storable 2.0.0 fails on vendor perl on Mac OS X 10.1
[p5sagit/p5-mst-13.2.git] / ext / Storable / t / tied_items.t
1 #!./perl
2
3 # $Id: tied_items.t,v 1.0 2000/09/01 19:40:42 ram Exp $
4 #
5 #  Copyright (c) 1995-2000, Raphael Manfredi
6 #  
7 #  You may redistribute only under the same terms as Perl 5, as specified
8 #  in the README file that comes with the distribution.
9 #
10 # $Log: tied_items.t,v $
11 # Revision 1.0  2000/09/01 19:40:42  ram
12 # Baseline for first official release.
13 #
14
15 #
16 # Tests ref to items in tied hash/array structures.
17 #
18
19 sub BEGIN {
20     if ($ENV{PERL_CORE}){
21         chdir('t') if -d 't';
22         @INC = ('.', '../lib', '../ext/Storable/t');
23     } else {
24         unshift @INC, 't';
25     }
26     require Config; import Config;
27     if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
28         print "1..0 # Skip: Storable was not built\n";
29         exit 0;
30     }
31     require 'st-dump.pl';
32 }
33
34 sub ok;
35 $^W = 0;
36
37 print "1..8\n";
38
39 use Storable qw(dclone);
40
41 $h_fetches = 0;
42
43 sub H::TIEHASH { bless \(my $x), "H" }
44 sub H::FETCH { $h_fetches++; $_[1] - 70 }
45
46 tie %h, "H";
47
48 $ref = \$h{77};
49 $ref2 = dclone $ref;
50
51 ok 1, $h_fetches == 0;
52 ok 2, $$ref2 eq $$ref;
53 ok 3, $$ref2 == 7;
54 ok 4, $h_fetches == 2;
55
56 $a_fetches = 0;
57
58 sub A::TIEARRAY { bless \(my $x), "A" }
59 sub A::FETCH { $a_fetches++; $_[1] - 70 }
60
61 tie @a, "A";
62
63 $ref = \$a[78];
64 $ref2 = dclone $ref;
65
66 ok 5, $a_fetches == 0;
67 ok 6, $$ref2 eq $$ref;
68 ok 7, $$ref2 == 8;
69 # I don't understand why it's 3 and not 2
70 ok 8, $a_fetches == 3;
71