1#!./perl -w 2# 3# Tests to make sure the regexp engine doesn't run into limits too soon. 4# 5 6BEGIN { 7 chdir 't' if -d 't'; 8 require './test.pl'; 9 set_up_inc('../lib'); 10} 11 12use strict; 13 14my $email = qr { 15 (?(DEFINE) 16 (?<address> (?&mailbox) | (?&group)) 17 (?<mailbox> (?&name_addr) | (?&addr_spec)) 18 (?<name_addr> (?&display_name)? (?&angle_addr)) 19 (?<angle_addr> (?&CFWS)? < (?&addr_spec) > (?&CFWS)?) 20 (?<group> (?&display_name) : (?:(?&mailbox_list) | (?&CFWS))? ; 21 (?&CFWS)?) 22 (?<display_name> (?&phrase)) 23 (?<mailbox_list> (?&mailbox) (?: , (?&mailbox))*) 24 25 (?<addr_spec> (?&local_part) \@ (?&domain)) 26 (?<local_part> (?&dot_atom) | (?"ed_string)) 27 (?<domain> (?&dot_atom) | (?&domain_literal)) 28 (?<domain_literal> (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* (?&FWS)? 29 \] (?&CFWS)?) 30 (?<dcontent> (?&dtext) | (?"ed_pair)) 31 (?<dtext> (?&NO_WS_CTL) | (?[ [:ascii:] & [:graph:] & [^][ \\ ] ])) 32 33 (?<atext> (?&ALPHA) | (?&DIGIT) | [-!#\$%&'*+/=?^_`{|}~]) 34 (?<atom> (?&CFWS)? (?&atext)+ (?&CFWS)?) 35 (?<dot_atom> (?&CFWS)? (?&dot_atom_text) (?&CFWS)?) 36 (?<dot_atom_text> (?&atext)+ (?: \. (?&atext)+)*) 37 38 (?<text> (?[ [:ascii:] & [^ \000 \n \r ] ])) 39 (?<quoted_pair> \\ (?&text)) 40 41 (?<qtext> (?&NO_WS_CTL) | (?[ [:ascii:] & [:graph:] & [^ " \\ ] ])) 42 (?<qcontent> (?&qtext) | (?"ed_pair)) 43 (?<quoted_string> (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))* 44 (?&FWS)? (?&DQUOTE) (?&CFWS)?) 45 46 (?<word> (?&atom) | (?"ed_string)) 47 (?<phrase> (?&word)+) 48 49 # Folding white space 50 (?<FWS> (?: (?&WSP)* (?&CRLF))? (?&WSP)+) 51 (?<ctext> (?&NO_WS_CTL) | (?[ [:ascii:] & [:graph:] & [^ () ] & [^ \\ ] ])) 52 (?<ccontent> (?&ctext) | (?"ed_pair) | (?&comment)) 53 (?<comment> \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) ) 54 (?<CFWS> (?: (?&FWS)? (?&comment))* 55 (?: (?:(?&FWS)? (?&comment)) | (?&FWS))) 56 57 # No whitespace control 58 (?<NO_WS_CTL> (?[ [:ascii:] & [:cntrl:] & [^ \000 \h \r \n ] ])) 59 60 (?<ALPHA> [A-Za-z]) 61 (?<DIGIT> [0-9]) 62 (?<CRLF> \r \n) 63 (?<DQUOTE> ") 64 (?<WSP> [ \t]) 65 ) 66 67 (?&address) 68}x; 69 70run_tests() unless caller; 71 72sub run_tests { 73 # rewinding DATA is necessary with PERLIO=stdio when this 74 # test is run from another thread 75 seek *DATA, 0, 0; 76 while (<DATA>) { last if /^__DATA__/ } 77 while (<DATA>) { 78 chomp; 79 next if /^#/; 80 like($_, qr/^$email$/, $_); 81 } 82 83 done_testing(); 84} 85 861; # Because reg_email_thr.t will (indirectly) require this script. 87 88# 89# Acme::MetaSyntactic ++ 90# 91__DATA__ 92Jeff_Tracy@thunderbirds.org 93"Lady Penelope"@thunderbirds.org 94"The\ Hood"@thunderbirds.org 95fred @ flintstones.net 96barney (rubble) @ flintstones.org 97bammbamm (bam! bam! (bam! bam! (bam!)) bam!) @ flintstones.org 98Michelangelo@[127.0.0.1] 99Donatello @ [127.0.0.1] 100Raphael (He as well) @ [127.0.0.1] 101"Leonardo" @ [127.0.0.1] 102Barbapapa <barbapapa @ barbapapa.net> 103"Barba Mama" <barbamama @ [127.0.0.1]> 104Barbalala (lalalalalalalala) <barbalala (Yes, her!) @ (barba) barbapapa.net> 105