]> code.delx.au - offlineimap/commitdiff
Added tag and test for it. All tests pass.
authorJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 06:09:16 +0000 (01:09 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 06:09:16 +0000 (01:09 -0500)
src/Network/IMAP/Parser/Prim.hs
testsrc/TestParserPrim.hs

index 204b0af8d0923880492f7e1b7ddd664881c2daed..13946f509e6bd7bd37edfd2e103c3fc86627a5fc 100644 (file)
@@ -121,3 +121,7 @@ quotedChar =
 textChar = noneOf crlf
 
 text = many1 textChar
+
+tag = many1 tagChar
+    where tagChar = (char '+' >> fail "No + for tag") <|> 
+                    astringChar
\ No newline at end of file
index 36d44600c4f09a3ef9c0171cf3359df009af0232..8737c9318ab8ae78dcecdc4511ae4ed157fb72fd 100644 (file)
@@ -95,12 +95,23 @@ prop_text s =
                  else Nothing
     where isValid = not (null s) && all (`notElem` crlf) s
 
+prop_tag :: String -> Result
+prop_tag s =
+    p tag s @=? if isValid
+      then Just s
+      else Nothing
+    where isValid = not (null s) && all isValidChar s
+          isValidChar c =
+              c `notElem` ('+' : atomSpecials) ||
+              c `elem` respSpecials
+
 allt = [q "quoted" prop_quoted,
         q "literal" prop_literal,
         q "string3501" prop_string3501,
         q "atom" prop_atom,
         q "astring basic" prop_astring_basic,
         q "astring full" prop_astring,
-        q "text" prop_text
+        q "text" prop_text,
+        q "tag" prop_tag
        ]