xref: /openbsd-src/gnu/usr.bin/perl/t/lib/warnings/class (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1*f2a19305Safresh1class.c        warnings from 'class' feature
2*f2a19305Safresh1__END__
3*f2a19305Safresh1# experimental warnings
4*f2a19305Safresh1use strict;
5*f2a19305Safresh1use feature 'class';
6*f2a19305Safresh1class C {
7*f2a19305Safresh1  method m {}
8*f2a19305Safresh1}
9*f2a19305Safresh1EXPECT
10*f2a19305Safresh1class is experimental at - line 4.
11*f2a19305Safresh1method is experimental at - line 5.
12*f2a19305Safresh1########
13*f2a19305Safresh1# constructor warnings
14*f2a19305Safresh1use v5.36;
15*f2a19305Safresh1use feature 'class';
16*f2a19305Safresh1no warnings 'experimental::class';
17*f2a19305Safresh1class C { }
18*f2a19305Safresh1C->new();
19*f2a19305Safresh1eval { C->new('foo') }; # suppress error
20*f2a19305Safresh1EXPECT
21*f2a19305Safresh1Odd number of arguments passed to "C" constructor at - line 7.
22*f2a19305Safresh1########
23*f2a19305Safresh1# field shadowing warning
24*f2a19305Safresh1use v5.36;
25*f2a19305Safresh1use feature 'class';
26*f2a19305Safresh1no warnings 'experimental::class';
27*f2a19305Safresh1class C {
28*f2a19305Safresh1  field $x;
29*f2a19305Safresh1  field $x;
30*f2a19305Safresh1}
31*f2a19305Safresh1EXPECT
32*f2a19305Safresh1"field" variable $x masks earlier declaration in same scope at - line 7.
33*f2a19305Safresh1########
34*f2a19305Safresh1# odd number of elements in field init
35*f2a19305Safresh1use v5.36;
36*f2a19305Safresh1use feature 'class';
37*f2a19305Safresh1no warnings 'experimental::class';
38*f2a19305Safresh1class C {
39*f2a19305Safresh1  field %h = (1, 2, 3);
40*f2a19305Safresh1}
41*f2a19305Safresh1C->new;
42*f2a19305Safresh1EXPECT
43*f2a19305Safresh1Odd number of elements in hash field initialization at - line 6.
44