diff --git a/Changes b/Changes index 117428a..d576076 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +1.2203: Mon Oct 07 2013 + - https://rt.cpan.org/Public/Bug/Display.html?id=89296 + 1.2202: Wed Oct 02 2013 - really minor pod fix https://rt.cpan.org/Public/Bug/Display.html?id=89195 diff --git a/MANIFEST b/MANIFEST index cf916b5..7557588 100644 --- a/MANIFEST +++ b/MANIFEST @@ -37,6 +37,7 @@ t/55_uid_stuff.t t/60_fetch_with_grammar.t t/70_list2range.t t/75_back_and_forth.t +t/80_top.t t/critic.t t/pod.t t/pod_coverage.t diff --git a/Simple.pm b/Simple.pm index 851a1fb..0f9a9a2 100644 --- a/Simple.pm +++ b/Simple.pm @@ -9,7 +9,7 @@ use IO::Socket; use IO::Select; use Net::IMAP::Simple::PipeSocket; -our $VERSION = "1.2202"; +our $VERSION = "1.2203"; BEGIN { # I'd really rather the pause/cpan indexers miss this "package" @@ -480,6 +480,7 @@ sub noop { sub top { my ( $self, $number ) = @_; + my $messages = $number || '1:' . $self->_last; my @lines; @@ -496,12 +497,13 @@ sub top { ## rfc2822 ## sections 3 and 4 of this standard. return $self->_process_cmd( - cmd => [ FETCH => qq[$number RFC822.HEADER] ], + cmd => [ FETCH => qq[$messages RFC822.HEADER] ], final => sub { - $lines[-1] =~ s/\)\x0d\x0a\z//; # sometimes we get this and I don't think we should + $lines[-1] =~ s/\)\x0d\x0a\z// # sometimes we get this and I don't think we should # I really hoping I'm not breaking someting by doing this. + if @lines; - \@lines + return wantarray ? @lines : \@lines }, process => sub { return if $_[0] =~ m/\*\s+\d+\s+FETCH/i; # should this really be case insensitive? diff --git a/t/80_top.t b/t/80_top.t new file mode 100644 index 0000000..4b90bac --- /dev/null +++ b/t/80_top.t @@ -0,0 +1,28 @@ +BEGIN { unless( $ENV{I_PROMISE_TO_TEST_SINGLE_THREADED} ) { print "1..1\nok 1\n"; exit 0; } } + +use strict; +use warnings; + +use Test; +use Net::IMAP::Simple; + +plan tests => our $tests = 1; + +our $imap; + +sub run_tests { + $imap->create_mailbox("blarg"); + my $n = $imap->select("blarg"); + $imap->delete("1:$n"); + $imap->expunge_mailbox; + + $imap->select("blarg"); + $imap->put( blarg => "Subject: test$_\n\ntest$_" ) for 1..2; + + my @r = $imap->top; + my @a = "@r" =~ m/(test\d+)/g; + + ok( "@a", "test1 test2" ); +} + +do "t/test_runner.pm";