1b39c5158Smillert#!./perl -w 2b39c5158Smillert 3898184e3Ssthenuse strict; 4*256a93a4Safresh1use warnings; 5*256a93a4Safresh1 6b39c5158Smillertuse Data::Dumper; 7b39c5158Smillert 8898184e3Ssthenuse Test::More tests => 4; 9b39c5158Smillert 10b39c5158Smillertpackage Foo; 11b39c5158Smillertuse overload '""' => 'as_string'; 12b39c5158Smillert 13b39c5158Smillertsub new { bless { foo => "bar" }, shift } 14b39c5158Smillertsub as_string { "%%%%" } 15b39c5158Smillert 16b39c5158Smillertpackage main; 17b39c5158Smillert 18b39c5158Smillertmy $f = Foo->new; 19b39c5158Smillert 20898184e3Ssthenisa_ok($f, 'Foo'); 21898184e3Ssthenis("$f", '%%%%', 'String overloading works'); 22b39c5158Smillert 23898184e3Ssthenmy $d = Dumper($f); 24b39c5158Smillert 25898184e3Ssthenlike($d, qr/bar/); 26898184e3Ssthenlike($d, qr/Foo/); 27b39c5158Smillert 28