Commit | Line | Data |
---|---|---|
4189a2e6 Z |
1 | #!./perl |
2 | ||
3 | sub BEGIN { | |
4 | unshift @INC, 't'; | |
5 | unshift @INC, 't/compat' if $] < 5.006002; | |
6 | require Config; import Config; | |
7 | if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) { | |
8 | print "1..0 # Skip: Storable was not built\n"; | |
9 | exit 0; | |
10 | } | |
11 | } | |
12 | ||
13 | use Storable (); | |
14 | use Test::More tests => 3; | |
15 | ||
16 | our $f; | |
17 | ||
18 | package TIED_HASH; | |
19 | ||
20 | sub TIEHASH { bless({}, $_[0]) } | |
21 | ||
22 | sub STORE { | |
23 | $f = Storable::freeze(\$_[2]); | |
24 | 1; | |
25 | } | |
26 | ||
27 | package TIED_ARRAY; | |
28 | ||
29 | sub TIEARRAY { bless({}, $_[0]) } | |
30 | ||
31 | sub STORE { | |
32 | $f = Storable::freeze(\$_[2]); | |
33 | 1; | |
34 | } | |
35 | ||
36 | package TIED_SCALAR; | |
37 | ||
38 | sub TIESCALAR { bless({}, $_[0]) } | |
39 | ||
40 | sub STORE { | |
41 | $f = Storable::freeze(\$_[1]); | |
42 | 1; | |
43 | } | |
44 | ||
45 | package main; | |
46 | ||
47 | my($s, @a, %h); | |
48 | tie $s, "TIED_SCALAR"; | |
49 | tie @a, "TIED_ARRAY"; | |
50 | tie %h, "TIED_HASH"; | |
51 | ||
52 | $f = undef; | |
53 | $s = 111; | |
54 | is $f, Storable::freeze(\111); | |
55 | ||
56 | $f = undef; | |
57 | $a[3] = 222; | |
58 | is $f, Storable::freeze(\222); | |
59 | ||
60 | $f = undef; | |
61 | $h{foo} = 333; | |
62 | is $f, Storable::freeze(\333); | |
63 | ||
64 | 1; |