NAME
Fennec::Declare - Nice syntax for Fennec via Devel::Declare
DESCRIPTION
Fennec is useful, but its syntax is not as nice as it could be. Leaving Devel::Declare out of core is a feature, but that does nto mean it shouldn't exist at all. This module provides Devel::Declare syntax enhancements to Fennec.
WARNING: EXPERIMENTAL
Devel::Declare is better than a source filter, but still magic in all kinds of possible bad ways. It adds new parsing capabilities to perl, but using it often still requires code to parse perl. Only perl can parse perl, as such there are likely many edge cases that have not been accounted for.
SYNOPSIS
package My::Test
use strict;
use warnings;
use Fennec;
use Fennec::Declare;
tests simple {
ok( 1, "In declared tests!" );
}
tests 'complicated name' {
ok( 1, "Complicated name!" );
}
tests old => sub {
ok( 1, "old style still works" );
};
tests old_deep => (
method => sub { ok( 1, "old with depth" )},
);
# Currently this does not work because of Fennec bug #58
# http://github.com/exodist/Fennec/issues#issue/58
# The syntax enhancement does as it should.
tests add_specs ( todo => 'not really todo' ) {
ok( 0, "This should be todo" );
}
cases some_cases {
my $x = 0;
case case_a { $x = 10 }
case case_b { $x = 100 }
case case_c { $x = 1000 }
tests divisible_by_ten { ok( !($x % 10), "$x/10" )}
tests positive { ok( $x, $x )}
}
describe a_describe {
my $x = 0;
# Note, SPEC before/after blocks are not enhanced
before_each { $x = 10 };
after_each { $x = 0 };
it is_ten { is( $x, 10, "x is 10" ); $x = 100 }
it is_not_100 { isnt( $x, 100, "x is not 100" ); $x = 100 }
}
1;
AUTOMATICALLY ENHANCED
Using Fennec::Declare automatically provides enhancements to the following:
- tests
- cases
- case
- describe
- it
ENHANCING SYNTAX FOR OTHERS
use Fennec::Declare @names_of_subs_to_enahnce;
So long as a sub takes for the form of:
subname item_name => ( method => sub { ... });
Fennec::Declare can enhance it. Simply provide the subs name to the use statement. before_XXX and after_XXX do not take this form, and thusly have not been enhanced.
AUTHORS
Chad Granum exodist7@gmail.com
COPYRIGHT
Copyright (C) 2010 Chad Granum
Fennec-Declare is free software; Standard perl licence.
Fennec-Declare is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.