t: rename abbreviated variables in Test::PLP
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 3 Sep 2015 17:54:24 +0000 (19:54 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 31 Mar 2018 20:58:53 +0000 (22:58 +0200)
lib/Test/PLP.pm

index c030742a137b43b5e5261de76090f11b43c9cb03..1eec19b1269bd7b1f2be0f6d174edaf4dbff6daa 100644 (file)
@@ -41,7 +41,7 @@ eval {
 } or 1;
 
 sub _plp_run {
-       my ($src, $env, $in) = @_;
+       my ($src, $env, $input) = @_;
 
        %ENV = (
                REQUEST_METHOD => 'GET',
@@ -58,11 +58,11 @@ sub _plp_run {
                $env ? %{$env} : (),
        ); # Apache/2.2.4 CGI environment
 
-       if (defined $in) {
-               $ENV{CONTENT_LENGTH} //= length $in;
+       if (defined $input) {
+               $ENV{CONTENT_LENGTH} //= length $input;
                $ENV{CONTENT_TYPE} //= 'application/x-www-form-urlencoded';
                close STDIN;
-               open STDIN, '<', $in;
+               open STDIN, '<', $input;
        }
 
        close STDOUT;
@@ -84,11 +84,11 @@ sub _plp_run {
 }
 
 sub plp_is {
-       my ($name, $src, $expect, $env, $in) = @_;
+       my ($name, $src, $expect, $env, $input) = @_;
        my $tb = __PACKAGE__->builder;
        local $Test::Builder::Level = $Test::Builder::Level + 1;
 
-       my ($output, $failure) = _plp_run($src, $env, $in);
+       my ($output, $failure) = _plp_run($src, $env, $input);
        if ($failure) {
                $tb->ok(0, $name);
                $tb->diag("    Error: $failure");
@@ -117,17 +117,17 @@ sub plp_ok {
 
        (my $name = $file) =~ s/[.][^.]+$//;
        $file = "$name.html";
-       my $infile = delete $replace{-input} // "$name.plp";
-       my $addin = -e "$name.txt" && "$name.txt";
+       my $src = delete $replace{-input} // "$name.plp";
+       my $input = -e "$name.txt" && "$name.txt";
        $name =~ s/^(\d*)-// and $name .= " ($1)";
        DecodeURI($name);
 
-       my $out = eval {
+       my $output = eval {
                local $/ = undef;  # slurp
                open my $fh, '<', $file or die "$!\n";
                return readline $fh;
        };
-       if (not defined $out) {
+       if (not defined $output) {
                $tb->ok(0, $name);
                $tb->diag("error reading output from $file: $@");
                return;
@@ -136,15 +136,15 @@ sub plp_ok {
        my $env = delete $replace{-env};
        $replace{HEAD} //= "Content-Type: text/html\nX-PLP-Version: $PLP::VERSION\n";
        $replace{VERSION        } //= $PLP::VERSION;
-       $replace{SCRIPT_NAME    } //= $infile;
-       $replace{SCRIPT_FILENAME} //= "./$infile";
+       $replace{SCRIPT_NAME    } //= $src;
+       $replace{SCRIPT_FILENAME} //= "./$src";
 
-       chomp $out;
-       $out =~ s/\$$_/$replace{$_}/g for keys %replace;
-       $out =~ s{
+       chomp $output;
+       $output =~ s/\$$_/$replace{$_}/g for keys %replace;
+       $output =~ s{
                <eval \s+ line="([^"]*)"> (.*?) </eval>
-       }{ _getwarning($2, $1, $infile) }msxge;
+       }{ _getwarning($2, $1, $src) }msxge;
 
-       plp_is($name, $infile, $out, $env, $addin);
+       plp_is($name, $src, $output, $env, $input);
 }