Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

136 lines (112 sloc) 3.991 kb
use v6;
use Test;
=begin origin
This file was originally derived from the perl5 CPAN module Perl6::Rules,
version 0.3 (12 Apr 2004), file t/continue.t.
=end origin
plan 40;
#?pugs emit force_todo(1,2,3,4,6);
# L<S05/Modifiers/causes the pattern to try to match only at>
for ("abcdef") {
ok(m:pos/abc/, "Matched 1: '$/'" );
#?pugs todo
is($/.to, 3, 'Interim position correct');
ok(m:pos/ghi|def/, "Matched 2: '$/'" );
#?pugs todo
is($/.to, 6, 'Final position correct');
}
#?rakudo skip "s:pos/// NYI"
{
$_ = "foofoofoo foofoofoo";
my $/;
ok(s:global:pos/foo/FOO/, 'Globally contiguous substitution');
#?pugs todo
is($_, "FOOFOOFOO foofoofoo", 'Correctly substituted contiguously');
}
#?pugs todo
{
my $str = "abcabcabc";
my $/;
ok($str ~~ m:p/abc/, 'Continued match');
ok($/.to == 3, 'Continued match pos');
# since match positions are now part of the match (and not the string),
# assigning to the string doesn't reset anything
$str = "abcabcabc";
my $x = $str ~~ m:i:p/abc/;
ok($/.to == 6, 'Insensitive continued match pos');
$x = $str ~~ m:i:p/abc/;
ok($/.to == 9, 'Insensitive recontinued match pos');
}
#?rakudo skip 'm:g'
#?niecza skip ':i'
{
my $str = "abcabcabc";
my @x = $str ~~ m:i:g:p/abc/;
#?pugs todo
is("@x", "abc abc abc", 'Insensitive repeated continued match');
#?pugs todo
ok($/.to == 9, 'Insensitive repeated continued match pos');
ok ($str !~~ m:i:p/abc/, 'no more match, string exhausted');
}
#?rakudo skip "m:p:i:g// NYI"
#?niecza skip ':i'
#?pugs todo
{
my $str = "abcabcabc";
my @x = ?($str ~~ m:p:i:g/abc/);
# XXX is that correct?
is($/.to, 3, 'Insensitive scalar repeated continued match pos');
}
#?pugs skip 'Cannot parse regex'
{
my $str = "abcabcabc";
my $match = $str.match(/abc/, :p(0));
ok $match.Bool, "Match anchored to 0";
is $match.from, 0, "and the match is in the correct position";
nok $str.match(/abc/, :p(1)).Bool, "No match anchored to 1";
nok $str.match(/abc/, :p(2)).Bool, "No match anchored to 2";
$match = $str.match(/abc/, :p(3));
ok $match.Bool, "Match anchored to 3";
is $match.from, 3, "and the match is in the correct position";
nok $str.match(/abc/, :p(4)).Bool, "No match anchored to 4";
$match = $str.match(/abc/, :p(6));
ok $match.Bool, "Match anchored to 6";
is $match.from, 6, "and the match is in the correct position";
nok $str.match(/abc/, :p(7)).Bool, "No match anchored to 7";
nok $str.match(/abc/, :p(8)).Bool, "No match anchored to 8";
nok $str.match(/abc/, :p(9)).Bool, "No match anchored to 9";
nok $str.match(/abc/, :p(10)).Bool, "No match anchored to 10";
}
{
my $str = "abcabcabc";
my $match = $str.match(/abc/, :pos(0));
#?pugs skip 'coercion'
ok $match.Bool, "Match anchored to 0";
is $match.from, 0, "and the match is in the correct position";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(1)).Bool, "No match anchored to 1";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(2)).Bool, "No match anchored to 2";
$match = $str.match(/abc/, :pos(3));
#?pugs skip 'coercion'
ok $match.Bool, "Match anchored to 3";
#?pugs todo
is $match.from, 3, "and the match is in the correct position";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(4)).Bool, "No match anchored to 4";
$match = $str.match(/abc/, :pos(6));
#?pugs skip 'coercion'
ok $match.Bool, "Match anchored to 6";
#?pugs todo
is $match.from, 6, "and the match is in the correct position";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(7)).Bool, "No match anchored to 7";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(8)).Bool, "No match anchored to 8";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(9)).Bool, "No match anchored to 9";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(10)).Bool, "No match anchored to 10";
}
done;
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.