This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test croaks inadvertently rmvd by bd2688c4c
[perl5.git] / t / lib / croak / op
CommitLineData
7a44ba35 1__END__
b14845b4
FC
2# NAME my $<special>
3my $!;
4EXPECT
5Can't use global $! in "my" at - line 1, near "my $!"
6Execution of - aborted due to compilation errors.
7########
7a44ba35
TC
8# NAME OP_HELEM fields
9package Foo;
10use fields qw(a b);
11sub new {
12 my $class = shift;
13 return fields::new($class);
14}
15my Foo $f = Foo->new;
16$f->{c} = 1;
17EXPECT
18No such class field "c" in variable $f of type Foo at - line 8.
19########
e6307ed0
FC
20# NAME "No such field" with block: ${$ref}{key}
21%FIELDS; # empty hash so all keys are invalid
22my main $r;
23${$r}{key};
24EXPECT
25No such class field "key" in variable $r of type main at - line 3.
26########
7a44ba35
TC
27# NAME OP_HSLICE fields
28package Foo;
29use fields qw(a b);
30sub new {
31 my $class = shift;
32 return fields::new($class);
33}
34my Foo $f = Foo->new;
35@$f{"a", "c"} = ( 1, 2 );
36EXPECT
37No such class field "c" in variable $f of type Foo at - line 8.
38########
0e706dd4
FC
39# NAME Single OP_HSLICE field
40%FIELDS; # vivify it, but leave it empty, so all fields are invalid
41my main $f;
42@$f{"a"};
43EXPECT
44No such class field "a" in variable $f of type main at - line 3.
45########
c5f75dba
FC
46# NAME OP_KVHSLICE fields
47BEGIN { %FIELDS = qw(a 1 b 1); }
48my main $f;
49%$f{"a","c"};
50EXPECT
51No such class field "c" in variable $f of type main at - line 3.
52########
4748e002
FC
53# NAME Can't declare conditional
54my($a?$b:$c)
55EXPECT
56Can't declare conditional expression in "my" at - line 1, at EOF
57Execution of - aborted due to compilation errors.
58########
59# NAME Can't declare do block
60my(do{})
61EXPECT
62Can't declare do block in "my" at - line 1, at EOF
63Execution of - aborted due to compilation errors.
64########
f0614d30
FC
65# NAME ($_, state $x) = ...
66($_, CORE::state $x) = ();
67EXPECT
68Initialization of state variables in list context currently forbidden at - line 1, near ");"
69Execution of - aborted due to compilation errors.
70########
71# NAME my $y; ($y, state $x) = ...
72my $y; ($y, CORE::state $x) = ();
73EXPECT
74Initialization of state variables in list context currently forbidden at - line 1, near ");"
75Execution of - aborted due to compilation errors.
76########
7a44ba35
TC
77# NAME delete BAD
78delete $x;
79EXPECT
80delete argument is not a HASH or ARRAY element or slice at - line 1.
81########
2186f873
FC
82# NAME delete sort
83use warnings;
84delete sort; # used to warn about scalar context, too
85EXPECT
86delete argument is not a HASH or ARRAY element or slice at - line 2.
87########
7a44ba35
TC
88# NAME exists BAD
89exists $x;
90EXPECT
91exists argument is not a HASH or ARRAY element or a subroutine at - line 1.
92########
93# NAME exists non-sub
94exists &foo()
95EXPECT
96exists argument is not a subroutine name at - line 1.
b5adc3e5
DIM
97########
98# NAME push BAREWORD
99no warnings 'experimental';
100push FRED;
101EXPECT
102Type of arg 1 to push must be array (not constant item) at - line 2, near "FRED;"
103Execution of - aborted due to compilation errors.
104########
105# NAME pop BAREWORD
106no warnings 'experimental';
107pop FRED;
108EXPECT
109Type of arg 1 to pop must be array (not constant item) at - line 2, near "FRED;"
110Execution of - aborted due to compilation errors.
111########
112# NAME shift BAREWORD
113no warnings 'experimental';
114shift FRED;
115EXPECT
116Type of arg 1 to shift must be array (not constant item) at - line 2, near "FRED;"
117Execution of - aborted due to compilation errors.
118########
119# NAME unshift BAREWORD
120no warnings 'experimental';
121unshift FRED;
122EXPECT
123Type of arg 1 to unshift must be array (not constant item) at - line 2, near "FRED;"
124Execution of - aborted due to compilation errors.
125########
126# NAME keys BAREWORD
127@a = keys FRED ;
128EXPECT
129Type of arg 1 to keys must be hash (not constant item) at - line 1, near "FRED ;"
130Execution of - aborted due to compilation errors.
131########
132# NAME values BAREWORD
133@a = values FRED ;
134EXPECT
135Type of arg 1 to values must be hash (not constant item) at - line 1, near "FRED ;"
136Execution of - aborted due to compilation errors.
137########
138# NAME each BAREWORD
139@a = each FRED ;
140EXPECT
141Type of arg 1 to each must be hash (not constant item) at - line 1, near "FRED ;"
142Execution of - aborted due to compilation errors.