diff --git a/doc/specifying-properties.tex b/doc/specifying-properties.tex index 4cc70492764aa69532b2253e7ec14e6441282f62..2db63ca735ba59d6ddbdb0920e798e8c2f72a4c4 100644 --- a/doc/specifying-properties.tex +++ b/doc/specifying-properties.tex @@ -54,6 +54,9 @@ Some imports are included automatically and do not need to be added here: \item The tested module itself. \end{itemize} +To prevent these modules from being imported, add \clean{without default imports} on the same line as \clean{@property-bootstrap}. +With this option, no modules are imported by default whatsoever. + \subsection{Advanced properties} \subsubsection{\clean{@invariant}} diff --git a/src/testproperties.icl b/src/testproperties.icl index 600ef5866a4da65e4d8a4e3756749b93a1f841cd..3bb3bcb2d51c89274e3dca8f482e6adc587feedc 100644 --- a/src/testproperties.icl +++ b/src/testproperties.icl @@ -322,13 +322,15 @@ where coverage = toReal (length (filter (not o isEmpty) propsets)) / toReal (length fes + length ies) tests = join "\n\n" [ "module " +++ testmodname - , join "\n" - [ "import Gast, Gast.CommandLine" - , "from Testing.TestEvents import :: TestLocation{..}" - , "from StdString import instance toString {#Char}" - , "import Control.GenBimap" - , "import " +++ modname - ] + , join "\n" $ + if default_imports + [ "import Gast, Gast.CommandLine" + , "from Testing.TestEvents import :: TestLocation{..}" + , "from StdString import instance toString {#Char}" + , "import Control.GenBimap" + , "import " +++ modname + ] + [] , bootstrap , generators_string , invariants @@ -343,7 +345,13 @@ where pvis = fromMaybe [] $ docPropertyTestWith <$> mod_doc props = flatten propsets - bootstrap = fromMaybe "" (docPropertyBootstrap =<< mod_doc) + (bootstrap,default_imports) = case docPropertyBootstrap =<< mod_doc of + Nothing -> + ("",True) + Just bs=:{bootstrap_content=MultiLine content} -> + ( content + , not bs.bootstrap_without_default_imports + ) invariants = join "\n\n" $ concatMap (\(_,td) -> map invariant td.TypeDoc.invariants) tes where