From e1c7d5442ca1d3bd67c200d2dbd94bd0e40e72bd Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Apr 2021 12:26:06 +0000 Subject: Use single hyphen for NULL value, allow the user to specify it This lets the user inject a footer without injecting a header. --- t/basic.t | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 't') diff --git a/t/basic.t b/t/basic.t index c607548..f81c661 100644 --- a/t/basic.t +++ b/t/basic.t @@ -7,6 +7,8 @@ use Apache::TestRequest qw/GET_BODY/; BEGIN { plan tests => 7; } +# Prepare environment + my $head; # expected page header my $foot; # expected page footer my @body; # sections of page body @@ -25,7 +27,7 @@ close $h; close $f; # Helper for replacing file contents -sub set { +sub overwrite { my $file = shift; open my $fh, '>', $file or die "Could not open > $file: $!"; print $fh join('', @_); @@ -34,56 +36,54 @@ sub set { # Run tests -set 't/htdocs/.htaccess', <Test\n", "This is a test page.\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '-less head'; @body = ("...\n", "This is a test page.\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '-ful head'; -set 't/htdocs/subdir/.htaccess', <\n", "This is a test page.\n", "\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}", '-wrapped document'; @body = ("\n", "This is a test page.\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", ''; @body = ("\n\n", "This is a test page.\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", ' with leading newline'; +overwrite 't/htdocs/.htaccess', <