Verified Commit 6987d49d authored by Camil Staps's avatar Camil Staps 🙂

Allow properties without arguments; allow @property-test-with on module level

parent 34a479b0
......@@ -18,18 +18,19 @@ from TypeDef import :: Type
*/
:: MultiLineString = MultiLine !String
fromMultiLine :: !MultiLineString -> String
class docDescription d :: !d -> Maybe Description
class docParams d :: !d -> [Description]
class docVars d :: !d -> [Description]
class docResults d :: !d -> [Description]
class docType d :: !d -> Maybe Type
class docThrows d :: !d -> [Description]
class docMembers d :: !d -> [Maybe ClassMemberDoc]
class docFields d :: !d -> Maybe [Maybe Description]
class docConstructors d :: !d -> Maybe [Maybe ConstructorDoc]
class docRepresentation d :: !d -> Maybe (Maybe Description)
class docDescription d :: !d -> Maybe Description
class docParams d :: !d -> [Description]
class docVars d :: !d -> [Description]
class docResults d :: !d -> [Description]
class docType d :: !d -> Maybe Type
class docThrows d :: !d -> [Description]
class docMembers d :: !d -> [Maybe ClassMemberDoc]
class docFields d :: !d -> Maybe [Maybe Description]
class docConstructors d :: !d -> Maybe [Maybe ConstructorDoc]
class docRepresentation d :: !d -> Maybe (Maybe Description)
class docPropertyBootstrap d :: !d -> Maybe String
class docPropertyTestWith d :: !d -> [PropertyVarInstantiation]
class docProperties d :: !d -> [Property]
/**
* Documentation of a Clean module.
......@@ -37,9 +38,12 @@ class docRepresentation d :: !d -> Maybe (Maybe Description)
:: ModuleDoc =
{ description :: Maybe Description
, property_bootstrap :: Maybe MultiLineString //* For generating unit tests with clean-test
, property_test_with :: [PropertyVarInstantiation] //* With which types to test the properties
}
instance docDescription ModuleDoc
instance docPropertyBootstrap ModuleDoc
instance docPropertyTestWith ModuleDoc
derive gDefault ModuleDoc
/**
......@@ -62,6 +66,8 @@ instance docVars FunctionDoc
instance docResults FunctionDoc
instance docType FunctionDoc
instance docThrows FunctionDoc
instance docPropertyTestWith FunctionDoc
instance docProperties FunctionDoc
:: Property
= ForAll String [(String,Type)] String
......
......@@ -33,14 +33,18 @@ gDefault{|Maybe|} _ = Nothing
fromMultiLine :: !MultiLineString -> String
fromMultiLine (MultiLine s) = s
instance docDescription ModuleDoc where docDescription d = d.ModuleDoc.description
instance docDescription FunctionDoc where docDescription d = d.FunctionDoc.description
instance docParams FunctionDoc where docParams d = d.FunctionDoc.params
instance docVars FunctionDoc where docVars d = d.FunctionDoc.vars
instance docResults FunctionDoc where docResults d = d.FunctionDoc.results
instance docType FunctionDoc where docType d = d.FunctionDoc.type
instance docThrows FunctionDoc where docThrows d = d.FunctionDoc.throws
instance docDescription ModuleDoc where docDescription d = d.ModuleDoc.description
instance docPropertyBootstrap ModuleDoc where docPropertyBootstrap d = fromMultiLine <$> d.property_bootstrap
instance docPropertyTestWith ModuleDoc where docPropertyTestWith d = d.ModuleDoc.property_test_with
instance docDescription FunctionDoc where docDescription d = d.FunctionDoc.description
instance docParams FunctionDoc where docParams d = d.FunctionDoc.params
instance docVars FunctionDoc where docVars d = d.FunctionDoc.vars
instance docResults FunctionDoc where docResults d = d.FunctionDoc.results
instance docType FunctionDoc where docType d = d.FunctionDoc.type
instance docThrows FunctionDoc where docThrows d = d.FunctionDoc.throws
instance docProperties FunctionDoc where docProperties d = d.properties
instance docPropertyTestWith FunctionDoc where docPropertyTestWith d = d.FunctionDoc.property_test_with
instance docDescription ClassMemberDoc where docDescription d = d.ClassMemberDoc.description
instance docParams ClassMemberDoc where docParams d = d.ClassMemberDoc.params
......@@ -147,13 +151,14 @@ where
parser :: Parser Char (String, [(String, Type)])
parser = skipSpaces *>
pMany (pSatisfy \c -> c <> ':' && not (isSpace c)) >>= \name ->
skipSpaces *> pToken ':' *> skipSpaces *> pToken 'A' *> pToken '.' *>
skipSpaces *> pToken ':' *>
((skipSpaces *> pToken 'A' *> pToken '.' *>
pMany
(skipSpaces *>
(liftA2 tuple
(toString <$> pMany (pSatisfy (not o isSpace)))
(pList [skipSpaces,pToken ':',pToken ':',skipSpaces] *> pTypeWithColonOrSemicolon)
) <* skipSpaces) >>= \args ->
) <* skipSpaces)) <|> skipSpaces *> pure []) >>= \args ->
pure (toString name, args)
skipSpaces = pMany (pSatisfy isSpace) *> pYield undef
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment