added all files
This commit is contained in:
parent
1d1f33c2ba
commit
910e8b0189
13 changed files with 173 additions and 32 deletions
6
a-simple-test/.gitignore
vendored
6
a-simple-test/.gitignore
vendored
|
@ -1,6 +0,0 @@
|
|||
.cabal-sandbox
|
||||
cabal.sandbox.config
|
||||
dist
|
||||
*.swp
|
||||
*~
|
||||
.ghci
|
|
@ -1,21 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -14,8 +14,17 @@ maintainer: Yann.Esposito@gmail.com
|
|||
category: Unknown
|
||||
build-type: Simple
|
||||
-- extra-source-files:
|
||||
data-files: scaffold/gitignore
|
||||
, scaffold/LICENSE
|
||||
data-files: scaffold/LICENSE
|
||||
, scaffold/Setup.hs
|
||||
, scaffold/gitignore
|
||||
, scaffold/project.cabal
|
||||
, scaffold/src/Main.hs
|
||||
, scaffold/src/ModuleName.hs
|
||||
, scaffold/src/ModuleName/Coconut.hs
|
||||
, scaffold/src/ModuleName/Swallow.hs
|
||||
, scaffold/test/ModuleName/Coconut/Test.hs
|
||||
, scaffold/test/ModuleName/Swallow/Test.hs
|
||||
, scaffold/test/Test.hs
|
||||
cabal-version: >=1.10
|
||||
|
||||
executable holy-project
|
||||
|
|
2
scaffold/Setup.hs
Normal file
2
scaffold/Setup.hs
Normal file
|
@ -0,0 +1,2 @@
|
|||
import Distribution.Simple
|
||||
main = defaultMain
|
67
scaffold/project.cabal
Normal file
67
scaffold/project.cabal
Normal file
|
@ -0,0 +1,67 @@
|
|||
-- Initial project.cabal generated by holy-project.
|
||||
-- For further documentation, see http://haskell.org/cabal/users-guide/
|
||||
|
||||
name: project
|
||||
version: 0.1.0.0
|
||||
synopsis: {{synopsis}}
|
||||
-- description:
|
||||
homepage: http://github.com/{{ghaccount}}/project
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: {{author}}
|
||||
maintainer: {{mail}}
|
||||
-- copyright:
|
||||
category: Unknown
|
||||
build-type: Simple
|
||||
-- extra-source-files:
|
||||
cabal-version: >=1.10
|
||||
|
||||
executable project
|
||||
main-is: Main.hs
|
||||
-- other-modules:
|
||||
-- other-extensions:
|
||||
build-depends: base >=4.6 && <4.7
|
||||
hs-source-dirs: src
|
||||
ghc-options: -Wall
|
||||
default-language: Haskell2010
|
||||
|
||||
library
|
||||
exposed-modules: Project
|
||||
, Project.Swallow
|
||||
, Project.Coconut
|
||||
-- other-modules:
|
||||
-- other-extensions:
|
||||
build-depends: base >=4.6 && <4.7
|
||||
ghc-options: -Wall
|
||||
hs-source-dirs: src
|
||||
default-language: Haskell2010
|
||||
|
||||
executable test-project
|
||||
hs-source-dirs: test
|
||||
ghc-options: -Wall
|
||||
main-is: Test.hs
|
||||
default-language: Haskell2010
|
||||
build-depends: base ==4.6.*, Cabal >= 1.16.0
|
||||
, project
|
||||
, HUnit
|
||||
, QuickCheck
|
||||
, smallcheck
|
||||
, tasty
|
||||
, tasty-hunit
|
||||
, tasty-quickcheck
|
||||
, tasty-smallcheck
|
||||
test-suite Tests
|
||||
hs-source-dirs: test
|
||||
ghc-options: -Wall
|
||||
main-is: Test.hs
|
||||
Type: exitcode-stdio-1.0
|
||||
default-language: Haskell2010
|
||||
build-depends: base ==4.6.*, Cabal >= 1.16.0
|
||||
, project
|
||||
, HUnit
|
||||
, QuickCheck
|
||||
, smallcheck
|
||||
, tasty
|
||||
, tasty-hunit
|
||||
, tasty-quickcheck
|
||||
, tasty-smallcheck
|
6
scaffold/src/Main.hs
Normal file
6
scaffold/src/Main.hs
Normal file
|
@ -0,0 +1,6 @@
|
|||
module Main where
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStrLn "You fight with the strength of many men sir Knight..."
|
||||
putStrLn "You have proved yourself worthy; will you join me?"
|
||||
putStrLn "You make me sad. So be it. Come, Patsy."
|
3
scaffold/src/ModuleName.hs
Normal file
3
scaffold/src/ModuleName.hs
Normal file
|
@ -0,0 +1,3 @@
|
|||
module {{moduleName}} where
|
||||
import {{moduleName}}.Swallow ()
|
||||
import {{moduleName}}.Coconut ()
|
8
scaffold/src/ModuleName/Coconut.hs
Normal file
8
scaffold/src/ModuleName/Coconut.hs
Normal file
|
@ -0,0 +1,8 @@
|
|||
module {{moduleName}}.Coconut (coconut,coconutfunc,CoconutDataStruct(..)) where
|
||||
data CoconutDataStruct = CoconutConstr [Integer] deriving (Show)
|
||||
|
||||
coconut :: Integer
|
||||
coconut = 10
|
||||
|
||||
coconutfunc :: CoconutDataStruct -> Int
|
||||
coconutfunc (CoconutConstr l) = length l
|
4
scaffold/src/ModuleName/Swallow.hs
Normal file
4
scaffold/src/ModuleName/Swallow.hs
Normal file
|
@ -0,0 +1,4 @@
|
|||
module {{moduleName}}.Swallow (swallow) where
|
||||
|
||||
swallow :: String -> String -> String
|
||||
swallow prefix suffix = prefix ++ suffix
|
31
scaffold/test/ModuleName/Coconut/Test.hs
Normal file
31
scaffold/test/ModuleName/Coconut/Test.hs
Normal file
|
@ -0,0 +1,31 @@
|
|||
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
module {{moduleName}}.Coconut.Test
|
||||
(coconutSuite)
|
||||
where
|
||||
|
||||
import Test.Tasty (testGroup, TestTree)
|
||||
import Test.Tasty.HUnit
|
||||
import Test.Tasty.SmallCheck as SC
|
||||
|
||||
import {{moduleName}}.Coconut
|
||||
|
||||
-- Make instance of CoconutDataStruct
|
||||
-- we simply use consN Constr where N is the arity of Constr (SmallCheck)
|
||||
-- we also needed the
|
||||
-- {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
|
||||
import Test.SmallCheck.Series
|
||||
instance Monad m => Serial m CoconutDataStruct where series = cons1 CoconutConstr
|
||||
-- Now we could test properties with smallcheck on CoconutDataStruct type.
|
||||
|
||||
coconutSuite :: TestTree
|
||||
coconutSuite = testGroup "coconut"
|
||||
[ testCase "coconut" testCoconut
|
||||
, SC.testProperty "coconut property" prop_coconut
|
||||
]
|
||||
|
||||
testCoconut :: Assertion
|
||||
testCoconut = coconut @=? 10
|
||||
|
||||
prop_coconut :: Property IO
|
||||
prop_coconut = forAll $ \coconutStruct -> coconutfunc coconutStruct >= 0
|
13
scaffold/test/ModuleName/Swallow/Test.hs
Normal file
13
scaffold/test/ModuleName/Swallow/Test.hs
Normal file
|
@ -0,0 +1,13 @@
|
|||
module {{moduleName}}.Swallow.Test
|
||||
(swallowSuite)
|
||||
where
|
||||
import Test.Tasty (testGroup, TestTree)
|
||||
import Test.Tasty.HUnit
|
||||
import {{moduleName}}.Swallow
|
||||
|
||||
swallowSuite :: TestTree
|
||||
swallowSuite = testGroup "Swallow"
|
||||
[testCase "swallow test" testSwallow]
|
||||
|
||||
testSwallow :: Assertion
|
||||
testSwallow = "something" @=? swallow "some" "thing"
|
15
scaffold/test/Test.hs
Normal file
15
scaffold/test/Test.hs
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Main where
|
||||
|
||||
import Test.Tasty (defaultMain,testGroup,TestTree)
|
||||
|
||||
import {{moduleName}}.Swallow.Test
|
||||
import {{moduleName}}.Coconut.Test
|
||||
|
||||
main :: IO ()
|
||||
main = defaultMain tests
|
||||
|
||||
tests :: TestTree
|
||||
tests = testGroup "All Tests"
|
||||
[ swallowSuite
|
||||
, coconutSuite
|
||||
]
|
16
src/Main.hs
16
src/Main.hs
|
@ -125,9 +125,10 @@ capitalize str = concat (map capitalizeWord (splitOneOf " -" str))
|
|||
capitalizeWord _ = []
|
||||
|
||||
|
||||
genFile :: MuContext IO -> [Char] -> [Char] -> IO ()
|
||||
genFile context filename outputFileName = do
|
||||
putStrLn $ '\t':outputFileName
|
||||
pkgfileName <- getDataFileName filename
|
||||
pkgfileName <- getDataFileName ("scaffold/"++filename)
|
||||
template <- BS.readFile pkgfileName
|
||||
transformedFile <- hastacheStr defaultConfig template context
|
||||
LZ.writeFile outputFileName transformedFile
|
||||
|
@ -138,5 +139,14 @@ createProject p = do
|
|||
createDirectory (projectName p)
|
||||
setCurrentDirectory (projectName p)
|
||||
putStrLn "I'm not a witch, I'm not a witch!"
|
||||
genFile context "scaffold/gitignore" ".gitignore"
|
||||
genFile context "scaffold/LICENSE" "LICENSE"
|
||||
genFile context "gitignore" $ ".gitignore"
|
||||
genFile context "LICENSE" $ "LICENSE"
|
||||
genFile context "Setup.hs" $ "Setup.hs"
|
||||
genFile context "project.cabal" $ (projectName p) ++ ".cabal"
|
||||
genFile context "src/Main.hs" $ "src/Main.hs"
|
||||
genFile context "src/ModuleName.hs" $ "src/"++(moduleName p)++".hs"
|
||||
genFile context "src/ModuleName/Coconut.hs" $ "src/"++(moduleName p)++"/Coconut.hs"
|
||||
genFile context "src/ModuleName/Swallow.hs" $ "src/"++(moduleName p)++"/Swallow.hs"
|
||||
genFile context "test/ModuleName/Coconut/Test.hs" $ "test/"++(moduleName p)++"/Coconut/Test.hs"
|
||||
genFile context "test/ModuleName/Swallow/Test.hs" $ "test/"++(moduleName p)++"/Swallow/Test.hs"
|
||||
genFile context "test/Test.hs" $ "test/Test.hs"
|
||||
|
|
Loading…
Reference in a new issue