NAME
Fuckin::Lazy - Lazy way to produce test structures (Or a very bad idea)
WARNING
Warning! Using the module would fall squarely into BAD PRACTICE. You
should predict what structures your code produces and put them into the
test yourself. Simply dumping a result and testing against it is a bad
idea. The only exception to this policy is when writing tests to make
sure the output does not change from what it currently is.
SYNOPSIS
use Test::More;
use Fuckin::Lazy qw/LAZY/;
my $foo = { a => 1, b => 2 };
is_deeply($foo, Fuckin'Lazy($foo), "Foo");
is_deeply(
$foo,
LAZY($foo),
"Foo"
);
is_deeply($foo, LAZY($foo), "Foo");
done_testing;
The first time you run the above test it will alter the test file itself
to produce this:
use Test::More;
use Fuckin::Lazy qw/LAZY/;
my $foo = { a => 1, b => 2 };
is_deeply($foo, {"a" => 1,"b" => 2}, "Foo");
is_deeply(
$foo,
{"a" => 1,"b" => 2},
"Foo"
);
is_deeply($foo, {"a" => 1,"b" => 2}, "Foo");
done_testing;
DESCRIPTION
A poor implementation of a bad idea!
EXPORTS
LAZY($var)
This function will turn the argument into the code for a perl data
structure and replace itself with the code. This is done when the
file is run. The data structure passed in is returned unchanged
allowing the test to pass.
MAGIC
Fuckin'Lazy($var)
Same as the LAZY() export, except it is the Fuckin::Lazy function,
not exported. The "'" can be used in place of "::" due to legacy
perl support.
IDEA
Thanks to Joshua Keroes for proposing the idea.
"Fucking::Lazy is beautifully horrible" - mst
COPYRIGHT
Copyright 2014 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.