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 ...@@ -18,18 +18,19 @@ from TypeDef import :: Type
*/ */
:: MultiLineString = MultiLine !String :: MultiLineString = MultiLine !String
fromMultiLine :: !MultiLineString -> String class docDescription d :: !d -> Maybe Description
class docParams d :: !d -> [Description]
class docDescription d :: !d -> Maybe Description class docVars d :: !d -> [Description]
class docParams d :: !d -> [Description] class docResults d :: !d -> [Description]
class docVars d :: !d -> [Description] class docType d :: !d -> Maybe Type
class docResults d :: !d -> [Description] class docThrows d :: !d -> [Description]
class docType d :: !d -> Maybe Type class docMembers d :: !d -> [Maybe ClassMemberDoc]
class docThrows d :: !d -> [Description] class docFields d :: !d -> Maybe [Maybe Description]
class docMembers d :: !d -> [Maybe ClassMemberDoc] class docConstructors d :: !d -> Maybe [Maybe ConstructorDoc]
class docFields d :: !d -> Maybe [Maybe Description] class docRepresentation d :: !d -> Maybe (Maybe Description)
class docConstructors d :: !d -> Maybe [Maybe ConstructorDoc] class docPropertyBootstrap d :: !d -> Maybe String
class docRepresentation d :: !d -> Maybe (Maybe Description) class docPropertyTestWith d :: !d -> [PropertyVarInstantiation]
class docProperties d :: !d -> [Property]
/** /**
* Documentation of a Clean module. * Documentation of a Clean module.
...@@ -37,9 +38,12 @@ class docRepresentation d :: !d -> Maybe (Maybe Description) ...@@ -37,9 +38,12 @@ class docRepresentation d :: !d -> Maybe (Maybe Description)
:: ModuleDoc = :: ModuleDoc =
{ description :: Maybe Description { description :: Maybe Description
, property_bootstrap :: Maybe MultiLineString //* For generating unit tests with clean-test , 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 docDescription ModuleDoc
instance docPropertyBootstrap ModuleDoc
instance docPropertyTestWith ModuleDoc
derive gDefault ModuleDoc derive gDefault ModuleDoc
/** /**
...@@ -62,6 +66,8 @@ instance docVars FunctionDoc ...@@ -62,6 +66,8 @@ instance docVars FunctionDoc
instance docResults FunctionDoc instance docResults FunctionDoc
instance docType FunctionDoc instance docType FunctionDoc
instance docThrows FunctionDoc instance docThrows FunctionDoc
instance docPropertyTestWith FunctionDoc
instance docProperties FunctionDoc
:: Property :: Property
= ForAll String [(String,Type)] String = ForAll String [(String,Type)] String
......
...@@ -33,14 +33,18 @@ gDefault{|Maybe|} _ = Nothing ...@@ -33,14 +33,18 @@ gDefault{|Maybe|} _ = Nothing
fromMultiLine :: !MultiLineString -> String fromMultiLine :: !MultiLineString -> String
fromMultiLine (MultiLine s) = s fromMultiLine (MultiLine s) = s
instance docDescription ModuleDoc where docDescription d = d.ModuleDoc.description instance docDescription ModuleDoc where docDescription d = d.ModuleDoc.description
instance docPropertyBootstrap ModuleDoc where docPropertyBootstrap d = fromMultiLine <$> d.property_bootstrap
instance docDescription FunctionDoc where docDescription d = d.FunctionDoc.description instance docPropertyTestWith ModuleDoc where docPropertyTestWith d = d.ModuleDoc.property_test_with
instance docParams FunctionDoc where docParams d = d.FunctionDoc.params
instance docVars FunctionDoc where docVars d = d.FunctionDoc.vars instance docDescription FunctionDoc where docDescription d = d.FunctionDoc.description
instance docResults FunctionDoc where docResults d = d.FunctionDoc.results instance docParams FunctionDoc where docParams d = d.FunctionDoc.params
instance docType FunctionDoc where docType d = d.FunctionDoc.type instance docVars FunctionDoc where docVars d = d.FunctionDoc.vars
instance docThrows FunctionDoc where docThrows d = d.FunctionDoc.throws 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 docDescription ClassMemberDoc where docDescription d = d.ClassMemberDoc.description
instance docParams ClassMemberDoc where docParams d = d.ClassMemberDoc.params instance docParams ClassMemberDoc where docParams d = d.ClassMemberDoc.params
...@@ -147,13 +151,14 @@ where ...@@ -147,13 +151,14 @@ where
parser :: Parser Char (String, [(String, Type)]) parser :: Parser Char (String, [(String, Type)])
parser = skipSpaces *> parser = skipSpaces *>
pMany (pSatisfy \c -> c <> ':' && not (isSpace c)) >>= \name -> pMany (pSatisfy \c -> c <> ':' && not (isSpace c)) >>= \name ->
skipSpaces *> pToken ':' *> skipSpaces *> pToken 'A' *> pToken '.' *> skipSpaces *> pToken ':' *>
((skipSpaces *> pToken 'A' *> pToken '.' *>
pMany pMany
(skipSpaces *> (skipSpaces *>
(liftA2 tuple (liftA2 tuple
(toString <$> pMany (pSatisfy (not o isSpace))) (toString <$> pMany (pSatisfy (not o isSpace)))
(pList [skipSpaces,pToken ':',pToken ':',skipSpaces] *> pTypeWithColonOrSemicolon) (pList [skipSpaces,pToken ':',pToken ':',skipSpaces] *> pTypeWithColonOrSemicolon)
) <* skipSpaces) >>= \args -> ) <* skipSpaces)) <|> skipSpaces *> pure []) >>= \args ->
pure (toString name, args) pure (toString name, args)
skipSpaces = pMany (pSatisfy isSpace) *> pYield undef 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