Debian Codegraph @

t/zzz-acceptance-draft7-format.t

raw
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 'Net::IDN::Encode' => 0,
34 'Data::Validate::URI' => 0,
35 };
36 }
37
38 if ($ENV{AUTHOR_TESTING}) {
39 eval { require Email::Address::XS; Email::Address::XS->VERSION(1.04); 1 } or fail $@;
40 eval { require Data::Validate::Domain; Data::Validate::Domain->VERSION(0.13); 1 } or fail $@;
41 eval { require Net::IDN::Encode; 1 } or fail $@;
42 eval { require Data::Validate::URI; 1 } or fail $@;
43 }
44
45 my $version = 'draft7';
46
47 $ENV{NO_SHORT_CIRCUIT} = 1;
48
49 acceptance_tests(
50 acceptance => {
51 specification => $version,
52 test_subdir => 'optional/format',
53 },
54 evaluator => {
55 specification_version => $version,
56 # validate_formats behaviour should default to true for this draft
57 collect_annotations => 0,
58 },
59 output_file => $version.'-acceptance-format.txt',
60 test => {
61 $ENV{NO_TODO} ? () : (todo_tests => [
62 { file => [
63 'iri-reference.json', # all strings are considered valid
64 'uri-template.json', # not yet implemented
65 # these all depend on optional prereqs
66 !$ENV{AUTHOR_TESTING} && !eval { require Email::Address::XS; Email::Address::XS->VERSION(1.04); 1 } ? qw(email.json idn-email.json) : (),
67 !$ENV{AUTHOR_TESTING} && !eval { require Data::Validate::Domain; Data::Validate::Domain->VERSION(0.13); 1 } ? qw(hostname.json idn-hostname.json) : (),
68 !$ENV{AUTHOR_TESTING} && !eval { require Net::IDN::Encode; 1 } ? 'idn-hostname.json' : (),
69 !$ENV{AUTHOR_TESTING} && !eval { require Data::Validate::URI; 1 } ? 'uri.json' : (),
70 ] },
71 # various edge cases that are difficult to accomodate
72 { file => 'hostname.json', group_description => 'validation of host names', test_description => [ 'trailing dot', 'contains "--" in the 3rd and 4th position' ] },
73 { file => 'hostname.json', group_description => 'validation of A-label (punycode) host names' },
74 { file => 'iri.json', test_description => [
75 'an invalid IRI based on IPv6',
76 'an IPv6 address without enclosing brackets is invalid',
77 'an IPv6 host whose embedded IPv4 has a leading zero is invalid',
78 'a trailing newline after a valid IRI is invalid',
79 ] },
80 { file => 'idn-hostname.json',
81 # IDN decoder, Data::Validate::Domain both have issues
82 group_description => [ 'validation of internationalized host names', 'validation of separators in internationalized host names' ] },
83 { file => 'uri.json', test_description => [
84 'lone percent sign is invalid',
85 'non-numeric port is invalid',
86 'leading zero in an embedded IPv4 address is invalid',
87 ] },
88 { file => 'uri-reference.json', test_description => [
89 'an incomplete percent-encoding',
90 'a non-numeric port in a network-path reference',
91 'a leading zero in the IPv4 part of an IPv6 literal',
92 'a colon in the first segment of a relative-path reference',
93 ] },
94 { file => 'ecmascript-regex.json', group_description => '\a is not an ECMA 262 control escape', test_description => 'when used as a pattern' },
95 { file => 'ecmascript-regex.json', group_description => [
96 'Python-specific regular expression syntax is not valid ECMA 262',
97 'global inline flag groups are not valid ECMA 262',
98 ] },
99 { file => 'ecmascript-regex.json', group_description => 'ECMA 262 lookbehind is valid, including variable width', test_description => 'a variable-width lookbehind (ES2018)' },
100 { file => 'ecmascript-regex.json', group_description => 'ECMA 262 character classes and escapes',
101 test_description => [ 'an empty character class is valid ECMA 262', 'a negated empty character class is valid ECMA 262' ] },
102 { file => 'email.json', test_description => [
103 'a trailing line feed is not valid',
104 'a trailing carriage return is not valid',
105 'a trailing space is not valid',
106 'a leading space is not valid',
107 'a domain label starting with a hyphen is not valid',
108 'a domain label ending with a hyphen is not valid',
109 'a domain ending with a dot is not valid',
110 'empty brackets after the @ are not valid',
111 'an IPv4-address-literal with three octets is not valid',
112 'an IPv4-address-literal with five octets is not valid',
113 'bracketed content that is not an address is not valid',
114 'a parenthesis in an unquoted local part is not valid',
115 'a parenthesis in the domain is not valid',
116 'an invalid domain',
117 'an invalid IPv4-address-literal',
118 ] },
119 ]),
120 },
121 );
122
123 END {
124 diag <<DIAG
125
126 ###############################
127
128 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!
129
130 ###############################
131 DIAG
132 if not is_passing;
133 }
134
135 done_testing;
136 __END__
137 see t/results/draft7-acceptance-format.txt for test results