[nginx-tests] Tests: perl tests with scalar changed after $r->pr...

Maxim Dounin mdounin at mdounin.ru
Fri Aug 14 06:14:04 UTC 2026


details:   http://freenginx.org/hg/nginx-tests/rev/b7be6f57f5a9
branches:  
changeset: 2088:b7be6f57f5a9
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Fri Aug 14 09:11:07 2026 +0300
description:
Tests: perl tests with scalar changed after $r->print().

diffstat:

 perl_refcount.t |  40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diffs (62 lines):

diff --git a/perl_refcount.t b/perl_refcount.t
--- a/perl_refcount.t
+++ b/perl_refcount.t
@@ -22,7 +22,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http perl/)->plan(6)
+my $t = Test::Nginx->new()->has(qw/http perl/)->plan(8)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -106,6 +106,34 @@ http {
                 return OK;
             }';
         }
+
+        location /print_changed {
+            perl 'sub {
+                my $r = shift;
+                $r->send_http_header;
+                my $foo = "it";
+                $foo .= " works";
+                $r->print($foo);
+                $foo = " changed";
+                $r->print($foo);
+                return OK;
+            }';
+        }
+
+        location /print_readonly_changed {
+            perl 'sub {
+                my $r = shift;
+                $r->send_http_header;
+                my $foo = "it";
+                $foo .= " works";
+                Internals::SvREADONLY($foo, 1);
+                $r->print($foo);
+                Internals::SvREADONLY($foo, 0);
+                $foo = " changed";
+                $r->print($foo);
+                return OK;
+            }';
+        }
     }
 }
 
@@ -162,4 +190,14 @@ like(http_get('/bless'), qr/500 Internal
 
 }
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.31.4');
+
+like(http_get('/print_changed'), qr/works changed/,
+	'perl print scalar changed');
+like(http_get('/print_readonly_changed'), qr/works changed/,
+	'perl print scalar readonly changed');
+
+}
+
 ###############################################################################


More information about the nginx-devel mailing list