summaryrefslogtreecommitdiff
path: root/t/parser.t
blob: 24c70fe26c6bbf9fae990b9c0504b8d7cc571208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!raku 
use v6.d;
use Test;
use MaildirIndexer::Parser;
use MaildirIndexer::Email;
 
subtest 'from string' => {
    ok !parse-email(''), "empty string won't parse";
 
    my $message = q:to<EOM>;
    bad stuff
    EOM
    ok !parse-email($message), "bad message won't parse";
 
    $message = q:to<EOM>;
    Head: value
 
    EOM
    is-deeplyparse-email($message),
               MaildirIndexer::Email.new(:headers(Head=>'value'),:body('')),
               "minimal message should parse" );
 
    $message = q:to<EOM>;
    Head: value
              continued
    And: more
 
    some body
    on two lines
    EOM
    is-deeplyparse-email($message),
               MaildirIndexer::Email.new(
                   :headers(%(
                       Head => 'value continued',
                       And => 'more',
                   )),
                   :body("some body\non two lines"),
               ),
               "full message should parse" );
 
    $message = q:to<EOM>;
    Head: value
              continued
    crap crap crap
    And: more
 
    some body
    on two lines
    EOM
    is-deeplyparse-email($message),
               MaildirIndexer::Email.new(
                   :headers(%(
                       Head => 'value continued',
                       And => 'more',
                   )),
                   :body("some body\non two lines"),
               ),
               "message wtih junk between headers should parse" );
}
 
done-testing;