mirror of
https://github.com/gren-lang/compiler.git
synced 2024-10-26 09:50:44 +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:
|
||||
Helpers.Instances
|
||||
Parse.Helpers
|
||||
|
||||
-- tests
|
||||
Parse.SpaceSpec
|
||||
|
@ -1,47 +1,41 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Parse.Helpers
|
||||
( checkParse
|
||||
, checkSuccessfulParse
|
||||
, checkParseError
|
||||
)
|
||||
( checkParse,
|
||||
checkSuccessfulParse,
|
||||
checkParseError,
|
||||
)
|
||||
where
|
||||
|
||||
import Data.ByteString qualified as BS
|
||||
import Parse.Space qualified as Space
|
||||
import Parse.Primitives qualified as P
|
||||
import Parse.Space qualified as Space
|
||||
import Reporting.Annotation qualified as A
|
||||
import Test.Hspec (Spec, describe, it)
|
||||
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 parser toBadEnd checkResult str =
|
||||
Hspec.shouldSatisfy
|
||||
( P.fromByteString parser toBadEnd str)
|
||||
checkResult
|
||||
|
||||
Hspec.shouldSatisfy
|
||||
(P.fromByteString parser toBadEnd str)
|
||||
checkResult
|
||||
|
||||
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 =
|
||||
let checkResult result =
|
||||
case result of
|
||||
Right (A.At _ target, _) ->
|
||||
checkTarget target
|
||||
Left _ ->
|
||||
False
|
||||
in
|
||||
checkParse parser toBadEnd checkResult
|
||||
let checkResult result =
|
||||
case result of
|
||||
Right (A.At _ target, _) ->
|
||||
checkTarget target
|
||||
Left _ ->
|
||||
False
|
||||
in 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 =
|
||||
let checkResult result =
|
||||
case result of
|
||||
Left error ->
|
||||
checkError error
|
||||
Right _ ->
|
||||
False
|
||||
in
|
||||
checkParse parser toBadEnd checkResult
|
||||
|
||||
|
||||
let checkResult result =
|
||||
case result of
|
||||
Left error ->
|
||||
checkError error
|
||||
Right _ ->
|
||||
False
|
||||
in checkParse parser toBadEnd checkResult
|
||||
|
Loading…
Reference in New Issue
Block a user