tests: Add a cabal new-build project
commit9425df0129bd98a465ddc583fa84013f397a667d
authorRodney Lorrimar <rodney.lorrimar@iohk.io>
dateMon 20 May 2019, 11:08 (7 years ago)
parenta2a28b5
test/shell-for/cabal.projectnew file+2
@@ -0,0 +1,2 @@
1+packages: pkga
2+ pkgb
test/shell-for/pkga/PkgA.hsnew file+16
@@ -0,0 +1,16 @@
1+module PkgA (decode) where
2+
3+import Control.Lens
4+import Data.Text.Lens
5+import Data.Char
6+import Data.Text (Text)
7+
8+decode :: Text -> Text
9+decode = unpacked . mapped %~ rot 13
10+
11+rot :: Int -> Char -> Char
12+rot n c | c >= 'a' && c <= 'z' = r 'a' 'z'
13+ | c >= 'A' && c <= 'Z' = r 'A' 'Z'
14+ | otherwise = c
15+ where
16+ r a b = chr $ ord a + ((ord c - ord a + n) `mod` (ord b - ord a + 1))
test/shell-for/pkga/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
test/shell-for/pkga/pkga.cabalnew file+20
@@ -0,0 +1,20 @@
1+cabal-version: 2.2
2+-- Initial package description 'pkga.cabal' generated by 'cabal init'. For
3+-- further documentation, see http://haskell.org/cabal/users-guide/
4+
5+name: pkga
6+version: 0.1.0.0
7+-- synopsis:
8+-- description:
9+-- bug-reports:
10+license: LicenseRef-PublicDomain
11+author: Rodney Lorrimar
12+maintainer: rodney.lorrimar@iohk.io
13+category: Testing
14+
15+library
16+ exposed-modules: PkgA
17+ build-depends: base
18+ , lens
19+ , text
20+ default-language: Haskell2010
test/shell-for/pkgb/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
test/shell-for/pkgb/app/Main.hsnew file+10
@@ -0,0 +1,10 @@
1+module Main where
2+
3+import ConduitExample (example)
4+import PkgB (message)
5+import qualified Data.Text.IO as T
6+
7+main :: IO ()
8+main = do
9+ T.putStrLn message
10+ example
test/shell-for/pkgb/pkgb.cabalnew file+36
@@ -0,0 +1,36 @@
1+cabal-version: 2.2
2+-- Initial package description 'pkgb.cabal' generated by 'cabal init'. For
3+-- further documentation, see http://haskell.org/cabal/users-guide/
4+
5+name: pkgb
6+version: 0.1.0.0
7+-- synopsis:
8+-- description:
9+-- bug-reports:
10+license: LicenseRef-PublicDomain
11+author: Rodney Lorrimar
12+maintainer: rodney.lorrimar@iohk.io
13+category: Testing
14+
15+library
16+ exposed-modules: ConduitExample
17+ , PkgB
18+ build-depends: base
19+ , pkga
20+ , conduit
21+ , conduit-extra
22+ , directory
23+ , resourcet
24+ hs-source-dirs: src
25+ default-language: Haskell2010
26+
27+executable pkgb
28+ main-is: Main.hs
29+ -- other-modules:
30+ -- other-extensions:
31+ build-depends: base
32+ , pkgb
33+ , optparse-applicative
34+ , text
35+ hs-source-dirs: app
36+ default-language: Haskell2010
test/shell-for/pkgb/src/ConduitExample.hsnew file+21
@@ -0,0 +1,21 @@
1+-- https://github.com/snoyberg/conduit#readme
2+
3+module ConduitExample (example) where
4+
5+import Conduit
6+import System.Directory (removeFile)
7+
8+example = do
9+ -- Pure operations: summing numbers.
10+ print $ runConduitPure $ yieldMany [1..10] .| sumC
11+
12+ -- Exception safe file access: copy a file.
13+ writeFile "input.txt" "This is a test." -- create the source file
14+ runConduitRes $ sourceFileBS "input.txt" .| sinkFile "output.txt" -- actual copying
15+ readFile "output.txt" >>= putStrLn -- prove that it worked
16+
17+ -- Perform transformations.
18+ print $ runConduitPure $ yieldMany [1..10] .| mapC (+ 1) .| sinkList
19+
20+ removeFile "input.txt"
21+ removeFile "output.txt"
test/shell-for/pkgb/src/PkgB.hsnew file+7
@@ -0,0 +1,7 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+
3+module PkgB (message) where
4+
5+import PkgA (decode)
6+
7+message = decode "Guvf vf n pnony cebwrpg!"
test/shell-for/pkgb/src/conduit.hsnew file+5
@@ -0,0 +1,5 @@
1+module Main where
2+
3+import ConduitExample
4+
5+main = example