| 1 |
# vim: set ft=perl ts=8 sts=2 sw=2 tw=100 et : |
| 2 |
use strictures 2; |
| 3 |
use 5.020; |
| 4 |
use stable 0.031 'postderef'; |
| 5 |
use experimental 'signatures'; |
| 6 |
no autovivification warn => qw(fetch store exists delete); |
| 7 |
use if "$]" >= 5.022, experimental => 're_strict'; |
| 8 |
no if "$]" >= 5.031009, feature => 'indirect'; |
| 9 |
no if "$]" >= 5.033001, feature => 'multidimensional'; |
| 10 |
no if "$]" >= 5.033006, feature => 'bareword_filehandles'; |
| 11 |
no if "$]" >= 5.041009, feature => 'smartmatch'; |
| 12 |
no feature 'switch'; |
| 13 |
use open ':std', ':encoding(UTF-8)'; # force stdin, stdout, stderr into utf8 |
| 14 |
|
| 15 |
use Test::Needs; |
| 16 |
use List::Util 1.50 'head'; |
| 17 |
use lib 't/lib'; |
| 18 |
use Helper; |
| 19 |
use Acceptance; |
| 20 |
|
| 21 |
BEGIN { |
| 22 |
my @variables = qw(AUTHOR_TESTING AUTOMATED_TESTING EXTENDED_TESTING); |
| 23 |
|
| 24 |
plan skip_all => 'These tests may fail if the test suite continues to evolve! They should only be run with ' |
| 25 |
.join(', ', map $_.'=1', head(-1, @variables)).' or '.$variables[-1].'=1' |
| 26 |
if not grep $ENV{$_}, @variables; |
| 27 |
} |
| 28 |
|
| 29 |
if ($ENV{EXTENDED_TESTING}) { |
| 30 |
test_needs { |
| 31 |
'Email::Address::XS' => '1.04', |
| 32 |
'Data::Validate::Domain' => 0.13, |
| 33 |
'Data::Validate::URI' => 0, |
| 34 |
}; |
| 35 |
} |
| 36 |
|
| 37 |
if ($ENV{AUTHOR_TESTING}) { |
| 38 |
eval { require Email::Address::XS; Email::Address::XS->VERSION(1.04); 1 } or fail $@; |
| 39 |
eval { require Data::Validate::Domain; Data::Validate::Domain->VERSION(0.13); 1 } or fail $@; |
| 40 |
eval { require Data::Validate::URI; 1 } or fail $@; |
| 41 |
} |
| 42 |
|
| 43 |
my $version = 'draft4'; |
| 44 |
|
| 45 |
$ENV{NO_SHORT_CIRCUIT} = 1; |
| 46 |
|
| 47 |
acceptance_tests( |
| 48 |
acceptance => { |
| 49 |
specification => $version, |
| 50 |
test_subdir => 'optional/format', |
| 51 |
}, |
| 52 |
evaluator => { |
| 53 |
specification_version => $version, |
| 54 |
# validate_formats behaviour should default to true for this draft |
| 55 |
collect_annotations => 0, |
| 56 |
}, |
| 57 |
output_file => $version.'-acceptance-format.txt', |
| 58 |
test => { |
| 59 |
$ENV{NO_TODO} ? () : (todo_tests => [ |
| 60 |
{ file => [ |
| 61 |
# these all depend on optional prereqs |
| 62 |
!$ENV{AUTHOR_TESTING} && !eval { require Email::Address::XS; Email::Address::XS->VERSION(1.04); 1 } ? 'email.json' : (), |
| 63 |
!$ENV{AUTHOR_TESTING} && !eval { require Data::Validate::Domain; Data::Validate::Domain->VERSION(0.13); 1 } ? 'hostname.json' : (), |
| 64 |
!$ENV{AUTHOR_TESTING} && !eval { require Data::Validate::URI; 1 } ? 'uri.json' : (), |
| 65 |
] }, |
| 66 |
# various edge cases that are difficult to accomodate |
| 67 |
{ file => 'hostname.json', group_description => 'validation of host names', test_description => 'trailing dot' }, |
| 68 |
{ file => 'hostname.json', group_description => 'validation of A-label (punycode) host names' }, |
| 69 |
{ file => 'uri.json', test_description => [ |
| 70 |
'lone percent sign is invalid', |
| 71 |
'non-numeric port is invalid', |
| 72 |
'leading zero in an embedded IPv4 address is invalid', |
| 73 |
] }, |
| 74 |
{ file => 'email.json', test_description => [ |
| 75 |
'a trailing line feed is not valid', |
| 76 |
'a trailing carriage return is not valid', |
| 77 |
'a trailing space is not valid', |
| 78 |
'a leading space is not valid', |
| 79 |
'a domain label starting with a hyphen is not valid', |
| 80 |
'a domain label ending with a hyphen is not valid', |
| 81 |
'a domain ending with a dot is not valid', |
| 82 |
'empty brackets after the @ are not valid', |
| 83 |
'an IPv4-address-literal with three octets is not valid', |
| 84 |
'an IPv4-address-literal with five octets is not valid', |
| 85 |
'bracketed content that is not an address is not valid', |
| 86 |
'a parenthesis in an unquoted local part is not valid', |
| 87 |
'a parenthesis in the domain is not valid', |
| 88 |
'an invalid domain', |
| 89 |
'an invalid IPv4-address-literal', |
| 90 |
] }, |
| 91 |
]), |
| 92 |
}, |
| 93 |
); |
| 94 |
|
| 95 |
END { |
| 96 |
diag <<DIAG |
| 97 |
|
| 98 |
############################### |
| 99 |
|
| 100 |
Attention CPANTesters: you do not need to file a ticket when this test fails. I will receive the test reports and act on it soon. thank you! |
| 101 |
|
| 102 |
############################### |
| 103 |
DIAG |
| 104 |
if not is_passing; |
| 105 |
} |
| 106 |
|
| 107 |
done_testing; |
| 108 |
__END__ |
| 109 |
see t/results/draft4-acceptance-format.txt for test results |