mirror of
https://github.com/gren-lang/compiler.git
synced 2024-09-11 08:45:42 +03:00
Add tests/Parse.Helpers to cabal file
This commit is contained in:
parent
d955f899cd
commit
21d90c4a32
@ -239,6 +239,7 @@ Test-Suite gren-tests
|
|||||||
|
|
||||||
other-modules:
|
other-modules:
|
||||||
Helpers.Instances
|
Helpers.Instances
|
||||||
|
Parse.Helpers
|
||||||
|
|
||||||
-- tests
|
-- tests
|
||||||
Parse.SpaceSpec
|
Parse.SpaceSpec
|
||||||
|
@ -1,47 +1,41 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Parse.Helpers
|
module Parse.Helpers
|
||||||
( checkParse
|
( checkParse,
|
||||||
, checkSuccessfulParse
|
checkSuccessfulParse,
|
||||||
, checkParseError
|
checkParseError,
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Data.ByteString qualified as BS
|
import Data.ByteString qualified as BS
|
||||||
import Parse.Space qualified as Space
|
|
||||||
import Parse.Primitives qualified as P
|
import Parse.Primitives qualified as P
|
||||||
|
import Parse.Space qualified as Space
|
||||||
import Reporting.Annotation qualified as A
|
import Reporting.Annotation qualified as A
|
||||||
import Test.Hspec (Spec, describe, it)
|
import Test.Hspec (Spec, describe, it)
|
||||||
import Test.Hspec qualified as Hspec
|
import Test.Hspec qualified as Hspec
|
||||||
|
|
||||||
|
|
||||||
checkParse :: (Show error, Show target) => Space.Parser error (A.Located target) -> (P.Row -> P.Col -> error) -> (Either error (A.Located target, A.Position) -> Bool) -> BS.ByteString -> IO ()
|
checkParse :: (Show error, Show target) => Space.Parser error (A.Located target) -> (P.Row -> P.Col -> error) -> (Either error (A.Located target, A.Position) -> Bool) -> BS.ByteString -> IO ()
|
||||||
checkParse parser toBadEnd checkResult str =
|
checkParse parser toBadEnd checkResult str =
|
||||||
Hspec.shouldSatisfy
|
Hspec.shouldSatisfy
|
||||||
( P.fromByteString parser toBadEnd str)
|
(P.fromByteString parser toBadEnd str)
|
||||||
checkResult
|
checkResult
|
||||||
|
|
||||||
|
|
||||||
checkSuccessfulParse :: (Show error, Show target) => Space.Parser error (A.Located target) -> (P.Row -> P.Col -> error) -> (target -> Bool) -> BS.ByteString -> IO ()
|
checkSuccessfulParse :: (Show error, Show target) => Space.Parser error (A.Located target) -> (P.Row -> P.Col -> error) -> (target -> Bool) -> BS.ByteString -> IO ()
|
||||||
checkSuccessfulParse parser toBadEnd checkTarget =
|
checkSuccessfulParse parser toBadEnd checkTarget =
|
||||||
let checkResult result =
|
let checkResult result =
|
||||||
case result of
|
case result of
|
||||||
Right (A.At _ target, _) ->
|
Right (A.At _ target, _) ->
|
||||||
checkTarget target
|
checkTarget target
|
||||||
Left _ ->
|
Left _ ->
|
||||||
False
|
False
|
||||||
in
|
in checkParse parser toBadEnd checkResult
|
||||||
checkParse parser toBadEnd checkResult
|
|
||||||
|
|
||||||
checkParseError :: (Show error, Show target)=> Space.Parser error (A.Located target) -> (P.Row -> P.Col -> error) -> (error -> Bool) -> BS.ByteString -> IO ()
|
checkParseError :: (Show error, Show target) => Space.Parser error (A.Located target) -> (P.Row -> P.Col -> error) -> (error -> Bool) -> BS.ByteString -> IO ()
|
||||||
checkParseError parser toBadEnd checkError =
|
checkParseError parser toBadEnd checkError =
|
||||||
let checkResult result =
|
let checkResult result =
|
||||||
case result of
|
case result of
|
||||||
Left error ->
|
Left error ->
|
||||||
checkError error
|
checkError error
|
||||||
Right _ ->
|
Right _ ->
|
||||||
False
|
False
|
||||||
in
|
in checkParse parser toBadEnd checkResult
|
||||||
checkParse parser toBadEnd checkResult
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user