Skip to content

Commit a905e36

Browse files
authored
Merge pull request #1 from andys8/update-haskell-ghc-92
2 parents c54a130 + 6941b69 commit a905e36

File tree

9 files changed

+169
-50
lines changed

9 files changed

+169
-50
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
11
dist/
22
dist-newstyle/
3+
dist
4+
dist-*
5+
cabal-dev
6+
*.o
7+
*.hi
8+
*.hie
9+
*.chi
10+
*.chs.h
11+
*.dyn_o
12+
*.dyn_hi
13+
.hpc
14+
.hsenv
15+
.cabal-sandbox/
16+
cabal.sandbox.config
17+
*.prof
18+
*.aux
19+
*.hp
20+
*.eventlog
21+
.stack-work/
22+
cabal.project.local
23+
cabal.project.local~
24+
.HTF/
25+
.ghc.environment.*

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ main = hspecWith defaultConfig {configFormatter = Just codewars} Spec.spec
2323
-- test/Spec.hs
2424
{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}
2525
```
26+
27+
## Development
28+
29+
```shell
30+
cabal install
31+
cabal test
32+
```

cabal.project.freeze

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
active-repositories: hackage.haskell.org:merge
2+
constraints: any.HUnit ==1.6.2.0,
3+
any.QuickCheck ==2.14.2,
4+
QuickCheck -old-random +templatehaskell,
5+
any.ansi-terminal ==0.11.3,
6+
ansi-terminal -example,
7+
any.array ==0.5.4.0,
8+
any.base ==4.16.3.0,
9+
any.binary ==0.8.9.0,
10+
any.bytestring ==0.11.3.1,
11+
any.call-stack ==0.4.0,
12+
any.colour ==2.3.6,
13+
any.containers ==0.6.5.1,
14+
any.deepseq ==1.4.6.1,
15+
any.directory ==1.3.6.2,
16+
any.exceptions ==0.10.4,
17+
any.filepath ==1.4.2.2,
18+
any.ghc ==9.2.4,
19+
any.ghc-bignum ==1.2,
20+
any.ghc-boot ==9.2.4,
21+
any.ghc-boot-th ==9.2.4,
22+
any.ghc-heap ==9.2.4,
23+
any.ghc-prim ==0.8.0,
24+
any.ghci ==9.2.4,
25+
any.hpc ==0.6.1.0,
26+
any.hspec ==2.10.4,
27+
any.hspec-core ==2.10.4,
28+
any.hspec-discover ==2.10.4,
29+
any.hspec-expectations ==0.8.2,
30+
any.mtl ==2.2.2,
31+
any.pretty ==1.1.3.6,
32+
any.primitive ==0.7.4.0,
33+
any.process ==1.6.13.2,
34+
any.quickcheck-io ==0.2.0,
35+
any.random ==1.2.1.1,
36+
any.rts ==1.0.2,
37+
any.setenv ==0.1.1.3,
38+
any.splitmix ==0.1.0.4,
39+
splitmix -optimised-mixer,
40+
any.stm ==2.5.0.2,
41+
any.template-haskell ==2.18.0.0,
42+
any.terminfo ==0.4.1.5,
43+
any.text ==2.0.1,
44+
text -developer +simdutf,
45+
any.tf-random ==0.5,
46+
any.time ==1.11.1.1,
47+
any.transformers ==0.5.6.2,
48+
any.unix ==2.7.2.2
49+
index-state: hackage.haskell.org 2022-09-07T06:34:06Z

hie.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cradle:
2+
cabal:
3+
- path: "src"
4+
component: "lib:hspec-formatters-codewars"
5+
- path: "test"
6+
component: "hspec-formatters-codewars:test:hspec-formatters-codewars-spec"

hspec-formatters-codewars.cabal

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1-
cabal-version: >=1.10
2-
3-
name: hspec-formatters-codewars
4-
version: 0.1.0
5-
synopsis: Hspec formatter for Codewars
6-
homepage: https://githuc.com/codewars/hspec-formatters-codewars
7-
license: MIT
8-
build-type: Simple
1+
cabal-version: 2.4
2+
name: hspec-formatters-codewars
3+
version: 0.1.0
4+
synopsis: Hspec formatter for Codewars
5+
homepage: https://github.com/codewars/hspec-formatters-codewars
6+
license: MIT
7+
build-type: Simple
98

109
library
11-
hs-source-dirs:
12-
src
10+
hs-source-dirs: src
11+
build-depends:
12+
, base >=4 && <5
13+
, hspec >=2.8 && <3
14+
, hspec-core >=2.8 && <3
15+
, text >=2 && <3
16+
17+
exposed-modules: Test.Hspec.Formatters.Codewars
18+
default-language: GHC2021
19+
20+
test-suite hspec-formatters-codewars-spec
21+
type: exitcode-stdio-1.0
22+
default-language: GHC2021
23+
main-is: Main.hs
24+
hs-source-dirs: test src
1325
build-depends:
14-
base ==4.*
15-
, hspec ==2.*
16-
, hspec-core ==2.*
17-
, text ==1.*
18-
exposed-modules:
19-
Test.Hspec.Formatters.Codewars
20-
default-language:
21-
Haskell2010
26+
, base >=4 && <5
27+
, hspec >=2.8 && <3
28+
, hspec-core >=2.8 && <3
29+
, text >=2 && <3
30+
31+
other-modules:
32+
Spec
33+
Spec.ExampleSpec
34+
Test.Hspec.Formatters.Codewars
35+
36+
build-tool-depends: hspec-discover:hspec-discover >=2 && <3
Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
11
{-# LANGUAGE OverloadedStrings #-}
2-
module Test.Hspec.Formatters.Codewars
3-
(
4-
codewars
5-
) where
62

7-
import Data.Text (pack, unpack, replace)
3+
module Test.Hspec.Formatters.Codewars (codewars) where
84

9-
import Test.Hspec.Formatters (Formatter (..),
10-
FailureReason (..),
11-
formatException,
12-
silent,
13-
writeLine)
5+
import Data.Text (pack, replace, unpack)
146

15-
codewars :: Formatter
16-
codewars = silent {
17-
exampleGroupStarted = \_ name -> do
18-
writeLine ""
19-
writeLine $ escapeLF $ "<DESCRIBE::>" ++ name
20-
21-
, exampleGroupDone = writeLine "\n<COMPLETEDIN::>"
7+
import Test.Hspec.Core.Formatters.V1 (
8+
FailureReason (..),
9+
Formatter (..),
10+
formatException,
11+
silent,
12+
writeLine,
13+
)
2214

23-
, exampleSucceeded = \(_, name) _ -> do
24-
writeLine ""
25-
writeLine $ escapeLF $ "<IT::>" ++ name
26-
writeLine "\n<PASSED::>Test Passed"
27-
writeLine "\n<COMPLETEDIN::>"
28-
29-
, exampleFailed = \(_, name) _ reason -> do
30-
writeLine ""
31-
writeLine $ escapeLF $ "<IT::>" ++ name
32-
writeLine ""
33-
writeLine $ escapeLF $ reasonAsString reason
34-
writeLine "\n<COMPLETEDIN::>"
35-
}
15+
codewars :: Formatter
16+
codewars =
17+
silent
18+
{ exampleGroupStarted = \_ name -> do
19+
writeLine ""
20+
writeLine $ escapeLF $ "<DESCRIBE::>" ++ name
21+
, exampleGroupDone = writeLine "\n<COMPLETEDIN::>"
22+
, exampleSucceeded = \(_, name) _ -> do
23+
writeLine ""
24+
writeLine $ escapeLF $ "<IT::>" ++ name
25+
writeLine "\n<PASSED::>Test Passed"
26+
writeLine "\n<COMPLETEDIN::>"
27+
, exampleFailed = \(_, name) _ reason -> do
28+
writeLine ""
29+
writeLine $ escapeLF $ "<IT::>" ++ name
30+
writeLine ""
31+
writeLine $ escapeLF $ reasonAsString reason
32+
writeLine "\n<COMPLETEDIN::>"
33+
}
3634

3735
reasonAsString :: FailureReason -> String
3836
reasonAsString reason =
@@ -44,9 +42,9 @@ reasonAsString reason =
4442
ExpectedButGot (Just src) expected got ->
4543
"<FAILED::>" ++ src ++ " expected " ++ expected ++ " but got " ++ got
4644
Error Nothing err ->
47-
"<ERROR::>" ++ (formatException err)
45+
"<ERROR::>" ++ formatException err
4846
Error (Just s) err ->
49-
"<ERROR::>" ++ s ++ (formatException err)
47+
"<ERROR::>" ++ s ++ formatException err
5048

5149
escapeLF :: String -> String
5250
escapeLF = unpack . replace "\n" "<:LF:>" . pack

test/Main.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Main where
2+
3+
import Test.Hspec.Runner
4+
import Test.Hspec.Formatters.Codewars (codewars)
5+
6+
import qualified Spec
7+
8+
main :: IO ()
9+
main = hspecWith defaultConfig {configFormatter = Just codewars} Spec.spec

test/Spec.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}

test/Spec/ExampleSpec.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Spec.ExampleSpec where
2+
3+
import Test.Hspec
4+
5+
spec :: Spec
6+
spec = describe "ExampleSpec" $ do
7+
it "can parse integers" $ do
8+
read "10" `shouldBe` (10 :: Int)
9+
10+
it "can parse floating-point numbers" $ do
11+
read "2.5" `shouldBe` (2.5 :: Float)

0 commit comments

Comments
 (0)