Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 89 lines (63 sloc) 2.347 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
b47bf2d @moritz RT #96424, capture from unsuccessful match
moritz authored
15 plan 36;
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');
b8687da @sorear Refudge a few evals for niecza
sorear authored
26 #?niecza skip 'auto $0 confuses this'
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
27 ok(@($/) == 0, 'Once no array capture');
28 ok(%($/).keys == 0, 'Once no hash capture');
986b669 [t] moved subrule.t to spec/
moritz authored
29
30
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
31 my regex rep {<&abc>**{4}}
986b669 [t] moved subrule.t to spec/
moritz authored
32
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
33 ok("abcabcabcabcd" ~~ m/<&rep>/, 'Rep match');
986b669 [t] moved subrule.t to spec/
moritz authored
34 ok($/, 'Rep matched');
35 is(~$/, "abcabcabcabc", 'Rep matched');
b8687da @sorear Refudge a few evals for niecza
sorear authored
36 #?niecza skip 'auto $0 confuses this'
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
37 ok(@($/) == 0, 'Rep no array capture');
38 ok(%($/).keys == 0, 'Rep no hash capture');
986b669 [t] moved subrule.t to spec/
moritz authored
39
40
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
41 my regex cap {<abc=&abc>}
986b669 [t] moved subrule.t to spec/
moritz authored
42
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
43 ok("abcabcabcabcd" ~~ m/<cap=&cap>/, 'Cap match');
986b669 [t] moved subrule.t to spec/
moritz authored
44 ok($/, 'Cap matched');
45 is(~$/, "abc", 'Cap zero matched');
46 is(~$/<cap>, "abc", 'Cap captured');
47
48 is(~$/<cap><abc>, "abc", 'Cap abc captured');
b8687da @sorear Refudge a few evals for niecza
sorear authored
49 #?niecza skip 'auto $0 confuses this'
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
50 ok(@($/) == 0, 'Cap no array capture');
51 ok(%($/).keys == 1, 'Cap hash capture');
986b669 [t] moved subrule.t to spec/
moritz authored
52
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
53 my regex repcap {<abc=&abc>**{4}}
986b669 [t] moved subrule.t to spec/
moritz authored
54
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
55 ok("abcabcabcabcd" ~~ m/<repcap=&repcap>/, 'Repcap match');
986b669 [t] moved subrule.t to spec/
moritz authored
56 ok($/, 'Repcap matched');
57 is(~$/, "abcabcabcabc", 'Repcap matched');
58 is(~$/<repcap>, "abcabcabcabc", 'Repcap captured');
59 is(~$/<repcap><abc>[0], "abc", 'Repcap abc zero captured');
60 is(~$/<repcap><abc>[1], "abc", 'Repcap abc one captured');
61 is(~$/<repcap><abc>[2], "abc", 'Repcap abc two captured');
62 is(~$/<repcap><abc>[3], "abc", 'Repcap abc three captured');
b8687da @sorear Refudge a few evals for niecza
sorear authored
63 #?niecza skip 'auto $0 confuses this'
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
64 ok(@($/) == 0, 'Repcap no array capture');
986b669 [t] moved subrule.t to spec/
moritz authored
65
66
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
67 my regex caprep {(<&abc>**{4})}
986b669 [t] moved subrule.t to spec/
moritz authored
68
fccd70c [t/spec] bring subrule.t up to date wrt current spec; fudge for rakudo
moritz authored
69 ok("abcabcabcabcd" ~~ m/<caprep=&caprep>/, 'Caprep match');
986b669 [t] moved subrule.t to spec/
moritz authored
70 ok($/, 'Caprep matched');
71 is(~$/, "abcabcabcabc", 'Caprep matched');
72 is(~$/<caprep>, "abcabcabcabc", 'Caprep captured');
73 is(~$/<caprep>[0], "abcabcabcabc", 'Caprep abc one captured');
74
4d4775e @moritz [subrule.t] tests for RT #76892
moritz authored
75 # RT #76892
76 {
77 nok 'abc' !~~ /<alpha>(.)/, 'unsuccessful non-match';
78 is $0, 'b', 'failed !~~ still makes $0 available';
79 is $<alpha>, 'a', 'failed !~~ still makes $<foo> available';
80 }
81
b47bf2d @moritz RT #96424, capture from unsuccessful match
moritz authored
82 # RT #96424
83 {
84 ok '0' ~~ /<alpha>|<digit>/, 'regex matches';
85 is $<alpha>.Str, '', 'Can call methods on captures from unsuccessful matches';
86 }
87
26cb83b [t/spec] more smartlinks; simplified subrule.t a bit
moritz authored
88 # vim: ft=perl6
Something went wrong with that request. Please try again.