use v6-alpha; use Test; =pod This file was originally derived from the perl5 CPAN module Perl6::Rules, version 0.3 (12 Apr 2004), file t/exhaustive.t. =cut plan 44; # Will need to be changed once :exhaustive starts working. if !eval('("a" ~~ /a/)') { skip_rest "skipped tests - rules support appears to be missing"; } else { force_todo(2,3,5,6,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42); my $str = "abrAcadAbbra"; my @expected = ( [ 0 => 'abrAcadAbbra' ], [ 0 => 'abrAcadA' ], [ 0 => 'abrAca' ], [ 0 => 'abrA' ], [ 3 => 'AcadAbbra' ], [ 3 => 'AcadA' ], [ 3 => 'Aca' ], [ 5 => 'adAbbra' ], [ 5 => 'adA' ], [ 7 => 'Abbra' ], ); for (1..2) -> $rep { ok($str ~~ m:i:exhaustive/ a .+ a /, "Repeatable every-way 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{$_} == $_.pos, "At correct position of '$_' ($rep)" ); delete %expected{$_}; } ok(%expected.keys == 0, "No matches missed ($rep)" ); } ok(!( "abcdefgh" ~~ m:exhaustive/ a .+ a / ), 'Failed every-way match'); ok(@$/ == 0, 'No matches'); ok($str ~~ m:ex:i/ a (.+) a /, 'Capturing every-way match'); ok(@$/ == @expected, 'Correct number of capturing matches'); my %expected; %expected{map {$_[1]}, @expected} = (1) x @expected; for (@$/) { ok( %expected{$_}, "Capture matched '$_'" ); ok( $_[1] = substr($_[0],1,-1), "Captured within '$_'" ); delete %expected{$_}; } my @adj =