diff options
author | Tom Feist <shabble@metavore.org> | 2011-02-28 00:32:04 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2011-02-28 00:32:04 +0000 |
commit | 1063657c9145eed77b9228066488c91880093391 (patch) | |
tree | 0c83a09d88e70150bef99c3d301c2b20f714445d /testing/lib/Test/Irssi.pm | |
parent | random checkin, thinks are a bit in flux and about to change greatly so I'm (diff) | |
download | irssi-scripts-1063657c9145eed77b9228066488c91880093391.tar.gz irssi-scripts-1063657c9145eed77b9228066488c91880093391.zip |
refactor everything to make tests more test-like.
Diffstat (limited to '')
-rw-r--r-- | testing/lib/Test/Irssi.pm | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/testing/lib/Test/Irssi.pm b/testing/lib/Test/Irssi.pm index 65e22b6..d776573 100644 --- a/testing/lib/Test/Irssi.pm +++ b/testing/lib/Test/Irssi.pm @@ -104,8 +104,9 @@ class Test::Irssi { default => sub { [] }, traits => [qw/Array/], handles => { - add_pending_test => 'push', - next_pending_test => 'pop', + add_pending_test => 'push', + next_pending_test => 'shift', + tests_remaining => 'count', } ); @@ -130,7 +131,8 @@ class Test::Irssi { sub new_test { my ($self, $name, @params) = @_; my $new = Test::Irssi::Test->new(name => $name, parent => $self); - $self->add_pending_test, $new; + $self->add_pending_test($new); + return $new; } method _build_callback_obj { @@ -170,17 +172,14 @@ class Test::Irssi { } - sub log { - my ($self, $msg) = @_; - $self->_logfile_fh->say($msg); - } - - method run_test { + method complete_test { # put the completed one onto the completed pile my $old_test = $self->active_test; $self->add_completed_test($old_test); + } + method run_test { # and make the next pending one active. my $test = $self->next_pending_test; $self->active_test($test); @@ -238,11 +237,17 @@ class Test::Irssi { } method summarise_test_results { - foreach my $t_name (sort keys %{$self->tests}) { - my $t_obj = $self->tests->{$t_name}; - printf("Test %s\t\t-\t%s\n", $t_name, $t_obj->passed?"pass":"fail"); + foreach my $test ($self->completed_tests) { + my $name = $test->name; + printf("Test %s\t\t-\t%s\n", $name, $test->passed?"pass":"fail"); } } + + sub log { + my ($self, $msg) = @_; + $self->_logfile_fh->say($msg); + } + } __END__ |