NAME

Test::CPAN::Health::Check::Examples - Check that example scripts are present

SYNOPSIS

use Test::CPAN::Health::Check::Examples;

my $check  = Test::CPAN::Health::Check::Examples->new;
my $result = $check->run($dist);

DESCRIPTION

Checks for the presence of an examples/, eg/, or example/ directory containing at least one file.

Score matrix:

  • 100 -- examples directory found with at least one file.

  • 50 -- examples directory found but empty.

  • 0 -- no examples directory found.

run

PURPOSE

Locate an examples directory and report whether it contains files.

API SPECIFICATION

INPUT

dist     Test::CPAN::Health::Distribution  required
context  Hashref                           optional  (unused)

OUTPUT

Test::CPAN::Health::Result with:

check_id  'examples'
status    'pass' | 'warn' | 'fail'
score     100 | 50 | 0
summary   human-readable verdict

MESSAGES

Code  | Severity | Message                            | Resolution
------+----------+------------------------------------+---------------------
EX001 | FAIL     | No examples directory found        | Add an examples/ or eg/ directory
EX002 | WARN     | Examples directory is empty        | Add at least one script to examples/
EX003 | PASS     | Examples directory found           |

FORMAL SPECIFICATION

-- Z schema (placeholder) --
ExamplesOp
dist  : Distribution
score : {0, 50, 100}
-------------------------------------------------------
no_dir      => score = 0
dir_empty   => score = 50
dir_nonempty => score = 100

SIDE EFFECTS

Reads directory listings from disk.

USAGE EXAMPLE

my $result = Test::CPAN::Health::Check::Examples->new->run($dist);

AUTHOR

Nigel Horne, <njh at nigelhorne.com>

LICENSE AND COPYRIGHT

Copyright (C) 2025-2026 Nigel Horne.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.