Commit | Line | Data |
7a6a85bf |
1 | #!./perl |
2 | |
3 | # $Id: overload.t,v 0.7.1.1 2000/08/13 20:10:10 ram Exp $ |
4 | # |
5 | # Copyright (c) 1995-2000, Raphael Manfredi |
6 | # |
7 | # You may redistribute only under the terms of the Artistic License, |
8 | # as specified in the README file that comes with the distribution. |
9 | # |
10 | # $Log: overload.t,v $ |
11 | # Revision 0.7.1.1 2000/08/13 20:10:10 ram |
12 | # patch1: created |
13 | # |
14 | |
15 | sub BEGIN { |
16 | chdir('t') if -d 't'; |
8268a68b |
17 | unshift @INC, '../lib'; |
9f233367 |
18 | require Config; import Config; |
19 | if ($Config{'extensions'} !~ /\bStorable\b/) { |
20 | print "1..0 # Skip: Storable was not built\n"; |
21 | exit 0; |
22 | } |
7a6a85bf |
23 | require 'lib/st-dump.pl'; |
24 | } |
25 | |
26 | sub ok; |
27 | |
28 | use Storable qw(freeze thaw); |
29 | |
30 | print "1..7\n"; |
31 | |
32 | package OVERLOADED; |
33 | |
34 | use overload |
35 | '""' => sub { $_[0][0] }; |
36 | |
37 | package main; |
38 | |
39 | $a = bless [77], OVERLOADED; |
40 | |
41 | $b = thaw freeze $a; |
42 | ok 1, ref $b eq 'OVERLOADED'; |
43 | ok 2, "$b" eq "77"; |
44 | |
45 | $c = thaw freeze \$a; |
46 | ok 3, ref $c eq 'REF'; |
47 | ok 4, ref $$c eq 'OVERLOADED'; |
48 | ok 5, "$$c" eq "77"; |
49 | |
50 | $d = thaw freeze [$a, $a]; |
51 | ok 6, "$d->[0]" eq "77"; |
52 | $d->[0][0]++; |
53 | ok 7, "$d->[1]" eq "78"; |
54 | |