aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--t/basic.t37
1 files changed, 20 insertions, 17 deletions
diff --git a/t/basic.t b/t/basic.t
index 936f6c4..c607548 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -11,6 +11,8 @@ my $head; # expected page header
my $foot; # expected page footer
my @body; # sections of page body
+mkdir 't/htdocs/subdir' if ! -d 't/htdocs/subdir';
+
# Read contents of header and footer
open my $h, '<', 't/htdocs/head.html'
@@ -33,12 +35,17 @@ sub set {
# Run tests
set 't/htdocs/.htaccess', <<CONF;
-Inject head.html foot.html
+Inject " "
CONF
-mkdir 't/htdocs/subdir' if ! -d 't/htdocs/subdir';
-set 't/htdocs/subdir/.htaccess', <<CONF;
-Inject head.html
+@body = ("This is a test page.\n");
+set 't/htdocs/test.html', @body;
+set 't/htdocs/ ', 'whatever';
+ok GET_BODY('/test.html'), ${body[0]}, # should not include 'whatever'
+ 'single-space argument should fail';
+
+set 't/htdocs/.htaccess', <<CONF;
+Inject head.html foot.html
CONF
@body = ("<title>Test</title>\n", "This is a test page.\n");
@@ -51,6 +58,15 @@ set 't/htdocs/test.html', @body;
ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<head>-ful head';
+set 't/htdocs/subdir/.htaccess', <<CONF;
+Inject head.html
+CONF
+
+@body = ("This is a test page.\n");
+set 't/htdocs/subdir/test.html', @body;
+ok GET_BODY('/subdir/test.html'), "$head${body[0]}",
+ 'different injection in subdirectory';
+
@body = ("<html>\n", "This is a test page.\n", "</html>\n");
set 't/htdocs/test.html', @body;
ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}",
@@ -66,19 +82,6 @@ set 't/htdocs/test.html', @body;
ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<!doctype> with leading newline';
-@body = ("This is a test page.\n");
-set 't/htdocs/subdir/test.html', @body;
-ok GET_BODY('/subdir/test.html'), "$head${body[0]}",
- 'different injection in subdirectory';
-
-set 't/htdocs/subdir/.htaccess', <<CONF;
-Inject " "
-CONF
-
-set 't/htdocs/ ', 'head'; # needed in case " " is (incorrectly) accepted
-ok GET_BODY('/subdir/test.html') eq "head${body[0]}" && 1 || 0, 0,
- 'single-space argument should fail';
-
unlink 't/htdocs/.htaccess';
unlink 't/htdocs/test.html';
unlink 't/htdocs/subdir/.htaccess';