Skip to content

Commit

Permalink
test: Use cabal-docspec instead of doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
Lysxia committed Apr 3, 2021
1 parent 846fafb commit c69f38d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 36 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,28 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest]
cabal: ["3.2"]
ghc:
- "8.0"
- "8.6"
- "8.8"
- "8.10"
exclude:
- os: macOS-latest
ghc: 8.8
- os: macOS-latest
ghc: 8.6
- os: macOS-latest
ghc: 8.0
- os: windows-latest
ghc: 8.8
- os: windows-latest
ghc: 8.6

- "9.0"
steps:
- name: Set environment
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
- name: Install cabal-docspec
run: |
mkdir -p $HOME/.cabal/bin
curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20210111/cabal-docspec-0.0.0.20210111.xz > cabal-docspec.xz
echo '0829bd034fba901cbcfe491d98ed8b28fd54f9cb5c91fa8e1ac62dc4413c9562 cabal-docspec.xz' | sha256sum -c -
xz -d < cabal-docspec.xz > $HOME/.cabal/bin/cabal-docspec
rm -f cabal-docspec.xz
chmod a+x $HOME/.cabal/bin/cabal-docspec
cabal-docspec --version
- uses: actions/checkout@v2
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'

Expand Down Expand Up @@ -64,6 +66,7 @@ jobs:
- name: Test
run: |
cabal test all
cabal-docspec
stack:
name: stack / ghc ${{ matrix.ghc }}
Expand Down
4 changes: 2 additions & 2 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import Distribution.Extra.Doctest (defaultMainWithDoctests)
main = defaultMainWithDoctests "generic-data-doctest"
import Distribution.Simple
main = defaultMain
20 changes: 1 addition & 19 deletions generic-data.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ author: Li-yao Xia
maintainer: lysxia@gmail.com
copyright: 2018-2020 Li-yao Xia
category: Generics
build-type: Custom
build-type: Simple
extra-source-files: README.md, CHANGELOG.md
cabal-version: >=1.10
tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3, GHC == 8.6.1,
GHC == 8.6.3, GHC == 8.6.5, GHC == 8.8.2

custom-setup
setup-depends:
base, Cabal, cabal-doctest >= 1.0.6 && < 1.1

library
hs-source-dirs: src
exposed-modules:
Expand Down Expand Up @@ -145,20 +141,6 @@ test-suite generic-data-inspection-test
if impl(ghc < 8.2) || os(windows)
buildable: False

test-suite generic-data-doctest
hs-source-dirs: test
main-is: doctest.hs
build-depends:
doctest,
QuickCheck,
generic-data,
base
ghc-options: -Wall
default-language: Haskell2010
type: exitcode-stdio-1.0
if !impl(ghc >= 8.6)
buildable: False

benchmark bench
hs-source-dirs: test
main-is: bench.hs
Expand Down
10 changes: 8 additions & 2 deletions src/Generic/Data/Internal/Generically.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ import Generic.Data.Internal.Read
import Generic.Data.Internal.Show
import Generic.Data.Internal.Traversable (GFoldable, GTraversable, gfoldMap, gtraverse, gsequenceA)

-- $setup
-- >>> :set -XDerivingVia -XDeriveGeneric
-- >>> import GHC.Generics (Generic, Generic1)

-- | Type with instances derived via 'Generic'.
--
-- === Examples
--
-- ==== __Deriving 'Eq', 'Ord', 'Show', 'Read'__
--
-- >>> :set -XDerivingVia -XDeriveGeneric
-- >>> :{
-- data T = C Int Bool
-- deriving Generic
Expand All @@ -48,6 +51,7 @@ import Generic.Data.Internal.Traversable (GFoldable, GTraversable, gfoldMap, gtr
--
-- The type must have only one constructor.
--
-- >>> import Data.Monoid (Sum)
-- >>> :{
-- data U = D [Int] (Sum Int)
-- deriving Generic
Expand Down Expand Up @@ -164,6 +168,7 @@ instance (Generic a, GBounded (Rep a)) => Bounded (FiniteEnumeration a) where
-- deriving (Functor, Applicative) via (Generically1 G)
-- :}
--
-- >>> import Control.Applicative (Alternative)
-- >>> :{
-- data G' a = G' (Maybe a) [a]
-- deriving Generic1
Expand All @@ -184,6 +189,7 @@ instance (Generic a, GBounded (Rep a)) => Bounded (FiniteEnumeration a) where
--
-- ==== __Deriving 'Eq1', 'Ord1'__
--
-- >>> import Data.Functor.Classes (Eq1, Ord1)
-- >>> :{
-- data I a = I [a] (Maybe a)
-- deriving Generic1
Expand Down Expand Up @@ -271,7 +277,7 @@ instance (Generic1 f, Functor (Rep1 f), GFoldable (Rep1 f), GTraversable (Rep1 f
--
-- === __Example__
--
-- >>> :set -XDeriveGeneric -XDerivingVia
-- >>> import Data.Monoid (Sum(..))
-- >>> data Point a = Point a a deriving Generic
-- >>> :{
-- newtype Vector a = Vector (Point a)
Expand Down
1 change: 1 addition & 0 deletions src/Generic/Data/Internal/Meta.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ gconName = conIdToString . conId

-- | The fixity of the first constructor.
--
-- >>> import GHC.Generics ((:*:)(..))
-- >>> gconFixity (Just 0)
-- Prefix
-- >>> gconFixity ([] :*: id)
Expand Down

0 comments on commit c69f38d

Please sign in to comment.