xref: /openbsd/gnu/usr.bin/perl/t/lib/warnings/builtin (revision 5486feef)
1  builtin.c     experimental warnings from builtin functions
2
3__END__
4# builtin.c - booleans
5use strict;
6use warnings qw(all -void);
7use builtin qw(is_bool true false);
8my ($is_bool, $true, $false) = (\&is_bool, \&true, \&false);
9is_bool(0);
10true;
11false;
12&is_bool(0);
13&true;
14&false;
15$is_bool->(0);
16$true->();
17$false->();
18no warnings 'experimental::builtin';
19is_bool(0);
20true;
21false;
22&is_bool(0);
23&true;
24&false;
25$is_bool->(0);
26$true->();
27$false->();
28EXPECT
29Built-in function 'builtin::is_bool' is experimental at - line 6.
30Built-in function 'builtin::is_bool' is experimental at - line 9.
31Built-in function 'builtin::is_bool' is experimental at - line 12.
32########
33# builtin.c - weakrefs
34use strict;
35use warnings qw(all -void);
36use builtin qw(weaken unweaken is_weak);
37my ($weaken, $unweaken, $is_weak) = (\&weaken, \&unweaken, \&is_weak);
38my $ref = [];
39is_weak($ref);
40weaken($ref);
41unweaken($ref);
42&is_weak($ref);
43&weaken($ref);
44&unweaken($ref);
45$is_weak->($ref);
46$weaken->($ref);
47$unweaken->($ref);
48no warnings 'experimental::builtin';
49is_weak($ref);
50weaken($ref);
51unweaken($ref);
52&is_weak($ref);
53&weaken($ref);
54&unweaken($ref);
55$is_weak->($ref);
56$weaken->($ref);
57$unweaken->($ref);
58EXPECT
59########
60# builtin.c - blessed refs
61use strict;
62use warnings qw(all -void);
63use builtin qw(blessed refaddr reftype);
64my ($blessed, $refaddr, $reftype) = (\&blessed, \&refaddr, \&reftype);
65my $ref = [];
66blessed($ref);
67refaddr($ref);
68reftype($ref);
69&blessed($ref);
70&refaddr($ref);
71&reftype($ref);
72$blessed->($ref);
73$refaddr->($ref);
74$reftype->($ref);
75no warnings 'experimental::builtin';
76blessed($ref);
77refaddr($ref);
78reftype($ref);
79&blessed($ref);
80&refaddr($ref);
81&reftype($ref);
82$blessed->($ref);
83$refaddr->($ref);
84$reftype->($ref);
85EXPECT
86########
87# builtin.c - indexed
88use strict;
89use warnings qw(all);
90use builtin qw(indexed);
91my @array = indexed 1..3;
92my $scalar = indexed 1..3;
93indexed 1..3;
94EXPECT
95Useless use of builtin::indexed in scalar context at - line 6.
96Useless use of builtin::indexed in void context at - line 7.
97########
98# builtin.c - import from bundles is idempotent
99use builtin qw(true false);
100use builtin ':5.39';
101use builtin ':5.39';
102EXPECT
103