From: Jarkko Hietaniemi Date: Thu, 31 Jul 2003 05:28:17 +0000 (+0000) Subject: Tests for change #20367 (and change use overload; to X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=05d3035d05f97548c36b396e73ec38035eca6e8b;p=p5sagit%2Fp5-mst-13.2.git Tests for change #20367 (and change use overload; to just require overload;) p4raw-link: @20367 on //depot/perl: 60ad8d7737ceae6f6c1fcd764c298b207f0f9a85 p4raw-id: //depot/perl@20368 --- diff --git a/lib/Tie/RefHash.pm b/lib/Tie/RefHash.pm index 373a94b..f393d7c 100644 --- a/lib/Tie/RefHash.pm +++ b/lib/Tie/RefHash.pm @@ -74,7 +74,7 @@ use vars '@ISA'; @ISA = qw(Tie::Hash); use strict; -use overload; # to support objects with overloaded "" +require overload; # to support objects with overloaded "" sub TIEHASH { my $c = shift; diff --git a/lib/Tie/RefHash.t b/lib/Tie/RefHash.t index d80b2e1..52e3a2d 100644 --- a/lib/Tie/RefHash.t +++ b/lib/Tie/RefHash.t @@ -18,12 +18,18 @@ BEGIN { use strict; use Tie::RefHash; use Data::Dumper; -my $numtests = 34; +my $numtests = 37; my $currtest = 1; print "1..$numtests\n"; my $ref = []; my $ref1 = []; +package Boustrophedon; # A class with overloaded "". +sub new { my ($c, $s) = @_; bless \$s, $c } +use overload '""' => sub { ${$_[0]} . reverse ${$_[0]} }; +package main; +my $ox = Boustrophedon->new("foobar"); + # Test standard hash functionality, by performing the same operations # on a tied hash and on a normal hash, and checking that the results # are the same. This does of course assume that Perl hashes are not @@ -93,6 +99,10 @@ test(not defined $h{$ref}); test(not exists($h{$ref})); test((keys %h) == 0); test((values %h) == 0); +$h{$ox} = "bellow"; # overloaded "" +test(exists $h{$ox}); +test($h{$ox} eq "bellow"); +test(not exists $h{"foobarraboof"}); undef $h; untie %h;