-
Notifications
You must be signed in to change notification settings - Fork 135
/
sigils-and-types.t
97 lines (80 loc) · 2.5 KB
/
sigils-and-types.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use v6;
use Test;
plan 28;
my $scalar;
ok $scalar.WHAT === Any, 'unitialized $var does Mu';
$scalar = 1;
ok $scalar ~~ Any, 'value contained in a $var does Mu';
{
my @array;
ok @array.does(Positional), 'unitialized @var does Positional';
}
{
my @array = [];
ok @array.does(Positional), 'value contained in a @var does Positional';
}
{
my @array = 1;
ok @array.does(Positional), 'generic val in a @var is converted to Positional';
}
ok eval('List').does(Positional), "List does Positional";
ok eval('Array').does(Positional), "Array does Positional";
ok eval('Range').does(Positional), "Range does Positional";
ok eval('Parcel').does(Positional), "Parcel does Positional";
#?niecza skip 'Undeclared name Buf'
ok eval('Buf').does(Positional), "Buf does Positional";
#?rakudo todo "Capture does Positional"
ok eval('Capture').does(Positional), "Capture does Positional";
my %hash;
#?pugs todo 'feature'
ok %hash.does(Associative), 'uninitialized %var does Associative';
%hash = {};
ok %hash.does(Associative), 'value in %var does Associative';
#?niecza todo
ok eval('Pair').does(Associative), "Pair does Associative";
ok eval('Set').does(Associative), "Set does Associative";
ok eval('Bag').does(Associative), "Bag does Associative";
#?niecza skip 'Undeclared name KeyHash'
ok eval('KeyHash').does(Associative), "KeyHash does Associative";
#?rakudo todo "Capture does Associative"
ok eval('Capture').does(Associative), "Capture does Associative";
sub foo {}
ok &foo.does(Callable), 'a Sub does Callable';
#?niecza skip 'Methods must be used in some kind of package'
{
my method meth {}
ok &meth.does(Callable), 'a Method does Callable';
}
proto mul(|) {*}
multi mul {}
ok &mul.does(Callable), 'a multi does Callable';
proto pro {}
ok &pro.does(Callable), 'a proto does Callable';
# &token, &rule return a Method?
#?niecza skip 'Methods must be used in some kind of package'
{
my token bar {<?>}
#?pugs todo 'feature'
ok &bar.does(Callable), 'a token does Callable';
my rule baz {<?>}
#?pugs todo 'feature'
ok &baz.does(Callable), 'a rule does Callable';
# &quux returns a Sub ?
macro quux {}
#?pugs todo 'feature'
ok &quux.does(Callable), 'a macro does Callable';
}
# RT 69318
{
sub a { return 'a' };
sub b { return 'b' };
dies_ok { &a = &b }, 'cannot just assign &b to &a';
is a(), 'a', 'and the correct function is still in place';
}
# RT #74654
{
sub f() { '42' };
my $x = &f;
is &$x(), '42', 'can use &$x() for invoking';
}
# vim: ft=perl6