Acme-Sort-Bozo

 view release on metacpan or  search on metacpan

t/00-load.t  view on Meta::CPAN

my $caught;
try {
    Acme::Sort::Bozo::compare( 'A' );
} catch {
    $caught = $_;
};

like(
    $caught,
    qr/requires two/,
    "compare() throws exception if given other than two args to compare."
);


note( "Testing Acme::Sort::Bozo::is_ordered() -- Default ascending order." );
my $compare = \&Acme::Sort::Bozo::compare;
is( 
    Acme::Sort::Bozo::is_ordered( $compare, [ qw/ A B C D E / ] ), 
    1, 
    "is_ordered( \&compare, [ qw/ A B C D E / ] ) returns true." 
);

t/00-load.t  view on Meta::CPAN

    "is_ordered( \&compare, [ qw/ E D C B A / ] ) returns false."
);

undef $caught;
try {
    Acme::Sort::Bozo::is_ordered( [ qw/ A B C D E / ] );
} catch { $caught = $_ };
like( 
    $caught, 
    qr/expects a coderef/, 
    "is_ordered() throws exception when not handed a coderef as first param."
);

undef $caught;
try {
    Acme::Sort::Bozo::is_ordered( $compare, qw/ A B C D E / );
} catch { $caught = $_ };
like(
    $caught,
    qr/expects an arrayref/,
    "is_ordered() throws an exception when not handed an arrayref as second param."
);

note "Testing Acme::Sort::Bozo::swap()";
my $listref = [qw/ A B C D E / ];
my $orig = join '', @{$listref};
my $new = join '', @{ Acme::Sort::Bozo::swap( $listref ) };
isnt( $new, $orig, "Swap successfully swapped two elements." );





( run in 0.341 second using v1.01-cache-2.11-cpan-496ff517765 )