This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
more torture tests for signatures
[perl5.git] / t / op / signatures.t
CommitLineData
30d9c59b
Z
1#!perl
2
3BEGIN {
4 chdir 't';
5 @INC = '../lib';
6 require './test.pl';
7}
acf0afbd 8plan 880;
30d9c59b
Z
9
10eval "#line 8 foo\nsub t004 :method (\$a) { }";
11is $@, "Experimental subroutine signatures not enabled at foo line 8\.\n",
12 "error when not enabled";
13
14eval "#line 8 foo\nsub t005 (\$) (\$a) { }";
15is $@, "Experimental subroutine signatures not enabled at foo line 8\.\n",
16 "error when not enabled";
17
18no warnings "illegalproto";
19
20our $a = 123;
21our $z;
22
23sub t000 ($a) { $a || "z" }
24is prototype(\&t000), "\$a", "(\$a) interpreted as protoype when not enabled";
25is &t000(456), 123, "(\$a) not signature when not enabled";
26is $a, 123;
27
28no warnings "experimental::signatures";
29use feature "signatures";
30
31sub t001 { $a || "z" }
32is prototype(\&t001), undef;
33is eval("t001()"), 123;
34is eval("t001(456)"), 123;
35is eval("t001(456, 789)"), 123;
36is $a, 123;
37
38sub t002 () { $a || "z" }
39is prototype(\&t002), undef;
40is eval("t002()"), 123;
41is eval("t002(456)"), undef;
42like $@, qr/\AToo many arguments for subroutine at/;
43is eval("t002(456, 789)"), undef;
44like $@, qr/\AToo many arguments for subroutine at/;
45is $a, 123;
46
47sub t003 ( ) { $a || "z" }
48is prototype(\&t003), undef;
49is eval("t003()"), 123;
50is eval("t003(456)"), undef;
51like $@, qr/\AToo many arguments for subroutine at/;
52is eval("t003(456, 789)"), undef;
53like $@, qr/\AToo many arguments for subroutine at/;
54is $a, 123;
55
56sub t006 ($a) { $a || "z" }
57is prototype(\&t006), undef;
58is eval("t006()"), undef;
59like $@, qr/\AToo few arguments for subroutine at/;
60is eval("t006(0)"), "z";
61is eval("t006(456)"), 456;
62is eval("t006(456, 789)"), undef;
63like $@, qr/\AToo many arguments for subroutine at/;
64is eval("t006(456, 789, 987)"), undef;
65like $@, qr/\AToo many arguments for subroutine at/;
66is $a, 123;
67
68sub t007 ($a, $b) { $a.$b }
69is prototype(\&t007), undef;
70is eval("t007()"), undef;
71like $@, qr/\AToo few arguments for subroutine at/;
72is eval("t007(456)"), undef;
73like $@, qr/\AToo few arguments for subroutine at/;
74is eval("t007(456, 789)"), "456789";
75is eval("t007(456, 789, 987)"), undef;
76like $@, qr/\AToo many arguments for subroutine at/;
77is eval("t007(456, 789, 987, 654)"), undef;
78like $@, qr/\AToo many arguments for subroutine at/;
79is $a, 123;
80
81sub t008 ($a, $b, $c) { $a.$b.$c }
82is prototype(\&t008), undef;
83is eval("t008()"), undef;
84like $@, qr/\AToo few arguments for subroutine at/;
85is eval("t008(456)"), undef;
86like $@, qr/\AToo few arguments for subroutine at/;
87is eval("t008(456, 789)"), undef;
88like $@, qr/\AToo few arguments for subroutine at/;
89is eval("t008(456, 789, 987)"), "456789987";
90is eval("t008(456, 789, 987, 654)"), undef;
91like $@, qr/\AToo many arguments for subroutine at/;
92is $a, 123;
93
94sub t009 ($abc, $def) { $abc.$def }
95is prototype(\&t009), undef;
96is eval("t009()"), undef;
97like $@, qr/\AToo few arguments for subroutine at/;
98is eval("t009(456)"), undef;
99like $@, qr/\AToo few arguments for subroutine at/;
100is eval("t009(456, 789)"), "456789";
101is eval("t009(456, 789, 987)"), undef;
102like $@, qr/\AToo many arguments for subroutine at/;
103is eval("t009(456, 789, 987, 654)"), undef;
104like $@, qr/\AToo many arguments for subroutine at/;
105is $a, 123;
106
107sub t010 ($a, $) { $a || "z" }
108is prototype(\&t010), undef;
109is eval("t010()"), undef;
110like $@, qr/\AToo few arguments for subroutine at/;
111is eval("t010(456)"), undef;
112like $@, qr/\AToo few arguments for subroutine at/;
113is eval("t010(0, 789)"), "z";
114is eval("t010(456, 789)"), 456;
115is eval("t010(456, 789, 987)"), undef;
116like $@, qr/\AToo many arguments for subroutine at/;
117is eval("t010(456, 789, 987, 654)"), undef;
118like $@, qr/\AToo many arguments for subroutine at/;
119is $a, 123;
120
121sub t011 ($, $a) { $a || "z" }
122is prototype(\&t011), undef;
123is eval("t011()"), undef;
124like $@, qr/\AToo few arguments for subroutine at/;
125is eval("t011(456)"), undef;
126like $@, qr/\AToo few arguments for subroutine at/;
127is eval("t011(456, 0)"), "z";
128is eval("t011(456, 789)"), 789;
129is eval("t011(456, 789, 987)"), undef;
130like $@, qr/\AToo many arguments for subroutine at/;
131is eval("t011(456, 789, 987, 654)"), undef;
132like $@, qr/\AToo many arguments for subroutine at/;
133is $a, 123;
134
135sub t012 ($, $) { $a || "z" }
136is prototype(\&t012), undef;
137is eval("t012()"), undef;
138like $@, qr/\AToo few arguments for subroutine at/;
139is eval("t012(456)"), undef;
140like $@, qr/\AToo few arguments for subroutine at/;
141is eval("t012(0, 789)"), 123;
142is eval("t012(456, 789)"), 123;
143is eval("t012(456, 789, 987)"), undef;
144like $@, qr/\AToo many arguments for subroutine at/;
145is eval("t012(456, 789, 987, 654)"), undef;
146like $@, qr/\AToo many arguments for subroutine at/;
147is $a, 123;
148
149sub t013 ($) { $a || "z" }
150is prototype(\&t013), undef;
151is eval("t013()"), undef;
152like $@, qr/\AToo few arguments for subroutine at/;
153is eval("t013(0)"), 123;
154is eval("t013(456)"), 123;
155is eval("t013(456, 789)"), undef;
156like $@, qr/\AToo many arguments for subroutine at/;
157is eval("t013(456, 789, 987)"), undef;
158like $@, qr/\AToo many arguments for subroutine at/;
159is eval("t013(456, 789, 987, 654)"), undef;
160like $@, qr/\AToo many arguments for subroutine at/;
161is $a, 123;
162
163sub t014 ($a = 222) { $a // "z" }
164is prototype(\&t014), undef;
165is eval("t014()"), 222;
166is eval("t014(0)"), 0;
167is eval("t014(undef)"), "z";
168is eval("t014(456)"), 456;
169is eval("t014(456, 789)"), undef;
170like $@, qr/\AToo many arguments for subroutine at/;
171is eval("t014(456, 789, 987)"), undef;
172like $@, qr/\AToo many arguments for subroutine at/;
173is $a, 123;
174
175sub t015 ($a = undef) { $a // "z" }
176is prototype(\&t015), undef;
177is eval("t015()"), "z";
178is eval("t015(0)"), 0;
179is eval("t015(undef)"), "z";
180is eval("t015(456)"), 456;
181is eval("t015(456, 789)"), undef;
182like $@, qr/\AToo many arguments for subroutine at/;
183is eval("t015(456, 789, 987)"), undef;
184like $@, qr/\AToo many arguments for subroutine at/;
185is $a, 123;
186
187sub t016 ($a = do { $z++; 222 }) { $a // "z" }
188$z = 0;
189is prototype(\&t016), undef;
190is eval("t016()"), 222;
191is $z, 1;
192is eval("t016(0)"), 0;
193is eval("t016(undef)"), "z";
194is eval("t016(456)"), 456;
195is eval("t016(456, 789)"), undef;
196like $@, qr/\AToo many arguments for subroutine at/;
197is eval("t016(456, 789, 987)"), undef;
198like $@, qr/\AToo many arguments for subroutine at/;
199is $z, 1;
200is eval("t016()"), 222;
201is $z, 2;
202is $a, 123;
203
204sub t018 { join("/", @_) }
205sub t017 ($p = t018 222, $a = 333) { $p // "z" }
206is prototype(\&t017), undef;
207is eval("t017()"), "222/333";
208is $a, 333;
209$a = 123;
210is eval("t017(0)"), 0;
211is eval("t017(undef)"), "z";
212is eval("t017(456)"), 456;
213is eval("t017(456, 789)"), undef;
214like $@, qr/\AToo many arguments for subroutine at/;
215is eval("t017(456, 789, 987)"), undef;
216like $@, qr/\AToo many arguments for subroutine at/;
217is $a, 123;
218
219sub t019 ($p = 222, $a = 333) { "$p/$a" }
220is prototype(\&t019), undef;
221is eval("t019()"), "222/333";
222is eval("t019(0)"), "0/333";
223is eval("t019(456)"), "456/333";
224is eval("t019(456, 789)"), "456/789";
225is eval("t019(456, 789, 987)"), undef;
226like $@, qr/\AToo many arguments for subroutine at/;
227is $a, 123;
228
229sub t020 :prototype($) { $_[0]."z" }
230sub t021 ($p = t020 222, $a = 333) { "$p/$a" }
231is prototype(\&t021), undef;
232is eval("t021()"), "222z/333";
233is eval("t021(0)"), "0/333";
234is eval("t021(456)"), "456/333";
235is eval("t021(456, 789)"), "456/789";
236is eval("t021(456, 789, 987)"), undef;
237like $@, qr/\AToo many arguments for subroutine at/;
238is $a, 123;
239
240sub t022 ($p = do { $z += 10; 222 }, $a = do { $z++; 333 }) { "$p/$a" }
241$z = 0;
242is prototype(\&t022), undef;
243is eval("t022()"), "222/333";
244is $z, 11;
245is eval("t022(0)"), "0/333";
246is $z, 12;
247is eval("t022(456)"), "456/333";
248is $z, 13;
249is eval("t022(456, 789)"), "456/789";
250is eval("t022(456, 789, 987)"), undef;
251like $@, qr/\AToo many arguments for subroutine at/;
252is $z, 13;
253is $a, 123;
254
255sub t023 ($a = sub { $_[0]."z" }) { $a->("a")."y" }
256is prototype(\&t023), undef;
257is eval("t023()"), "azy";
258is eval("t023(sub { \"x\".\$_[0].\"x\" })"), "xaxy";
259is eval("t023(sub { \"x\".\$_[0].\"x\" }, 789)"), undef;
260like $@, qr/\AToo many arguments for subroutine at/;
261is $a, 123;
262
263sub t036 ($a = $a."x") { $a."y" }
264is prototype(\&t036), undef;
265is eval("t036()"), "123xy";
266is eval("t036(0)"), "0y";
267is eval("t036(456)"), "456y";
268is eval("t036(456, 789)"), undef;
269like $@, qr/\AToo many arguments for subroutine at/;
270is $a, 123;
271
acf0afbd
Z
272sub t120 ($a = $_) { $a // "z" }
273is prototype(\&t120), undef;
274$_ = "___";
275is eval("t120()"), "___";
276$_ = "___";
277is eval("t120(undef)"), "z";
278$_ = "___";
279is eval("t120(0)"), 0;
280$_ = "___";
281is eval("t120(456)"), 456;
282$_ = "___";
283is eval("t120(456, 789)"), undef;
284like $@, qr/\AToo many arguments for subroutine at/;
285is $a, 123;
286
287sub t121 ($a = caller) { $a // "z" }
288is prototype(\&t121), undef;
289is eval("t121()"), "main";
290is eval("t121(undef)"), "z";
291is eval("t121(0)"), 0;
292is eval("t121(456)"), 456;
293is eval("t121(456, 789)"), undef;
294like $@, qr/\AToo many arguments for subroutine at/;
295is eval("package T121::Z; ::t121()"), "T121::Z";
296is eval("package T121::Z; ::t121(undef)"), "z";
297is eval("package T121::Z; ::t121(0)"), 0;
298is eval("package T121::Z; ::t121(456)"), 456;
299is eval("package T121::Z; ::t121(456, 789)"), undef;
300like $@, qr/\AToo many arguments for subroutine at/;
301is $a, 123;
302
303sub t129 ($a = return 222) { $a."x" }
304is prototype(\&t129), undef;
305is eval("t129()"), "222";
306is eval("t129(0)"), "0x";
307is eval("t129(456)"), "456x";
308is eval("t129(456, 789)"), undef;
309like $@, qr/\AToo many arguments for subroutine at/;
310is $a, 123;
311
312use feature "current_sub";
313sub t122 ($c = 5, $r = $c > 0 ? __SUB__->($c - 1) : "") { $c.$r }
314is prototype(\&t122), undef;
315is eval("t122()"), "543210";
316is eval("t122(0)"), "0";
317is eval("t122(1)"), "10";
318is eval("t122(5)"), "543210";
319is eval("t122(5, 789)"), "5789";
320is eval("t122(5, 789, 987)"), undef;
321like $@, qr/\AToo many arguments for subroutine at/;
322is $a, 123;
323
324sub t123 ($list = wantarray) { $list ? "list" : "scalar" }
325is prototype(\&t123), undef;
326is eval("scalar(t123())"), "scalar";
327is eval("(t123())[0]"), "list";
328is eval("scalar(t123(0))"), "scalar";
329is eval("(t123(0))[0]"), "scalar";
330is eval("scalar(t123(1))"), "list";
331is eval("(t123(1))[0]"), "list";
332is eval("t123(456, 789)"), undef;
333like $@, qr/\AToo many arguments for subroutine at/;
334is $a, 123;
335
336sub t124 ($b = (local $a = $a + 1)) { "$a/$b" }
337is prototype(\&t124), undef;
338is eval("t124()"), "124/124";
339is $a, 123;
340is eval("t124(456)"), "123/456";
341is $a, 123;
342is eval("t124(456, 789)"), undef;
343like $@, qr/\AToo many arguments for subroutine at/;
344is $a, 123;
345
346sub t125 ($c = (our $t125_counter)++) { $c }
347is prototype(\&t125), undef;
348is eval("t125()"), 0;
349is eval("t125()"), 1;
350is eval("t125()"), 2;
351is eval("t125(456)"), 456;
352is eval("t125(789)"), 789;
353is eval("t125()"), 3;
354is eval("t125()"), 4;
355is eval("t125(456, 789)"), undef;
356like $@, qr/\AToo many arguments for subroutine at/;
357is $a, 123;
358
359use feature "state";
360sub t126 ($c = (state $s = $z++)) { $c }
361is prototype(\&t126), undef;
362$z = 222;
363is eval("t126(456)"), 456;
364is $z, 222;
365is eval("t126()"), 222;
366is $z, 223;
367is eval("t126(456)"), 456;
368is $z, 223;
369is eval("t126()"), 222;
370is $z, 223;
371is eval("t126(456, 789)"), undef;
372like $@, qr/\AToo many arguments for subroutine at/;
373is $z, 223;
374is $a, 123;
375
376sub t127 ($c = do { state $s = $z++; $s++ }) { $c }
377is prototype(\&t127), undef;
378$z = 222;
379is eval("t127(456)"), 456;
380is $z, 222;
381is eval("t127()"), 222;
382is $z, 223;
383is eval("t127()"), 223;
384is eval("t127()"), 224;
385is $z, 223;
386is eval("t127(456)"), 456;
387is eval("t127(789)"), 789;
388is eval("t127()"), 225;
389is eval("t127()"), 226;
390is eval("t127(456, 789)"), undef;
391like $@, qr/\AToo many arguments for subroutine at/;
392is $z, 223;
393is $a, 123;
394
30d9c59b
Z
395sub t037 ($a = 222, $b = $a."x") { "$a/$b" }
396is prototype(\&t037), undef;
397is eval("t037()"), "222/222x";
398is eval("t037(0)"), "0/0x";
399is eval("t037(456)"), "456/456x";
400is eval("t037(456, 789)"), "456/789";
401is eval("t037(456, 789, 987)"), undef;
402like $@, qr/\AToo many arguments for subroutine at/;
403is $a, 123;
404
acf0afbd
Z
405sub t128 ($a = 222, $b = ($a = 333)) { "$a/$b" }
406is prototype(\&t128), undef;
407is eval("t128()"), "333/333";
408is eval("t128(0)"), "333/333";
409is eval("t128(456)"), "333/333";
410is eval("t128(456, 789)"), "456/789";
411is eval("t128(456, 789, 987)"), undef;
412like $@, qr/\AToo many arguments for subroutine at/;
413is $a, 123;
414
415sub t130 { join(",", @_).";".scalar(@_) }
416sub t131 ($a = 222, $b = goto &t130) { "$a/$b" }
417is prototype(\&t131), undef;
418is eval("t131()"), ";0";
419is eval("t131(0)"), "0;1";
420is eval("t131(456)"), "456;1";
421is eval("t131(456, 789)"), "456/789";
422is eval("t131(456, 789, 987)"), undef;
423like $@, qr/\AToo many arguments for subroutine at/;
424is $a, 123;
425
30d9c59b
Z
426eval "#line 8 foo\nsub t024 (\$a =) { }";
427is $@, "Optional parameter lacks default expression at foo line 8\.\n";
428
429sub t025 ($ = undef) { $a // "z" }
430is prototype(\&t025), undef;
431is eval("t025()"), 123;
432is eval("t025(0)"), 123;
433is eval("t025(456)"), 123;
434is eval("t025(456, 789)"), undef;
435like $@, qr/\AToo many arguments for subroutine at/;
436is eval("t025(456, 789, 987)"), undef;
437like $@, qr/\AToo many arguments for subroutine at/;
438is eval("t025(456, 789, 987, 654)"), undef;
439like $@, qr/\AToo many arguments for subroutine at/;
440is $a, 123;
441
442sub t026 ($ = 222) { $a // "z" }
443is prototype(\&t026), undef;
444is eval("t026()"), 123;
445is eval("t026(0)"), 123;
446is eval("t026(456)"), 123;
447is eval("t026(456, 789)"), undef;
448like $@, qr/\AToo many arguments for subroutine at/;
449is eval("t026(456, 789, 987)"), undef;
450like $@, qr/\AToo many arguments for subroutine at/;
451is eval("t026(456, 789, 987, 654)"), undef;
452like $@, qr/\AToo many arguments for subroutine at/;
453is $a, 123;
454
455sub t032 ($ = do { $z++; 222 }) { $a // "z" }
456$z = 0;
457is prototype(\&t032), undef;
458is eval("t032()"), 123;
459is $z, 1;
460is eval("t032(0)"), 123;
461is eval("t032(456)"), 123;
462is eval("t032(456, 789)"), undef;
463like $@, qr/\AToo many arguments for subroutine at/;
464is eval("t032(456, 789, 987)"), undef;
465like $@, qr/\AToo many arguments for subroutine at/;
466is eval("t032(456, 789, 987, 654)"), undef;
467like $@, qr/\AToo many arguments for subroutine at/;
468is $z, 1;
469is $a, 123;
470
471sub t027 ($ =) { $a // "z" }
472is prototype(\&t027), undef;
473is eval("t027()"), 123;
474is eval("t027(0)"), 123;
475is eval("t027(456)"), 123;
476is eval("t027(456, 789)"), undef;
477like $@, qr/\AToo many arguments for subroutine at/;
478is eval("t027(456, 789, 987)"), undef;
479like $@, qr/\AToo many arguments for subroutine at/;
480is eval("t027(456, 789, 987, 654)"), undef;
481like $@, qr/\AToo many arguments for subroutine at/;
482is $a, 123;
483
484sub t119 ($ =, $a = 333) { $a // "z" }
485is prototype(\&t119), undef;
486is eval("t119()"), 333;
487is eval("t119(0)"), 333;
488is eval("t119(456)"), 333;
489is eval("t119(456, 789)"), 789;
490is eval("t119(456, 789, 987)"), undef;
491like $@, qr/\AToo many arguments for subroutine at/;
492is eval("t119(456, 789, 987, 654)"), undef;
493like $@, qr/\AToo many arguments for subroutine at/;
494is $a, 123;
495
496sub t028 ($a, $b = 333) { "$a/$b" }
497is prototype(\&t028), undef;
498is eval("t028()"), undef;
499like $@, qr/\AToo few arguments for subroutine at/;
500is eval("t028(0)"), "0/333";
501is eval("t028(456)"), "456/333";
502is eval("t028(456, 789)"), "456/789";
503is eval("t028(456, 789, 987)"), undef;
504like $@, qr/\AToo many arguments for subroutine at/;
505is $a, 123;
506
507sub t045 ($a, $ = 333) { "$a/" }
508is prototype(\&t045), undef;
509is eval("t045()"), undef;
510like $@, qr/\AToo few arguments for subroutine at/;
511is eval("t045(0)"), "0/";
512is eval("t045(456)"), "456/";
513is eval("t045(456, 789)"), "456/";
514is eval("t045(456, 789, 987)"), undef;
515like $@, qr/\AToo many arguments for subroutine at/;
516is $a, 123;
517
518sub t046 ($, $b = 333) { "$a/$b" }
519is prototype(\&t046), undef;
520is eval("t046()"), undef;
521like $@, qr/\AToo few arguments for subroutine at/;
522is eval("t046(0)"), "123/333";
523is eval("t046(456)"), "123/333";
524is eval("t046(456, 789)"), "123/789";
525is eval("t046(456, 789, 987)"), undef;
526like $@, qr/\AToo many arguments for subroutine at/;
527is $a, 123;
528
529sub t047 ($, $ = 333) { "$a/" }
530is prototype(\&t047), undef;
531is eval("t047()"), undef;
532like $@, qr/\AToo few arguments for subroutine at/;
533is eval("t047(0)"), "123/";
534is eval("t047(456)"), "123/";
535is eval("t047(456, 789)"), "123/";
536is eval("t047(456, 789, 987)"), undef;
537like $@, qr/\AToo many arguments for subroutine at/;
538is $a, 123;
539
540sub t029 ($a, $b, $c = 222, $d = 333) { "$a/$b/$c/$d" }
541is prototype(\&t029), undef;
542is eval("t029()"), undef;
543like $@, qr/\AToo few arguments for subroutine at/;
544is eval("t029(0)"), undef;
545like $@, qr/\AToo few arguments for subroutine at/;
546is eval("t029(456)"), undef;
547like $@, qr/\AToo few arguments for subroutine at/;
548is eval("t029(456, 789)"), "456/789/222/333";
549is eval("t029(456, 789, 987)"), "456/789/987/333";
550is eval("t029(456, 789, 987, 654)"), "456/789/987/654";
551is eval("t029(456, 789, 987, 654, 321)"), undef;
552like $@, qr/\AToo many arguments for subroutine at/;
553is eval("t029(456, 789, 987, 654, 321, 111)"), undef;
554like $@, qr/\AToo many arguments for subroutine at/;
555is $a, 123;
556
557sub t038 ($a, $b = $a."x") { "$a/$b" }
558is prototype(\&t038), undef;
559is eval("t038()"), undef;
560like $@, qr/\AToo few arguments for subroutine at/;
561is eval("t038(0)"), "0/0x";
562is eval("t038(456)"), "456/456x";
563is eval("t038(456, 789)"), "456/789";
564is eval("t038(456, 789, 987)"), undef;
565like $@, qr/\AToo many arguments for subroutine at/;
566is $a, 123;
567
568eval "#line 8 foo\nsub t030 (\$a = 222, \$b) { }";
569is $@, "Mandatory parameter follows optional parameter at foo line 8\.\n";
570
571eval "#line 8 foo\nsub t031 (\$a = 222, \$b = 333, \$c, \$d) { }";
572is $@, "Mandatory parameter follows optional parameter at foo line 8\.\n";
573
574sub t034 (@abc) { join("/", @abc).";".scalar(@abc) }
575is prototype(\&t034), undef;
576is eval("t034()"), ";0";
577is eval("t034(0)"), "0;1";
578is eval("t034(456)"), "456;1";
579is eval("t034(456, 789)"), "456/789;2";
580is eval("t034(456, 789, 987)"), "456/789/987;3";
581is eval("t034(456, 789, 987, 654)"), "456/789/987/654;4";
582is eval("t034(456, 789, 987, 654, 321)"), "456/789/987/654/321;5";
583is eval("t034(456, 789, 987, 654, 321, 111)"), "456/789/987/654/321/111;6";
584is $a, 123;
585
586sub t035 (@) { $a }
587is prototype(\&t035), undef;
588is eval("t035()"), 123;
589is eval("t035(0)"), 123;
590is eval("t035(456)"), 123;
591is eval("t035(456, 789)"), 123;
592is eval("t035(456, 789, 987)"), 123;
593is eval("t035(456, 789, 987, 654)"), 123;
594is eval("t035(456, 789, 987, 654, 321)"), 123;
595is eval("t035(456, 789, 987, 654, 321, 111)"), 123;
596is $a, 123;
597
598sub t039 (%abc) { join("/", map { $_."=".$abc{$_} } sort keys %abc) }
599is prototype(\&t039), undef;
600is eval("t039()"), "";
601is eval("t039(0)"), undef;
602like $@, qr#\AOdd name/value argument for subroutine at#;
603is eval("t039(456)"), undef;
604like $@, qr#\AOdd name/value argument for subroutine at#;
605is eval("t039(456, 789)"), "456=789";
606is eval("t039(456, 789, 987)"), undef;
607like $@, qr#\AOdd name/value argument for subroutine at#;
608is eval("t039(456, 789, 987, 654)"), "456=789/987=654";
609is eval("t039(456, 789, 987, 654, 321)"), undef;
610like $@, qr#\AOdd name/value argument for subroutine at#;
611is eval("t039(456, 789, 987, 654, 321, 111)"), "321=111/456=789/987=654";
612is $a, 123;
613
614sub t040 (%) { $a }
615is prototype(\&t040), undef;
616is eval("t040()"), 123;
617is eval("t040(0)"), undef;
618like $@, qr#\AOdd name/value argument for subroutine at#;
619is eval("t040(456)"), undef;
620like $@, qr#\AOdd name/value argument for subroutine at#;
621is eval("t040(456, 789)"), 123;
622is eval("t040(456, 789, 987)"), undef;
623like $@, qr#\AOdd name/value argument for subroutine at#;
624is eval("t040(456, 789, 987, 654)"), 123;
625is eval("t040(456, 789, 987, 654, 321)"), undef;
626like $@, qr#\AOdd name/value argument for subroutine at#;
627is eval("t040(456, 789, 987, 654, 321, 111)"), 123;
628is $a, 123;
629
630sub t041 ($a, @b) { $a.";".join("/", @b) }
631is prototype(\&t041), undef;
632is eval("t041()"), undef;
633like $@, qr/\AToo few arguments for subroutine at/;
634is eval("t041(0)"), "0;";
635is eval("t041(456)"), "456;";
636is eval("t041(456, 789)"), "456;789";
637is eval("t041(456, 789, 987)"), "456;789/987";
638is eval("t041(456, 789, 987, 654)"), "456;789/987/654";
639is eval("t041(456, 789, 987, 654, 321)"), "456;789/987/654/321";
640is eval("t041(456, 789, 987, 654, 321, 111)"), "456;789/987/654/321/111";
641is $a, 123;
642
643sub t042 ($a, @) { $a.";" }
644is prototype(\&t042), undef;
645is eval("t042()"), undef;
646like $@, qr/\AToo few arguments for subroutine at/;
647is eval("t042(0)"), "0;";
648is eval("t042(456)"), "456;";
649is eval("t042(456, 789)"), "456;";
650is eval("t042(456, 789, 987)"), "456;";
651is eval("t042(456, 789, 987, 654)"), "456;";
652is eval("t042(456, 789, 987, 654, 321)"), "456;";
653is eval("t042(456, 789, 987, 654, 321, 111)"), "456;";
654is $a, 123;
655
656sub t043 ($, @b) { $a.";".join("/", @b) }
657is prototype(\&t043), undef;
658is eval("t043()"), undef;
659like $@, qr/\AToo few arguments for subroutine at/;
660is eval("t043(0)"), "123;";
661is eval("t043(456)"), "123;";
662is eval("t043(456, 789)"), "123;789";
663is eval("t043(456, 789, 987)"), "123;789/987";
664is eval("t043(456, 789, 987, 654)"), "123;789/987/654";
665is eval("t043(456, 789, 987, 654, 321)"), "123;789/987/654/321";
666is eval("t043(456, 789, 987, 654, 321, 111)"), "123;789/987/654/321/111";
667is $a, 123;
668
669sub t044 ($, @) { $a.";" }
670is prototype(\&t044), undef;
671is eval("t044()"), undef;
672like $@, qr/\AToo few arguments for subroutine at/;
673is eval("t044(0)"), "123;";
674is eval("t044(456)"), "123;";
675is eval("t044(456, 789)"), "123;";
676is eval("t044(456, 789, 987)"), "123;";
677is eval("t044(456, 789, 987, 654)"), "123;";
678is eval("t044(456, 789, 987, 654, 321)"), "123;";
679is eval("t044(456, 789, 987, 654, 321, 111)"), "123;";
680is $a, 123;
681
682sub t049 ($a, %b) { $a.";".join("/", map { $_."=".$b{$_} } sort keys %b) }
683is prototype(\&t049), undef;
684is eval("t049()"), undef;
685like $@, qr/\AToo few arguments for subroutine at/;
686is eval("t049(222)"), "222;";
687is eval("t049(222, 456)"), undef;
688like $@, qr#\AOdd name/value argument for subroutine at#;
689is eval("t049(222, 456, 789)"), "222;456=789";
690is eval("t049(222, 456, 789, 987)"), undef;
691like $@, qr#\AOdd name/value argument for subroutine at#;
692is eval("t049(222, 456, 789, 987, 654)"), "222;456=789/987=654";
693is eval("t049(222, 456, 789, 987, 654, 321)"), undef;
694like $@, qr#\AOdd name/value argument for subroutine at#;
695is eval("t049(222, 456, 789, 987, 654, 321, 111)"),
696 "222;321=111/456=789/987=654";
697is $a, 123;
698
699sub t051 ($a, $b, $c, @d) { "$a;$b;$c;".join("/", @d).";".scalar(@d) }
700is prototype(\&t051), undef;
701is eval("t051()"), undef;
702like $@, qr/\AToo few arguments for subroutine at/;
703is eval("t051(456)"), undef;
704like $@, qr/\AToo few arguments for subroutine at/;
705is eval("t051(456, 789)"), undef;
706like $@, qr/\AToo few arguments for subroutine at/;
707is eval("t051(456, 789, 987)"), "456;789;987;;0";
708is eval("t051(456, 789, 987, 654)"), "456;789;987;654;1";
709is eval("t051(456, 789, 987, 654, 321)"), "456;789;987;654/321;2";
710is eval("t051(456, 789, 987, 654, 321, 111)"), "456;789;987;654/321/111;3";
711is $a, 123;
712
713sub t052 ($a, $b, %c) { "$a;$b;".join("/", map { $_."=".$c{$_} } sort keys %c) }
714is prototype(\&t052), undef;
715is eval("t052()"), undef;
716like $@, qr/\AToo few arguments for subroutine at/;
717is eval("t052(222)"), undef;
718like $@, qr/\AToo few arguments for subroutine at/;
719is eval("t052(222, 333)"), "222;333;";
720is eval("t052(222, 333, 456)"), undef;
721like $@, qr#\AOdd name/value argument for subroutine at#;
722is eval("t052(222, 333, 456, 789)"), "222;333;456=789";
723is eval("t052(222, 333, 456, 789, 987)"), undef;
724like $@, qr#\AOdd name/value argument for subroutine at#;
725is eval("t052(222, 333, 456, 789, 987, 654)"), "222;333;456=789/987=654";
726is eval("t052(222, 333, 456, 789, 987, 654, 321)"), undef;
727like $@, qr#\AOdd name/value argument for subroutine at#;
728is eval("t052(222, 333, 456, 789, 987, 654, 321, 111)"),
729 "222;333;321=111/456=789/987=654";
730is $a, 123;
731
732sub t053 ($a, $b, $c, %d) {
733 "$a;$b;$c;".join("/", map { $_."=".$d{$_} } sort keys %d)
734}
735is prototype(\&t053), undef;
736is eval("t053()"), undef;
737like $@, qr/\AToo few arguments for subroutine at/;
738is eval("t053(222)"), undef;
739like $@, qr/\AToo few arguments for subroutine at/;
740is eval("t053(222, 333)"), undef;
741like $@, qr/\AToo few arguments for subroutine at/;
742is eval("t053(222, 333, 444)"), "222;333;444;";
743is eval("t053(222, 333, 444, 456)"), undef;
744like $@, qr#\AOdd name/value argument for subroutine at#;
745is eval("t053(222, 333, 444, 456, 789)"), "222;333;444;456=789";
746is eval("t053(222, 333, 444, 456, 789, 987)"), undef;
747like $@, qr#\AOdd name/value argument for subroutine at#;
748is eval("t053(222, 333, 444, 456, 789, 987, 654)"),
749 "222;333;444;456=789/987=654";
750is eval("t053(222, 333, 444, 456, 789, 987, 654, 321)"), undef;
751like $@, qr#\AOdd name/value argument for subroutine at#;
752is eval("t053(222, 333, 444, 456, 789, 987, 654, 321, 111)"),
753 "222;333;444;321=111/456=789/987=654";
754is $a, 123;
755
756sub t048 ($a = 222, @b) { $a.";".join("/", @b).";".scalar(@b) }
757is prototype(\&t048), undef;
758is eval("t048()"), "222;;0";
759is eval("t048(0)"), "0;;0";
760is eval("t048(456)"), "456;;0";
761is eval("t048(456, 789)"), "456;789;1";
762is eval("t048(456, 789, 987)"), "456;789/987;2";
763is eval("t048(456, 789, 987, 654)"), "456;789/987/654;3";
764is eval("t048(456, 789, 987, 654, 321)"), "456;789/987/654/321;4";
765is eval("t048(456, 789, 987, 654, 321, 111)"), "456;789/987/654/321/111;5";
766is $a, 123;
767
768sub t054 ($a = 222, $b = 333, @c) { "$a;$b;".join("/", @c).";".scalar(@c) }
769is prototype(\&t054), undef;
770is eval("t054()"), "222;333;;0";
771is eval("t054(456)"), "456;333;;0";
772is eval("t054(456, 789)"), "456;789;;0";
773is eval("t054(456, 789, 987)"), "456;789;987;1";
774is eval("t054(456, 789, 987, 654)"), "456;789;987/654;2";
775is eval("t054(456, 789, 987, 654, 321)"), "456;789;987/654/321;3";
776is eval("t054(456, 789, 987, 654, 321, 111)"), "456;789;987/654/321/111;4";
777is $a, 123;
778
779sub t055 ($a = 222, $b = 333, $c = 444, @d) {
780 "$a;$b;$c;".join("/", @d).";".scalar(@d)
781}
782is prototype(\&t055), undef;
783is eval("t055()"), "222;333;444;;0";
784is eval("t055(456)"), "456;333;444;;0";
785is eval("t055(456, 789)"), "456;789;444;;0";
786is eval("t055(456, 789, 987)"), "456;789;987;;0";
787is eval("t055(456, 789, 987, 654)"), "456;789;987;654;1";
788is eval("t055(456, 789, 987, 654, 321)"), "456;789;987;654/321;2";
789is eval("t055(456, 789, 987, 654, 321, 111)"), "456;789;987;654/321/111;3";
790is $a, 123;
791
792sub t050 ($a = 211, %b) { $a.";".join("/", map { $_."=".$b{$_} } sort keys %b) }
793is prototype(\&t050), undef;
794is eval("t050()"), "211;";
795is eval("t050(222)"), "222;";
796is eval("t050(222, 456)"), undef;
797like $@, qr#\AOdd name/value argument for subroutine at#;
798is eval("t050(222, 456, 789)"), "222;456=789";
799is eval("t050(222, 456, 789, 987)"), undef;
800like $@, qr#\AOdd name/value argument for subroutine at#;
801is eval("t050(222, 456, 789, 987, 654)"), "222;456=789/987=654";
802is eval("t050(222, 456, 789, 987, 654, 321)"), undef;
803like $@, qr#\AOdd name/value argument for subroutine at#;
804is eval("t050(222, 456, 789, 987, 654, 321, 111)"),
805 "222;321=111/456=789/987=654";
806is $a, 123;
807
808sub t056 ($a = 211, $b = 311, %c) {
809 "$a;$b;".join("/", map { $_."=".$c{$_} } sort keys %c)
810}
811is prototype(\&t056), undef;
812is eval("t056()"), "211;311;";
813is eval("t056(222)"), "222;311;";
814is eval("t056(222, 333)"), "222;333;";
815is eval("t056(222, 333, 456)"), undef;
816like $@, qr#\AOdd name/value argument for subroutine at#;
817is eval("t056(222, 333, 456, 789)"), "222;333;456=789";
818is eval("t056(222, 333, 456, 789, 987)"), undef;
819like $@, qr#\AOdd name/value argument for subroutine at#;
820is eval("t056(222, 333, 456, 789, 987, 654)"), "222;333;456=789/987=654";
821is eval("t056(222, 333, 456, 789, 987, 654, 321)"), undef;
822like $@, qr#\AOdd name/value argument for subroutine at#;
823is eval("t056(222, 333, 456, 789, 987, 654, 321, 111)"),
824 "222;333;321=111/456=789/987=654";
825is $a, 123;
826
827sub t057 ($a = 211, $b = 311, $c = 411, %d) {
828 "$a;$b;$c;".join("/", map { $_."=".$d{$_} } sort keys %d)
829}
830is prototype(\&t057), undef;
831is eval("t057()"), "211;311;411;";
832is eval("t057(222)"), "222;311;411;";
833is eval("t057(222, 333)"), "222;333;411;";
834is eval("t057(222, 333, 444)"), "222;333;444;";
835is eval("t057(222, 333, 444, 456)"), undef;
836like $@, qr#\AOdd name/value argument for subroutine at#;
837is eval("t057(222, 333, 444, 456, 789)"), "222;333;444;456=789";
838is eval("t057(222, 333, 444, 456, 789, 987)"), undef;
839like $@, qr#\AOdd name/value argument for subroutine at#;
840is eval("t057(222, 333, 444, 456, 789, 987, 654)"),
841 "222;333;444;456=789/987=654";
842is eval("t057(222, 333, 444, 456, 789, 987, 654, 321)"), undef;
843like $@, qr#\AOdd name/value argument for subroutine at#;
844is eval("t057(222, 333, 444, 456, 789, 987, 654, 321, 111)"),
845 "222;333;444;321=111/456=789/987=654";
846is $a, 123;
847
848sub t058 ($a, $b = 333, @c) { "$a;$b;".join("/", @c).";".scalar(@c) }
849is prototype(\&t058), undef;
850is eval("t058()"), undef;
851like $@, qr/\AToo few arguments for subroutine at/;
852is eval("t058(456)"), "456;333;;0";
853is eval("t058(456, 789)"), "456;789;;0";
854is eval("t058(456, 789, 987)"), "456;789;987;1";
855is eval("t058(456, 789, 987, 654)"), "456;789;987/654;2";
856is eval("t058(456, 789, 987, 654, 321)"), "456;789;987/654/321;3";
857is eval("t058(456, 789, 987, 654, 321, 111)"), "456;789;987/654/321/111;4";
858is $a, 123;
859
860eval "#line 8 foo\nsub t059 (\@a, \$b) { }";
861is $@, "Slurpy parameter not last at foo line 8\.\n";
862
863eval "#line 8 foo\nsub t060 (\@a, \$b = 222) { }";
864is $@, "Slurpy parameter not last at foo line 8\.\n";
865
866eval "#line 8 foo\nsub t061 (\@a, \@b) { }";
867is $@, "Slurpy parameter not last at foo line 8\.\n";
868
869eval "#line 8 foo\nsub t062 (\@a, \%b) { }";
870is $@, "Slurpy parameter not last at foo line 8\.\n";
871
872eval "#line 8 foo\nsub t063 (\@, \$b) { }";
873is $@, "Slurpy parameter not last at foo line 8\.\n";
874
875eval "#line 8 foo\nsub t064 (\@, \$b = 222) { }";
876is $@, "Slurpy parameter not last at foo line 8\.\n";
877
878eval "#line 8 foo\nsub t065 (\@, \@b) { }";
879is $@, "Slurpy parameter not last at foo line 8\.\n";
880
881eval "#line 8 foo\nsub t066 (\@, \%b) { }";
882is $@, "Slurpy parameter not last at foo line 8\.\n";
883
884eval "#line 8 foo\nsub t067 (\@a, \$) { }";
885is $@, "Slurpy parameter not last at foo line 8\.\n";
886
887eval "#line 8 foo\nsub t068 (\@a, \$ = 222) { }";
888is $@, "Slurpy parameter not last at foo line 8\.\n";
889
890eval "#line 8 foo\nsub t069 (\@a, \@) { }";
891is $@, "Slurpy parameter not last at foo line 8\.\n";
892
893eval "#line 8 foo\nsub t070 (\@a, \%) { }";
894is $@, "Slurpy parameter not last at foo line 8\.\n";
895
896eval "#line 8 foo\nsub t071 (\@, \$) { }";
897is $@, "Slurpy parameter not last at foo line 8\.\n";
898
899eval "#line 8 foo\nsub t072 (\@, \$ = 222) { }";
900is $@, "Slurpy parameter not last at foo line 8\.\n";
901
902eval "#line 8 foo\nsub t073 (\@, \@) { }";
903is $@, "Slurpy parameter not last at foo line 8\.\n";
904
905eval "#line 8 foo\nsub t074 (\@, \%) { }";
906is $@, "Slurpy parameter not last at foo line 8\.\n";
907
908eval "#line 8 foo\nsub t075 (\%a, \$b) { }";
909is $@, "Slurpy parameter not last at foo line 8\.\n";
910
911eval "#line 8 foo\nsub t076 (\%, \$b) { }";
912is $@, "Slurpy parameter not last at foo line 8\.\n";
913
914eval "#line 8 foo\nsub t077 (\$a, \@b, \$c) { }";
915is $@, "Slurpy parameter not last at foo line 8\.\n";
916
917eval "#line 8 foo\nsub t078 (\$a, \%b, \$c) { }";
918is $@, "Slurpy parameter not last at foo line 8\.\n";
919
920eval "#line 8 foo\nsub t079 (\$a, \@b, \$c, \$d) { }";
921is $@, "Slurpy parameter not last at foo line 8\.\n";
922
923sub t080 ($a,,, $b) { $a.$b }
924is prototype(\&t080), undef;
925is eval("t080()"), undef;
926like $@, qr/\AToo few arguments for subroutine at/;
927is eval("t080(456)"), undef;
928like $@, qr/\AToo few arguments for subroutine at/;
929is eval("t080(456, 789)"), "456789";
930is eval("t080(456, 789, 987)"), undef;
931like $@, qr/\AToo many arguments for subroutine at/;
932is eval("t080(456, 789, 987, 654)"), undef;
933like $@, qr/\AToo many arguments for subroutine at/;
934is $a, 123;
935
936sub t081 ($a, $b,,) { $a.$b }
937is prototype(\&t081), undef;
938is eval("t081()"), undef;
939like $@, qr/\AToo few arguments for subroutine at/;
940is eval("t081(456)"), undef;
941like $@, qr/\AToo few arguments for subroutine at/;
942is eval("t081(456, 789)"), "456789";
943is eval("t081(456, 789, 987)"), undef;
944like $@, qr/\AToo many arguments for subroutine at/;
945is eval("t081(456, 789, 987, 654)"), undef;
946like $@, qr/\AToo many arguments for subroutine at/;
947is $a, 123;
948
949eval "#line 8 foo\nsub t082 (, \$a) { }";
950like $@, qr/\AParse error at foo line 8\.\n/;
951
952eval "#line 8 foo\nsub t083 (,) { }";
953like $@, qr/\AParse error at foo line 8\.\n/;
954
955sub t084($a,$b){ $a.$b }
956is prototype(\&t084), undef;
957is eval("t084()"), undef;
958like $@, qr/\AToo few arguments for subroutine at/;
959is eval("t084(456)"), undef;
960like $@, qr/\AToo few arguments for subroutine at/;
961is eval("t084(456, 789)"), "456789";
962is eval("t084(456, 789, 987)"), undef;
963like $@, qr/\AToo many arguments for subroutine at/;
964is eval("t084(456, 789, 987, 654)"), undef;
965like $@, qr/\AToo many arguments for subroutine at/;
966is $a, 123;
967
968sub t085
969 (
970 $
971 a
972 ,
973 ,
974 $
975 b
976 =
977 333
978 ,
979 ,
980 )
981 { $a.$b }
982is prototype(\&t085), undef;
983is eval("t085()"), undef;
984like $@, qr/\AToo few arguments for subroutine at/;
985is eval("t085(456)"), "456333";
986is eval("t085(456, 789)"), "456789";
987is eval("t085(456, 789, 987)"), undef;
988like $@, qr/\AToo many arguments for subroutine at/;
989is eval("t085(456, 789, 987, 654)"), undef;
990like $@, qr/\AToo many arguments for subroutine at/;
991is $a, 123;
992
993sub t086
994 ( #foo)))
995 $ #foo)))
996 a #foo)))
997 , #foo)))
998 , #foo)))
999 $ #foo)))
1000 b #foo)))
1001 = #foo)))
1002 333 #foo)))
1003 , #foo)))
1004 , #foo)))
1005 ) #foo)))
1006 { $a.$b }
1007is prototype(\&t086), undef;
1008is eval("t086()"), undef;
1009like $@, qr/\AToo few arguments for subroutine at/;
1010is eval("t086(456)"), "456333";
1011is eval("t086(456, 789)"), "456789";
1012is eval("t086(456, 789, 987)"), undef;
1013like $@, qr/\AToo many arguments for subroutine at/;
1014is eval("t086(456, 789, 987, 654)"), undef;
1015like $@, qr/\AToo many arguments for subroutine at/;
1016is $a, 123;
1017
1018sub t087
1019 (#foo)))
1020 $ #foo)))
1021 a#foo)))
1022 ,#foo)))
1023 ,#foo)))
1024 $ #foo)))
1025 b#foo)))
1026 =#foo)))
1027 333#foo)))
1028 ,#foo)))
1029 ,#foo)))
1030 )#foo)))
1031 { $a.$b }
1032is prototype(\&t087), undef;
1033is eval("t087()"), undef;
1034like $@, qr/\AToo few arguments for subroutine at/;
1035is eval("t087(456)"), "456333";
1036is eval("t087(456, 789)"), "456789";
1037is eval("t087(456, 789, 987)"), undef;
1038like $@, qr/\AToo many arguments for subroutine at/;
1039is eval("t087(456, 789, 987, 654)"), undef;
1040like $@, qr/\AToo many arguments for subroutine at/;
1041is $a, 123;
1042
1043eval "#line 8 foo\nsub t088 (\$ #foo\na) { }";
1044is $@, "";
1045
1046eval "#line 8 foo\nsub t089 (\$#foo\na) { }";
1047like $@, qr/\AParse error at foo line 8\.\n/;
1048
1049eval "#line 8 foo\nsub t090 (\@ #foo\na) { }";
1050is $@, "";
1051
1052eval "#line 8 foo\nsub t091 (\@#foo\na) { }";
1053like $@, qr/\AParse error at foo line 8\.\n/;
1054
1055eval "#line 8 foo\nsub t092 (\% #foo\na) { }";
1056is $@, "";
1057
1058eval "#line 8 foo\nsub t093 (\%#foo\na) { }";
1059like $@, qr/\AParse error at foo line 8\.\n/;
1060
1061eval "#line 8 foo\nsub t094 (123) { }";
1062like $@, qr/\AParse error at foo line 8\.\n/;
1063
1064eval "#line 8 foo\nsub t095 (\$a, 123) { }";
1065like $@, qr/\AParse error at foo line 8\.\n/;
1066
1067eval "#line 8 foo\nsub t096 (\$a 123) { }";
1068like $@, qr/\AParse error at foo line 8\.\n/;
1069
1070eval "#line 8 foo\nsub t097 (\$a { }) { }";
1071like $@, qr/\AParse error at foo line 8\.\n/;
1072
1073eval "#line 8 foo\nsub t098 (\$a; \$b) { }";
1074like $@, qr/\AParse error at foo line 8\.\n/;
1075
1076eval "#line 8 foo\nsub t099 (\$\$) { }";
1077like $@, qr/\AParse error at foo line 8\.\n/;
1078
1079no warnings "experimental::lexical_topic";
1080sub t100 ($_) { "$::_/$_" }
1081is prototype(\&t100), undef;
1082$_ = "___";
1083is eval("t100()"), undef;
1084like $@, qr/\AToo few arguments for subroutine at/;
1085$_ = "___";
1086is eval("t100(0)"), "___/0";
1087$_ = "___";
1088is eval("t100(456)"), "___/456";
1089$_ = "___";
1090is eval("t100(456, 789)"), undef;
1091like $@, qr/\AToo many arguments for subroutine at/;
1092$_ = "___";
1093is eval("t100(456, 789, 987)"), undef;
1094like $@, qr/\AToo many arguments for subroutine at/;
1095is $a, 123;
1096
1097eval "#line 8 foo\nsub t101 (\@_) { }";
1098like $@, qr/\ACan't use global \@_ in "my" at foo line 8/;
1099
1100eval "#line 8 foo\nsub t102 (\%_) { }";
1101like $@, qr/\ACan't use global \%_ in "my" at foo line 8/;
1102
1103my $t103 = sub ($a) { $a || "z" };
1104is prototype($t103), undef;
1105is eval("\$t103->()"), undef;
1106like $@, qr/\AToo few arguments for subroutine at/;
1107is eval("\$t103->(0)"), "z";
1108is eval("\$t103->(456)"), 456;
1109is eval("\$t103->(456, 789)"), undef;
1110like $@, qr/\AToo many arguments for subroutine at/;
1111is eval("\$t103->(456, 789, 987)"), undef;
1112like $@, qr/\AToo many arguments for subroutine at/;
1113is $a, 123;
1114
1115my $t118 = sub :prototype($) ($a) { $a || "z" };
1116is prototype($t118), "\$";
1117is eval("\$t118->()"), undef;
1118like $@, qr/\AToo few arguments for subroutine at/;
1119is eval("\$t118->(0)"), "z";
1120is eval("\$t118->(456)"), 456;
1121is eval("\$t118->(456, 789)"), undef;
1122like $@, qr/\AToo many arguments for subroutine at/;
1123is eval("\$t118->(456, 789, 987)"), undef;
1124like $@, qr/\AToo many arguments for subroutine at/;
1125is $a, 123;
1126
1127sub t033 ($a = sub ($a) { $a."z" }) { $a->("a")."y" }
1128is prototype(\&t033), undef;
1129is eval("t033()"), "azy";
1130is eval("t033(sub { \"x\".\$_[0].\"x\" })"), "xaxy";
1131is eval("t033(sub { \"x\".\$_[0].\"x\" }, 789)"), undef;
1132like $@, qr/\AToo many arguments for subroutine at/;
1133is $a, 123;
1134
1135sub t104 :method ($a) { $a || "z" }
1136is prototype(\&t104), undef;
1137is eval("t104()"), undef;
1138like $@, qr/\AToo few arguments for subroutine at/;
1139is eval("t104(0)"), "z";
1140is eval("t104(456)"), 456;
1141is eval("t104(456, 789)"), undef;
1142like $@, qr/\AToo many arguments for subroutine at/;
1143is eval("t104(456, 789, 987)"), undef;
1144like $@, qr/\AToo many arguments for subroutine at/;
1145is $a, 123;
1146
1147sub t105 :prototype($) ($a) { $a || "z" }
1148is prototype(\&t105), "\$";
1149is eval("t105()"), undef;
1150like $@, qr/\ANot enough arguments for main::t105 /;
1151is eval("t105(0)"), "z";
1152is eval("t105(456)"), 456;
1153is eval("t105(456, 789)"), undef;
1154like $@, qr/\AToo many arguments for main::t105 at/;
1155is eval("t105(456, 789, 987)"), undef;
1156like $@, qr/\AToo many arguments for main::t105 at/;
1157is $a, 123;
1158
1159sub t106 :prototype(@) ($a) { $a || "z" }
1160is prototype(\&t106), "\@";
1161is eval("t106()"), undef;
1162like $@, qr/\AToo few arguments for subroutine at/;
1163is eval("t106(0)"), "z";
1164is eval("t106(456)"), 456;
1165is eval("t106(456, 789)"), undef;
1166like $@, qr/\AToo many arguments for subroutine at/;
1167is eval("t106(456, 789, 987)"), undef;
1168like $@, qr/\AToo many arguments for subroutine at/;
1169is $a, 123;
1170
1171eval "#line 8 foo\nsub t107 (\$a) :method { }";
1172isnt $@, "";
1173
1174eval "#line 8 foo\nsub t108 (\$a) :prototype(\$) { }";
1175isnt $@, "";
1176
1177sub t109 { }
1178is prototype(\&t109), undef;
1179is scalar(@{[ t109() ]}), 0;
1180is scalar(t109()), undef;
1181
1182sub t110 () { }
1183is prototype(\&t110), undef;
1184is scalar(@{[ t110() ]}), 0;
1185is scalar(t110()), undef;
1186
1187sub t111 ($a) { }
1188is prototype(\&t111), undef;
1189is scalar(@{[ t111(222) ]}), 0;
1190is scalar(t111(222)), undef;
1191
1192sub t112 ($) { }
1193is prototype(\&t112), undef;
1194is scalar(@{[ t112(222) ]}), 0;
1195is scalar(t112(222)), undef;
1196
1197sub t114 ($a = undef) { }
1198is prototype(\&t114), undef;
1199is scalar(@{[ t114() ]}), 0;
1200is scalar(t114()), undef;
1201is scalar(@{[ t114(333) ]}), 0;
1202is scalar(t114(333)), undef;
1203
1204sub t113 ($a = 222) { }
1205is prototype(\&t113), undef;
1206is scalar(@{[ t113() ]}), 0;
1207is scalar(t113()), undef;
1208is scalar(@{[ t113(333) ]}), 0;
1209is scalar(t113(333)), undef;
1210
1211sub t115 ($a = do { $z++; 222 }) { }
1212is prototype(\&t115), undef;
1213$z = 0;
1214is scalar(@{[ t115() ]}), 0;
1215is $z, 1;
1216is scalar(t115()), undef;
1217is $z, 2;
1218is scalar(@{[ t115(333) ]}), 0;
1219is scalar(t115(333)), undef;
1220is $z, 2;
1221
1222sub t116 (@a) { }
1223is prototype(\&t116), undef;
1224is scalar(@{[ t116() ]}), 0;
1225is scalar(t116()), undef;
1226is scalar(@{[ t116(333) ]}), 0;
1227is scalar(t116(333)), undef;
1228
1229sub t117 (%a) { }
1230is prototype(\&t117), undef;
1231is scalar(@{[ t117() ]}), 0;
1232is scalar(t117()), undef;
1233is scalar(@{[ t117(333, 444) ]}), 0;
1234is scalar(t117(333, 444)), undef;
1235
12361;