<commit_before>use v6;
use Test;

plan 4;

# L<S05/New metacharacters/"The ~ operator is a helper for matching
# nested subrules with a specific terminator">

regex t1 {
    '(' ~ ')' 'ab'
}

ok 'c(ab)d' ~~ m/<t1>/, 'Can work with ~ and constant atoms (match)';
ok 'ab)d'  !~~ m/<t1>/, '~ and constant atoms (missing opening bracket)';
ok '(a)d'  !~~ m/<t1>/, '~ and constant atoms (wrong content)';
# this shouldn't throw an exception. See here:
# http://irclog.perlgeek.de/perl6/2009-01-08#i_816425
#?rakudo skip 'should not throw exceptions'
ok 'x(ab'  !~~ m/<t1>/,  '~ and constant atoms (missing closing bracket)';
<commit_msg>[t/spec] more tests for ~ in regexes<commit_after>use v6;
use Test;

plan 7;

# L<S05/New metacharacters/"The ~ operator is a helper for matching
# nested subrules with a specific terminator">

regex t1 {
    '(' ~ ')' 'ab'
}

ok 'c(ab)d' ~~ m/<t1>/, 'Can work with ~ and constant atoms (match)';
ok 'ab)d'  !~~ m/<t1>/, '~ and constant atoms (missing opening bracket)';
ok '(a)d'  !~~ m/<t1>/, '~ and constant atoms (wrong content)';
# this shouldn't throw an exception. See here:
# http://irclog.perlgeek.de/perl6/2009-01-08#i_816425
#?rakudo skip 'should not throw exceptions'
ok 'x(ab'  !~~ m/<t1>/,  '~ and constant atoms (missing closing bracket)';

#?rakudo skip 'parse errors'
{
    regex recursive {
        '(' ~ ')' [ 'a'* <recursive>* ]
    };

    ok '()'     ~~ m/<recursive>/, 'Can match "()" with tilde generator';
    ok '(a)'    ~~ m/<recursive>/, 'Can match "(a)" with tilde generator';
    ok '(aa)'   ~~ m/<recursive>/, 'Can match "(aa)" with tilde generator';
}

{'fraction_non_alphanumeric': 0.19183168316831684, 'fraction_numerical': 0.0297029702970297, 'mean_word_length': 3.7005813953488373, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3670244', 'n_tokens_mistral': 653, 'n_tokens_neox': 612, 'n_words': 184}