In perl.git, the branch smartmatch has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/90a32bcb5e6a686bec0d5726c12e209e6c769d92?hp=0483c67272447ab9cf7bf63ea915eccf128eda1a>

- Log -----------------------------------------------------------------
commit 90a32bcb5e6a686bec0d5726c12e209e6c769d92
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Sat May 9 15:50:25 2009 +0200

    Add a test for object ~~ string, with stringification overload
-----------------------------------------------------------------------

Summary of changes:
 t/op/smartmatch.t |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/op/smartmatch.t b/t/op/smartmatch.t
index fa66de9..3124b7a 100644
--- a/t/op/smartmatch.t
+++ b/t/op/smartmatch.t
@@ -32,13 +32,14 @@ tie my %tied_hash, 'Tie::StdHash';
 }
 
 {
-    package Test::Object::CopyOverload;
+    package Test::Object::WithOverload;
     sub new { bless { key => 'magic' } }
     use overload '~~' => sub { my %hash = %{ $_[0] }; $_[1] eq $hash{key} };
     use overload '""' => sub { "stringified" };
+    use overload 'eq' => sub {"$_[0]" eq "$_[1]"};
 }
 
-our $ov_obj = Test::Object::CopyOverload->new;
+our $ov_obj = Test::Object::WithOverload->new;
 our $obj = Test::Object::NoOverload->new;
 
 my @keyandmore = qw(key and more);
@@ -170,6 +171,7 @@ __DATA__
 # object (overloaded or not) ~~ Any
        $obj            qr/NoOverload/
        $ov_obj         qr/^stringified$/
+       $ov_obj         "stringified"
 
 # ~~ Coderef
        sub{0}          sub { ref $_[0] eq "CODE" }
@@ -204,7 +206,7 @@ __DATA__
 !      [1]             \&foo
 !      {a=>1}          \&foo
        $obj            sub { ref($_[0]) =~ /NoOverload/ }
-       $ov_obj         sub { ref($_[0]) =~ /CopyOverload/ }
+       $ov_obj         sub { ref($_[0]) =~ /WithOverload/ }
 # empty stuff matches, because the sub is never called:
        []              \&foo
        {}              \&foo

--
Perl5 Master Repository

Reply via email to