Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 39 lines (30 sloc) 1.252 kB
a9ca9d7 [t/spec] tests for external aliases in regexes
moritz authored
1 use v6;
2 use Test;
3
45a21e4 [t/spec] external array aliases in regexes
moritz authored
4 plan 16;
a9ca9d7 [t/spec] tests for external aliases in regexes
moritz authored
5
6 # L<S05/External aliasing/>
7
8 my $x;
9 our $y;
10
b108056 [external-aliasing.t] normal // regexen do not make a lexical scope, …
lwall authored
11 ok 'ab cd ef' ~~ m/:s <ident> $x=<ident> $y=<ident>/,
a9ca9d7 [t/spec] tests for external aliases in regexes
moritz authored
12 'regex matched';
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
13 isa-ok $x, Match, 'stored a match object in outer lexical var';
14 isa-ok $y, Match, 'stored a match object in outer package var';
15 isa-ok $<ident>, Match, '... the normal capture also is a Match object';
a9ca9d7 [t/spec] tests for external aliases in regexes
moritz authored
16 is ~$<ident>, 'ab', 'normal match object still works';
17 is ~$x, 'cd', 'outer lexical var got the right value';
18 is ~$y, 'ef', 'outer package var got the right value';
19
20 # this is a bit guesswork here on how outer vars interact with .caps and
21 # .chunks. It seems sane to assume that .caps will ignore those parts that
22 # are bound to external variables (since it knows nothing about them)
23
24 is +$/.caps, 'one capture';
25 is ~$/.caps.[0].value, 'ab', 'right value in .caps';
26 is +$/.chunks, 2, 'two chunks';
27 is $/.chunks.map({.key}).join('|'), 'ident|~', 'right keys of .chunks';
28 is $/.chunks.map({.value}).join('|'), 'ab| cd ef', 'right values of .chunks';
29
45a21e4 [t/spec] external array aliases in regexes
moritz authored
30 {
31 my @a;
b108056 [external-aliasing.t] normal // regexen do not make a lexical scope, …
lwall authored
32 ok 'abc' ~~ m/@a=(.)+/, 'regex with outer array matches';
45a21e4 [t/spec] external array aliases in regexes
moritz authored
33 is +@a, 3, 'bound the right number of matches';
34 ok ?(all(@a) ~~ Match), 'All of them are Match objects';
35 is @a.join('|'), 'a|b|c', 'right values';
36 }
37
a9ca9d7 [t/spec] tests for external aliases in regexes
moritz authored
38 # vim: ft=perl6
Something went wrong with that request. Please try again.