/
indirect.t
44 lines (39 loc) 路 1.05 KB
/
indirect.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
40
41
42
43
44
use v6;
use Test;
plan 10;
{
my constant name = 'TestName';
class ::(name) {
method f() { 42 }
}
is TestName.f, 42,
'can declare and use a class with indirect (but constant) name';
is ::(name).^name, 'TestName',
'and it reports the right name';
}
{
my constant name = 'a';
sub ::(name) ($x) { $x + 38 }
is a(4), 42, 'indirect sub name works';
is &a.name, 'a', 'and the sub knows its name';
}
{
class A {
method ::('indirect') {
42
}
method ::('with space') {
23
}
}
is A.indirect, 42, 'can declare method with indirect name';
is A."with space"(), 23, 'can declare indirect method name with space';
}
# RT #126385
{
ok ::('&say') =:= &say, '::("&foo") without whitespace';
ok ::( '&say') =:= &say, '::("&foo") with whitespace (1)';
ok ::( '&say' ) =:= &say, '::("&foo") with whitespace (2)';
ok ::( # we do something explainable to have the need for a comment
'&say' ) =:= &say, '::("&foo") with a comment';
}