NAME

Test::App::Generator::Sample::Module - Example module for schema extraction testing

VERSION

Version 0.34

SYNOPSIS

use Test::App::Generator::Sample::Module;

my $obj = Test::App::Generator::Sample::Module->new();
my $result = $obj->validate_email('user@example.com');

DESCRIPTION

A sample module with a variety of well and poorly documented methods, used to exercise App::Test::Generator::SchemaExtractor. The methods cover common parameter types, validation patterns, and confidence levels so that the extractor's heuristics can be tested against known inputs.

new

Constructor. Returns a new instance.

my $obj = Test::App::Generator::Sample::Module->new();

Returns

A blessed hashref.

API specification

input

{ class => { type => SCALAR } }

output

{ type => OBJECT, isa => 'Test::App::Generator::Sample::Module' }

validate_email

Validate an email address against basic structural rules.

my $ok = $obj->validate_email('user@example.com');

Arguments

  • $email

    String ($MIN_EMAIL_LEN-$MAX_EMAIL_LEN chars). Required.

Returns

1 if the address is valid. Croaks on any validation failure.

API specification

input

{
    self  => { type => OBJECT, isa => 'Test::App::Generator::Sample::Module' },
    email => { type => SCALAR, min => 5, max => 254 },
}

output

{ type => SCALAR, value => 1 }

calculate_age

Calculate age in years from a birth year.

my $age = $obj->calculate_age(1985);

Arguments

  • $birth_year

    Integer ($MIN_BIRTH_YEAR to current year). Required.

Returns

Age in years as an integer.

API specification

input

{
    self       => { type => OBJECT, isa => 'Test::App::Generator::Sample::Module' },
    birth_year => { type => SCALAR, min => 1900 },
}

output

{ type => SCALAR }

process_names

Process a list of names and return the count of non-empty entries.

my $count = $obj->process_names(['Alice', 'Bob', '']);

Arguments

  • $names

    Arrayref of name strings. Required.

Returns

Count of non-empty name strings as an integer.

API specification

input

{
    self  => { type => OBJECT,   isa => 'Test::App::Generator::Sample::Module' },
    names => { type => ARRAYREF },
}

output

{ type => SCALAR, min => 0 }

set_config

Store a configuration hashref on the object.

$obj->set_config({ timeout => 30, retries => 3 });

Arguments

  • $config

    Hashref of configuration options. Required.

Returns

1 on success. Croaks if $config is absent or not a hashref.

API specification

input

{
    self   => { type => OBJECT,  isa => 'Test::App::Generator::Sample::Module' },
    config => { type => HASHREF },
}

output

{ type => SCALAR, value => 1 }

greet

Generate a greeting message for a named person.

my $msg = $obj->greet('Alice');
my $msg = $obj->greet('Alice', 'Good morning');

Arguments

  • $name

    String ($MIN_NAME_LEN-$MAX_NAME_LEN chars). Required.

  • $greeting

    String. Optional — defaults to "Hello".

Returns

Greeting string of the form "$greeting, $name!".

API specification

input

{
    self     => { type => OBJECT, isa => 'Test::App::Generator::Sample::Module' },
    name     => { type => SCALAR, min => 1, max => 50 },
    greeting => { type => SCALAR, optional => 1 },
}

output

{ type => SCALAR }

check_flag

Return a normalised boolean for a flag value.

my $result = $obj->check_flag(1);   # returns 1
my $result = $obj->check_flag(0);   # returns 0

Arguments

  • $enabled

    Boolean scalar. Required.

Returns

1 if $enabled is true, 0 otherwise.

API specification

input

{
    self    => { type => OBJECT, isa => 'Test::App::Generator::Sample::Module' },
    enabled => { type => SCALAR },
}

output

{ type => SCALAR }

validate_score

Validate a numeric test score and return a pass/fail string.

my $status = $obj->validate_score(75.5);  # returns 'Pass'
my $status = $obj->validate_score(45.0);  # returns 'Fail'

Arguments

  • $score

    Number ($MIN_SCORE-$MAX_SCORE). Required.

Returns

The string 'Pass' if the score meets or exceeds $PASS_THRESHOLD, 'Fail' otherwise. Croaks on invalid input.

API specification

input

{
    self  => { type => OBJECT, isa => 'Test::App::Generator::Sample::Module' },
    score => { type => SCALAR, min => 0.0, max => 100.0 },
}

output

{ type => SCALAR }

mysterious_method

A deliberately under-documented method used to test that App::Test::Generator::SchemaExtractor correctly assigns low confidence when validation is absent.

AUTHOR

Example Author

LICENSE

This is free software.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 291:

Non-ASCII character seen before =encoding in '—'. Assuming UTF-8