File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ use v6 ;
2
+ use Test ;
3
+
4
+ plan 10 ;
5
+
6
+ {
7
+ sub f (: a(: $ b )) { $ b }
8
+ sub g (: a( $ b )) { $ b }
9
+
10
+ is f( a => 1 ), 1 , ' can use the alias name (1)' ;
11
+ is g( a => 1 ), 1 , ' can use the alias name (1)' ;
12
+ is f( b => 1 ), 1 , ' can use the var name' ;
13
+ dies_ok { eval ' g( b => 1)' },
14
+ ' cannot use the var name if there is no : in front of it' ;
15
+ }
16
+
17
+ {
18
+ sub mandatory (: x (: $ y )! ) { $ y }
19
+ is mandatory( y => 2 ), 2 , ' mandatory named' ;
20
+ is mandatory( x => 3 ), 3 , ' mandatory renamed' ;
21
+ dies_ok { eval ' mandatory()' }, ' and it really is mandatory' ;
22
+ }
23
+
24
+ {
25
+ sub typed (: i(: % j )) { % j . keys . [0 ] };
26
+ is typed(i => { a => 1 }), ' a' , ' typed renames -- sanity' ;
27
+ dies_ok { eval ' typed(:j)' }, ' type constraint on var' ;
28
+ dies_ok { eval ' typed(:i)' }, ' type constraint on var propagates to alias' ;
29
+ }
You can’t perform that action at this time.
0 commit comments