#!/usr/bin/perl

use strict;
use warnings;
use 5.010;

use Test::More tests => 10;

my $src = q{$_=q{print+($l=($~=<>)=~y///c)%4?$~:"\$_=q{$_};eval"x($l/4)};eval};
my $cmd = qq{perl -e'$src'};

is( qx(echo -n | $cmd), '', 'empty input -> empty output' );

# Length is not a multiple of 4
foreach my $input ( qw(a ab 123 foobar -1 ~!@#$%^&* ) ) {
    is( qx(echo -n '$input' | $cmd), $input, "$input -> $input" );
}

# Length is a multiple of 4, 25% bonus
foreach my $length ( (4, 8, 12) ) {
    my $input = 'a' x $length;
    is( qx(echo -n '$input' | $cmd), $src x ($length/4), "length == $length -> source x ". $length/4 );
}