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