App-Test-Generator

 view release on metacpan or  search on metacpan

lib/App/Test/Generator/Model/Method.pm  view on Meta::CPAN

package App::Test::Generator::Model::Method;

use strict;
use warnings;

use Carp qw(croak);
use Readonly;

Readonly my $HIGH_CONFIDENCE_THRESHOLD   => 40;
Readonly my $MEDIUM_CONFIDENCE_THRESHOLD => 20;

our $VERSION = '0.42';

=head1 NAME

App::Test::Generator::Model::Method - Evidence-based model of a single method under test

=head1 VERSION

Version 0.42

=head1 DESCRIPTION

Accumulates weighted evidence about a single method's return behaviour,
gathered independently by several analysers
(L<App::Test::Generator::Analyzer::Return> and friends), then resolves
that evidence into a best-guess return type, test classification, and
confidence level. This lets multiple independent heuristics contribute
to one final judgement instead of the first heuristic to run winning
outright.

=head2 new

Construct a new Method model.

    my $method = App::Test::Generator::Model::Method->new(
        name   => 'get_name',
        source => 'sub get_name { return $_[0]->{name}; }',
    );

=head3 Arguments

=over 4

=item * C<name>

The method's name. Required.

=item * C<source>

The method's raw Perl source text. Required.

=back

=head3 Returns

A blessed hashref with C<evidence> initialised to an empty arrayref
and C<return_type>, C<classification>, and C<confidence> initialised
to C<undef>. Croaks with C<"name required"> or C<"source required">
if either argument is missing.

=head3 API specification

=head4 input

    {
        name   => { type => SCALAR },
        source => { type => SCALAR },
    }

=head4 output

    { type => OBJECT, isa => 'App::Test::Generator::Model::Method' }

=cut

sub new {
	my ($class, %args) = @_;
	croak 'name required'   unless defined $args{name};
	croak 'source required' unless defined $args{source};

	my $self = {
		name          => $args{name},
		source        => $args{source},
		# parameters    => [],
		evidence      => [],
		return_type   => undef,



( run in 0.498 second using v1.01-cache-2.11-cpan-7fcb06a456a )