#!./perl
#
# Tests to make sure the regexp engine doesn't run into limits too soon.
#
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
print "1..13\n";
my $email = qr {
(?(DEFINE)
(?
(?&mailbox) | (?&group))
(? (?&name_addr) | (?&addr_spec))
(? (?&display_name)? (?&angle_addr))
(? (?&CFWS)? < (?&addr_spec) > (?&CFWS)?)
(? (?&display_name) : (?:(?&mailbox_list) | (?&CFWS))? ;
(?&CFWS)?)
(? (?&phrase))
(? (?&mailbox) (?: , (?&mailbox))*)
(? (?&local_part) \@ (?&domain))
(? (?&dot_atom) | (?"ed_string))
(? (?&dot_atom) | (?&domain_literal))
(? (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* (?&FWS)?
\] (?&CFWS)?)
(? (?&dtext) | (?"ed_pair))
(? (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e])
(? (?&ALPHA) | (?&DIGIT) | [!#\$%&'*+-/=?^_`{|}~])
(? (?&CFWS)? (?&atext)+ (?&CFWS)?)
(? (?&CFWS)? (?&dot_atom_text) (?&CFWS)?)
(? (?&atext)+ (?: \. (?&atext)+)*)
(? [\x01-\x09\x0b\x0c\x0e-\x7f])
(? \\ (?&text))
(? (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e])
(? (?&qtext) | (?"ed_pair))
(? (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))*
(?&FWS)? (?&DQUOTE) (?&CFWS)?)
(? (?&atom) | (?"ed_string))
(? (?&word)+)
# Folding white space
(? (?: (?&WSP)* (?&CRLF))? (?&WSP)+)
(? (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e])
(? (?&ctext) | (?"ed_pair) | (?&comment))
(? \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) )
(? (?: (?&FWS)? (?&comment))*
(?: (?:(?&FWS)? (?&comment)) | (?&FWS)))
# No whitespace control
(? [\x01-\x08\x0b\x0c\x0e-\x1f\x7f])
(? [A-Za-z])
(? [0-9])
(? \x0d \x0a)
(? ")
(? [\x20\x09])
)
(?&address)
}x;
run_tests() unless caller;
sub run_tests {
my $count = 0;
$| = 1;
# rewinding DATA is necessary with PERLIO=stdio when this
# test is run from another thread
seek *DATA, 0, 0;
while () { last if /^__DATA__/ }
while () {
chomp;
next if /^#/;
print /^$email$/ ? "ok " : "not ok ", ++ $count, "\n";
}
}
#
# Acme::MetaSyntactic ++
#
__DATA__
Jeff_Tracy@thunderbirds.org
"Lady Penelope"@thunderbirds.org
"The\ Hood"@thunderbirds.org
fred @ flintstones.net
barney (rubble) @ flintstones.org
bammbamm (bam! bam! (bam! bam! (bam!)) bam!) @ flintstones.org
Michelangelo@[127.0.0.1]
Donatello @ [127.0.0.1]
Raphael (He as well) @ [127.0.0.1]
"Leonardo" @ [127.0.0.1]
Barbapapa
"Barba Mama"
Barbalala (lalalalalalalala)