gen_literal s =
"{" ++ show (length s) ++ "}\r\n" ++ s
+gen_string3501 :: String -> Bool -> String
+gen_string3501 s True = gen_quoted s
+gen_string3501 s False = gen_literal s
+
prop_string3501 :: String -> Bool -> Result
-prop_string3501 s True = p string3501 (gen_quoted s) @?= Just s
-prop_string3501 s False = p string3501 (gen_literal s) @?= Just s
+prop_string3501 s useQuoted = p string3501 (gen_string3501 s useQuoted) @?= Just s
prop_atom :: String -> Result
prop_atom s =
prop_astring_basic :: String -> Result
prop_astring_basic s =
- p astring s @?= if isvalid
+ p astring s @?= if isValidAtom s
then Just s
else Nothing
- where isvalid = not (null s) && all isValidChar s
- isValidChar c =
+
+isValidAtom s = not (null s) && all isValidChar s
+ where isValidChar c =
c `notElem` atomSpecials ||
c `elem` respSpecials
+prop_astring :: String -> Bool -> Result
+prop_astring s useQuoted =
+ if isValidAtom s
+ then p astring s @=? Just s
+ else p astring (gen_string3501 s useQuoted) @=? Just s
+
+prop_text :: String -> Result
+prop_text s =
+ p text s @=? if isValid
+ then Just 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 basic" prop_astring_basic,
+ q "astring full" prop_astring,
+ q "text" prop_text,
+ q "tag" prop_tag
]
+