Algorithm-Dependency

 view release on metacpan or  search on metacpan

LICENSE  view on Meta::CPAN

MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

        Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it

t/02_api.t  view on Meta::CPAN

use Algorithm::Dependency               ();
use Algorithm::Dependency::Ordered      ();
use Algorithm::Dependency::Source::File ();
use Algorithm::Dependency::Source::HoA  ();

# Execute the tests
Test::ClassAPI->execute('complete');
exit(0);

# Now, define the API for the classes
__DATA__

Algorithm::Dependency=class
Algorithm::Dependency::Item=abstract
Algorithm::Dependency::Ordered=class
Algorithm::Dependency::Source=abstract
Algorithm::Dependency::Source::File=class
Algorithm::Dependency::Source::HoA=class

[Algorithm::Dependency]
new=method

t/03_basics.t  view on Meta::CPAN

	$|  = 1;
	$^W = 1;
}

use Test::More tests => 118;
use File::Spec::Functions ':ALL';
use Algorithm::Dependency;
use Algorithm::Dependency::Source::File;

# Where is the test data located
my $TESTDATA = catdir( 't', 'data' );
ok( -d $TESTDATA, 'Found test data directory' );





# Load the data/basics.txt file in as a source file, and test it rigorously.
my $file = File::Spec->catfile( $TESTDATA, 'basics.txt' );
my $Source = Algorithm::Dependency::Source::File->new( $file );

ok( $Source, "Source is true" );
ok( ref $Source, "Source is a reference" );
isa_ok( $Source, 'Algorithm::Dependency::Source::File' );
isa_ok( $Source, 'Algorithm::Dependency::Source' );
ok( exists $Source->{loaded}, "Source has a loaded value" );
ok( ! $Source->{loaded}, "Source isn't loaded" );

ok( eval {$Source->load;}, "Source ->load returns true" );

t/03_basics.t  view on Meta::CPAN

	$rv = $Dep->schedule( @{ $data->[0] } );
	ok( $rv, "Dependency->schedule($args) returns something" );
	is_deeply( $rv, $data->[2], "Dependency->schedule($args) returns expected values" );
}

# Does missing dependencies return defined but false for a source we
# know doesn't have any missing dependencies
is( $Source->missing_dependencies, 0, "->missing_dependencies returns as expected when nothing missing" );

# Load the source we know has missing dependencies
$file = File::Spec->catfile( $TESTDATA, 'missing.txt' );
my $Missing = Algorithm::Dependency::Source::File->new( $file );
ok( $Missing, "Missing is true" );
ok( ref $Missing, "Missing is a reference" );
isa_ok( $Missing, 'Algorithm::Dependency::Source::File' );
isa_ok( $Missing, 'Algorithm::Dependency::Source' );
ok( eval {$Missing->load;}, "Missing ->load returns true" );

is_deeply( $Missing->missing_dependencies, [ 'C', 'E' ], "->missing_dependencies returns as expected when something missing" );

t/04_complex.t  view on Meta::CPAN

	$|  = 1;
	$^W = 1;
}

use Test::More tests => 170;
use File::Spec::Functions ':ALL';
use Algorithm::Dependency;
use Algorithm::Dependency::Source::File;

# Where is the test data located
my $TESTDATA = catdir( 't', 'data' );
ok( -d $TESTDATA, 'Found test data directory' );





# Load the data/complex.txt file in as a source file
my $file = File::Spec->catfile( $TESTDATA, 'complex.txt' );
my $Source = Algorithm::Dependency::Source::File->new( $file );
ok( $Source, "Complex source created" );
ok( eval {$Source->load;}, "Complex source loads" );

# Try it's unordere dependency with nothing selected
my $Dep = Algorithm::Dependency->new( source => $Source );
ok( $Dep, "Algorithm::Dependency->new returns true" );
ok( ref $Dep, "Algorithm::Dependency->new returns reference" );
isa_ok( $Dep, 'Algorithm::Dependency');

t/05_ordered.t  view on Meta::CPAN

	$|  = 1;
	$^W = 1;
}

use Test::More tests => 209;
use File::Spec::Functions ':ALL';
use Algorithm::Dependency::Ordered;
use Algorithm::Dependency::Source::File;

# Where is the test data located
my $TESTDATA = catdir( 't', 'data' );
ok( -d $TESTDATA, 'Found test data directory' );





# Load the source files
my $basic = File::Spec->catfile( $TESTDATA, 'basics.txt' );
my $BSource = Algorithm::Dependency::Source::File->new( $basic );
ok( $BSource, "Basic source created" );
ok( eval {$BSource->load;}, "Basic source loads" );
my $complex = File::Spec->catfile( $TESTDATA, 'complex.txt' );
my $CSource = Algorithm::Dependency::Source::File->new( $complex );
ok( $CSource, "Complex source created" );
ok( eval {$CSource->load;}, "Complex source loads" );





