mirror of
https://github.com/Avi-D-coder/implicit-hie.git
synced 2024-09-11 09:05:25 +03:00
tests
This commit is contained in:
parent
576652d009
commit
9ebaeb0041
15609
codex.tags
Normal file
15609
codex.tags
Normal file
File diff suppressed because it is too large
Load Diff
8
hie.yaml
Normal file
8
hie.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
cradle:
|
||||
stack:
|
||||
- path: ./src
|
||||
component: "implicit-hie:lib"
|
||||
- path: ./app
|
||||
component: "implicit-hie:exe:implicit-hie-exe"
|
||||
- path: ./test
|
||||
component: "implicit-hie:test:implicit-hie-test"
|
@ -4,7 +4,7 @@ cabal-version: 1.12
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: f408920e6437a2881526a6b665a159c8770af5eca3ebc6e444ff7b0f4853e4ed
|
||||
-- hash: 43f070b60e4bc798c52d79691e2dcdd543171eeee553cd2f28579bf9e3b6e10a
|
||||
|
||||
name: implicit-hie
|
||||
version: 0.1.0.0
|
||||
@ -32,7 +32,7 @@ library
|
||||
Paths_implicit_hie
|
||||
hs-source-dirs:
|
||||
src
|
||||
ghc-options: -O2 -flate-specialise -fexpose-all-unfoldings -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints
|
||||
ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints
|
||||
build-depends:
|
||||
attoparsec
|
||||
, base >=4.7 && <5
|
||||
@ -45,7 +45,7 @@ executable implicit-hie-exe
|
||||
Paths_implicit_hie
|
||||
hs-source-dirs:
|
||||
app
|
||||
ghc-options: -O2 -flate-specialise -fexpose-all-unfoldings -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
attoparsec
|
||||
, base >=4.7 && <5
|
||||
@ -60,7 +60,7 @@ test-suite implicit-hie-test
|
||||
Paths_implicit_hie
|
||||
hs-source-dirs:
|
||||
test
|
||||
ghc-options: -O2 -flate-specialise -fexpose-all-unfoldings -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
attoparsec
|
||||
, base >=4.7 && <5
|
||||
|
@ -25,9 +25,9 @@ dependencies:
|
||||
- attoparsec
|
||||
|
||||
ghc-options:
|
||||
- -O2
|
||||
- -flate-specialise
|
||||
- -fexpose-all-unfoldings
|
||||
# - -O2
|
||||
# - -flate-specialise
|
||||
# - -fexpose-all-unfoldings
|
||||
- -fspecialize-aggressively
|
||||
- -Wall
|
||||
- -Wincomplete-record-updates
|
||||
|
25
src/Lib.hs
25
src/Lib.hs
@ -8,6 +8,7 @@ import Data.Attoparsec.Text
|
||||
import Data.Char (isSpace)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Debug.Trace
|
||||
|
||||
type Name = Text
|
||||
|
||||
@ -47,13 +48,15 @@ parseComponentName = do
|
||||
takeWhile1 (not . isSpace)
|
||||
|
||||
parseNamed :: Indent -> Text -> (Name -> Path -> Component) -> Parser Component
|
||||
parseNamed i compType compCon = do
|
||||
indent i
|
||||
_ <- asciiCI compType
|
||||
_ <- skipSpace
|
||||
n <- parseComponentName
|
||||
skipToNextLine
|
||||
compCon n <$> parsePath i
|
||||
parseNamed i compType compCon =
|
||||
do
|
||||
indent i
|
||||
_ <- asciiCI compType <?> "asciiCI " <> T.unpack compType
|
||||
_ <- skipSpace <?> "skipSpace"
|
||||
n <- parseComponentName <?> "N"
|
||||
skipToNextLine
|
||||
compCon n <$> parsePath i
|
||||
<?> T.unpack ("parseNamed " <> compType)
|
||||
|
||||
skipToNextLine :: Parser ()
|
||||
skipToNextLine = skipWhile (not . isEndOfLine) >> endOfLine
|
||||
@ -70,15 +73,17 @@ parsePath i =
|
||||
skipToNextLine
|
||||
skipMany $ indent i >> skipToNextLine
|
||||
pure p
|
||||
<?> "hs-source-dirs"
|
||||
)
|
||||
<|> ( do
|
||||
indent i
|
||||
skipToNextLine
|
||||
parsePath i
|
||||
<?> "skip line"
|
||||
)
|
||||
<|> pure "."
|
||||
<|> (pure "." <?> "not found") <?> "parsePath"
|
||||
|
||||
-- | Skip at least n spaces
|
||||
indent :: Indent -> Parser ()
|
||||
indent 0 = skipMany space
|
||||
indent i = space >> indent (i - 1)
|
||||
indent 0 = skipMany space <?> "indent 0"
|
||||
indent i = space >> indent (i - 1) <?> "indent 0"
|
||||
|
66
test/Spec.hs
66
test/Spec.hs
@ -2,8 +2,70 @@
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Data.Text (Text)
|
||||
import Test.Hspec
|
||||
import Lib
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Attoparsec
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Test suite not yet implemented"
|
||||
main = hspec spec
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses executable section"
|
||||
$ exeSection ~> parseNamed 0 "executable" Exe
|
||||
`shouldParse` Exe "implicit-hie-exe" "app"
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses test section"
|
||||
$ testSection ~> parseNamed 0 "test-suite" Test
|
||||
`shouldParse` Test "implicit-hie-test" "test"
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses library section"
|
||||
$ libSection ~> parseLib 0
|
||||
`shouldParse` Lib "src"
|
||||
|
||||
exeSection :: Text
|
||||
exeSection =
|
||||
"executable implicit-hie-exe\n\
|
||||
\ main-is: Main.hs \n\
|
||||
\ other-modules:\n\
|
||||
\ Paths_implicit_hie\n\
|
||||
\ hs-source-dirs:\n\
|
||||
\ app\n\
|
||||
\ ghc-options: -O2\n"
|
||||
|
||||
testSection :: Text
|
||||
testSection =
|
||||
"test-suite implicit-hie-test\n\
|
||||
\ type: exitcode-stdio-1.0\n\
|
||||
\ main-is: Spec.hs\n\
|
||||
\ other-modules:\n\
|
||||
\ Paths_implicit_hie\n\
|
||||
\ hs-source-dirs:\n\
|
||||
\ test\n\
|
||||
\ ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N\n\
|
||||
\ build-depends:\n\
|
||||
\ attoparsec\n\
|
||||
\ , base >=4.7 && <5\n\
|
||||
\ , hspec\n\
|
||||
\ , hspec-attoparsec\n\
|
||||
\ , implicit-hie\n\
|
||||
\ , text\n\
|
||||
\ default-language: Haskell2010\n"
|
||||
|
||||
libSection :: Text
|
||||
libSection =
|
||||
"library\
|
||||
\ exposed-modules:\n\
|
||||
\ Lib\n\
|
||||
\ other-modules:\n\
|
||||
\ Paths_implicit_hie\n\
|
||||
\ hs-source-dirs:\n\
|
||||
\ src\n\
|
||||
\ ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints\n\
|
||||
\ build-depends:\n\
|
||||
\ attoparsec\n\
|
||||
\ , base >=4.7 && <5\n\
|
||||
\ , text\n\
|
||||
\ default-language: Haskell2010\n\
|
||||
\"
|
||||
|
Loading…
Reference in New Issue
Block a user