Acme-EyeDrops
view release on metacpan or search on metacpan
#!/usr/bin/perl
# 06_not.t (was reshape.t)
use strict;
use Acme::EyeDrops qw(sightly get_eye_string);
# -------------------------------------------------
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);
}
# --------------------------------------------------
print "1..47\n";
my $hellostr = <<'HELLO';
print "hello world\n";
HELLO
my $camelstr = get_eye_string('camel');
my $indent_camelstr = $camelstr; $indent_camelstr =~ s/^/ /mg;
my $tmpf = 'bill.tmp';
my $tmpeye = 'tmpeye.eye';
# --------------------------------------------------
my $itest = 0;
my $prog;
sub test_one {
my ($e, $ostr) = @_;
build_file($tmpf, $prog);
my $outstr = `$^X -w -Mstrict $tmpf`;
my $rc = $? >> 8;
$rc == 0 or print "not ";
++$itest; print "ok $itest - $e rc\n";
$outstr eq $ostr or print "not ";
++$itest; print "ok $itest - $e output\n";
}
# -------------------------------------------------
$prog = sightly({ Shape => 'camel',
SourceString => $hellostr,
Expand => 1,
InformHandler => sub {},
Regex => 1 } );
my $bigprog = $prog;
test_one('big camel', "hello world\n");
$bigprog =~ tr/!-~/#/;
$bigprog eq $camelstr and print "not ";
++$itest; print "ok $itest - bigprog\n";
# -------------------------------------------------
build_file($tmpeye, $camelstr);
$prog = sightly({ Shape => 'tmpeye',
EyeDir => '.',
SourceString => $hellostr,
Expand => 1,
InformHandler => sub {},
Regex => 1 } );
$bigprog = $prog;
( run in 0.972 second using v1.01-cache-2.11-cpan-5a3173703d6 )