Acme-AsciiArtinator
view release on metacpan or search on metacpan
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
#
##################################################
open($fh,"<", $OUTPUT);
my @output = <$fh>;
close $fh;
# test output
#
# make sure artinated code produces same outputs
# as the original code on the test cases.
#
$ntest = 1;
if (defined $opts{"test_argv1"}) {
print "Running post-tests on artinated code\n";
}
while (defined $opts{"test_argv$ntest"} || defined $opts{"test_input$ntest"}) {
my (@test_argv, @test_stdin) = ();
print "Testing output # $ntest:\n";
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
\ \ \ \/___|___\/ / / /
\ \ \/____|____\/ / /
\ \/_____|_____\/ /
\/______|______\/
/ | \
=head1 UNDER THE HOOD
To fill in the shape of the spider, we inserted whitespace,
semi-colons, sharps, and maybe the occasional C<{> C<}> pair
into the original code. Certain blocks of text, like
C<print>, C<while>, and C<y#_ # _#> are kept intact since
splitting them would cause the program to either fail to
compile or to behave differently.
The ASCII Artinator tokenizes the code and
does its best to identify
=over 4
=item 1. Character strings that must not be divided
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
=head1 BEST PRACTICES
Certain coding practices will increase the chance that
C<Acme::AsciiArtinator> will be able to embed your code
in the artwork of your choice. In no particular order,
here are some suggestions:
=over 4
=item * Make sure the original code works
Make sure the code compiles and test it to see if it
works like you expect it to
before running the ASCII Artinator. It would be frustrating to
try to debug an artinated script only to later realize that
there was some bug in the original input.
=item * Get rid of comments
This module won't handle comments very well. There's no way
to stop the ASCII Artinator from splitting your comment across
two lines and breaking the code.
=item * Reduce whitespace
In addition to making the code longer and thus more difficult
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
=item output => filename
Specifies the output file for the embedded code. If omitted,
output is written to the file "ascii-art.pl" in the current
directory.
=item compile_check => 0 | 1
Runs the Perl interpreter with the C<-cw> flags on the
original code string and asserts that the code compiles.
=item debug => 0 | 1
Causes the ASCII Artinator to display verbose messages
about what it is trying to do while it is doing what it
is trying to do.
=item test_argv1 => [ @args ], test_argv2 => [ @args ] , test_argv3 => ...
Executes the original and the artinated code and compares the output
to make sure that the artination process did not change the
behavior of the code. A separate test will be conducted for
every C<test_argvE<lt>NNNE<gt>> parameter passed to the
C<asciiartinate> method. The arguments associated with each
parameter will be passed to the code as command-line arguments.
=item test_input1 => [ @data ], test_input2 => [ @data ], test_input3 => ...
Executes the original and the artinated code and compares the output
to make sure that the artination process did not change the
behavior of the code. A separate test will be conducted for
every C<test_inputE<lt>NNNE<gt>> parameter passed to the
C<asciiartinate> method. The data associated with each
parameter will be passed to the standard input of the code.
=back
=head1 TODO
( run in 0.479 second using v1.01-cache-2.11-cpan-f985c23238c )