1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
use strict;
use Test::More 'no_plan'; # XXX
BEGIN { use_ok('Email::Find') }
my %Tests;
BEGIN {
%Tests = (
# 'Hahah! Use "@".+*@[132.205.7.51] and watch them cringe!'
# => '"@".+*@[132.205.7.51]',
'What about "@"@foo.com?' => '"@"@foo.com',
'Eli the Beared <*@qz.to>' => '*@qz.to',
# '"@"+*@[132.205.7.51]' => '+*@[132.205.7.51]',
'somelongusername@aol.com' => 'somelongusername@aol.com',
'%2Fjoe@123.com' => '%2Fjoe@123.com',
'joe@123.com?subject=hello.' => 'joe@123.com',
);
}
while (my($text, $expect) = each %Tests) {
my($orig_text) = $text;
my $cb = sub {
is $_[0]->address, $expect, "Found $_[1]";
return $_[1];
};
my $finder = Email::Find->new($cb);
my $found = $finder->find(\$text);
is $found, 1, " just one";
is $text, $orig_text, " and replaced";
}
|