/
make.t
39 lines (30 loc) 路 1.2 KB
/
make.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use Test;
plan 9;
# should be: L<S05/Bracket rationalization/"An B<explicit> reduction using the C<make> function">
# L<S05/Bracket rationalization/reduction using the>
# L<S05/Match objects/"Fortunately, when you just want to return a different">
# https://github.com/Raku/old-issue-tracker/issues/1901
"blah foo blah" ~~ / foo # Match 'foo'
{ make 'bar' } # But pretend we matched 'bar'
/;
ok($/, 'matched');
is $/.ast, 'bar', '$/.ast';
{
temp $/;
"" ~~ /^/;
cmp-ok $/.made, '===', Nil, 'unmade Match returns Nil from .made';
cmp-ok $/.ast, '===', Nil, 'unmade Match returns Nil from .ast';
$/.make: Any;
cmp-ok $/.made, '===', Any, 'can get made type objects from .made (1)';
cmp-ok $/.ast, '===', Any, 'can get made type objects from .ast (1)';
my class FooBar {}
$/.make: FooBar;
cmp-ok $/.made, '===', FooBar, 'can get made type objects from .made (2)';
cmp-ok $/.ast, '===', FooBar, 'can get made type objects from .ast (2)';
}
# https://github.com/rakudo/rakudo/issues/2057
{
lives-ok { "" ~~ /{ (make 0 for 0) }/ for ^100 },
'check that we did not regress';
}
# vim: expandtab shiftwidth=4