summaryrefslogtreecommitdiff
path: root/t/lib/warnings/builtin
blob: 110bc3986fbe3baec2fc89d1515c7fdb95cf95af (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  builtin.c     experimental warnings from builtin functions

__END__
# builtin.c - booleans
use strict;
use warnings qw(all -void);
use builtin qw(is_bool true false);
my ($is_bool, $true, $false) = (\&is_bool, \&true, \&false);
is_bool(0);
true;
false;
&is_bool(0);
&true;
&false;
$is_bool->(0);
$true->();
$false->();
no warnings 'experimental::builtin';
is_bool(0);
true;
false;
&is_bool(0);
&true;
&false;
$is_bool->(0);
$true->();
$false->();
EXPECT
Built-in function 'builtin::is_bool' is experimental at - line 6.
Built-in function 'builtin::true' is experimental at - line 7.
Built-in function 'builtin::false' is experimental at - line 8.
Built-in function 'builtin::is_bool' is experimental at - line 9.
Built-in function 'builtin::true' is experimental at - line 10.
Built-in function 'builtin::false' is experimental at - line 11.
Built-in function 'builtin::is_bool' is experimental at - line 12.
Built-in function 'builtin::true' is experimental at - line 13.
Built-in function 'builtin::false' is experimental at - line 14.
########
# builtin.c - weakrefs
use strict;
use warnings qw(all -void);
use builtin qw(weaken unweaken is_weak);
my ($weaken, $unweaken, $is_weak) = (\&weaken, \&unweaken, \&is_weak);
my $ref = [];
is_weak($ref);
weaken($ref);
unweaken($ref);
&is_weak($ref);
&weaken($ref);
&unweaken($ref);
$is_weak->($ref);
$weaken->($ref);
$unweaken->($ref);
no warnings 'experimental::builtin';
is_weak($ref);
weaken($ref);
unweaken($ref);
&is_weak($ref);
&weaken($ref);
&unweaken($ref);
$is_weak->($ref);
$weaken->($ref);
$unweaken->($ref);
EXPECT
Built-in function 'builtin::is_weak' is experimental at - line 7.
Built-in function 'builtin::weaken' is experimental at - line 8.
Built-in function 'builtin::unweaken' is experimental at - line 9.
Built-in function 'builtin::is_weak' is experimental at - line 10.
Built-in function 'builtin::weaken' is experimental at - line 11.
Built-in function 'builtin::unweaken' is experimental at - line 12.
Built-in function 'builtin::is_weak' is experimental at - line 13.
Built-in function 'builtin::weaken' is experimental at - line 14.
Built-in function 'builtin::unweaken' is experimental at - line 15.
########
# builtin.c - blessed refs
use strict;
use warnings qw(all -void);
use builtin qw(blessed refaddr reftype);
my ($blessed, $refaddr, $reftype) = (\&blessed, \&refaddr, \&reftype);
my $ref = [];
blessed($ref);
refaddr($ref);
reftype($ref);
&blessed($ref);
&refaddr($ref);
&reftype($ref);
$blessed->($ref);
$refaddr->($ref);
$reftype->($ref);
no warnings 'experimental::builtin';
blessed($ref);
refaddr($ref);
reftype($ref);
&blessed($ref);
&refaddr($ref);
&reftype($ref);
$blessed->($ref);
$refaddr->($ref);
$reftype->($ref);
EXPECT
Built-in function 'builtin::blessed' is experimental at - line 7.
Built-in function 'builtin::refaddr' is experimental at - line 8.
Built-in function 'builtin::reftype' is experimental at - line 9.
Built-in function 'builtin::blessed' is experimental at - line 10.
Built-in function 'builtin::refaddr' is experimental at - line 11.
Built-in function 'builtin::reftype' is experimental at - line 12.
Built-in function 'builtin::blessed' is experimental at - line 13.
Built-in function 'builtin::refaddr' is experimental at - line 14.
Built-in function 'builtin::reftype' is experimental at - line 15.
########
# builtin.c - indexed
use strict;
use warnings qw(all);
use builtin qw(indexed);
my @array = indexed 1..3;
my $scalar = indexed 1..3;
indexed 1..3;
EXPECT
Built-in function 'builtin::indexed' is experimental at - line 5.
Built-in function 'builtin::indexed' is experimental at - line 6.
Built-in function 'builtin::indexed' is experimental at - line 7.
Useless use of builtin::indexed in scalar context at - line 6.
Useless use of builtin::indexed in void context at - line 7.