Aion-Annotation

 view release on metacpan or  search on metacpan

t/aion/annotation/reader.t  view on Meta::CPAN

use common::sense; use open qw/:std :utf8/;  use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  use String::Diff q...
# # NAME
# 
# Aion::Annotation::Reader - считывает аннотации, комментарии и времена обновления модулей
# 
# # VERSION
# 
# 0.1.0
# 
# # SYNOPSIS
# 
# Файл etc/annotation/todo.ann:
#@> etc/annotation/todo.ann
#>> For::Test#abc,5=add1
#>> For::Test#xyz,11=add2
#@< EOF
# 
# Файл etc/annotation/remarks.ini:
#@> etc/annotation/remarks.ini
#>> For::Test#,4=The package for testing
#>> For::Test#abc,9=Is property\n  readonly
#@< EOF
# 
# Файл var/cache/modules.mtime.ini:
#@> var/cache/modules.mtime.ini
#>> For::Test=2025-01-02 03:04:05
#@< EOF
# 
subtest 'SYNOPSIS' => sub { 
use Aion::Annotation::Reader;
use Time::Local qw/timelocal/;

my $reader = Aion::Annotation::Reader->new('todo');

my @ann; push @ann, $_ while <$reader>;

my $ann = [
	{pkg => 'For::Test', name => 'abc', line => '5',  annotation => 'add1'},
	{pkg => 'For::Test', name => 'xyz', line => '11', annotation => 'add2'},
];

local ($::_g0 = do {\@ann}, $::_e0 = do {$ann}); ::is_deeply $::_g0, $::_e0, '\@ann # --> $ann' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

my $reader_remarks = Aion::Annotation::Reader->new(Aion::Annotation::Reader::READ_REMARKS);

my $remarks = [
	{pkg => 'For::Test', name => '',    line => '4', remark => 'The package for testing'},
	{pkg => 'For::Test', name => 'abc', line => '9', remark => "Is property\n  readonly"},
];

local ($::_g0 = do {\@{$reader_remarks}}, $::_e0 = do {$remarks}); ::is_deeply $::_g0, $::_e0, '\@{$reader_remarks} # --> $remarks' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

my $reader_mtime = Aion::Annotation::Reader->new(Aion::Annotation::Reader::READ_MTIME);

# Время хранится как unixtime, поэтому ожидаемое значение не зависит от часового пояса
my $mtime = [{pkg => 'For::Test', mtime => timelocal(5, 4, 3, 2, 0, 2025)}];

local ($::_g0 = do {\@{$reader_mtime}}, $::_e0 = do {$mtime}); ::is_deeply $::_g0, $::_e0, '\@{$reader_mtime} # --> $mtime' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

# 
# # DESCRIPTION



( run in 1.435 second using v1.01-cache-2.11-cpan-28bccf0f6e5 )