Acme-EyeDrops

 view release on metacpan or  search on metacpan

t/13_to.t  view on Meta::CPAN

#!/usr/bin/perl
# 13_to.t
# Tests _make_filler(), get_eye_dir(), slurp_yerself()
# get_eye_properties(), get_eye_keywords(), find_eye_shapes()

use strict;
use Acme::EyeDrops qw(get_eye_dir
                      get_eye_shapes
                      get_eye_properties
                      get_eye_keywords
                      find_eye_shapes);

select(STDERR);$|=1;select(STDOUT);$|=1;  # autoflush

# --------------------------------------------------

sub build_file {
   my ($f, $d) = @_;
   local *F; open(F, '>'.$f) or die "open '$f': $!";
   print F $d or die "write '$f': $!"; close(F);
}

# --------------------------------------------------

my $tmpf = 'bill.tmp';

# --------------------------------------------------
# A valid property file should:
#  1) contain no "weird" chars.
#  2) no line should contain trailing spaces
#  3) be properly newline-terminated
#  4) contain no leading newlines
#  5) contain no trailing newlines
# test_one_propchars() below verifies that is
# the case for all .eyp shapes.
#  6) contain only valid properties
# Tested by get_prop_names()
#  7) contain only valid keywords
# Tested near the end via get_eye_keywords().
# --------------------------------------------------

my @eye_shapes = get_eye_shapes();
my $n_tests = @eye_shapes * 6;
$n_tests += 101;   # plus other tests

print "1..$n_tests\n";

# --------------------------------------------------

my $itest = 0;

# --------------------------------------------------

# Test _make_filler()
{
   my $fillv = '#';
   # This line is used in A::E pour_sightly().
   # Note: 11 is the length of, for example, $:='.'^'~';
   # Multiple of 6 because each filler contains 6 tokens:
   #   $:  =  '.'  ^  '~'  ;
   # Also, no single quoted string should contain " or ;
   # Oh, and $; variable is banned.
   # XXX: add tests for all these later.
   my @filler = Acme::EyeDrops::_make_filler(
                   ref($fillv) ? $fillv : [ '$:', '$~', '$^' ]);
   my $nfiller = @filler;
   $nfiller == 72 or print "not ";
   ++$itest; print "ok $itest - _make_filler 72 items (got $nfiller)\n";
   $nfiller % 6 == 0 or print "not ";
   ++$itest; print "ok $itest - _make_filler multiple of 6 (got $nfiller)\n";

   @filler = Acme::EyeDrops::_make_filler([ '$:', '$~', '$^', '$:', '$~' ]);
   $nfiller = @filler;



( run in 1.792 second using v1.01-cache-2.11-cpan-5a3173703d6 )