diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-18 04:17:15 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-18 04:17:15 +0000 |
commit | b695f709e8a342e35e482b0437eb6cdacdc58b6b (patch) | |
tree | 2d16192636e6ba806ff7a907f682c74f7705a920 /ext/Storable/t/overload.t | |
parent | d780cd7a0195e946e636d3ee546f6ef4f21d6acc (diff) | |
download | perl-b695f709e8a342e35e482b0437eb6cdacdc58b6b.tar.gz |
The Grand Trek: move the *.t files from t/ to lib/ and ext/.
No doubt I made some mistakes like missed some files or
misnamed some files. The naming rules were more or less:
(1) if the module is from CPAN, follows its ways, be it
t/*.t or test.pl.
(2) otherwise if there are multiple tests for a module
put them in a t/
(3) otherwise if there's only one test put it in Module.t
(4) helper files go to module/ (locale, strict, warnings)
(5) use longer filenames now that we can (but e.g. the
compat-0.6.t and the Text::Balanced test files still
were renamed to be more civil against the 8.3 people)
installperl was updated appropriately not to install the
*.t files or the help files from under lib.
TODO: some helper files still remain under t/ that could
follow their 'masters'. UPDATE: On second thoughts, why
should they. They can continue to live under t/lib, and
in fact the locale/strict/warnings helpers that were moved
could be moved back. This way the amount of non-installable
stuff under lib/ stays smaller.
p4raw-id: //depot/perl@10676
Diffstat (limited to 'ext/Storable/t/overload.t')
-rw-r--r-- | ext/Storable/t/overload.t | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/ext/Storable/t/overload.t b/ext/Storable/t/overload.t new file mode 100644 index 0000000000..6d1e5816d1 --- /dev/null +++ b/ext/Storable/t/overload.t @@ -0,0 +1,97 @@ +#!./perl + +# $Id: overload.t,v 1.0.1.1 2001/02/17 12:27:22 ram Exp $ +# +# Copyright (c) 1995-2000, Raphael Manfredi +# +# You may redistribute only under the same terms as Perl 5, as specified +# in the README file that comes with the distribution. +# +# $Log: overload.t,v $ +# Revision 1.0.1.1 2001/02/17 12:27:22 ram +# patch8: added test for structures with indirect ref to overloaded +# +# Revision 1.0 2000/09/01 19:40:42 ram +# Baseline for first official release. +# + +sub BEGIN { + chdir('t') if -d 't'; + @INC = '.'; + push @INC, '../lib'; + require Config; import Config; + if ($Config{'extensions'} !~ /\bStorable\b/) { + print "1..0 # Skip: Storable was not built\n"; + exit 0; + } + require 'lib/st-dump.pl'; +} + +sub ok; + +use Storable qw(freeze thaw); + +print "1..12\n"; + +package OVERLOADED; + +use overload + '""' => sub { $_[0][0] }; + +package main; + +$a = bless [77], OVERLOADED; + +$b = thaw freeze $a; +ok 1, ref $b eq 'OVERLOADED'; +ok 2, "$b" eq "77"; + +$c = thaw freeze \$a; +ok 3, ref $c eq 'REF'; +ok 4, ref $$c eq 'OVERLOADED'; +ok 5, "$$c" eq "77"; + +$d = thaw freeze [$a, $a]; +ok 6, "$d->[0]" eq "77"; +$d->[0][0]++; +ok 7, "$d->[1]" eq "78"; + +package REF_TO_OVER; + +sub make { + my $self = bless {}, shift; + my ($over) = @_; + $self->{over} = $over; + return $self; +} + +package OVER; + +use overload + '+' => \&plus, + '""' => sub { ref $_[0] }; + +sub plus { + return 314; +} + +sub make { + my $self = bless {}, shift; + my $ref = REF_TO_OVER->make($self); + $self->{ref} = $ref; + return $self; +} + +package main; + +$a = OVER->make(); +$b = thaw freeze $a; + +ok 8, ref $b eq 'OVER'; +ok 9, $a + $a == 314; +ok 10, ref $b->{ref} eq 'REF_TO_OVER'; +ok 11, "$b->{ref}->{over}" eq "$b"; +ok 12, $b + $b == 314; + +1; + |