xref: /openbsd/gnu/usr.bin/perl/t/lib/warnings/builtin (revision d415bd75)
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::true' is experimental at - line 7.
31Built-in function 'builtin::false' is experimental at - line 8.
32Built-in function 'builtin::is_bool' is experimental at - line 9.
33Built-in function 'builtin::true' is experimental at - line 10.
34Built-in function 'builtin::false' is experimental at - line 11.
35Built-in function 'builtin::is_bool' is experimental at - line 12.
36Built-in function 'builtin::true' is experimental at - line 13.
37Built-in function 'builtin::false' is experimental at - line 14.
38########
39# builtin.c - weakrefs
40use strict;
41use warnings qw(all -void);
42use builtin qw(weaken unweaken is_weak);
43my ($weaken, $unweaken, $is_weak) = (\&weaken, \&unweaken, \&is_weak);
44my $ref = [];
45is_weak($ref);
46weaken($ref);
47unweaken($ref);
48&is_weak($ref);
49&weaken($ref);
50&unweaken($ref);
51$is_weak->($ref);
52$weaken->($ref);
53$unweaken->($ref);
54no warnings 'experimental::builtin';
55is_weak($ref);
56weaken($ref);
57unweaken($ref);
58&is_weak($ref);
59&weaken($ref);
60&unweaken($ref);
61$is_weak->($ref);
62$weaken->($ref);
63$unweaken->($ref);
64EXPECT
65Built-in function 'builtin::is_weak' is experimental at - line 7.
66Built-in function 'builtin::weaken' is experimental at - line 8.
67Built-in function 'builtin::unweaken' is experimental at - line 9.
68Built-in function 'builtin::is_weak' is experimental at - line 10.
69Built-in function 'builtin::weaken' is experimental at - line 11.
70Built-in function 'builtin::unweaken' is experimental at - line 12.
71Built-in function 'builtin::is_weak' is experimental at - line 13.
72Built-in function 'builtin::weaken' is experimental at - line 14.
73Built-in function 'builtin::unweaken' is experimental at - line 15.
74########
75# builtin.c - blessed refs
76use strict;
77use warnings qw(all -void);
78use builtin qw(blessed refaddr reftype);
79my ($blessed, $refaddr, $reftype) = (\&blessed, \&refaddr, \&reftype);
80my $ref = [];
81blessed($ref);
82refaddr($ref);
83reftype($ref);
84&blessed($ref);
85&refaddr($ref);
86&reftype($ref);
87$blessed->($ref);
88$refaddr->($ref);
89$reftype->($ref);
90no warnings 'experimental::builtin';
91blessed($ref);
92refaddr($ref);
93reftype($ref);
94&blessed($ref);
95&refaddr($ref);
96&reftype($ref);
97$blessed->($ref);
98$refaddr->($ref);
99$reftype->($ref);
100EXPECT
101Built-in function 'builtin::blessed' is experimental at - line 7.
102Built-in function 'builtin::refaddr' is experimental at - line 8.
103Built-in function 'builtin::reftype' is experimental at - line 9.
104Built-in function 'builtin::blessed' is experimental at - line 10.
105Built-in function 'builtin::refaddr' is experimental at - line 11.
106Built-in function 'builtin::reftype' is experimental at - line 12.
107Built-in function 'builtin::blessed' is experimental at - line 13.
108Built-in function 'builtin::refaddr' is experimental at - line 14.
109Built-in function 'builtin::reftype' is experimental at - line 15.
110########
111# builtin.c - indexed
112use strict;
113use warnings qw(all);
114use builtin qw(indexed);
115my @array = indexed 1..3;
116my $scalar = indexed 1..3;
117indexed 1..3;
118EXPECT
119Built-in function 'builtin::indexed' is experimental at - line 5.
120Built-in function 'builtin::indexed' is experimental at - line 6.
121Built-in function 'builtin::indexed' is experimental at - line 7.
122Useless use of builtin::indexed in scalar context at - line 6.
123Useless use of builtin::indexed in void context at - line 7.
124