Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix and unfudge overlapping.t
* make number of tests not dependent on number of matches
* remove (1) x $count 5ism
* remove duplicate tests

Overall we now have 20 instead of 41 subtests, but we still test the same
functionality, and more transparent than before
  • Loading branch information
moritz committed Dec 13, 2014
1 parent 3cef4f5 commit 9990bba
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions S05-modifier/overlapping.t
Expand Up @@ -10,7 +10,7 @@ It probably needs a few syntax updates to remove p5isms
=end pod

plan 41;
plan 20;

# should be: L<S05/Modifiers/With the new C<:ov> (C<:overlap>) modifier,>
# L<S05/Modifiers/match at all possible character positions>
Expand All @@ -24,40 +24,19 @@ my @expected = (
[ 7, 'Abbra' ],
);

#?rakudo todo 'm:overlap NYI'
#?DOES 22
{
for (1..2) -> $rep {
ok($str ~~ m:i:overlap/ a .+ a /, "Repeatable overlapping match ($rep)" );

ok(@$/ == @expected, "Correct number of matches ($rep)" );
my %expected; %expected{map {$_[1]}, @expected} = (1) x @expected;
my %position; %position{map {$_[1]}, @expected} = map {$_[0]}, @expected;
for (@$/) {
ok( %expected{$_}, "Matched '$_' ($rep)" );
ok( %position{$_} == $_.to, "At correct position of '$_' ($rep)" );
%expected{$_} :delete;
}
ok(%expected.keys == 0, "No matches missed ($rep)" );
my @expected_pos = @expected.map: { $_[0] };
my @expected_str = @expected.map: { $_[1] };
is $/.list.join('|'), @expected_str.join('|'), 'Got right submatches';
is $/.list.map(*.from), @expected_pos, 'Got right position of submatches';
}
}

#?rakudo skip "m:overlap// NYI"
#?DOES 8
{
ok(!( "abcdefgh" ~~ m:overlap/ a .+ a / ), 'Failed overlapping match');
ok(@$/ == 0, 'No matches');

ok($str ~~ m:i:overlap/ a (.+) a /, 'Capturing overlapping match');

ok(@$/ == @expected, 'Correct number of capturing matches');
my %expected; %expected{@expected} = (1) x @expected;
for (@$/) {
my %expected; %expected{map {$_[1]}, @expected} = (1) x @expected;
ok( $_[1] = substr($_[0],1,-1), "Captured within '$_'" );
%expected{$_} :delete;
}
}
ok(!( "abcdefgh" ~~ m:overlap/ a .+ a / ), 'Failed overlapping match');

{
# $str eq abrAcadAbbra
Expand Down

0 comments on commit 9990bba

Please sign in to comment.