use v6-alpha; use Test; =pod This file was derived from the perl5 CPAN module Perl6::Rules, version 0.3 (12 Apr 2004), file t/subrule.t. It has (hopefully) been, and should continue to be, updated to be valid perl6. =cut plan 18; if !eval('("a" ~~ /a/)') { skip_rest "skipped tests - rules support appears to be missing"; exit; } rule abc {abc} rule once {} ok("abcabcabcabcd" ~~ m//, 'Once match'); ok($/, 'Once matched'); is($/, "abc", 'Once matched'); ok(@$/ == 0, 'Once no array capture'); ok(%$/.keys == 0, 'Once no hash capture'); rule rep {**{4}} ok("abcabcabcabcd" ~~ m//, 'Rep match'); ok($/, 'Rep matched'); is($/, "abcabcabcabc", 'Rep matched'); ok(@$/ == 0, 'Rep no array capture'); ok(%$/.keys == 0, 'Rep no hash capture'); rule cap {} ok("abcabcabcabcd" ~~ m//, 'Cap match'); ok($/, 'Cap matched'); is($/, "abc", 'Cap zero matched'); is($/, "abc", 'Cap captured'); is($/, "abc", 'Cap abc captured'); ok(@$/ == 0, 'Cap no array capture'); ok(%$/.keys == 1, 'Cap hash capture'); rule repcap {**{4}} ok("abcabcabcabcd" ~~ m//, 'Repcap match'); ok($/, 'Repcap matched'); is($/, "abcabcabcabc", 'Repcap matched'); is($/, "abcabcabcabc", 'Repcap captured'); is(eval('$/[0]'), "abc", 'Repcap abc zero captured'); is(eval('$/[1]'), "abc", 'Repcap abc one captured'); is(eval('$/[2]'), "abc", 'Repcap abc two captured'); is(eval('$/[3]'), "abc", 'Repcap abc three captured'); ok(@$/ == 0, 'Repcap no array capture'); rule caprep {(**{4})} ok("abcabcabcabcd" ~~ m//, 'Caprep match'); ok($/, 'Caprep matched'); is($/, "abcabcabcabc", 'Caprep matched'); is($/, "abcabcabcabc", 'Caprep captured'); is(eval('$/[0]'), "abcabcabcabc", 'Caprep abc one captured');