This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Revert "[perl #77496] tied gets scalars and globs confused"
[perl5.git] / t / op / sub.t
index b76d34c..5bd4508 100644 (file)
@@ -1,12 +1,12 @@
-#!./perl
+#!./perl -w
 
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
-    require Config; import Config;
+    require './test.pl';
 }
 
-use Test::More tests => 4;
+plan( tests => 8 );
 
 sub empty_sub {}
 
@@ -17,3 +17,26 @@ is(scalar(@test), 0, 'Didnt return anything');
 @test = empty_sub(1,2,3);
 is(scalar(@test), 0, 'Didnt return anything');
 
+# RT #63790:  calling PL_sv_yes as a sub is special-cased to silently
+# return (so Foo->import() silently fails if import() doesn't exist),
+# But make sure it correctly pops the stack and mark stack before returning.
+
+{
+    my @a;
+    push @a, 4, 5, main->import(6,7);
+    ok(eq_array(\@a, [4,5]), "import with args");
+
+    @a = ();
+    push @a, 14, 15, main->import;
+    ok(eq_array(\@a, [14,15]), "import without args");
+
+    my $x = 1;
+
+    @a = ();
+    push @a, 24, 25, &{$x == $x}(26,27);
+    ok(eq_array(\@a, [24,25]), "yes with args");
+
+    @a = ();
+    push @a, 34, 35, &{$x == $x};
+    ok(eq_array(\@a, [34,35]), "yes without args");
+}