2
2
3
3
use Test ;
4
4
5
- plan 22 ;
5
+ plan 36 ;
6
6
7
7
# See L<http://www.nntp.perl.org/group/perl.perl6.language/22858> --
8
8
# previously, "my $a; say $::("a")" died (you had to s/my/our/). Now, it was
@@ -14,13 +14,21 @@ plan 22;
14
14
my $ b_var = " a_var" ;
15
15
16
16
is $::($ b_var ), 42 , ' basic symbolic scalar dereferentiation works' ;
17
+ lives_ok { $::($ b_var ) = 23 }, ' can use $::(...) as lvalue' ;
18
+ is $ a_var , 23 , ' and the assignment worked' ;
19
+ $::($ b_var ) = ' a' , ' b' , ' c' ;
20
+ is $ a_var , ' a' , ' ... and it is item assignment' ;
17
21
}
18
22
19
23
{
20
24
my @ a_var = <a b c >;
21
25
my $ b_var = " a_var" ;
22
26
23
27
is @::($ b_var )[1 ], " b" , ' basic symbolic array dereferentiation works' ;
28
+ @::($ b_var ) = (' X' , ' Y' , ' Z' );
29
+ is @ a_var . join (' ' ), ' X Y Z' , ' can assign to symbolic deref' ;
30
+ @::($ b_var ) = ' u' , ' v' , ' w' ;
31
+ is @ a_var . join (' ' ), ' u v w' , ' ... and it is list assignment when the sigil is @' ;
24
32
}
25
33
26
34
{
@@ -37,6 +45,35 @@ plan 22;
37
45
is &::($ b_var )(), 42 , ' basic symbolic code dereferentiation works' ;
38
46
}
39
47
48
+ my $ outer = ' outside' ;
49
+ {
50
+ my $ inner = ' inside' ;
51
+
52
+ ok ::(' Int' ) === Int , ' can look up a type object with ::()' ;
53
+ is ::(' $inner' ), $ inner , ' can look up lexical from same block' ;
54
+ is ::(' $outer' ), $ outer , ' can look up lexical from outer block' ;
55
+
56
+ lives_ok { ::(' $outer' ) = ' new' }, ' Can use ::() as lvalue' ;
57
+ is $ outer , ' new' , ' and the assignment worked' ;
58
+ sub c { ' sub c' };
59
+ is ::(' &c' ). (), ' sub c' , ' can look up lexical sub' ;
60
+
61
+ is ::(' e' ), e, ' Can look up numerical constants' ;
62
+ }
63
+
64
+ {
65
+ package Outer {
66
+ class Inner { }
67
+ }
68
+
69
+ class A::B { };
70
+
71
+ is ::(' Outer::Inner' ). perl , Outer::Inner. perl , ' can look up name with :: (1)' ;
72
+ # ?rakudo skip 'A::B lookup'
73
+ is ::(' A::B' ). perl , A::B. perl , ' can look up name with :: (1)' ;
74
+ }
75
+
76
+
40
77
# ?rakudo skip 'NYI'
41
78
{
42
79
$ pugs ::is::cool = 42 ;
0 commit comments