-
Notifications
You must be signed in to change notification settings - Fork 135
/
named-renaming.t
36 lines (30 loc) · 970 Bytes
/
named-renaming.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
use v6.c;
use Test;
plan 11;
{
sub f(:a(:$b)) { $b }
sub g(:a( $b)) { $b }
is f( a => 1), 1, 'can use the alias name (1)';
is g( a => 1), 1, 'can use the alias name (1)';
is f( b => 1), 1, 'can use the var name';
dies-ok { EVAL 'g( b => 1)' },
'cannot use the var name if there is no : in front of it';
}
{
sub mandatory(:x(:$y)!) { $y }
is mandatory( y => 2), 2, 'mandatory named';
is mandatory( x => 3), 3, 'mandatory renamed';
dies-ok { EVAL 'mandatory()' }, 'and it really is mandatory';
}
{
sub typed(:i(:%j)) { %j.keys.[0] };
is typed(i => { a => 1 }), 'a', 'typed renames -- sanity';
dies-ok { EVAL 'typed(:j)' }, 'type constraint on var';
dies-ok { EVAL 'typed(:i)' }, 'type constraint on var propagates to alias';
}
# RT #123956
{
sub rt123956 (:t( :$th )) { $th }
is rt123956( th => 5 ), 5,
'whitespaces allowed between named parameter and parentheses in signature';
}