-# Copyright (C) 2016 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use warnings;
use Test::More;
-use_ok('PublicInbox::SearchMsg');
use_ok('PublicInbox::SearchThread');
use Email::Simple;
my $mt = eval {
}
);
-my $th = PublicInbox::SearchThread->new(\@msgs);
-$th->thread;
-$th->order(sub { [ sort { $a->{id} cmp $b->{id} } @{$_[0]} ] });
-my $st = '';
-my @q = map { (0, $_) } @{$th->{rootset}};
-while (@q) {
- my $level = shift @q;
- my $node = shift @q or next;
- $st .= (" "x$level). "$node->{id}\n";
- my $cl = $level + 1;
- unshift @q, map { ($cl, $_) } @{$node->{children}}
-}
+my $st = thread_to_s(\@msgs);
SKIP: {
skip 'Mail::Thread missing', 1 unless $mt;
$mt->order(sub { sort { $a->messageid cmp $b->messageid } @_ });
my $check = '';
- @q = map { (0, $_) } $mt->rootset;
+ my @q = map { (0, $_) } $mt->rootset;
while (@q) {
my $level = shift @q;
my $node = shift @q or next;
done_testing();
-1;
+sub thread_to_s {
+ my ($msgs) = @_;
+ my $rootset = PublicInbox::SearchThread::thread($msgs, sub {
+ [ sort { $a->{id} cmp $b->{id} } @{$_[0]} ] });
+ my $st = '';
+ my @q = map { (0, $_) } @$rootset;
+ while (@q) {
+ my $level = shift @q;
+ my $node = shift @q or next;
+ $st .= (" "x$level). "$node->{id}\n";
+ my $cl = $level + 1;
+ unshift @q, map { ($cl, $_) } @{$node->{children}};
+ }
+ $st;
+}