summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-11-16 12:55:30 +0000
committerdakkar <dakkar@thenautilus.net>2018-11-16 12:55:30 +0000
commitca4f040604868fda6981cf2859b8147c3eab6e20 (patch)
treec6c4981b6ff93fdd342d091fc34f56c2cee7ec3a /t
parentmeta & test (diff)
downloadMaildirIndexer-ca4f040604868fda6981cf2859b8147c3eab6e20.tar.gz
MaildirIndexer-ca4f040604868fda6981cf2859b8147c3eab6e20.tar.bz2
MaildirIndexer-ca4f040604868fda6981cf2859b8147c3eab6e20.zip
test the parser
Diffstat (limited to 't')
-rw-r--r--t/parser.t61
1 files changed, 61 insertions, 0 deletions
diff --git a/t/parser.t b/t/parser.t
new file mode 100644
index 0000000..aafbb27
--- /dev/null
+++ b/t/parser.t
@@ -0,0 +1,61 @@
+#!perl6
+use v6.d.PREVIEW;
+use Test;
+use MaildirIndexer::Parser;
+use MaildirIndexer::Email;
+
+subtest 'from string' => {
+ is-deeply parse-email(''), Nil, "empty string won't parse";
+
+ my $message = q:to<EOM>;
+ bad stuff
+ EOM
+ is-deeply parse-email($message), Nil, "bad message won't parse";
+
+ $message = q:to<EOM>;
+ Head: value
+
+ EOM
+ is-deeply( parse-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-deeply( parse-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-deeply( parse-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;