<commit_before>use v6;
use Test;
plan 8;

# L<S05/Syntactic categories/>

{
    token rule_backslash:<Y> { YY };
    eval_dies_ok  '/foo \y/', 
        'can not compile regex with unknown backslash rule';
    eval_lives_ok '/fuu \Y/', 'can compile a regex with new backslash rule';
    ok 'YY'  ~~ /^\Y$/, 'can use that rule (positive)';
    ok 'yX' !~~ /^\Y$/, 'can use that rule (negative)';
}
eval_dies_ok '/\Y/', 'backslash rules are lexically scoped';

{
    # nothing in the spec says that backslash rules need to be one char
    # only, and we have LTM after all
    # I feel so evil today... ;-)
    token rule_backslash:<moep> { 'Hax' };
    eval_lives_ok '/\moep/', 'can compile regex with multi char backslash rule';
    ok 'Haxe' ~~ m/^\moep/, '... it matches';
    ok 'Haxe' ~~ m/^\moepe$/, '... with correct end of escape sequence';
}

# vim: ft=perl6<commit_msg>[t/spec] bring new-symbols.t more in line with S02 and S05<commit_after>use v6;
use Test;
plan 8;

# L<S05/Syntactic categories/>

{
    augment slang Regex {
        token backslash:<Y> { YY };
    }
    eval_dies_ok  '/foo \y/', 
        'can not compile regex with unknown backslash rule';
    eval_lives_ok '/fuu \Y/', 'can compile a regex with new backslash rule';
    ok 'YY'  ~~ /^\Y$/, 'can use that rule (positive)';
    ok 'yX' !~~ /^\Y$/, 'can use that rule (negative)';
}
eval_dies_ok '/\Y/', 'backslash rules are lexically scoped';

{
    # nothing in the spec says that backslash rules need to be one char
    # only, and we have LTM after all
    # I feel so evil today... ;-)
    augment slang Regex {
        token backslash:<moep> { 'Hax' };
    }
    eval_lives_ok '/\moep/', 'can compile regex with multi char backslash rule';
    ok 'Haxe' ~~ m/^\moep/, '... it matches';
    ok 'Haxe' ~~ m/^\moepe$/, '... with correct end of escape sequence';
}

# vim: ft=perl6
{'fraction_non_alphanumeric': 0.1552928533046749, 'fraction_numerical': 0.007522837184309511, 'mean_word_length': 2.701789264413519, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5092679', 'n_tokens_mistral': 689, 'n_tokens_neox': 671, 'n_words': 234}