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