X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fthread-cycle.t;h=16ceee71f25e0c1bc46f0450729a22e625a96ae7;hb=4ba430497bfb4763691b0ad8af573eb6ff420b96;hp=0e1ecfe261507efa5e1697d999e393c3ff050176;hpb=fdd089ee175bf458d2674893e19b4af2edd82b4e;p=public-inbox.git diff --git a/t/thread-cycle.t b/t/thread-cycle.t index 0e1ecfe2..16ceee71 100644 --- a/t/thread-cycle.t +++ b/t/thread-cycle.t @@ -3,7 +3,6 @@ use strict; use warnings; use Test::More; -use_ok('PublicInbox::SearchMsg'); use_ok('PublicInbox::SearchThread'); use Email::Simple; my $mt = eval { @@ -70,22 +69,14 @@ SKIP: { is($check, $st, 'Mail::Thread output matches'); } -@msgs = map { bless $_, 'PublicInbox::SearchMsg' } ( - { mid => 'a@b' }, - { mid => 'b@c', references => ' ' }, - { mid => 'd@e', references => '' }, -); - -is(thread_to_s(\@msgs), "a\@b\n b\@c\nd\@e\n", 'ok with self-references'); - done_testing(); sub thread_to_s { - my $th = PublicInbox::SearchThread->new(shift); - $th->thread; - $th->order(sub { [ sort { $a->{id} cmp $b->{id} } @{$_[0]} ] }); + my ($msgs) = @_; + my $rootset = PublicInbox::SearchThread::thread($msgs, sub { + [ sort { $a->{id} cmp $b->{id} } @{$_[0]} ] }); my $st = ''; - my @q = map { (0, $_) } @{$th->{rootset}}; + my @q = map { (0, $_) } @$rootset; while (@q) { my $level = shift @q; my $node = shift @q or next;