xref: /openbsd-src/gnu/usr.bin/perl/t/lib/warnings/builtin (revision 5486feefcc8cb79b19e014ab332cc5dfd05b3b33)
1256a93a4Safresh1  builtin.c     experimental warnings from builtin functions
2256a93a4Safresh1
3256a93a4Safresh1__END__
4256a93a4Safresh1# builtin.c - booleans
5256a93a4Safresh1use strict;
6256a93a4Safresh1use warnings qw(all -void);
7256a93a4Safresh1use builtin qw(is_bool true false);
8256a93a4Safresh1my ($is_bool, $true, $false) = (\&is_bool, \&true, \&false);
9256a93a4Safresh1is_bool(0);
10256a93a4Safresh1true;
11256a93a4Safresh1false;
12256a93a4Safresh1&is_bool(0);
13256a93a4Safresh1&true;
14256a93a4Safresh1&false;
15256a93a4Safresh1$is_bool->(0);
16256a93a4Safresh1$true->();
17256a93a4Safresh1$false->();
18256a93a4Safresh1no warnings 'experimental::builtin';
19256a93a4Safresh1is_bool(0);
20256a93a4Safresh1true;
21256a93a4Safresh1false;
22256a93a4Safresh1&is_bool(0);
23256a93a4Safresh1&true;
24256a93a4Safresh1&false;
25256a93a4Safresh1$is_bool->(0);
26256a93a4Safresh1$true->();
27256a93a4Safresh1$false->();
28256a93a4Safresh1EXPECT
29256a93a4Safresh1Built-in function 'builtin::is_bool' is experimental at - line 6.
30256a93a4Safresh1Built-in function 'builtin::is_bool' is experimental at - line 9.
31256a93a4Safresh1Built-in function 'builtin::is_bool' is experimental at - line 12.
32256a93a4Safresh1########
33256a93a4Safresh1# builtin.c - weakrefs
34256a93a4Safresh1use strict;
35256a93a4Safresh1use warnings qw(all -void);
36256a93a4Safresh1use builtin qw(weaken unweaken is_weak);
37256a93a4Safresh1my ($weaken, $unweaken, $is_weak) = (\&weaken, \&unweaken, \&is_weak);
38256a93a4Safresh1my $ref = [];
39256a93a4Safresh1is_weak($ref);
40256a93a4Safresh1weaken($ref);
41256a93a4Safresh1unweaken($ref);
42256a93a4Safresh1&is_weak($ref);
43256a93a4Safresh1&weaken($ref);
44256a93a4Safresh1&unweaken($ref);
45256a93a4Safresh1$is_weak->($ref);
46256a93a4Safresh1$weaken->($ref);
47256a93a4Safresh1$unweaken->($ref);
48256a93a4Safresh1no warnings 'experimental::builtin';
49256a93a4Safresh1is_weak($ref);
50256a93a4Safresh1weaken($ref);
51256a93a4Safresh1unweaken($ref);
52256a93a4Safresh1&is_weak($ref);
53256a93a4Safresh1&weaken($ref);
54256a93a4Safresh1&unweaken($ref);
55256a93a4Safresh1$is_weak->($ref);
56256a93a4Safresh1$weaken->($ref);
57256a93a4Safresh1$unweaken->($ref);
58256a93a4Safresh1EXPECT
59256a93a4Safresh1########
60256a93a4Safresh1# builtin.c - blessed refs
61256a93a4Safresh1use strict;
62256a93a4Safresh1use warnings qw(all -void);
63256a93a4Safresh1use builtin qw(blessed refaddr reftype);
64256a93a4Safresh1my ($blessed, $refaddr, $reftype) = (\&blessed, \&refaddr, \&reftype);
65256a93a4Safresh1my $ref = [];
66256a93a4Safresh1blessed($ref);
67256a93a4Safresh1refaddr($ref);
68256a93a4Safresh1reftype($ref);
69256a93a4Safresh1&blessed($ref);
70256a93a4Safresh1&refaddr($ref);
71256a93a4Safresh1&reftype($ref);
72256a93a4Safresh1$blessed->($ref);
73256a93a4Safresh1$refaddr->($ref);
74256a93a4Safresh1$reftype->($ref);
75256a93a4Safresh1no warnings 'experimental::builtin';
76256a93a4Safresh1blessed($ref);
77256a93a4Safresh1refaddr($ref);
78256a93a4Safresh1reftype($ref);
79256a93a4Safresh1&blessed($ref);
80256a93a4Safresh1&refaddr($ref);
81256a93a4Safresh1&reftype($ref);
82256a93a4Safresh1$blessed->($ref);
83256a93a4Safresh1$refaddr->($ref);
84256a93a4Safresh1$reftype->($ref);
85256a93a4Safresh1EXPECT
86256a93a4Safresh1########
87256a93a4Safresh1# builtin.c - indexed
88256a93a4Safresh1use strict;
89256a93a4Safresh1use warnings qw(all);
90256a93a4Safresh1use builtin qw(indexed);
91256a93a4Safresh1my @array = indexed 1..3;
92256a93a4Safresh1my $scalar = indexed 1..3;
93256a93a4Safresh1indexed 1..3;
94256a93a4Safresh1EXPECT
95256a93a4Safresh1Useless use of builtin::indexed in scalar context at - line 6.
96256a93a4Safresh1Useless use of builtin::indexed in void context at - line 7.
97*5486feefSafresh1########
98*5486feefSafresh1# builtin.c - import from bundles is idempotent
99*5486feefSafresh1use builtin qw(true false);
100*5486feefSafresh1use builtin ':5.39';
101*5486feefSafresh1use builtin ':5.39';
102*5486feefSafresh1EXPECT
103