Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 92 lines (65 sloc) 2.368 kB
986b669 [t] moved subrule.t to spec/
moritz authored
1 use v6;
2
3 use Test;
4
5 =begin pod
6
7 This file was derived from the perl5 CPAN module Perl6::Rules,
8 version 0.3 (12 Apr 2004), file t/subrule.t.
9
10 It has (hopefully) been, and should continue to be, updated to
11 be valid perl6.
12
13 =end pod
14
6bcda09 @moritz test availability of $/ in embedded blocks in regexes
moritz authored
15 plan 38;
986b669 [t] moved subrule.t to spec/
moritz authored
16
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
17 # L<S05/Match objects/When used as a hash>
986b669 [t] moved subrule.t to spec/
moritz authored
18
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
19 my regex abc {abc}
986b669 [t] moved subrule.t to spec/
moritz authored
20
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
21 my regex once {<&abc>}
986b669 [t] moved subrule.t to spec/
moritz authored
22
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
23 ok("abcabcabcabcd" ~~ m/<&once>/, 'Once match');
986b669 [t] moved subrule.t to spec/
moritz authored
24 ok($/, 'Once matched');
25 is(~$/, "abc", 'Once matched');
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
26 ok(@($/) == 0, 'Once no array capture');
27 ok(%($/).keys == 0, 'Once no hash capture');
986b669 [t] moved subrule.t to spec/
moritz authored
28
29
644e553 @moritz rakudo refudging
moritz authored
30 my regex rep {<&abc>**4}
986b669 [t] moved subrule.t to spec/
moritz authored
31
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
32 ok("abcabcabcabcd" ~~ m/<&rep>/, 'Rep match');
986b669 [t] moved subrule.t to spec/
moritz authored
33 ok($/, 'Rep matched');
34 is(~$/, "abcabcabcabc", 'Rep matched');
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
35 ok(@($/) == 0, 'Rep no array capture');
36 ok(%($/).keys == 0, 'Rep no hash capture');
986b669 [t] moved subrule.t to spec/
moritz authored
37
38
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
39 my regex cap {<abc=&abc>}
986b669 [t] moved subrule.t to spec/
moritz authored
40
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
41 ok("abcabcabcabcd" ~~ m/<cap=&cap>/, 'Cap match');
986b669 [t] moved subrule.t to spec/
moritz authored
42 ok($/, 'Cap matched');
43 is(~$/, "abc", 'Cap zero matched');
44 is(~$/<cap>, "abc", 'Cap captured');
45
46 is(~$/<cap><abc>, "abc", 'Cap abc captured');
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
47 ok(@($/) == 0, 'Cap no array capture');
48 ok(%($/).keys == 1, 'Cap hash capture');
986b669 [t] moved subrule.t to spec/
moritz authored
49
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
50 my regex repcap {<abc=&abc>**{4}}
986b669 [t] moved subrule.t to spec/
moritz authored
51
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
52 ok("abcabcabcabcd" ~~ m/<repcap=&repcap>/, 'Repcap match');
986b669 [t] moved subrule.t to spec/
moritz authored
53 ok($/, 'Repcap matched');
54 is(~$/, "abcabcabcabc", 'Repcap matched');
55 is(~$/<repcap>, "abcabcabcabc", 'Repcap captured');
56 is(~$/<repcap><abc>[0], "abc", 'Repcap abc zero captured');
57 is(~$/<repcap><abc>[1], "abc", 'Repcap abc one captured');
58 is(~$/<repcap><abc>[2], "abc", 'Repcap abc two captured');
59 is(~$/<repcap><abc>[3], "abc", 'Repcap abc three captured');
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
60 ok(@($/) == 0, 'Repcap no array capture');
986b669 [t] moved subrule.t to spec/
moritz authored
61
62
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
63 my regex caprep {(<&abc>**{4})}
986b669 [t] moved subrule.t to spec/
moritz authored
64
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
65 ok("abcabcabcabcd" ~~ m/<caprep=&caprep>/, 'Caprep match');
986b669 [t] moved subrule.t to spec/
moritz authored
66 ok($/, 'Caprep matched');
67 is(~$/, "abcabcabcabc", 'Caprep matched');
68 is(~$/<caprep>, "abcabcabcabc", 'Caprep captured');
69 is(~$/<caprep>[0], "abcabcabcabc", 'Caprep abc one captured');
70
4d4775e @moritz [subrule.t] tests for RT #76892
moritz authored
71 # RT #76892
72 {
73 nok 'abc' !~~ /<alpha>(.)/, 'unsuccessful non-match';
74 is $0, 'b', 'failed !~~ still makes $0 available';
75 is $<alpha>, 'a', 'failed !~~ still makes $<foo> available';
76 }
77
b47bf2d @moritz RT #96424, capture from unsuccessful match
moritz authored
78 # RT #96424
79 {
80 ok '0' ~~ /<alpha>|<digit>/, 'regex matches';
81 is $<alpha>.Str, '', 'Can call methods on captures from unsuccessful matches';
82 }
83
6bcda09 @moritz test availability of $/ in embedded blocks in regexes
moritz authored
84 {
85 my $tracker;
86 ok 'abc' ~~ /<alpha> { $tracker = $<alpha> } /, 'sanity';
87 is $tracker.Str, 'a',
88 'can use $/ and subrule capture in embeeded code block';
89 }
90
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
91 # vim: ft=perl6
Something went wrong with that request. Please try again.