Skip to content

Instantly share code, notes, and snippets.

@pjlsergeant
Created July 10, 2012 07:58
Show Gist options
  • Select an option

  • Save pjlsergeant/3081936 to your computer and use it in GitHub Desktop.

Select an option

Save pjlsergeant/3081936 to your computer and use it in GitHub Desktop.
Idea for inline-testing and contracts for Perl method creation
method implication =>
applies => sub {
my ( $class, %args ) = @_;
return $args{'lhs'} <= $args{'rhs'};
},
to => {
lhs => { isa => 'Bool', required => 1 },
rhs => { isa => 'Bool', required => 1 },
},
yielding => 'Bool',
such_that => [
{ given => { lhs => 0, rhs => 0 }, then => 1 },
{ given => { lhs => 0, rhs => 1 }, then => 1 },
{ given => { lhs => 1, rhs => 0 }, then => 0 },
{ given => { lhs => 1, rhs => 1 }, then => 1 },
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment