Backfill simple Parse.Space test

This commit is contained in:
Aaron VonderHaar 2022-05-01 01:28:43 -07:00
parent eff5b1c6b1
commit 1c2569ac3f
3 changed files with 41 additions and 0 deletions

View File

@ -231,6 +231,12 @@ Test-Suite gren-tests
Main-Is:
Spec.hs
other-modules:
Helpers.Instances
-- tests
Parse.SpaceSpec
Build-Depends:
hspec >= 2.7.10 && < 3

View File

@ -0,0 +1,19 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Helpers.Instances where
import qualified AST.Source as Src
import qualified Data.Utf8 as Utf8
import qualified Reporting.Error.Syntax as E
instance Show (Utf8.Utf8 a) where
show utf8 = "\"" <> Utf8.toChars utf8 <> "\""
deriving instance Eq Src.Comment
deriving instance Show Src.Comment
deriving instance Eq E.Space
deriving instance Show E.Space

16
tests/Parse/SpaceSpec.hs Normal file
View File

@ -0,0 +1,16 @@
{-# LANGUAGE OverloadedStrings #-}
module Parse.SpaceSpec where
import Helpers.Instances ()
import qualified Parse.Primitives as P
import qualified Parse.Space as Space
import Test.Hspec
spec :: Spec
spec = do
describe "chomp" $ do
let parseChomp = P.fromByteString (Space.chomp (\e _ _ -> Just e)) (\_ _ -> Nothing)
it "parses spaces and newlines" $
parseChomp " \n " `shouldBe` (Right [])