User Tools

Site Tools


codesnippets:codingconventions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

codesnippets:codingconventions [2024/06/02 22:58] f2b216codesnippets:codingconventions [2025/10/08 00:48] (current) – external edit 127.0.0.1
Line 244: Line 244:
     * description (''Description'')     * description (''Description'')
       * in way that it becomes a complete sentence when started with module name       * in way that it becomes a complete sentence when started with module name
-        * like in the code below it translates to ''PrettyLines is to print to a line oriented output devices (e.g. stdout), in a pretty formatted way.'' +        * like in the code below it translates to ''HPowerLib.ExportTest makes it easier to export functional tests that are not exported themselves.'' 
-    * copright according to the example below+    * copyright according to the example below
     * license     * license
       * All rights reserved       * All rights reserved
Line 261: Line 261:
     * bullets     * bullets
       * most important properties       * most important properties
-      * example +    expandable example 
-      * output of example+      * may be with output of example 
 +      * ideally using doc test 
 +        * example: <code> 
 +-- >>> fact 5 
 +-- 120  
 +</code>
  
   * Example: <code Haskell>   * Example: <code Haskell>
 {-| {-|
-Description : is to print to a line oriented output devices (e.g. stdout), in a pretty formatted way.+Description : makes it easier to export functional tests that are not exported themselves.
 Copyright   : (c) Jörg K.-H. W. Brüggmann, 2021-2024 Copyright   : (c) Jörg K.-H. W. Brüggmann, 2021-2024
 License     : All rights reserved License     : All rights reserved
Line 273: Line 278:
 Portability : POSIX Portability : POSIX
  
-supports formatting by the following type class:+makes it easier to export functional tests that are not exported themselves.
  
-    Formatting+suggested prefix: __/Exp/__
  
-        * of types that can be converted into a string by using 'format' and 'print' it to IO ().+See also module HPowerLib.ImportTests, which supports import of the tests into the test framework Tasty.
  
-* implements the following instances of type classes Formatting:+==== __Example code to export tests__
  
-    * 'DataStruct.Tree' 
- 
-* example 
  
     @     @
-module Main where+...
  
-import qualified DataStruct as Dt +module HPowerLib.Parser 
-import qualified PrettyLines as PrtLns (Formatting(..)) +    ( 
- +        ... 
-main :: IO () +        , ..
-main = do +        , testGroup_parseComposable 
-    PrtLns.print $ myTree +    ) where
- +
-data Symbol = A | B | C +
-    deriving Show+
  
 ... ...
     @     @
- 
-* creates the following output to stdout 
- 
-    @ 
-    Ah 
-    +-Ah 
-    +-Beh 
-    | +-Ah 
-    | +-Beh 
-    | +-Ceh 
-    +-Ceh 
-    +-Ah 
-    @ 
- 
 -} -}
 </code> </code>
Line 461: Line 446:
  
   * example: <code Haskell>   * example: <code Haskell>
-class Show => Format d where +-- HUnit 
-    {- |  +-- | ...capability to compare the expected value with the actual one,  
-    * formated in a human readable pretty waywhen printed to a text file or stream like _stdout_.+-- |    and to display the difference if there is one. 
 +{-|  
 +-} 
 +class Show cmp ) => HUnit cmp where 
 +    -- equals 
 +    {- | ...compares the expected value with the actual one. 
 +    * result 'True' if both values are equalotherwise 'False'
     -}     -}
-    display  +    equals  
-        -- | data to be formated in a pretty way +        :: cmp      -- ^ actual value 
-        :: d +        -> cmp      -- ^ expected value 
-        -- | formatted string representing the data +        -> Bool     -- ^ 'True' when actual value and expected value is considered equal, otherwise 'False' 
-        -> String+
 </code> </code>
  
codesnippets/codingconventions.1717361906.txt.gz · Last modified: (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki