Class::Agreement

Class::Agreement is a Perl module that add contracts to your Perl classes easily.
Download

Class::Agreement Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Ian Langworth
  • Publisher web site:
  • http://search.cpan.org/~ian/

Class::Agreement Tags


Class::Agreement Description

Class::Agreement is a Perl module that add contracts to your Perl classes easily. Class::Agreement is a Perl module that add contracts to your Perl classes easily.SYNOPSIS package SomeClass; use Class::Agreement; # use base 'Class::Accessor' or 'Class::MethodMaker', # or roll your own: sub new { ... } invariant { my ($self) = @_; $self->count > 0; }; precondition add_a_positive => sub { my ( $self, $value ) = @_; return ( $value >= 0 ); }; sub add_a_positive { my ( $self, $value ) = @_; ... } sub choose_word { my ( $self, $value ) = @_; ... } postcondition choose_word => sub { return ( result >= 0 ); }; dependent increase_foo => sub { my ( $self, $amount ) = @_; my $old_foo = $self->foo; return sub { my ( $self, $amount ) = @_; return ( $old_foo < $self->get_foo ); } }; sub increase_foo { my ( $self, $amount ) = @_; $self->set_foo( $self->get_foo + $amount ); }Class::Agreement is an implementation of behavioral contracts for Perl5. This module allows you to easily add pre- and postconditions to new or existing Perl classes.This module provides contracts such as dependent contracts, contracts for higher-order functions, and informative messages when things fail.At the time of this writing, Class::Agreement is one of only two contract implementations that blames contract-breaking components correctly. (See: "Object-oriented Programming Languages Need Well-founded Contracts" at http://citeseer.ist.psu.edu/findler01objectoriented.html.)Using Class::Agreement lets you specify proper input and output of your functions or methods, thus strengthening your code and allowing you to spot bugs earlier.Requirements:· Perl Requirements: · Perl


Class::Agreement Related Software