Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 35 lines (28 sloc) 1.117 kB
fd56de2 [t/spec]: S05 - Moved some capturing tests and added a few
unobe authored
1 use v6;
2
3 use Test;
4
5 plan 9;
6
7 if !eval('("a" ~~ /a/)') {
8 skip_rest "skipped tests - rules support appears to be missing";
9 exit;
10 }
11
12 # L<< S05/Return values from matches/"A match always returns a Match object" >>
13 {
14 my $match = 'abd' ~~ m/ (a) (b) c || (\w) b d /;
15 isa_ok( $match, 'Match', 'Match object returned');
16 isa_ok( $/, 'Match', 'Match object assigned to $/');
17 ok( $/ === $match, 'Same match objects');
18 }
19
20 # L<< S05/Return values from matches/"The array elements of a C<Match> object are referred to" >>
21 {
22 'abd' ~~ m/ (a) (b) c || (\w) b d /;
23 ok( $/[0] eq 'a', 'positional capture accessible');
24 ok( @($/).[0] eq 'a', 'array context - correct number of positional captures');
25 ok( @($/).elems == 1, 'array context - correct number of positional captures');
26 }
27
28 # L<< S05/Return values from matches/"When used as a hash, a C<Match> object" >>
29 {
30 'abd' ~~ m/ <alpha> <alpha> c || <alpha> b d /;
31 ok( $/<alpha> eq 'a', 'named capture accessible');
32 ok( %($/).keys == 1, 'hash context - correct number of named captures');
33 ok( %($/).<alpha> eq 'a', 'hash context - named capture accessible');
34 }
Something went wrong with that request. Please try again.