From fa7b4c4482f718ffbcbfe580c37f9c2f2067ec43 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 28 Feb 2011 20:53:15 +0000 Subject: added other tests --- testing/lib/Test/Irssi.pm | 2 +- testing/lib/Test/Irssi/Driver.pm | 4 ++-- testing/test2.pl | 38 ++++++++++++++++++++++++++++++++++++ testing/test3.pl | 42 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100755 testing/test2.pl create mode 100755 testing/test3.pl diff --git a/testing/lib/Test/Irssi.pm b/testing/lib/Test/Irssi.pm index d776573..4e2030b 100644 --- a/testing/lib/Test/Irssi.pm +++ b/testing/lib/Test/Irssi.pm @@ -237,7 +237,7 @@ class Test::Irssi { } method summarise_test_results { - foreach my $test ($self->completed_tests) { + foreach my $test (@{$self->completed_tests}) { my $name = $test->name; printf("Test %s\t\t-\t%s\n", $name, $test->passed?"pass":"fail"); } diff --git a/testing/lib/Test/Irssi/Driver.pm b/testing/lib/Test/Irssi/Driver.pm index 3b6000b..1319f2a 100644 --- a/testing/lib/Test/Irssi/Driver.pm +++ b/testing/lib/Test/Irssi/Driver.pm @@ -76,7 +76,7 @@ sub STOP { $self->parent->_logfile_fh->close(); say "\n\n"; - #$self->parent->summarise_test_results(); + $self->parent->summarise_test_results(); } ### Handle terminal STDIN. Send it to the background program's STDIN. @@ -183,7 +183,7 @@ sub test_complete { } # otherwise, we're done, and can shutdown. - #$kernel->yield('shutdown'); + #kernel->yield('shutdown'); } diff --git a/testing/test2.pl b/testing/test2.pl new file mode 100755 index 0000000..661e66b --- /dev/null +++ b/testing/test2.pl @@ -0,0 +1,38 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use feature qw/say/; + +use lib 'blib/lib'; + +use Test::Irssi; + +my $tester = Test::Irssi->new + (irssi_binary => "/opt/stow/repo/irssi-debug/bin/irssi", + irssi_homedir => $ENV{HOME} . "/projects/tmp/test/irssi-debug"); + +my $test = $tester->new_test('test2'); +$test->add_input_sequence("/echo 'Window one'\n"); +$test->add_delay(5); +$test->add_input_sequence("/window new hide\n"); +$test->add_input_sequence("/win 2\n"); +for (1..10) { + $test->add_input_sequence($_); + $test->add_delay(0.2); +} +$test->add_input_sequence("\x01/echo \x05\n"); +$test->add_delay(10); +$test->add_input_sequence("\x1b\x31"); +$test->add_delay(10); +#$test->add_input_sequence("This is\x0acursor movement\x0a"); +# $test->add_delay(5); + + + +# $test->add_expected_output("Hello"); + + + +$tester->run; diff --git a/testing/test3.pl b/testing/test3.pl new file mode 100755 index 0000000..1c783ac --- /dev/null +++ b/testing/test3.pl @@ -0,0 +1,42 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use feature qw/say/; + +use lib 'blib/lib'; + +use Test::Irssi; + +my $tester = Test::Irssi->new + (irssi_binary => "/opt/stow/repo/irssi-debug/bin/irssi", + irssi_homedir => $ENV{HOME} . "/projects/tmp/test/irssi-debug"); + +say "Created test instance"; + +my $test = $tester->new_test('test1'); + +$test->add_input_sequence("/echo Hello cats\n"); +$test->add_delay(1); +$test->add_input_sequence("/echo Hello Again\n"); +$test->add_input_sequence("this is a long test"); +$test->add_pattern_match(qw/long/, 'prompt', 'prompt contains hello'); + +my $test2 = $tester->new_test('test2'); +$test2->add_delay(1); +$test2->add_input_sequence("\x01"); +$test2->add_delay(0.1); +$test2->add_input_sequence("\x0b"); +$test2->add_delay(0.1); +$test2->add_input_sequence("/clear\n"); +$test2->add_delay(0.1); +$test2->add_input_sequence("/echo moo\n"); + +# for (1..10) { +# $test->add_input_sequence("\xff"); +# $test->add_delay(0.1); + +# } + +$tester->run; -- cgit v1.2.3