Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 6f49cae0f4
Fetching contributors…

Cannot retrieve contributors at this time

executable file 40 lines (32 sloc) 0.927 kB
#!/usr/bin/env perl
use strict;
use warnings;
no warnings 'redefine';
# TODO : I don't think this use lib is a good idea.
use lib '../lib';
use vars qw(@args);
use Test::More 'no_plan';
BEGIN {
note( "Testing Devel::Trepan::CmdProcessor::Hook" );
use_ok( 'Devel::Trepan::CmdProcessor::Hook' );
}
@args = ();
my $hook1 = sub {
my ($name, $a) = @_;
push @args, $name;
};
my $hooks = Devel::Trepan::CmdProcessor::Hook->new();
is(scalar(@{$hooks->{list}}), 0, "Initialized hooks should have empty list");
$hooks->insert(-1, 'hook1', $hook1);
is(scalar(@{$hooks->{list}}), 1, "hooks should have 1 item");
$hooks->run;
is (scalar @args, 1);
is ($args[0], 'hook1');
$hooks->insert_if_new(-1, 'hook1', $hook1);
is(scalar(@{$hooks->{list}}), 1, "hooks should still have 1 item");
@args = ();
$hooks->insert_if_new(-1, 'hook2', $hook1);
$hooks->run;
is (scalar @args, 2);
is ($args[0], 'hook2');
is ($args[1], 'hook1');
Jump to Line
Something went wrong with that request. Please try again.