Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 37 lines (30 sloc) 1.265 kb
fd56de2 [t/spec]: S05 - Moved some capturing tests and added a few
unobe authored
1 use v6;
2
3 use Test;
4
3d2c0c9 added tests for $/.list and $/.hash
krunen authored
5 plan 11;
fd56de2 [t/spec]: S05 - Moved some capturing tests and added a few
unobe authored
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');
3d2c0c9 added tests for $/.list and $/.hash
krunen authored
26 ok( $/.list.elems == 1, 'the .list methods returns a list object');
fd56de2 [t/spec]: S05 - Moved some capturing tests and added a few
unobe authored
27 }
28
29 # L<< S05/Return values from matches/"When used as a hash, a C<Match> object" >>
30 {
31 'abd' ~~ m/ <alpha> <alpha> c || <alpha> b d /;
32 ok( $/<alpha> eq 'a', 'named capture accessible');
33 ok( %($/).keys == 1, 'hash context - correct number of named captures');
34 ok( %($/).<alpha> eq 'a', 'hash context - named capture accessible');
3d2c0c9 added tests for $/.list and $/.hash
krunen authored
35 ok( $/.hash.keys[0] eq 'alpha', 'the .hash method returns a hash object');
fd56de2 [t/spec]: S05 - Moved some capturing tests and added a few
unobe authored
36 }
Something went wrong with that request. Please try again.