This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Regenerate known_pod_issues.dat
[perl5.git] / t / op / sub.t
CommitLineData
f7218ed4 1#!./perl -w
2d981f27
AB
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
f7218ed4 6 require './test.pl';
2d981f27
AB
7}
8
4d198de3 9plan( tests => 8 );
2d981f27
AB
10
11sub empty_sub {}
12
13is(empty_sub,undef,"Is empty");
14is(empty_sub(1,2,3),undef,"Is still empty");
15@test = empty_sub();
16is(scalar(@test), 0, 'Didnt return anything');
17@test = empty_sub(1,2,3);
18is(scalar(@test), 0, 'Didnt return anything');
19
4d198de3
DM
20# RT #63790: calling PL_sv_yes as a sub is special-cased to silently
21# return (so Foo->import() silently fails if import() doesn't exist),
22# But make sure it correctly pops the stack and mark stack before returning.
23
24{
25 my @a;
26 push @a, 4, 5, main->import(6,7);
27 ok(eq_array(\@a, [4,5]), "import with args");
28
29 @a = ();
30 push @a, 14, 15, main->import;
31 ok(eq_array(\@a, [14,15]), "import without args");
32
33 my $x = 1;
34
35 @a = ();
36 push @a, 24, 25, &{$x == $x}(26,27);
37 ok(eq_array(\@a, [24,25]), "yes with args");
38
39 @a = ();
40 push @a, 34, 35, &{$x == $x};
41 ok(eq_array(\@a, [34,35]), "yes without args");
42}