# Test the creation of a basic ordered dependency tree
my $BDep = Algorithm::Dependency::Ordered->new( source => $BSource, selected => ['B'] );

t/06_ignore_orphans.t  view on Meta::CPAN

	$^W = 1;
}

use Test::More tests => 11;
use File::Spec::Functions ':ALL';
use Algorithm::Dependency;
use Algorithm::Dependency::Ordered;
use Algorithm::Dependency::Source::File;

# Where is the test data located
my $TESTDATA = catdir( 't', 'data' );
ok( -d $TESTDATA, 'Found test data directory' );





# Load the source file
my $basic = File::Spec->catfile( $TESTDATA, 'missing.txt' );
my $Source = Algorithm::Dependency::Source::File->new( $basic );
isa_ok( $Source, 'Algorithm::Dependency::Source::File' );

# Can we see the missing dependency in the source file
is_deeply( $Source->missing_dependencies, [ 'C', 'E' ], 'The source file has missing dependencies as expected' );

# Test normal and ordered types
foreach my $class ( 'Algorithm::Dependency', 'Algorithm::Dependency::Ordered' ) {
	my $Normal = $class->new(
		source   => $Source,

t/08_weight.t  view on Meta::CPAN

	$|  = 1;
	$^W = 1;
}

use Test::More tests => 55;
use File::Spec::Functions ':ALL';
use Algorithm::Dependency::Weight;
use Algorithm::Dependency::Source::File;

# Where is the test data located
my $TESTDATA = catdir( 't', 'data' );
ok( -d $TESTDATA, 'Found test data directory' );





# Load the data/basics.txt file in as a source file, and test it rigorously.
my $file = File::Spec->catfile( $TESTDATA, 'basics.txt' );
my $Source = Algorithm::Dependency::Source::File->new( $file );
isa_ok( $Source, 'Algorithm::Dependency::Source::File' );
isa_ok( $Source, 'Algorithm::Dependency::Source' );
my @items = $Source->items;
is( scalar(@items), 6, "Source ->items returns a list" );
is( scalar($Source->items), 6, "Source ->items returns a list" );

# Create a Weight object
my $algorithm = Algorithm::Dependency::Weight->new( source => $Source );
isa_ok( $algorithm, 'Algorithm::Dependency::Weight'         );

t/08_weight.t  view on Meta::CPAN

is_deeply( $algorithm->weight_all, $basic, 'Got weight for all' );
delete $basic->{B};
delete $basic->{D};
is_deeply( $algorithm->weight_hash(qw{A C E F}), $basic, 'basic: Got weight for selected' );





# Larger scale processing
$file = File::Spec->catfile( $TESTDATA, 'complex.txt' );
$Source = Algorithm::Dependency::Source::File->new( $file );
isa_ok( $Source, 'Algorithm::Dependency::Source::File' );
isa_ok( $Source, 'Algorithm::Dependency::Source' );
@items = $Source->items;
is( scalar(@items), 20, "Source ->items returns a list" );
is( scalar($Source->items), 20, "Source ->items returns a list" );
$algorithm = Algorithm::Dependency::Weight->new( source => $Source );
isa_ok( $algorithm, 'Algorithm::Dependency::Weight'         );
isa_ok( $algorithm->source, 'Algorithm::Dependency::Source' );
my $complex = {

t/08_weight.t  view on Meta::CPAN

		$complex->{$item},
		"complex: Got weight for '$item'",
	);
}
	




# Test weightings in circulars
$file = File::Spec->catfile( $TESTDATA, 'circular.txt' );
$Source = Algorithm::Dependency::Source::File->new( $file );
isa_ok( $Source, 'Algorithm::Dependency::Source::File' );
isa_ok( $Source, 'Algorithm::Dependency::Source' );
@items = $Source->items;
is( scalar(@items), 8, "Source ->items returns a list" );
is( scalar($Source->items), 8, "Source ->items returns a list" );
$algorithm = Algorithm::Dependency::Weight->new( source => $Source );
isa_ok( $algorithm, 'Algorithm::Dependency::Weight'         );
isa_ok( $algorithm->source, 'Algorithm::Dependency::Source' );
my $circular = {

xt/author/pod-spell.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;

# generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007005
use Test::Spelling 0.12;
use Pod::Wordlist;


add_stopwords(<DATA>);
all_pod_files_spelling_ok( qw( examples lib script t xt ) );
__DATA__
ARRAYs
Adam
Algorithm
Dependency
Etheridge
File
HoA
Invert
Item
Karen



( run in 1.105 second using v1.01-cache-2.11-cpan-140bd7fdf52 )