Skip to content

Commit

Permalink
RakuAST: add test for RakuAST::Regex::Backtrack::Greedy
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Mar 23, 2023
1 parent 07d4677 commit b258927
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/core.c/RakuAST/Deparse.pm6
Expand Up @@ -60,9 +60,9 @@ class RakuAST::Deparse {
method regex-assertion-fail(--> '<!> ') { }
method regex-assertion-recurse(--> '<~~> ') { }

method regex-backtrack-frugal( --> '?') { }
method regex-backtrack-ratchet(--> ':') { }
method regex-backtrack-greedy( --> ':!') { }
method regex-backtrack-frugal( --> '?') { }
method regex-backtrack-ratchet(--> ':') { }
method regex-backtrack-greedy( --> '!') { }

method regex-match-from(--> '<( ') { }
method regex-match-to( --> ')> ') { }
Expand Down
1 change: 0 additions & 1 deletion t/12-rakuast/TODO
Expand Up @@ -24,7 +24,6 @@ RakuAST::ParameterDefaultThunk
RakuAST::QuoteWordsAtom
RakuAST::Regex::Assertion::Callable
RakuAST::Regex::Assertion::Named::Args
RakuAST::Regex::Backtrack::Greedy
RakuAST::Regex::BacktrackModifiedAtom
RakuAST::Regex::Quantifier::BlockRange
RakuAST::Regex::SequentialConjunction
Expand Down
10 changes: 5 additions & 5 deletions t/12-rakuast/regex.rakutest
Expand Up @@ -352,8 +352,6 @@ subtest 'Quantified built-in character class matches (frugal mode)' => {
);
is-deeply $deparsed, '/ \d+?/', 'deparse';

say $raku;

match-ok "99cents", "9";
}

Expand All @@ -371,16 +369,18 @@ subtest 'Quantified negated built-in character class matches (frugal mode)' => {
}

subtest 'Greedy quantifier will backtrack' => {
# / ^ \d+9/
# / ^ \d+!9/
ast RakuAST::Regex::Sequence.new(
RakuAST::Regex::Anchor::BeginningOfString.new,
RakuAST::Regex::QuantifiedAtom.new(
atom => RakuAST::Regex::CharClass::Digit.new,
quantifier => RakuAST::Regex::Quantifier::OneOrMore.new
quantifier => RakuAST::Regex::Quantifier::OneOrMore.new(
backtrack => RakuAST::Regex::Backtrack::Greedy
)
),
RakuAST::Regex::Literal.new('9')
);
is-deeply $deparsed, '/ ^ \d+9/', 'deparse';
is-deeply $deparsed, '/ ^ \d+!9/', 'deparse';

match-ok "99cents", '99';
}
Expand Down

0 comments on commit b258927

Please sign in to comment.