3 # This tests (?[...]). XXX These are just basic tests, as full ones would be
4 # best done with an infrastructure change to allow getting out the inversion
5 # list of the constructed set and then comparing it character by character
6 # with the expected result.
15 @INC = ('../lib','.');
20 no warnings 'experimental::regex_sets';
22 like("a", qr/(?[ [a] # This is a comment
23 ])/, 'Can ignore a comment');
24 like("a", qr/(?[ [a] # [[:notaclass:]]
25 ])/, 'A comment isn\'t parsed');
26 unlike("\x85", qr/(?[ \t
\85 ])/, 'NEL is white space');
27 unlike("\x85", qr/(?[ [\t
\85] ])/, '... including within nested []');
28 like("\x85", qr/(?[ \t + \
\85 ])/, 'can escape NEL to match');
29 like("\x85", qr/(?[ [\
\85] ])/, '... including within nested []');
30 like("\t", qr/(?[ \t + \
\85 ])/, 'can do basic union');
31 like("\cK", qr/(?[ \s ])/, '\s matches \cK');
32 unlike("\cK", qr/(?[ \s - \cK ])/, 'can do basic subtraction');
33 like(" ", qr/(?[ \s - \cK ])/, 'can do basic subtraction');
34 like(":", qr/(?[ [:] ])/, '[:] is not a posix class');
35 unlike("\t", qr/(?[ ! \t ])/, 'can do basic complement');
36 like("\t", qr/(?[ ! [ ^ \t ] ])/, 'can do basic complement');
37 unlike("\r", qr/(?[ \t ])/, '\r doesn\'t match \t ');
38 like("\r", qr/(?[ ! \t ])/, 'can do basic complement');
39 like("0", qr/(?[ [:word:] & [:digit:] ])/, 'can do basic intersection');
40 unlike("A", qr/(?[ [:word:] & [:digit:] ])/, 'can do basic intersection');
41 like("0", qr/(?[[:word:]&[:digit:]])/, 'spaces around internal [] aren\'t required');
43 like("a", qr/(?[ [a] | [b] ])/, '| means union');
44 like("b", qr/(?[ [a] | [b] ])/, '| means union');
45 unlike("c", qr/(?[ [a] | [b] ])/, '| means union');
47 like("a", qr/(?[ [ab] ^ [bc] ])/, 'basic symmetric difference works');
48 unlike("b", qr/(?[ [ab] ^ [bc] ])/, 'basic symmetric difference works');
49 like("c", qr/(?[ [ab] ^ [bc] ])/, 'basic symmetric difference works');
51 like("2", qr/(?[ ( ( \pN & ( [a] + [2] ) ) ) ])/, 'Nesting parens and grouping');
52 unlike("a", qr/(?[ ( ( \pN & ( [a] + [2] ) ) ) ])/, 'Nesting parens and grouping');