packages feed

test-framework-th 0.2.3 → 0.2.4

raw patch · 2 files changed

+21/−10 lines, 2 files

Files

src/Test/Framework/TH.hs view
@@ -28,7 +28,7 @@ import Test.Framework (defaultMain, testGroup)  -- | Generate the usual code and extract the usual functions needed in order to run HUnit/Quickcheck/Quickcheck2.---   All functions beginning with case_ or prop_ will be extracted.+--   All functions beginning with case_, prop_ or test_ will be extracted. --   --   > {-# OPTIONS_GHC -fglasgow-exts -XTemplateHaskell #-} --   > module MyModuleTest where@@ -43,31 +43,39 @@ --   >  --   > prop_Reverse xs = reverse (reverse xs) == xs --   >   where types = xs :: [Int]+--   >+--   > test_Group =+--   >     [ testCase "1" case_Foo+--   >     , testProperty "2" prop_Reverse+--   >     ] --   ---   will automagically extract prop_Reverse, case_Foo and case_Bar and run them as well as present them as belonging to the testGroup 'MyModuleTest' such as+--   will automagically extract prop_Reverse, case_Foo, case_Bar and test_Group and run them as well as present them as belonging to the testGroup 'MyModuleTest' such as -- --   > me: runghc MyModuleTest.hs  --   > MyModuleTest: --   >   Reverse: [OK, passed 100 tests] --   >   Foo: [OK] --   >   Bar: [OK]+--   >   Group:+--   >     1: [OK]+--   >     2: [OK, passed 100 tests] --   >  --   >          Properties  Test Cases   Total       ---   >  Passed  1           2            3          +--   >  Passed  2           3            5           --   >  Failed  0           0            0           ---   >  Total   1           1            3+--   >  Total   2           3            5   --    defaultMainGenerator :: ExpQ defaultMainGenerator = -  [| defaultMain [ testGroup $(locationModule) $ $(propListGenerator) ++ $(caseListGenerator) ] |]+  [| defaultMain [ testGroup $(locationModule) $ $(propListGenerator) ++ $(caseListGenerator) ++ $(testListGenerator) ] |]  defaultMainGenerator2 :: ExpQ defaultMainGenerator2 = -  [| defaultMain [ testGroup $(locationModule) $ $(caseListGenerator) ++ $(propListGenerator) ] |]+  [| defaultMain [ testGroup $(locationModule) $ $(caseListGenerator) ++ $(propListGenerator) ++ $(testListGenerator) ] |]  -- | Generate the usual code and extract the usual functions needed for a testGroup in HUnit/Quickcheck/Quickcheck2.---   All functions beginning with case_ or prop_ will be extracted.+--   All functions beginning with case_, prop_ or test_ will be extracted. --   --   > -- file SomeModule.hs --   > fooTestGroup = $(testGroupGenerator)@@ -89,7 +97,7 @@ -- testGroupGenerator :: ExpQ testGroupGenerator =-  [| testGroup $(locationModule) $ $(propListGenerator) ++ $(caseListGenerator) |]+  [| testGroup $(locationModule) $ $(propListGenerator) ++ $(caseListGenerator) ++ $(testListGenerator) |]  listGenerator :: String -> String -> ExpQ listGenerator beginning funcName =@@ -100,6 +108,9 @@  caseListGenerator :: ExpQ caseListGenerator = listGenerator "^case_" "testCase"++testListGenerator :: ExpQ+testListGenerator = listGenerator "^test_" "testGroup"  -- | The same as --   e.g. \n f -> testProperty (fixName n) f
test-framework-th.cabal view
@@ -1,5 +1,5 @@ name: test-framework-th-version: 0.2.3+version: 0.2.4 cabal-version: >= 1.6 build-type: Simple license: BSD3@@ -10,7 +10,7 @@ description:    @test-framework-th@ contains two interesting functions: @defaultMainGenerator@ and @testGroupGenerator@.    .-   @defaultMainGenerator@ will extract all functions beginning with case_ or prop_ in the module and put them in a testGroup.+   @defaultMainGenerator@ will extract all functions beginning with case_, prop_ or test_in the module and put them in a testGroup.    .    > -- file SomeModule.hs    > ( -# LANGUAGE TemplateHaskell #- )