mirror of
https://github.com/gren-lang/compiler.git
synced 2024-09-11 08:45:42 +03:00
Reproduce bug in test.
This commit is contained in:
parent
9f055d9727
commit
0517d24b1e
@ -39,6 +39,7 @@ data Decl
|
|||||||
| Alias (Maybe Src.DocComment) (A.Located Src.Alias)
|
| Alias (Maybe Src.DocComment) (A.Located Src.Alias)
|
||||||
| Port (Maybe Src.DocComment) Src.Port
|
| Port (Maybe Src.DocComment) Src.Port
|
||||||
| TopLevelComments (NonEmpty Src.Comment)
|
| TopLevelComments (NonEmpty Src.Comment)
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
declaration :: Space.Parser E.Decl (Decl, [Src.Comment])
|
declaration :: Space.Parser E.Decl (Decl, [Src.Comment])
|
||||||
declaration =
|
declaration =
|
||||||
|
@ -263,6 +263,7 @@ Test-Suite gren-tests
|
|||||||
Parse.SpaceSpec
|
Parse.SpaceSpec
|
||||||
Parse.UnderscorePatternSpec
|
Parse.UnderscorePatternSpec
|
||||||
Parse.MultilineStringSpec
|
Parse.MultilineStringSpec
|
||||||
|
Parse.DeclSpec
|
||||||
|
|
||||||
Build-Depends:
|
Build-Depends:
|
||||||
hspec >= 2.7.10 && < 3
|
hspec >= 2.7.10 && < 3
|
||||||
|
37
tests/Parse/DeclSpec.hs
Normal file
37
tests/Parse/DeclSpec.hs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module Parse.DeclSpec where
|
||||||
|
|
||||||
|
import Data.ByteString qualified as BS
|
||||||
|
import Helpers.Instances ()
|
||||||
|
import Parse.Declaration (declaration)
|
||||||
|
import Parse.Primitives qualified as P
|
||||||
|
import Test.Hspec (Spec, describe, it, shouldSatisfy)
|
||||||
|
|
||||||
|
data ParseError
|
||||||
|
= DeclError P.Row P.Col
|
||||||
|
| OtherError String P.Row P.Col
|
||||||
|
deriving (Show, Eq)
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec = do
|
||||||
|
describe "Top Level Variables" $ do
|
||||||
|
it "regression test" $
|
||||||
|
parse "test = \"test\""
|
||||||
|
|
||||||
|
it "Variables can be non-ascii characters" $ do
|
||||||
|
parse "æøå = \"test\""
|
||||||
|
|
||||||
|
parse :: BS.ByteString -> IO ()
|
||||||
|
parse str =
|
||||||
|
P.fromByteString
|
||||||
|
(P.specialize (\_ row col -> DeclError row col) declaration)
|
||||||
|
(OtherError "fromByteString failed")
|
||||||
|
str
|
||||||
|
`shouldSatisfy` valid
|
||||||
|
|
||||||
|
valid :: Either x y -> Bool
|
||||||
|
valid result =
|
||||||
|
case result of
|
||||||
|
Right _ -> True
|
||||||
|
Left _ -> False
|
Loading…
Reference in New Issue
Block a user