Re: [PATCH: perl@8342] comp/proto..........FAILED tests 112-123
[p5sagit/p5-mst-13.2.git] / t / lib / st-overload.t
CommitLineData
7a6a85bf 1#!./perl
2
9e21b3d0 3# $Id: overload.t,v 1.0 2000/09/01 19:40:42 ram Exp $
7a6a85bf 4#
5# Copyright (c) 1995-2000, Raphael Manfredi
6#
9e21b3d0 7# You may redistribute only under the same terms as Perl 5, as specified
8# in the README file that comes with the distribution.
7a6a85bf 9#
10# $Log: overload.t,v $
9e21b3d0 11# Revision 1.0 2000/09/01 19:40:42 ram
12# Baseline for first official release.
7a6a85bf 13#
14
15sub BEGIN {
16 chdir('t') if -d 't';
20822f61 17 @INC = '.';
18 push @INC, '../lib';
9f233367 19 require Config; import Config;
20 if ($Config{'extensions'} !~ /\bStorable\b/) {
21 print "1..0 # Skip: Storable was not built\n";
22 exit 0;
23 }
7a6a85bf 24 require 'lib/st-dump.pl';
25}
26
27sub ok;
28
29use Storable qw(freeze thaw);
30
31print "1..7\n";
32
33package OVERLOADED;
34
35use overload
36 '""' => sub { $_[0][0] };
37
38package main;
39
40$a = bless [77], OVERLOADED;
41
42$b = thaw freeze $a;
43ok 1, ref $b eq 'OVERLOADED';
44ok 2, "$b" eq "77";
45
46$c = thaw freeze \$a;
47ok 3, ref $c eq 'REF';
48ok 4, ref $$c eq 'OVERLOADED';
49ok 5, "$$c" eq "77";
50
51$d = thaw freeze [$a, $a];
52ok 6, "$d->[0]" eq "77";
53$d->[0][0]++;
54ok 7, "$d->[1]" eq "78";
55